Search notes:

$VIMRUNTIME/filetype.vim

$VIMRUNTIME/filetype.vim is used to detect file types.
It contains lines such as
au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks	setf sql
$VIMRUNTIME/filetype.vim is run when :filetype on is executed.
TODO: is it also run when filetype plugin on is executed?
If it's not possible to detect tye file type by its name (mostly suffix), then Vim uses $VIMRUNTIME/scripts.vim to determine a file type.

Rough content of filetype.vim

The content of filetype.vim roughly looks like so:
if exists("did_load_filetypes")
  finish
endif
let did_load_filetypes = 1


augroup filetypedetect

… 
… Stuff about ignored extensions etc.
…

au BufNewFile,BufRead $VIMRUNTIME/doc/*.txt   setf help
au BufNewFile,BufRead *.inp                   call dist#ft#Check_inp()
au BufNewFile,BufRead *.8th                   setf 8th

au BufNewFile,BufRead *.sql                   call dist#ft#SQL()
… etc. etc.

augroup END

" Source the user-specified filetype file, for backwards compatibility with Vim 5.x.
if exists("myfiletypefile") && filereadable(expand(myfiletypefile))
   execute "source " . myfiletypefile
endif


augroup filetypedetect

au BufNewFile,BufRead *
	\ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
	\ | runtime! scripts.vim | endif
au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif


…
… Extra checks for when no filetype has been detected now.
…

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758198204, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/vim/runtime/filetype_vim(88): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78