changeset 51929:3da2cf447bf9

Revert last change.
author Juanma Barranquero <lekktu@gmail.com>
date Mon, 14 Jul 2003 20:39:39 +0000
parents c94d493b710a
children 608552c82ffc
files lisp/progmodes/sql.el
diffstat 1 files changed, 187 insertions(+), 901 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/sql.el	Mon Jul 14 20:37:35 2003 +0000
+++ b/lisp/progmodes/sql.el	Mon Jul 14 20:39:39 2003 +0000
@@ -1,10 +1,10 @@
 ;;; sql.el --- specialized comint.el for SQL interpreters
 
-;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003  Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002  Free Software Foundation, Inc.
 
 ;; Author: Alex Schroeder <alex@gnu.org>
 ;; Maintainer: Alex Schroeder <alex@gnu.org>
-;; Version: 1.8.0
+;; Version: 1.7.0
 ;; Keywords: comm languages processes
 ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode
 
@@ -78,114 +78,24 @@
 
 ;;; Bugs:
 
-;; sql-ms now uses osql instead of isql.  Osql flushes its error
-;; stream more frequently than isql so that error messages are
-;; available.  There is no prompt and some output still is buffered.
-;; This improves the interaction under Emacs but it still is somewhat
-;; awkward.
-
-;; Quoted identifiers are not supported for hilighting.  Most
-;; databases support the use of double quoted strings in place of
-;; identifiers; ms (Microsoft SQLServer) also supports identifiers
-;; enclosed within brackets [].
+;; Using sql-ms (isql by Microsoft): When commands with syntax errors
+;; or execution errors are executed, there is no server feedback.
+;; This happens in stored procedures for example.  The server messages
+;; only appear after the process is exited.  This makes things
+;; somewhat unreliable.
 
 ;; ChangeLog available on request.
 
-;;; Product Support:
-
-;; Set the variable `sql-product' to the product you usually use.  If
-;; you occasionally use another product, for certain files, add a
-;; comment on the first line of the file saying
-;; -*- sql-product: mysql -*-
-;; See section "File Variables" in the Emacs manual for more info.
-
-;;; Adding another product:
-
-;; To add support for additional SQL products the following steps
-;; must be followed ("xyz" is the name of the product in the examples
-;; below):
-
-;; 1) Add the product to `sql-product' choice list.
-
-;;     (const :tag "XyzDB" xyz)
-
-;; 2) Add an entry to the `sql-product-support' list.
-
-;;     (xyz
-;;      :font-lock sql-mode-xyz-font-lock-keywords
-;;      :sqli-login (user password server database)
-;;      :sqli-connect sql-connect-xyz
-;;      :sqli-prompt-regexp "^xyzdb> "
-;;      :sqli-prompt-length 7
-;;      :sqli-input-sender nil
-;;      :syntax-alist ((?# . "w")))
-
-;; 3) Add customizable values for the product interpreter and options.
-
-;;     ;; Customization for XyzDB
-;;
-;;     (defcustom sql-xyz-program "ixyz"
-;;       "*Command to start ixyz by XyzDB."
-;;       :type 'file
-;;       :group 'SQL)
-;;
-;;     (defcustom sql-xyz-options '("-X" "-Y" "-Z")
-;;       "*List of additional options for `sql-xyz-program'."
-;;       :type '(repeat string)
-;;       :group 'SQL)
-
-;; 4) Add an entry to SQL->Product submenu.
+;;; To Do:
 
-;;     ["XyzDB" sql-highlight-xyz-keywords
-;;      :style radio
-;;      :selected (eq sql-product 'xyz)]
-
-;; 5) Add the font-lock specifications.  At a minimum, default to
-;;    using ANSI keywords.  See sql-mode-oracle-font-lock-keywords for
-;;    a more complex example.
-
-;;     (defvar sql-mode-xyz-font-lock-keywords sql-mode-ansi-font-lock-keywords
-;;       "XyzDB SQL keywords used by font-lock.")
-
-;; 6) Add a product highlighting function.
-
-;;     (defun sql-highlight-xyz-keywords ()
-;;       "Highlight XyzDB keywords."
-;;       (interactive)
-;;       (sql-set-product 'xyz))
-
-;; 7) Add an autoloaded SQLi function.
+;; Add better hilight support for other brands; there is a bias towards
+;; Oracle because that's what I use at work.  Anybody else just send in
+;; your lists of reserved words, keywords and builtin functions!  As
+;; long as I don't receive any feedback, everything is hilighted with
+;; ANSI keywords only.  I received the list of ANSI keywords from a
+;; user; if you know of any changes, let me know.
 
-;;     ;;;###autoload
-;;     (defun sql-xyz ()
-;;       "Run ixyz by XyzDB as an inferior process."
-;;       (interactive)
-;;       (sql-product-interactive 'xyz))
-
-;; 8) Add a connect function which formats the command line arguments
-;;    and starts the product interpreter in a comint buffer.  See the
-;;    existing connect functions for examples of the types of
-;;    processing available.
-
-;;     (defun sql-connect-xyz ()
-;;       "Create comint buffer and connect to XyzDB using the login
-;;     parameters and command options."
-;;
-;;         ;; Do something with `sql-user', `sql-password',
-;;         ;; `sql-database', and `sql-server'.
-;;         (let ((params sql-xyz-options))
-;;           (if (not (string= "" sql-server))
-;;              (setq params (append (list "-S" sql-server) params)))
-;;           (if (not (string= "" sql-database))
-;;               (setq params (append (list "-D" sql-database) params)))
-;;           (if (not (string= "" sql-password))
-;;               (setq params (append (list "-P" sql-password) params)))
-;;           (if (not (string= "" sql-user))
-;;               (setq params (append (list "-U" sql-user) params)))
-;;           (set-buffer (apply 'make-comint "SQL" sql-xyz-program
-;;                              nil params))))
-
-;; 9) Save and compile sql.el.
+;; Add different hilighting levels.
 
 ;;; Thanks to all the people who helped me out:
 
@@ -195,7 +105,6 @@
 ;; Gregor Zych <zych@pool.informatik.rwth-aachen.de>
 ;; nino <nino@inform.dk>
 ;; Berend de Boer <berend@pobox.com>
-;; Michael Mauger <mmaug@yahoo.com>
 
 
 
@@ -203,8 +112,7 @@
 
 (require 'comint)
 ;; Need the following to allow GNU Emacs 19 to compile the file.
-(eval-when-compile
-  (require 'regexp-opt))
+(require 'regexp-opt)
 (require 'custom)
 
 ;;; Allow customization
@@ -214,7 +122,7 @@
   :version "20.4"
   :group 'processes)
 
-;; These four variables will be used as defaults, if set.
+;; These three variables will be used as defaults, if set.
 
 (defcustom sql-user ""
   "*Default username."
@@ -239,145 +147,6 @@
   :type 'string
   :group 'SQL)
 
-;; SQL Product support
-(defcustom sql-product 'ansi
-  "*Select the SQL database product used so that buffers can be
-highlighted properly when you open them."
-  :type '(choice (const :tag "ANSI" ansi)
-		 (const :tag "DB2" db2)
-		 (const :tag "Informix" informix)
-		 (const :tag "Ingres" ingres)
-		 (const :tag "Interbase" interbase)
-		 (const :tag "Linter" linter)
-		 (const :tag "Microsoft" ms)
-		 (const :tag "MySQL" mysql)
-		 (const :tag "Oracle" oracle)
-		 (const :tag "PostGres" postgres)
-		 (const :tag "Solid" solid)
-		 (const :tag "SQLite" sqlite)
-		 (const :tag "Sybase" sybase))
-  :group 'SQL)
-
-(defvar sql-interactive-product nil
-  "Product under `sql-interactive-mode'.")
-
-(defvar sql-product-support
-  '((ansi
-     :font-lock sql-mode-ansi-font-lock-keywords)
-    (db2
-     :font-lock sql-mode-db2-font-lock-keywords
-     :sqli-login nil
-     :sqli-connect sql-connect-db2
-     :sqli-prompt-regexp "^db2 => "
-     :sqli-prompt-length 7)
-    (informix
-     :font-lock sql-mode-informix-font-lock-keywords
-     :sqli-login (database)
-     :sqli-connect sql-connect-informix
-     :sqli-prompt-regexp "^SQL> "
-     :sqli-prompt-length 5)
-    (ingres
-     :font-lock sql-mode-ingres-font-lock-keywords
-     :sqli-login (database)
-     :sqli-connect sql-connect-ingres
-     :sqli-prompt-regexp "^\* "
-     :sqli-prompt-length 2)
-    (interbase
-     :font-lock sql-mode-interbase-font-lock-keywords
-     :sqli-login (user password database)
-     :sqli-connect sql-connect-interbase
-     :sqli-prompt-regexp "^SQL> "
-     :sqli-prompt-length 5)
-    (linter
-     :font-lock sql-mode-linter-font-lock-keywords
-     :sqli-login (user password database server)
-     :sqli-connect sql-connect-linter
-     :sqli-prompt-regexp "^SQL>"
-     :sqli-prompt-length 4)
-    (ms
-     :font-lock sql-mode-ms-font-lock-keywords
-     :sqli-login (user password server database)
-     :sqli-connect sql-connect-ms
-     :sqli-prompt-regexp "^[0-9]*>"
-     :sqli-prompt-length 5
-     :syntax-alist ((?@ . "w")))
-    (mysql
-     :font-lock sql-mode-mysql-font-lock-keywords
-     :sqli-login (user password database server)
-     :sqli-connect sql-connect-mysql
-     :sqli-prompt-regexp "^mysql> "
-     :sqli-prompt-length 6)
-    (oracle
-     :font-lock sql-mode-oracle-font-lock-keywords
-     :sqli-login (user password database)
-     :sqli-connect sql-connect-oracle
-     :sqli-prompt-regexp "^SQL> "
-     :sqli-prompt-length 5
-     :syntax-alist ((?$ . "w") (?# . "w")))
-    (postgres
-     :font-lock sql-mode-postgres-font-lock-keywords
-     :sqli-login (database server)
-     :sqli-connect sql-connect-postgres
-     :sqli-prompt-regexp "^.*> *"
-     :sqli-prompt-length 5)
-    (solid
-     :font-lock sql-mode-solid-font-lock-keywords
-     :sqli-login (user password server)
-     :sqli-connect sql-connect-solid
-     :sqli-prompt-regexp "^"
-     :sqli-prompt-length 0)
-    (sqlite
-     :font-lock sql-mode-sqlite-font-lock-keywords
-     :sqli-login (user password server database)
-     :sqli-connect sql-connect-sqlite
-     :sqli-prompt-regexp "^sqlite> "
-     :sqli-prompt-length 8)
-    (sybase
-     :font-lock sql-mode-sybase-font-lock-keywords
-     :sqli-login (server user password database)
-     :sqli-connect sql-connect-sybase
-     :sqli-prompt-regexp "^SQL> "
-     :sqli-prompt-length 5
-     :syntax-alist ((?@ . "w")))
-    )
-  "This variable contains a list of product features for each of the
-SQL products handled by `sql-mode'.  Without an entry in this list a
-product will not be properly highlighted and will not support
-`sql-interactive-mode'.
-
-Each element in the list is in the following format:
-
- \(PRODUCT FEATURE VALUE ...)
-
-where PRODUCT is the appropriate value of `sql-product'.  The product
-name is then followed by FEATURE-VALUE pairs.  If a FEATURE is not
-specified, its VALUE is treated as nil.  FEATURE must be one of the
-following:
-
- :font-lock             name of the variable containing the product
-                        specific font lock highlighting patterns.
-
- :sqli-login            a list of login parameters (i.e., user,
-                        password, database and server) needed to
-                        connect to the database.
-
- :sqli-connect          the name of a function which accepts no
-                        parameters that will use the values of
-                        `sql-user', `sql-password',
-                        `sql-database' and `sql-server' to open a
-                        comint buffer and connect to the
-                        database.  Do product specific
-                        configuration of comint in this function.
-
- :sqli-prompt-regexp    a regular expression string that matches the
-                        prompt issued by the product interpreter.
-
- :sqli-prompt-length    the length of the prompt on the line.
-
- :syntax-alist          an alist of syntax table entries to enable
-                        special character treatment by font-lock and
-                        imenu. ")
-
 ;; misc customization of sql.el behaviour
 
 (defcustom sql-electric-stuff nil
@@ -408,15 +177,8 @@
 ;; imenu support for sql-mode.
 
 (defvar sql-imenu-generic-expression
-  ;; Items are in reverse order because they are rendered in reverse.
-  '(("Rules/Defaults" "^\\s-*create\\s-+\\(rule\\|default\\)\\s-+\\(\\w+\\)" 2)
-    ("Sequences" "^\\s-*create\\s-+sequence\\s-+\\(\\w+\\)" 1)
-    ("Triggers" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?trigger\\s-+\\(\\w+\\)" 3)
-    ("Functions" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?function\\s-+\\(\\w+\\)" 3)
-    ("Procedures" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?proc\\(edure\\)?\\s-+\\(\\w+\\)" 4)
-    ("Packages" "^\\s-*create\\s-+\\(or\\s-+replace\\s-+\\)?package\\s-+\\(body\\s-+\\)?\\(\\w+\\)" 3)
-    ("Indexes" "^\\s-*create\\s-+index\\s-+\\(\\w+\\)" 1)
-    ("Tables/Views" "^\\s-*create\\s-+\\(\\(global\\s-+\\)?\\(temporary\\s-+\\)?table\\|view\\)\\s-+\\(\\w+\\)" 4))
+  '(("Tables" "^\\s-*create\\s-+table\\s-+\\(\\w+\\)" 1)
+    ("Indexes" "^\\s-*create\\s-+index\\s-+\\(\\w+\\)" 1))
   "Define interesting points in the SQL buffer for `imenu'.
 
 This is used to set `imenu-generic-expression' when SQL mode is
@@ -512,7 +274,7 @@
   :group 'SQL)
 
 (defcustom sql-sqlite-options nil
-  "*List of additional options for `sql-sqlite-program'.
+  "*List of additional options for `sql-mysql-program'.
 The following list of options is reported to make things work
 on Windows: \"-C\" \"-t\" \"-f\" \"-n\"."
   :type '(repeat string)
@@ -591,8 +353,8 @@
 
 ;; Customization for Microsoft
 
-(defcustom sql-ms-program "osql"
-  "*Command to start osql by Microsoft.
+(defcustom sql-ms-program "isql"
+  "*Command to start isql by Microsoft.
 
 Starts `sql-interactive-mode' after doing some setup.
 
@@ -706,12 +468,12 @@
 (defvar sql-prompt-regexp nil
   "Prompt used to initialize `comint-prompt-regexp'.
 
-You can change `sql-prompt-regexp' on `sql-interactive-mode-hook'.")
+You can change `comint-prompt-regexp' on `sql-interactive-mode-hook'.")
 
 (defvar sql-prompt-length 0
   "Prompt used to set `left-margin' in `sql-interactive-mode'.
 
-You can change `sql-prompt-length' on `sql-interactive-mode-hook'.")
+You can change it on `sql-interactive-mode-hook'.")
 
 (defvar sql-alternate-buffer-name nil
   "Buffer-local string used to possibly rename the SQLi buffer.
@@ -756,60 +518,22 @@
 					     (get-buffer-process sql-buffer))]
    ["Send Region" sql-send-region (and (or (and (boundp 'mark-active); Emacs
 						mark-active)
-					   (mark t)); XEmacs
+					   (mark)); XEmacs
 				       (buffer-live-p sql-buffer)
 				       (get-buffer-process sql-buffer))]
    ["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer)
 				       (get-buffer-process sql-buffer))]
-   ["--" nil nil]
-   ["Start SQLi session" sql-product-interactive (sql-product-feature :sqli-connect)]
    ["Show SQLi buffer" sql-show-sqli-buffer t]
    ["Set SQLi buffer" sql-set-sqli-buffer t]
    ["Pop to SQLi buffer after send"
     sql-toggle-pop-to-buffer-after-send-region
     :style toggle
     :selected sql-pop-to-buffer-after-send-region]
-   ["--" nil nil]
-   ("Product"
-    ["ANSI" sql-highlight-ansi-keywords
-     :style radio
-     :selected (eq sql-product 'ansi)]
-    ["DB2" sql-highlight-db2-keywords
-     :style radio
-     :selected (eq sql-product 'db2)]
-    ["Informix" sql-highlight-informix-keywords
-     :style radio
-     :selected (eq sql-product 'informix)]
-    ["Ingres" sql-highlight-ingres-keywords
-     :style radio
-     :selected (eq sql-product 'ingres)]
-    ["Interbase" sql-highlight-interbase-keywords
-     :style radio
-     :selected (eq sql-product 'interbase)]
-    ["Linter" sql-highlight-linter-keywords
-     :style radio
-     :selected (eq sql-product 'linter)]
-    ["Microsoft" sql-highlight-ms-keywords
-     :style radio
-     :selected (eq sql-product 'ms)]
-    ["MySQL" sql-highlight-mysql-keywords
-     :style radio
-     :selected (eq sql-product 'mysql)]
-    ["Oracle" sql-highlight-oracle-keywords
-     :style radio
-     :selected (eq sql-product 'oracle)]
-    ["Postgres" sql-highlight-postgres-keywords
-     :style radio
-     :selected (eq sql-product 'postgres)]
-    ["Solid" sql-highlight-solid-keywords
-     :style radio
-     :selected (eq sql-product 'solid)]
-    ["SQLite" sql-highlight-sqlite-keywords
-     :style radio
-     :selected (eq sql-product 'sqlite)]
-    ["Sybase" sql-highlight-sybase-keywords
-     :style radio
-     :selected (eq sql-product 'sybase)]
+   ("Highlighting"
+    ["ANSI SQL keywords" sql-highlight-ansi-keywords t]
+    ["Oracle keywords" sql-highlight-oracle-keywords t]
+    ["Postgres keywords" sql-highlight-postgres-keywords t]
+    ["Linter keywords" sql-highlight-linter-keywords t]
     )))
 
 ;; easy menu for sql-interactive-mode.
@@ -827,22 +551,12 @@
   "Abbrev table used in `sql-mode' and `sql-interactive-mode'.")
 (if sql-mode-abbrev-table
     ()
-  (let ((nargs (cdr (subr-arity (symbol-function 'define-abbrev))))
-	d-a)
-    ;; In Emacs 21.3+, provide SYSTEM-FLAG to define-abbrev.
-    (setq d-a
-	  (if (>= nargs 6)
-	      '(lambda (name expansion) (define-abbrev sql-mode-abbrev-table name expansion nil 0 t))
-	    '(lambda (name expansion) (define-abbrev sql-mode-abbrev-table name expansion))))
-
-    (define-abbrev-table 'sql-mode-abbrev-table nil)
-    (funcall d-a "ins" "insert")
-    (funcall d-a "upd" "update")
-    (funcall d-a "del" "delete")
-    (funcall d-a "sel" "select")
-    (funcall d-a "proc" "procedure")
-    (funcall d-a "func" "function")
-    (funcall d-a "cr" "create")))
+  (let ((wrapper))
+    (define-abbrev-table 'sql-mode-abbrev-table ())
+    (define-abbrev sql-mode-abbrev-table  "ins" "insert")
+    (define-abbrev sql-mode-abbrev-table  "upd" "update")
+    (define-abbrev sql-mode-abbrev-table  "del" "delete")
+    (define-abbrev sql-mode-abbrev-table  "sel" "select")))
 
 ;; Syntax Table
 
@@ -867,57 +581,7 @@
 
 ;; Font lock support
 
-(defvar sql-mode-font-lock-object-name
-  (list (concat "^\\s-*\\(create\\(\\s-+or\\s-+replace\\)?\\|drop\\|alter\\)?\\s-+"
-		"\\(\\(global\\s-+\\)?\\(temporary\\s-+\\)?table\\|view\\|package\\(\\s-+body\\)?\\|"
-		"proc\\(edure\\)?\\|function\\|trigger\\|sequence\\|rule\\|default\\)\\s-+\\(\\w+\\)")
-	8 'font-lock-function-name-face)
-
-  "Pattern to match the names of top-level objects in a CREATE,
-DROP or ALTER statement.
-
-The format of variable should be a valid `font-lock-keywords'
-entry.")
-
-(defvar sql-mode-ansi-font-lock-keywords
-  (let ((ansi-keywords (eval-when-compile
-			 (concat "\\b"
-				 (regexp-opt '(
-
-"authorization" "avg" "begin" "close" "cobol" "commit"
-"continue" "count" "declare" "double" "end" "escape"
-"exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator"
-"key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli"
-"precision" "primary" "procedure" "references" "rollback"
-"schema" "section" "some" "sqlcode" "sqlerror" "sum" "work"
-
-) t) "\\b")))
-	(ansi-reserved-words (eval-when-compile
-			       (concat "\\b"
-				       (regexp-opt '(
-
-"all" "and" "any" "as" "asc" "between" "by" "check" "create"
-"current" "default" "delete" "desc" "distinct" "exists" "float" "for"
-"from" "grant" "group" "having" "in" "insert" "into" "is"
-"like" "not" "null" "of" "on" "option" "or" "order" "privileges"
-"public" "select" "set" "table" "to" "union" "unique"
-"update" "user" "values" "view" "where" "with"
-
-) t) "\\b")))
-	(ansi-types (eval-when-compile
-		      (concat "\\b"
-			      (regexp-opt '(
-
-;; ANSI Keywords that look like types
-"character" "cursor" "dec" "int" "real"
-;; ANSI Reserved Word that look like types
-"char" "integer" "smallint"
-
-) t) "\\b"))))
-    (list (cons ansi-keywords 'font-lock-keyword-face)
-		(cons ansi-reserved-words 'font-lock-keyword-face)
-	  (cons ansi-types 'font-lock-type-face)))
-
+(defvar sql-mode-ansi-font-lock-keywords nil
   "ANSI SQL keywords used by font-lock.
 
 This variable is used by `sql-mode' and `sql-interactive-mode'.  The
@@ -925,186 +589,39 @@
 function `regexp-opt'.  Therefore, take a look at the source before
 you define your own sql-mode-ansi-font-lock-keywords.  You may want to
 add functions and PL/SQL keywords.")
-
-(defvar sql-mode-oracle-font-lock-keywords
-  (let ((oracle-keywords (eval-when-compile
-			   (concat "\\b"
-				   (regexp-opt '(
-;; Oracle (+ANSI) SQL keywords
-
-; ANSI keywords
+(if sql-mode-ansi-font-lock-keywords
+    ()
+  (let ((ansi-keywords (eval-when-compile
+			 (concat "\\b"
+				 (regexp-opt '(
 "authorization" "avg" "begin" "close" "cobol" "commit"
 "continue" "count" "declare" "double" "end" "escape"
 "exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator"
 "key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli"
 "precision" "primary" "procedure" "references" "rollback"
-"schema" "section" "some" "sqlcode" "sqlerror" "sum" "work"
-
-; ANSI reserved words
+"schema" "section" "some" "sqlcode" "sqlerror" "sum" "work") t) "\\b")))
+	(ansi-reserved-words (eval-when-compile
+			       (concat "\\b"
+				       (regexp-opt '(
 "all" "and" "any" "as" "asc" "between" "by" "check" "create"
 "current" "default" "delete" "desc" "distinct" "exists" "float" "for"
 "from" "grant" "group" "having" "in" "insert" "into" "is"
 "like" "not" "null" "of" "on" "option" "or" "order" "privileges"
 "public" "select" "set" "table" "to" "union" "unique"
-"update" "user" "values" "view" "where" "with"
-
-"access" "add" "admin" "after" "allocate" "alter" "analyze" "archive"
-"archivelog" "audit" "authid" "backup" "become" "before" "block"
-"body" "cache" "cancel" "cascade" "change" "checkpoint" "cluster"
-"comment" "compile" "compress" "compute" "connect" "constraint"
-"constraints" "contents" "controlfile" "cross" "currval" "cycle"
-"database" "datafile" "dba" "deterministic" "disable" "dismount"
-"drop" "dump" "each" "else" "else" "elsif" "enable" "events" "except"
-"exceptions" "exclusive" "execute" "exit" "explain" "extent"
-"externally" "false" "file" "flush" "force" "freelist" "freelists"
-"full" "function" "global" "grant" "groups" "identified" "if"
-"immediate" "including" "increment" "index" "initial" "initrans"
-"inner" "instance" "intersect" "join" "layer" "left" "level" "link"
-"lists" "lock" "logfile" "long" "loop" "manage" "manual"
-"maxdatafiles" "maxextents" "maxinistances" "maxlogfiles"
-"maxloghistory" "maxlogmembers" "maxtrans" "maxvalue" "merge"
-"minextents" "minus" "minvalue" "mode" "modify" "mount" "natural"
-"new" "next" "nextval" "noarchivelog" "noaudit" "nocache" "nocompress"
-"nocycle" "nomaxvalue" "nominvalue" "none" "noorder" "noresetlogs"
-"normal" "nosort" "nowait" "off" "offline" "old" "online" "only"
-"optimal" "others" "out" "outer" "over" "own" "package" "parallel"
-"parallel_enable" "pctfree" "pctincrease" "pctused" "plan" "pragma"
-"preserve" "prior" "private" "profile" "quota" "raise" "raw" "read"
-"recover" "referencing" "rename" "replace" "resetlogs" "resource"
-"restrict_references" "restricted" "return" "returning" "reuse"
-"revoke" "right" "rnds" "rnps" "role" "roles" "row" "rowlabel"
-"rownum" "rows" "savepoint" "scn" "segment" "sequence" "session"
-"share" "shared" "size" "snapshot" "sort" "statement_id" "statistics"
-"stop" "storage" "subtype" "successful" "switch" "synonym" "sysdate"
-"system" "tables" "tablespace" "temporary" "then" "thread" "tracing"
-"transaction" "trigger" "triggers" "true" "truncate" "type" "uid"
-"under" "unlimited" "until" "use" "using" "validate" "when" "while"
-"wnds" "wnps" "write"
-
-) t) "\\b")))
-	(oracle-warning-words (eval-when-compile
-				 (concat "\\b"
-					 (regexp-opt '(
-;; PLSQL defined exceptions
-
-"access_into_null" "case_not_found" "collection_is_null"
-"cursor_already_open" "dup_val_on_index" "invalid_cursor"
-"invalid_number" "login_denied" "no_data_found" "not_logged_on"
-"program_error" "rowtype_mismatch" "self_is_null" "storage_error"
-"subscript_beyond_count" "subscript_outside_limit" "sys_invalid_rowid"
-"timeout_on_resource" "too_many_rows" "value_error" "zero_divide"
-"exception" "notfound"
-
-) t) "\\b")))
-
-	(oracle-sqlplus-commands
-	 (eval-when-compile
-	   (concat "^\\(\\("
-					 (regexp-opt '(
-;; SQL*Plus commands
-
-"@" "@@" "accept" "append" "archive" "attribute" "break"
-"btitle" "change" "clear" "column" "connect" "copy" "define"
-"del" "describe" "disconnect" "edit" "execute" "exit" "get" "help"
-"host" "input" "list" "password" "pause" "print" "prompt" "recover"
-"remark" "repfooter" "repheader" "run" "save" "show" "shutdown"
-"spool" "start" "startup" "store" "timing" "ttitle" "undefine"
-"variable" "whenever"
-
-) t)
+"update" "user" "values" "view" "where" "with") t) "\\b")))
+	(ansi-types (eval-when-compile
+		      (concat "\\b"
+			      (regexp-opt '(
+;; ANSI Keywords that look like types
+"character" "cursor" "dec" "int" "real"
+;; ANSI Reserved Word that look like types
+"char" "integer" "smallint" ) t) "\\b"))))
+    (setq sql-mode-ansi-font-lock-keywords
+	  (list (cons ansi-keywords 'font-lock-function-name-face)
+		(cons ansi-reserved-words 'font-lock-keyword-face)
+		(cons ansi-types 'font-lock-type-face)))))
 
-   "\\)\\|"
-   "\\(compute\\s-+\\(avg\\|cou\\|min\\|max\\|num\\|sum\\|std\\|var\\)\\)\\|"
-   "\\(set\\s-+\\(appi\\(nfo\\)?\\|array\\(size\\)?\\|"
-   "auto\\(commit\\)?\\|autop\\(rint\\)?\\|autorecovery\\|"
-   "autot\\(race\\)?\\|blo\\(ckterminator\\)?\\|cmds\\(ep\\)?\\|"
-   "colsep\\|com\\(patibility\\)?\\|con\\(cat\\)?\\|"
-   "copyc\\(ommit\\)?\\|copytypecheck\\|def\\(ine\\)?\\|"
-   "describe\\|echo\\|editf\\(ile\\)?\\|emb\\(edded\\)?\\|"
-   "esc\\(ape\\)?\\|feed\\(back\\)?\\|flagger\\|"
-   "flu\\(sh\\)?\\|hea\\(ding\\)?\\|heads\\(ep\\)?\\|"
-   "instance\\|lin\\(esize\\)?\\|lobof\\(fset\\)?\\|"
-   "logsource\\|long\\|longc\\(hunksize\\)?\\|mark\\(up\\)?\\|"
-   "newp\\(age\\)?\\|null\\|numf\\(ormat\\)?\\|"
-   "num\\(width\\)?\\|pages\\(ize\\)?\\|pau\\(se\\)?\\|"
-   "recsep\\|recsepchar\\|serverout\\(put\\)?\\|"
-   "shift\\(inout\\)?\\|show\\(mode\\)?\\|"
-   "sqlbl\\(anklines\\)?\\|sqlc\\(ase\\)?\\|"
-   "sqlco\\(ntinue\\)?\\|sqln\\(umber\\)?\\|"
-   "sqlpluscompat\\(ibility\\)?\\|sqlpre\\(fix\\)?\\|"
-   "sqlp\\(rompt\\)?\\|sqlt\\(erminator\\)?\\|"
-   "suf\\(fix\\)?\\|tab\\|term\\(out\\)?\\|ti\\(me\\)?\\|"
-   "timi\\(ng\\)?\\|trim\\(out\\)?\\|trims\\(pool\\)?\\|"
-   "und\\(erline\\)?\\|ver\\(ify\\)?\\|wra\\(p\\)?\\)\\)\\)"
-   "\\b.*$"
-   )))
-
-	(oracle-types
-	 (eval-when-compile
-			(concat "\\b"
-				(regexp-opt '(
-;; Oracle Keywords that look like types
-;; Oracle Reserved Words that look like types
-
-"bfile" "binary_integer" "blob" "boolean" "byte" "char" "character"
-"clob" "date" "day" "dec" "decimal" "double" "float" "int" "integer"
-"interval" "local" "long" "month" "natural" "naturaln" "nchar" "nclob"
-"number" "numeric" "nvarchar2" "pls_integer" "positive" "positiven"
-"precision" "raw" "real" "rowid" "second" "signtype" "smallint"
-"string" "time" "timestamp" "urowid" "varchar" "varchar2" "year"
-"zone"
-
-) t) "\\b")))
-	(oracle-builtin-functions (eval-when-compile
-			(concat "\\b"
-				(regexp-opt '(
-;; Misc Oracle builtin functions
-
-"abs" "acos" "add_months" "ascii" "asciistr" "asin" "atan" "atan2"
-"avg" "bfilename" "bin_to_num" "bitand" "case" "cast" "ceil"
-"chartorowid" "chr" "coalesce" "compose" "concat" "convert" "corr"
-"cos" "cosh" "count" "covar_pop" "covar_samp" "cume_dist"
-"current_date" "current_timestamp" "current_user" "dbtimezone"
-"decode" "decompose" "dense_rank" "depth" "deref" "dump" "empty_blob"
-"empty_clob" "existsnode" "exp" "extract" "extractvalue" "first"
-"first_value" "floor" "from_tz" "greatest" "group_id" "grouping"
-"grouping_id" "hextoraw" "initcap" "instr" "lag" "last" "last_day"
-"last_value" "lead" "least" "length" "ln" "localtimestamp" "log"
-"lower" "lpad" "ltrim" "make_ref" "max" "min" "mod" "months_between"
-"nchr" "new_time" "next_day" "nls_charset_decl_len" "nls_charset_id"
-"nls_charset_name" "nls_initcap" "nls_lower" "nlssort" "nls_upper"
-"ntile" "nullif" "numtodsinterval" "numtoyminterval" "nvl" "nvl2"
-"path" "percent_rank" "percentile_cont" "percentile_disc" "power"
-"rank" "ratio_to_report" "rawtohex" "rawtonhex" "ref" "reftohex"
-"regr_slope" "regr_intercept" "regr_count" "regr_r2" "regr_avgx"
-"regr_avgy" "regr_sxx" "regr_syy" "regr_sxy" "round"
-"row_number" "rowidtochar" "rowidtonchar" "rpad" "rtrim"
-"sessiontimezone" "sign" "sin" "sinh" "soundex" "sqrt" "stddev"
-"stddev_pop" "stddev_samp" "substr" "sum" "sys_connect_by_path"
-"sys_context" "sys_dburigen" "sys_extract_utc" "sys_guid" "sys_typeid"
-"sys_xmlagg" "sys_xmlgen" "sysdate" "systimestamp" "tan" "tanh"
-"to_char" "to_clob" "to_date" "to_dsinterval" "to_lob" "to_multi_byte"
-"to_nchar" "to_nclob" "to_number" "to_single_byte" "to_timestamp"
-"to_timestamp_tz" "to_yminterval" "translate" "treat" "trim" "trunc"
-"tz_offset" "uid" "unistr" "updatexml" "upper" "user" "userenv"
-"value" "var_pop" "var_samp" "variance" "vsize" "width_bucket"
-"xmlagg" "xmlcolattval" "xmlconcat" "xmlelement" "xmlforest"
-"xmlsequence" "xmltransform"
-
-) t) "\\b"))))
-    (list (cons oracle-sqlplus-commands 'font-lock-doc-face)
-	  (cons oracle-keywords 'font-lock-keyword-face)
-			(cons oracle-warning-words 'font-lock-warning-face)
-			;; XEmacs doesn't have font-lock-builtin-face
-			(if (string-match "XEmacs\\|Lucid" emacs-version)
-			    (cons oracle-builtin-functions 'font-lock-preprocessor-face)
-			  ;; GNU Emacs 19 doesn't have it either
-			  (if (string-match "GNU Emacs 19" emacs-version)
-		(cons oracle-builtin-functions 'font-lock-keyword-face)
-			    ;; Emacs
-			    (cons oracle-builtin-functions 'font-lock-builtin-face)))
-	  (cons oracle-types 'font-lock-type-face)))
-
+(defvar sql-mode-oracle-font-lock-keywords nil
   "Oracle SQL keywords used by font-lock.
 
 This variable is used by `sql-mode' and `sql-interactive-mode'.  The
@@ -1112,8 +629,98 @@
 function `regexp-opt'.  Therefore, take a look at the source before
 you define your own sql-mode-oracle-font-lock-keywords.  You may want
 to add functions and PL/SQL keywords.")
+(if sql-mode-oracle-font-lock-keywords
+    ()
+  (let ((oracle-keywords (eval-when-compile
+			   (concat "\\b"
+				   (regexp-opt '(
+"admin" "after" "allocate" "analyze" "archive" "archivelog" "backup"
+"become" "before" "block" "body" "cache" "cancel" "cascade" "change"
+"checkpoint" "compile" "constraint" "constraints" "contents"
+"controlfile" "cycle" "database" "datafile" "dba" "disable" "dismount"
+"dump" "each" "else" "elsif" "enable" "events" "except" "exceptions"
+"execute" "exit" "explain" "extent" "externally" "false" "flush" "force"
+"freelist" "freelists" "function" "groups" "if" "including" "initrans"
+"instance" "layer" "link" "lists" "logfile" "loop" "manage" "manual"
+"maxdatafiles" "maxinistances" "maxlogfiles" "maxloghistory"
+"maxlogmembers" "maxtrans" "maxvalue" "minextents" "minvalue" "mount"
+"new" "next" "noarchivelog" "nocache" "nocycle" "nomaxvalue"
+"nominvalue" "none" "noorder" "noresetlogs" "normal" "nosort" "off"
+"old" "only" "optimal" "others" "out" "own" "package" "parallel"
+"pctincrease" "pctused" "plan" "pragma" "private" "profile" "quota"
+"raise" "read" "recover" "referencing" "resetlogs" "restrict_references"
+"restricted" "return" "returning" "reuse" "rnds" "rnps" "role" "roles"
+"savepoint" "scn" "segment" "sequence" "shared" "snapshot" "sort"
+"statement_id" "statistics" "stop" "storage" "subtype" "switch" "system"
+"tables" "tablespace" "temporary" "thread" "time" "tracing"
+"transaction" "triggers" "true" "truncate" "type" "under" "unlimited"
+"until" "use" "using" "when" "while" "wnds" "wnps" "write") t) "\\b")))
+	(oracle-warning-words (eval-when-compile
+				 (concat "\\b"
+					 (regexp-opt '(
+"cursor_already_open" "dup_val_on_index" "exception" "invalid_cursor"
+"invalid_number" "login_denied" "no_data_found" "not_logged_on"
+"notfound" "others" "pragma" "program_error" "storage_error"
+"timeout_on_resource" "too_many_rows" "transaction_backed_out"
+"value_error" "zero_divide") t) "\\b")))
+	(oracle-reserved-words (eval-when-compile
+				 (concat "\\b"
+					 (regexp-opt '(
+"access" "add" "alter" "audit" "cluster" "column" "comment" "compress"
+"connect" "drop" "else" "exclusive" "file" "grant"
+"identified" "immediate" "increment" "index" "initial" "intersect"
+"level" "lock" "long" "maxextents" "minus" "mode" "modify" "noaudit"
+"nocompress" "nowait" "number" "offline" "online" "pctfree" "prior"
+"raw" "rename" "resource" "revoke" "row" "rowlabel" "rownum"
+"rows" "session" "share" "size" "start" "successful" "synonym" "sysdate"
+"then" "trigger" "uid" "validate" "whenever") t) "\\b")))
+	(oracle-types (eval-when-compile
+			(concat "\\b"
+				(regexp-opt '(
+;; Oracle Keywords that look like types
+;; Oracle Reserved Words that look like types
+"binary_integer" "blob" "boolean" "constant" "date" "decimal" "rowid"
+"varchar" "varchar2") t) "\\b")))
+	(oracle-builtin-functions (eval-when-compile
+			(concat "\\b"
+				(regexp-opt '(
+;; Misc Oracle builtin functions
+"abs" "add_months" "ascii" "avg" "ceil" "chartorowid" "chr" "concat"
+"convert" "cos" "cosh" "count" "currval" "decode" "dump" "exp" "floor"
+"glb" "greatest" "greatest_lb" "hextoraw" "initcap" "instr" "instrb"
+"last_day" "least" "least_ub" "length" "lengthb" "ln" "log" "lower"
+"lpad" "ltrim" "lub" "max" "min" "mod" "months_between" "new_time"
+"next_day" "nextval" "nls_initcap" "nls_lower" "nls_upper" "nlssort"
+"nvl" "power" "rawtohex" "replace" "round" "rowidtochar" "rpad"
+"rtrim" "sign" "sin" "sinh" "soundex" "sqlcode" "sqlerrm" "sqrt"
+"stddev" "sum" "substr" "substrb" "tan" "tanh" "to_char"
+"to_date" "to_label" "to_multi_byte" "to_number" "to_single_byte"
+"translate" "trim" "trunc" "uid" "upper" "userenv" "variance" "vsize") t) "\\b"))))
+    (setq sql-mode-oracle-font-lock-keywords
+	  (append sql-mode-ansi-font-lock-keywords
+		  (list (cons oracle-keywords 'font-lock-function-name-face)
+			(cons oracle-warning-words 'font-lock-warning-face)
+			(cons oracle-reserved-words 'font-lock-keyword-face)
+			;; XEmacs doesn't have font-lock-builtin-face
+			(if (string-match "XEmacs\\|Lucid" emacs-version)
+			    (cons oracle-builtin-functions 'font-lock-preprocessor-face)
+			  ;; GNU Emacs 19 doesn't have it either
+			  (if (string-match "GNU Emacs 19" emacs-version)
+			      (cons oracle-builtin-functions 'font-lock-function-name-face)
+			    ;; Emacs
+			    (cons oracle-builtin-functions 'font-lock-builtin-face)))
+			(cons oracle-types 'font-lock-type-face))))))
 
-(defvar sql-mode-postgres-font-lock-keywords
+(defvar sql-mode-postgres-font-lock-keywords nil
+  "Postgres SQL keywords used by font-lock.
+
+This variable is used by `sql-mode' and `sql-interactive-mode'.  The
+regular expressions are created during compilation by calling the
+function `regexp-opt'.  Therefore, take a look at the source before
+you define your own sql-mode-postgres-font-lock-keywords.")
+
+(if sql-mode-postgres-font-lock-keywords
+    ()
   (let ((postgres-reserved-words (eval-when-compile
 				 (concat "\\b"
 					 (regexp-opt '(
@@ -1122,17 +729,14 @@
 	(postgres-types (eval-when-compile
 			  (concat "\\b"
 				  (regexp-opt '(
-
 "bool" "box" "circle" "char" "char2" "char4" "char8" "char16" "date"
 "float4" "float8" "int2" "int4" "int8" "line" "lseg" "money" "path"
 "point" "polygon" "serial" "text" "time" "timespan" "timestamp" "varchar"
-
 ) t)"\\b")))
 	(postgres-builtin-functions (eval-when-compile
 			(concat "\\b"
 				(regexp-opt '(
 ;; Misc Postgres builtin functions
-
 "abstime" "age" "area" "box" "center" "date_part" "date_trunc"
 "datetime" "dexp" "diameter" "dpow" "float" "float4" "height"
 "initcap" "integer" "isclosed" "isfinite" "isoldpath" "isopen"
@@ -1140,8 +744,8 @@
 "position" "radius" "reltime" "revertpoly" "rpad" "rtrim" "substr"
 "substring" "text" "timespan" "translate" "trim" "upgradepath"
 "upgradepoly" "upper" "varchar" "width"
-
 ) t) "\\b"))))
+    (setq sql-mode-postgres-font-lock-keywords
 	  (append sql-mode-ansi-font-lock-keywords
 		  (list (cons postgres-reserved-words 'font-lock-keyword-face)
 			;; XEmacs doesn't have 'font-lock-builtin-face
@@ -1149,20 +753,21 @@
 			    (cons postgres-builtin-functions 'font-lock-preprocessor-face)
 			  ;; Emacs
 			  (cons postgres-builtin-functions 'font-lock-builtin-face))
-		  (cons postgres-types 'font-lock-type-face))))
+			(cons postgres-types 'font-lock-type-face))))))
+
 
-  "Postgres SQL keywords used by font-lock.
+(defvar sql-mode-linter-font-lock-keywords nil
+  "Linter SQL keywords used by font-lock.
 
 This variable is used by `sql-mode' and `sql-interactive-mode'.  The
 regular expressions are created during compilation by calling the
-function `regexp-opt'.  Therefore, take a look at the source before
-you define your own sql-mode-postgres-font-lock-keywords.")
+function `regexp-opt'.")
 
-(defvar sql-mode-linter-font-lock-keywords
+(if sql-mode-linter-font-lock-keywords
+    ()
   (let ((linter-keywords (eval-when-compile
 			   (concat "\\b"
 				   (regexp-opt '(
-
 "autocommit" "autoinc" "autorowid" "cancel" "cascade" "channel"
 "committed" "count" "countblob" "cross" "current" "data" "database"
 "datafile" "datafiles" "datesplit" "dba" "dbname" "default" "deferred"
@@ -1187,12 +792,10 @@
 "trigger_info_size" "true" "trunc" "uncommitted" "unicode" "unknown"
 "unlimited" "unlisted" "user" "utf8" "value" "varying" "volumes"
 "wait" "windows_code" "workspace" "write" "xml"
-
 ) t) "\\b")))
 	(linter-reserved-words (eval-when-compile
 				 (concat "\\b"
 					 (regexp-opt '(
-
 "access" "action" "add" "address" "after" "all" "alter" "always" "and"
 "any" "append" "as" "asc" "ascic" "async" "at_begin" "at_end" "audit"
 "aud_obj_name_len" "backup" "base" "before" "between" "blobfile"
@@ -1210,22 +813,18 @@
 "start" "stop" "sync" "synchronize" "synonym" "sysdate" "table" "then"
 "to" "union" "unique" "unlock" "until" "update" "using" "values"
 "view" "when" "where" "with" "without"
-
 ) t) "\\b")))
 	(linter-types (eval-when-compile
 			(concat "\\b"
 				(regexp-opt '(
-
 "bigint" "bitmap" "blob" "boolean" "char" "character" "date"
 "datetime" "dec" "decimal" "double" "float" "int" "integer" "nchar"
 "number" "numeric" "real" "smallint" "varbyte" "varchar" "byte"
 "cursor" "long"
-
 ) t) "\\b")))
 	(linter-builtin-functions (eval-when-compile
 			(concat "\\b"
 				(regexp-opt '(
-
 "abs" "acos" "asin" "atan" "atan2" "avg" "ceil" "cos" "cosh" "divtime"
 "exp" "floor" "getbits" "getblob" "getbyte" "getlong" "getraw"
 "getstr" "gettext" "getword" "hextoraw" "lenblob" "length" "log"
@@ -1236,367 +835,59 @@
 "to_gmtime" "to_localtime" "to_number" "trim" "upper" "decode"
 "substr" "substring" "chr" "dayname" "days" "greatest" "hex" "initcap"
 "instr" "least" "multime" "replace" "width"
-
 ) t) "\\b"))))
+    (setq sql-mode-linter-font-lock-keywords
 	  (append sql-mode-ansi-font-lock-keywords
-	    (list (cons linter-keywords 'font-lock-keywords-face)
+		  (list (cons linter-keywords 'font-lock-function-name-face)
 			(cons linter-reserved-words 'font-lock-keyword-face)
 			;; XEmacs doesn't have font-lock-builtin-face
 			(if (string-match "XEmacs\\|Lucid" emacs-version)
 			    (cons linter-builtin-functions 'font-lock-preprocessor-face)
 			  ;; GNU Emacs 19 doesn't have it either
 			  (if (string-match "GNU Emacs 19" emacs-version)
-			(cons linter-builtin-functions 'font-lock-keywords-face)
+			      (cons linter-builtin-functions 'font-lock-function-name-face)
 			    ;; Emacs
 			    (cons linter-builtin-functions 'font-lock-builtin-face)))
-		  (cons linter-types 'font-lock-type-face))))
-
-  "Linter SQL keywords used by font-lock.
-
-This variable is used by `sql-mode' and `sql-interactive-mode'.  The
-regular expressions are created during compilation by calling the
-function `regexp-opt'.")
-
-(defvar sql-mode-ms-font-lock-keywords
-  (let ((ms-reserved-words (eval-when-compile
-			     (concat "\\b"
-				     (regexp-opt '(
-
-"absolute" "add" "all" "alter" "and" "any" "as" "asc" "authorization"
-"avg" "backup" "begin" "between" "break" "browse" "bulk" "by"
-"cascade" "case" "check" "checkpoint" "close" "clustered" "coalesce"
-"column" "commit" "committed" "compute" "confirm" "constraint"
-"contains" "containstable" "continue" "controlrow" "convert" "count"
-"create" "cross" "current" "current_date" "current_time"
-"current_timestamp" "current_user" "database" "deallocate"
-"declare" "default" "delete" "deny" "desc" "disk" "distinct"
-"distributed" "double" "drop" "dummy" "dump" "else" "end" "errlvl"
-"errorexit" "escape" "except" "exec" "execute" "exists" "exit" "fetch"
-"file" "fillfactor" "first" "floppy" "for" "foreign" "freetext"
-"freetexttable" "from" "full" "goto" "grant" "group" "having"
-"holdlock" "identity" "identity_insert" "identitycol" "if" "in"
-"index" "inner" "insert" "intersect" "into" "is" "isolation" "join"
-"key" "kill" "last" "left" "level" "like" "lineno" "load" "max" "min"
-"mirrorexit" "national" "next" "nocheck" "nolock" "nonclustered" "not"
-"null" "nullif" "of" "off" "offsets" "on" "once" "only" "open"
-"opendatasource" "openquery" "openrowset" "option" "or" "order"
-"outer" "output" "over" "paglock" "percent" "perm" "permanent" "pipe"
-"plan" "precision" "prepare" "primary" "print" "prior" "privileges"
-"proc" "procedure" "processexit" "public" "raiserror" "read"
-"readcommitted" "readpast" "readtext" "readuncommitted" "reconfigure"
-"references" "relative" "repeatable" "repeatableread" "replication"
-"restore" "restrict" "return" "revoke" "right" "rollback" "rowcount"
-"rowguidcol" "rowlock" "rule" "save" "schema" "select" "serializable"
-"session_user" "set" "shutdown" "some" "statistics" "sum"
-"system_user" "table" "tablock" "tablockx" "tape" "temp" "temporary"
-"textsize" "then" "to" "top" "tran" "transaction" "trigger" "truncate"
-"tsequal" "uncommitted" "union" "unique" "update" "updatetext"
-"updlock" "use" "user" "values" "view" "waitfor" "when" "where"
-"while" "with" "work" "writetext"
-"collate" "function" "openxml" "returns"
-
-) t) "\\b")))
-	(ms-types (eval-when-compile
-		    (concat "\\b"
-			    (regexp-opt '(
-
-"binary" "bit" "char" "character" "cursor" "datetime" "dec" "decimal"
-"double" "float" "image" "int" "integer" "money" "national" "nchar"
-"ntext" "numeric" "numeric" "nvarchar" "precision" "real"
-"smalldatetime" "smallint" "smallmoney" "text" "timestamp" "tinyint"
-"uniqueidentifier" "varbinary" "varchar" "varying"
-
-) t) "\\b")))
-
-	(ms-vars "\\b@[a-zA-Z0-9_]*\\b")
-
-	(ms-builtin-functions (eval-when-compile
-				(concat "\\b"
-					(regexp-opt '(
-;; Misc MS builtin functions
-
-"@@connections" "@@cpu_busy" "@@cursor_rows" "@@datefirst" "@@dbts"
-"@@error" "@@fetch_status" "@@identity" "@@idle" "@@io_busy"
-"@@langid" "@@language" "@@lock_timeout" "@@max_connections"
-"@@max_precision" "@@nestlevel" "@@options" "@@pack_received"
-"@@pack_sent" "@@packet_errors" "@@procid" "@@remserver" "@@rowcount"
-"@@servername" "@@servicename" "@@spid" "@@textsize" "@@timeticks"
-"@@total_errors" "@@total_read" "@@total_write" "@@trancount"
-"@@version" "abs" "acos" "and" "app_name" "ascii" "asin" "atan" "atn2"
-"avg" "case" "cast" "ceiling" "char" "charindex" "coalesce"
-"col_length" "col_name" "columnproperty" "containstable" "convert"
-"cos" "cot" "count" "current_timestamp" "current_user" "cursor_status"
-"databaseproperty" "datalength" "dateadd" "datediff" "datename"
-"datepart" "day" "db_id" "db_name" "degrees" "difference" "exp"
-"file_id" "file_name" "filegroup_id" "filegroup_name"
-"filegroupproperty" "fileproperty" "floor" "formatmessage"
-"freetexttable" "fulltextcatalogproperty" "fulltextserviceproperty"
-"getansinull" "getdate" "grouping" "host_id" "host_name" "ident_incr"
-"ident_seed" "identity" "index_col" "indexproperty" "is_member"
-"is_srvrolemember" "isdate" "isnull" "isnumeric" "left" "len" "log"
-"log10" "lower" "ltrim" "max" "min" "month" "nchar" "newid" "nullif"
-"object_id" "object_name" "objectproperty" "openquery" "openrowset"
-"parsename" "patindex" "patindex" "permissions" "pi" "power"
-"quotename" "radians" "rand" "replace" "replicate" "reverse" "right"
-"round" "rtrim" "session_user" "sign" "sin" "soundex" "space" "sqrt"
-"square" "stats_date" "stdev" "stdevp" "str" "stuff" "substring" "sum"
-"suser_id" "suser_name" "suser_sid" "suser_sname" "system_user" "tan"
-"textptr" "textvalid" "typeproperty" "unicode" "upper" "user"
-"user_id" "user_name" "var" "varp" "year"
-
-) t) "\\b")))
+			(cons linter-types 'font-lock-type-face))))))
 
-	(ms-config-commands
-	 (eval-when-compile
-	   (concat "^\\(\\(set\\s-+\\("
-		   (regexp-opt '(
-
-"datefirst" "dateformat" "deadlock_priority" "lock_timeout"
-"concat_null_yields_null" "cursor_close_on_commit"
-"disable_def_cnst_chk" "fips_flagger" "identity_insert" "language"
-"offsets" "quoted_identifier" "arithabort" "arithignore" "fmtonly"
-"nocount" "noexec" "numeric_roundabort" "parseonly"
-"query_governor_cost_limit" "rowcount" "textsize" "ansi_defaults"
-"ansi_null_dflt_off" "ansi_null_dflt_on" "ansi_nulls" "ansi_padding"
-"ansi_warnings" "forceplan" "showplan_all" "showplan_text"
-"statistics" "implicit_transactions" "remote_proc_transactions"
-"transaction" "xact_abort"
-
-) t)
-		   "\\)\\)\\|go\\s-*\\|use\\s-+\\|setuser\\s-+\\|dbcc\\s-+\\).*$"))))
-
-    (list (cons ms-config-commands 'font-lock-doc-face)
-	  (cons ms-reserved-words 'font-lock-keyword-face)
-	  ;; XEmacs doesn't have 'font-lock-builtin-face
-	  (if (string-match "XEmacs\\|Lucid" emacs-version)
-	      (cons ms-builtin-functions 'font-lock-preprocessor-face)
-	    ;; Emacs
-	    (cons ms-builtin-functions 'font-lock-builtin-face))
-	  (cons ms-vars  'font-lock-variable-name-face)
-	  (cons ms-types 'font-lock-type-face)))
-
-  "Microsoft SQLServer SQL keywords used by font-lock.
-
-This variable is used by `sql-mode' and `sql-interactive-mode'.  The
-regular expressions are created during compilation by calling the
-function `regexp-opt'.  Therefore, take a look at the source before
-you define your own sql-mode-ms-font-lock-keywords.")
-
-(defvar sql-mode-sybase-font-lock-keywords sql-mode-ansi-font-lock-keywords
-  "Sybase SQL keywords used by font-lock.
-
-This variable is used by `sql-mode' and `sql-interactive-mode'.  The
-regular expressions are created during compilation by calling the
-function `regexp-opt'.  Therefore, take a look at the source before
-you define your own sql-mode-sybase-font-lock-keywords.")
-
-(defvar sql-mode-informix-font-lock-keywords sql-mode-ansi-font-lock-keywords
-  "Informix SQL keywords used by font-lock.
-
-This variable is used by `sql-mode' and `sql-interactive-mode'.  The
-regular expressions are created during compilation by calling the
-function `regexp-opt'.  Therefore, take a look at the source before
-you define your own sql-mode-informix-font-lock-keywords.")
-
-(defvar sql-mode-interbase-font-lock-keywords sql-mode-ansi-font-lock-keywords
-  "Interbase SQL keywords used by font-lock.
-
-This variable is used by `sql-mode' and `sql-interactive-mode'.  The
-regular expressions are created during compilation by calling the
-function `regexp-opt'.  Therefore, take a look at the source before
-you define your own sql-mode-interbase-font-lock-keywords.")
-
-(defvar sql-mode-ingres-font-lock-keywords sql-mode-ansi-font-lock-keywords
-  "Ingres SQL keywords used by font-lock.
-
-This variable is used by `sql-mode' and `sql-interactive-mode'.  The
-regular expressions are created during compilation by calling the
-function `regexp-opt'.  Therefore, take a look at the source before
-you define your own sql-mode-interbase-font-lock-keywords.")
-
-(defvar sql-mode-solid-font-lock-keywords sql-mode-ansi-font-lock-keywords
-  "Solid SQL keywords used by font-lock.
-
-This variable is used by `sql-mode' and `sql-interactive-mode'.  The
-regular expressions are created during compilation by calling the
-function `regexp-opt'.  Therefore, take a look at the source before
-you define your own sql-mode-solid-font-lock-keywords.")
-
-(defvar sql-mode-mysql-font-lock-keywords sql-mode-ansi-font-lock-keywords
-  "MySQL SQL keywords used by font-lock.
-
-This variable is used by `sql-mode' and `sql-interactive-mode'.  The
-regular expressions are created during compilation by calling the
-function `regexp-opt'.  Therefore, take a look at the source before
-you define your own sql-mode-mysql-font-lock-keywords.")
-
-(defvar sql-mode-sqlite-font-lock-keywords sql-mode-ansi-font-lock-keywords
-  "SQLite SQL keywords used by font-lock.
-
-This variable is used by `sql-mode' and `sql-interactive-mode'.  The
-regular expressions are created during compilation by calling the
-function `regexp-opt'.  Therefore, take a look at the source before
-you define your own sql-mode-sqlite-font-lock-keywords.")
-
-(defvar sql-mode-db2-font-lock-keywords sql-mode-ansi-font-lock-keywords
-  "DB2 SQL keywords used by font-lock.
-
-This variable is used by `sql-mode' and `sql-interactive-mode'.  The
-regular expressions are created during compilation by calling the
-function `regexp-opt'.  Therefore, take a look at the source before
-you define your own sql-mode-db2-font-lock-keywords.")
-
-(defvar sql-mode-font-lock-keywords nil
+(defvar sql-mode-font-lock-keywords sql-mode-ansi-font-lock-keywords
   "SQL keywords used by font-lock.
 
-Setting this variable directly no longer has any affect.  Use
-`sql-product' and `sql-add-product-keywords' to control the
-highlighting rules in sql-mode.")
-
-
-
-;;; SQL Product support functions
-
-(defun sql-product-feature (feature &optional product)
-  "Lookup `feature' needed to support the current SQL product.
-
-See \[sql-product-support] for a list of products and supported features."
-  (cadr
-   (memq feature
-	 (assoc (or product sql-product)
-		sql-product-support))))
-
-(defun sql-product-font-lock (keywords-only imenu)
-  "Sets `font-lock-defaults' and `font-lock-keywords' based on
-the product-specific keywords and syntax-alists defined in
-`sql-product-support'."
-  (let
-      ;; Get the product-specific syntax-alist.
-      ((syntax-alist
-	(append
-	 (sql-product-feature :syntax-alist)
-	 '((?_ . "w") (?. . "w")))))
-
-    ;; Get the product-specific keywords.
-    (setq sql-mode-font-lock-keywords
-	  (append
-	   (eval (sql-product-feature :font-lock))
-	   (list sql-mode-font-lock-object-name)))
-
-    ;; Setup font-lock.  (What is the minimum we should have to do
-    ;; here?)
-    (setq font-lock-set-defaults nil
-	  font-lock-keywords sql-mode-font-lock-keywords
-	  font-lock-defaults (list 'sql-mode-font-lock-keywords
-				   keywords-only t syntax-alist))
-
-    ;; Setup imenu; it needs the same syntax-alist.
-    (when imenu
-	(setq imenu-syntax-alist syntax-alist))))
-
-;;;###autoload
-(defun sql-add-product-keywords (product keywords)
-  "Append a `font-lock-keywords' entry to the existing entries defined
-  for the specified `product'."
-
-  (let ((font-lock (sql-product-feature :font-lock product)))
-       (set font-lock (append (eval font-lock) (list keywords)))))
+This variable defaults to `sql-mode-ansi-font-lock-keywords'.  This is
+used for the default `font-lock-defaults' value in `sql-mode'.  This
+can be changed by some entry functions to provide more hilighting.")
 
 
 
 ;;; Functions to switch highlighting
 
-(defun sql-highlight-product ()
-  "Turns on the appropriate font highlighting for the SQL product
-selected."
-
-  (when (eq major-mode 'sql-mode)
-    ;; Setup font-lock
-    (sql-product-font-lock nil t)
-
-    ;; Force fontification, if its enabled.
-    (if font-lock-mode
-	(font-lock-fontify-buffer))
-
-    ;; Set the mode name to include the product.
-    (setq mode-name (concat "SQL[" (prin1-to-string sql-product) "]"))))
-
-(defun sql-set-product (product)
-  "Set `sql-product' to product and enable appropriate
-highlighting."
-  (interactive "SEnter SQL product: ")
-  (when (not (assoc product sql-product-support))
-    (error "SQL product %s is not supported; treated as ANSI" product)
-    (setq product 'ansi))
-
-  ;; Save product setting and fontify.
-  (setq sql-product product)
-  (sql-highlight-product))
-
 (defun sql-highlight-oracle-keywords ()
-  "Highlight Oracle keywords."
+  "Highlight Oracle keywords.
+Basically, this just sets `font-lock-keywords' appropriately."
   (interactive)
-  (sql-set-product 'oracle))
+  (setq font-lock-keywords sql-mode-oracle-font-lock-keywords)
+  (font-lock-fontify-buffer))
 
 (defun sql-highlight-postgres-keywords ()
-  "Highlight Postgres keywords."
+  "Highlight Postgres keywords.
+Basically, this just sets `font-lock-keywords' appropriately."
   (interactive)
-  (sql-set-product 'postgres))
+  (setq font-lock-keywords sql-mode-postgres-font-lock-keywords)
+  (font-lock-fontify-buffer))
 
 (defun sql-highlight-linter-keywords ()
-  "Highlight LINTER keywords."
+  "Highlight LINTER keywords.
+Basically, this just sets `font-lock-keywords' appropriately."
   (interactive)
-  (sql-set-product 'linter))
-
-(defun sql-highlight-ms-keywords ()
-  "Highlight Microsoft SQLServer keywords."
-  (interactive)
-  (sql-set-product 'ms))
+  (setq font-lock-keywords sql-mode-linter-font-lock-keywords)
+  (font-lock-fontify-buffer))
 
 (defun sql-highlight-ansi-keywords ()
-  "Highlight ANSI SQL keywords."
-  (interactive)
-  (sql-set-product 'ansi))
-
-(defun sql-highlight-sybase-keywords ()
-  "Highlight Sybase SQL keywords."
-  (interactive)
-  (sql-set-product 'sybase))
-
-(defun sql-highlight-informix-keywords ()
-  "Highlight Informix SQL keywords."
-  (interactive)
-  (sql-set-product 'informix))
-
-(defun sql-highlight-interbase-keywords ()
-  "Highlight Interbase SQL keywords."
-  (interactive)
-  (sql-set-product 'interbase))
-
-(defun sql-highlight-ingres-keywords ()
-  "Highlight Ingres SQL keywords."
+  "Highlight ANSI SQL keywords.
+Basically, this just sets `font-lock-keywords' appropriately."
   (interactive)
-  (sql-set-product 'ingres))
-
-(defun sql-highlight-solid-keywords ()
-  "Highlight Solid SQL keywords."
-  (interactive)
-  (sql-set-product 'solid))
-
-(defun sql-highlight-mysql-keywords ()
-  "Highlight MySQL SQL keywords."
-  (interactive)
-  (sql-set-product 'mysql))
-
-(defun sql-highlight-sqlite-keywords ()
-  "Highlight SQLite SQL keywords."
-  (interactive)
-  (sql-set-product 'sqlite))
-
-(defun sql-highlight-db2-keywords ()
-  "Highlight DB2 SQL keywords."
-  (interactive)
-  (sql-set-product 'db2))
+  (setq font-lock-keywords sql-mode-ansi-font-lock-keywords)
+  (font-lock-fontify-buffer))
 
 
 
@@ -1662,7 +953,6 @@
     Sybase: \\[sql-sybase]
     Ingres: \\[sql-ingres]
     Microsoft: \\[sql-ms]
-    DB2: \\[sql-db2]
     Interbase: \\[sql-interbase]
     Linter: \\[sql-linter]
 
@@ -1709,30 +999,26 @@
 The function asks for the username if WHAT contains symbol `user', for
 the password if it contains symbol `password', for the server if it
 contains symbol `server', and for the database if it contains symbol
-`database'.  The members of WHAT are processed in the order in which
-they are provided.
+`database'.
 
 In order to ask the user for username, password and database, call the
 function like this: (sql-get-login 'user 'password 'database)."
   (interactive)
-  (while what
-    (cond
-     ((eq (car what) 'user)		; user
+  (if (memq 'user what)
       (setq sql-user
 	    (read-from-minibuffer "User: " sql-user nil nil
 				  sql-user-history)))
-     ((eq (car what) 'password)		; password
+  (if (memq 'password what)
       (setq sql-password
 	    (sql-read-passwd "Password: " sql-password)))
-     ((eq (car what) 'server)		; server
+  (if (memq 'server what)
       (setq sql-server
 	    (read-from-minibuffer "Server: " sql-server nil nil
 				  sql-server-history)))
-     ((eq (car what) 'database)		; database
+  (if (memq 'database what)
       (setq sql-database
 	    (read-from-minibuffer "Database: " sql-database nil nil
 				  sql-database-history))))
-    (setq what (cdr what))))
 
 (defun sql-find-sqli-buffer ()
   "Return the current default SQLi buffer or nil.