aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/sql.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/sql.el')
-rw-r--r--lisp/progmodes/sql.el941
1 files changed, 584 insertions, 357 deletions
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index 1a9251599ce..0e0d89b07e1 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -1,11 +1,12 @@
1;;; sql.el --- specialized comint.el for SQL interpreters 1;;; sql.el --- specialized comint.el for SQL interpreters
2 2
3;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 3;; Copyright (C) 1998,99,2000,01,02,03,04 Free Software Foundation, Inc.
4 4
5;; Author: Alex Schroeder <alex@gnu.org> 5;; Author: Alex Schroeder <alex@gnu.org>
6;; Maintainer: Michael Mauger <mmaug@yahoo.com> 6;; Maintainer: Michael Mauger <mmaug@yahoo.com>
7;; Version: 1.8.0 7;; Version: 2.0.1
8;; Keywords: comm languages processes 8;; Keywords: comm languages processes
9;; URL: http://savannah.gnu.org/cgi-bin/viewcvs/emacs/emacs/lisp/progmodes/sql.el
9;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode 10;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode
10 11
11;; This file is part of GNU Emacs. 12;; This file is part of GNU Emacs.
@@ -101,7 +102,7 @@
101 102
102;; (const :tag "XyzDB" xyz) 103;; (const :tag "XyzDB" xyz)
103 104
104;; 2) Add an entry to the `sql-product-support' list. 105;; 2) Add an entry to the `sql-product-alist' list.
105 106
106;; (xyz 107;; (xyz
107;; :font-lock sql-mode-xyz-font-lock-keywords 108;; :font-lock sql-mode-xyz-font-lock-keywords
@@ -136,7 +137,7 @@
136;; using ANSI keywords. See sql-mode-oracle-font-lock-keywords for 137;; using ANSI keywords. See sql-mode-oracle-font-lock-keywords for
137;; a more complex example. 138;; a more complex example.
138 139
139;; (defvar sql-mode-xyz-font-lock-keywords sql-mode-ansi-font-lock-keywords 140;; (defvar sql-mode-xyz-font-lock-keywords nil
140;; "XyzDB SQL keywords used by font-lock.") 141;; "XyzDB SQL keywords used by font-lock.")
141 142
142;; 6) Add a product highlighting function. 143;; 6) Add a product highlighting function.
@@ -192,13 +193,18 @@
192 193
193;;; Thanks to all the people who helped me out: 194;;; Thanks to all the people who helped me out:
194 195
196;; Alex Schroeder <alex@gnu.org>
195;; Kai Blauberg <kai.blauberg@metla.fi> 197;; Kai Blauberg <kai.blauberg@metla.fi>
196;; <ibalaban@dalet.com> 198;; <ibalaban@dalet.com>
197;; Yair Friedman <yfriedma@JohnBryce.Co.Il> 199;; Yair Friedman <yfriedma@JohnBryce.Co.Il>
198;; Gregor Zych <zych@pool.informatik.rwth-aachen.de> 200;; Gregor Zych <zych@pool.informatik.rwth-aachen.de>
199;; nino <nino@inform.dk> 201;; nino <nino@inform.dk>
200;; Berend de Boer <berend@pobox.com> 202;; Berend de Boer <berend@pobox.com>
201;; Michael Mauger <mmaug@yahoo.com> 203;; Adam Jenkins <adam@thejenkins.org>
204;; Michael Mauger <mmaug@yahoo.com> -- improved product support
205;; Drew Adams <drew.adams@oracle.com> -- Emacs 20 support
206;; Harald Maier <maierh@myself.com> -- sql-send-string
207;; Stefan Monnier <monnier@iro.umontreal.ca> -- font-lock corrections
202 208
203 209
204 210
@@ -209,6 +215,8 @@
209(eval-when-compile 215(eval-when-compile
210 (require 'regexp-opt)) 216 (require 'regexp-opt))
211(require 'custom) 217(require 'custom)
218(eval-when-compile ;; needed in Emacs 19, 20
219 (setq max-specpdl-size 2000))
212 220
213;;; Allow customization 221;;; Allow customization
214 222
@@ -264,7 +272,7 @@ highlighted properly when you open them."
264(defvar sql-interactive-product nil 272(defvar sql-interactive-product nil
265 "Product under `sql-interactive-mode'.") 273 "Product under `sql-interactive-mode'.")
266 274
267(defvar sql-product-support 275(defvar sql-product-alist
268 '((ansi 276 '((ansi
269 :font-lock sql-mode-ansi-font-lock-keywords) 277 :font-lock sql-mode-ansi-font-lock-keywords)
270 (db2 278 (db2
@@ -319,9 +327,9 @@ highlighted properly when you open them."
319 :syntax-alist ((?$ . "w") (?# . "w"))) 327 :syntax-alist ((?$ . "w") (?# . "w")))
320 (postgres 328 (postgres
321 :font-lock sql-mode-postgres-font-lock-keywords 329 :font-lock sql-mode-postgres-font-lock-keywords
322 :sqli-login (database server) 330 :sqli-login (user database server)
323 :sqli-connect sql-connect-postgres 331 :sqli-connect sql-connect-postgres
324 :sqli-prompt-regexp "^.*> *" 332 :sqli-prompt-regexp "^.*[#>] *"
325 :sqli-prompt-length 5) 333 :sqli-prompt-length 5)
326 (solid 334 (solid
327 :font-lock sql-mode-solid-font-lock-keywords 335 :font-lock sql-mode-solid-font-lock-keywords
@@ -372,10 +380,12 @@ following:
372 database. Do product specific 380 database. Do product specific
373 configuration of comint in this function. 381 configuration of comint in this function.
374 382
375 :sqli-prompt-regexp a regular expression string that matches the 383 :sqli-prompt-regexp a regular expression string that matches
376 prompt issued by the product interpreter. 384 the prompt issued by the product
385 interpreter. (Not needed in 21.3+)
377 386
378 :sqli-prompt-length the length of the prompt on the line. 387 :sqli-prompt-length the length of the prompt on the line.(Not
388 needed in 21.3+)
379 389
380 :syntax-alist an alist of syntax table entries to enable 390 :syntax-alist an alist of syntax table entries to enable
381 special character treatment by font-lock and 391 special character treatment by font-lock and
@@ -412,14 +422,14 @@ buffer is shown using `display-buffer'."
412 422
413(defvar sql-imenu-generic-expression 423(defvar sql-imenu-generic-expression
414 ;; Items are in reverse order because they are rendered in reverse. 424 ;; Items are in reverse order because they are rendered in reverse.
415 '(("Rules/Defaults" "^\\s-*create\\s-+\\(rule\\|default\\)\\s-+\\(\\w+\\)" 2) 425 '(("Rules/Defaults" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*\\(rule\\|default\\)\\s-+\\(\\w+\\)" 3)
416 ("Sequences" "^\\s-*create\\s-+sequence\\s-+\\(\\w+\\)" 1) 426 ("Sequences" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*sequence\\s-+\\(\\w+\\)" 2)
417 ("Triggers" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?trigger\\s-+\\(\\w+\\)" 3) 427 ("Triggers" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*trigger\\s-+\\(\\w+\\)" 2)
418 ("Functions" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?function\\s-+\\(\\w+\\)" 3) 428 ("Functions" "^\\s-*\\(create\\s-+\\(\\w+\\s-+\\)*\\)?function\\s-+\\(\\w+\\)" 3)
419 ("Procedures" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?proc\\(edure\\)?\\s-+\\(\\w+\\)" 4) 429 ("Procedures" "^\\s-*\\(create\\s-+\\(\\w+\\s-+\\)*\\)?proc\\(edure\\)?\\s-+\\(\\w+\\)" 4)
420 ("Packages" "^\\s-*create\\s-+\\(or\\s-+replace\\s-+\\)?package\\s-+\\(body\\s-+\\)?\\(\\w+\\)" 3) 430 ("Packages" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*package\\s-+\\(body\\s-+\\)?\\(\\w+\\)" 3)
421 ("Indexes" "^\\s-*create\\s-+index\\s-+\\(\\w+\\)" 1) 431 ("Indexes" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*index\\s-+\\(\\w+\\)" 2)
422 ("Tables/Views" "^\\s-*create\\s-+\\(\\(global\\s-+\\)?\\(temporary\\s-+\\)?table\\|view\\)\\s-+\\(\\w+\\)" 4)) 432 ("Tables/Views" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*\\(table\\|view\\)\\s-+\\(\\w+\\)" 3))
423 "Define interesting points in the SQL buffer for `imenu'. 433 "Define interesting points in the SQL buffer for `imenu'.
424 434
425This is used to set `imenu-generic-expression' when SQL mode is 435This is used to set `imenu-generic-expression' when SQL mode is
@@ -745,6 +755,7 @@ Based on `comint-mode-map'.")
745 (let ((map (make-sparse-keymap))) 755 (let ((map (make-sparse-keymap)))
746 (define-key map (kbd "C-c C-c") 'sql-send-paragraph) 756 (define-key map (kbd "C-c C-c") 'sql-send-paragraph)
747 (define-key map (kbd "C-c C-r") 'sql-send-region) 757 (define-key map (kbd "C-c C-r") 'sql-send-region)
758 (define-key map (kbd "C-c C-s") 'sql-send-string)
748 (define-key map (kbd "C-c C-b") 'sql-send-buffer) 759 (define-key map (kbd "C-c C-b") 'sql-send-buffer)
749 map) 760 map)
750 "Mode map used for `sql-mode'.") 761 "Mode map used for `sql-mode'.")
@@ -764,6 +775,7 @@ Based on `comint-mode-map'.")
764 (get-buffer-process sql-buffer))] 775 (get-buffer-process sql-buffer))]
765 ["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer) 776 ["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer)
766 (get-buffer-process sql-buffer))] 777 (get-buffer-process sql-buffer))]
778 ["Send String" sql-send-string t]
767 ["--" nil nil] 779 ["--" nil nil]
768 ["Start SQLi session" sql-product-interactive (sql-product-feature :sqli-connect)] 780 ["Start SQLi session" sql-product-interactive (sql-product-feature :sqli-connect)]
769 ["Show SQLi buffer" sql-show-sqli-buffer t] 781 ["Show SQLi buffer" sql-show-sqli-buffer t]
@@ -792,7 +804,7 @@ Based on `comint-mode-map'.")
792 ["Linter" sql-highlight-linter-keywords 804 ["Linter" sql-highlight-linter-keywords
793 :style radio 805 :style radio
794 :selected (eq sql-product 'linter)] 806 :selected (eq sql-product 'linter)]
795 ["Microsoft" sql-highlight-ms-keywords 807 ["MS SQLServer" sql-highlight-ms-keywords
796 :style radio 808 :style radio
797 :selected (eq sql-product 'ms)] 809 :selected (eq sql-product 'ms)]
798 ["MySQL" sql-highlight-mysql-keywords 810 ["MySQL" sql-highlight-mysql-keywords
@@ -828,24 +840,24 @@ Based on `comint-mode-map'.")
828 840
829(defvar sql-mode-abbrev-table nil 841(defvar sql-mode-abbrev-table nil
830 "Abbrev table used in `sql-mode' and `sql-interactive-mode'.") 842 "Abbrev table used in `sql-mode' and `sql-interactive-mode'.")
831(if sql-mode-abbrev-table 843(unless sql-mode-abbrev-table
832 () 844 (define-abbrev-table 'sql-mode-abbrev-table nil)
833 (let ((nargs (cdr (subr-arity (symbol-function 'define-abbrev)))) 845 (mapcar
834 d-a)
835 ;; In Emacs 21.3+, provide SYSTEM-FLAG to define-abbrev. 846 ;; In Emacs 21.3+, provide SYSTEM-FLAG to define-abbrev.
836 (setq d-a 847 '(lambda (abbrev)
837 (if (>= nargs 6) 848 (let ((name (car abbrev))
838 '(lambda (name expansion) (define-abbrev sql-mode-abbrev-table name expansion nil 0 t)) 849 (expansion (cdr abbrev)))
839 '(lambda (name expansion) (define-abbrev sql-mode-abbrev-table name expansion)))) 850 (condition-case nil
840 851 (define-abbrev sql-mode-abbrev-table name expansion nil 0 t)
841 (define-abbrev-table 'sql-mode-abbrev-table nil) 852 (error
842 (funcall d-a "ins" "insert") 853 (define-abbrev sql-mode-abbrev-table name expansion)))))
843 (funcall d-a "upd" "update") 854 '(("ins" "insert")
844 (funcall d-a "del" "delete") 855 ("upd" "update")
845 (funcall d-a "sel" "select") 856 ("del" "delete")
846 (funcall d-a "proc" "procedure") 857 ("sel" "select")
847 (funcall d-a "func" "function") 858 ("proc" "procedure")
848 (funcall d-a "cr" "create"))) 859 ("func" "function")
860 ("cr" "create"))))
849 861
850;; Syntax Table 862;; Syntax Table
851 863
@@ -855,9 +867,7 @@ Based on `comint-mode-map'.")
855 (modify-syntax-entry ?/ ". 14" table) 867 (modify-syntax-entry ?/ ". 14" table)
856 (modify-syntax-entry ?* ". 23" table) 868 (modify-syntax-entry ?* ". 23" table)
857 ;; double-dash starts comment 869 ;; double-dash starts comment
858 (if (string-match "XEmacs\\|Lucid" emacs-version) 870 (modify-syntax-entry ?- ". 12b" table)
859 (modify-syntax-entry ?- ". 56" table)
860 (modify-syntax-entry ?- ". 12b" table))
861 ;; newline and formfeed end coments 871 ;; newline and formfeed end coments
862 (modify-syntax-entry ?\n "> b" table) 872 (modify-syntax-entry ?\n "> b" table)
863 (modify-syntax-entry ?\f "> b" table) 873 (modify-syntax-entry ?\f "> b" table)
@@ -871,55 +881,117 @@ Based on `comint-mode-map'.")
871;; Font lock support 881;; Font lock support
872 882
873(defvar sql-mode-font-lock-object-name 883(defvar sql-mode-font-lock-object-name
874 (list (concat "^\\s-*\\(create\\(\\s-+or\\s-+replace\\)?\\|drop\\|alter\\)?\\s-+" 884 (list (concat "^\\s-*\\(create\\|drop\\|alter\\)\\s-+" ;; lead off with CREATE, DROP or ALTER
875 "\\(\\(global\\s-+\\)?\\(temporary\\s-+\\)?table\\|view\\|package\\(\\s-+body\\)?\\|" 885 "\\(\\w+\\s-+\\)*" ;; optional intervening keywords
876 "proc\\(edure\\)?\\|function\\|trigger\\|sequence\\|rule\\|default\\)\\s-+\\(\\w+\\)") 886 "\\(table\\|view\\|package\\(\\s-+body\\)?\\|proc\\(edure\\)?"
877 8 'font-lock-function-name-face) 887 "\\|function\\|trigger\\|sequence\\|rule\\|default\\)\\s-+"
878 888 "\\(\\w+\\)")
879 "Pattern to match the names of top-level objects in a CREATE, 889 6 'font-lock-function-name-face)
880DROP or ALTER statement. 890
881 891 "Pattern to match the names of top-level objects.
882The format of variable should be a valid `font-lock-keywords' 892
883entry.") 893The pattern matches the name in a CREATE, DROP or ALTER
894statement. The format of variable should be a valid
895`font-lock-keywords' entry.")
896
897(defmacro sql-keywords-re (&rest keywords)
898 "Compile-time generation of regexp matching any one of KEYWORDS."
899 `(eval-when-compile
900 (concat "\\b"
901 (regexp-opt ',keywords t)
902 "\\b")))
884 903
885(defvar sql-mode-ansi-font-lock-keywords 904(defvar sql-mode-ansi-font-lock-keywords
886 (let ((ansi-keywords (eval-when-compile 905 (let ((ansi-funcs (sql-keywords-re
887 (concat "\\b" 906"abs" "avg" "bit_length" "cardinality" "cast" "char_length"
888 (regexp-opt '( 907"character_length" "coalesce" "convert" "count" "current_date"
889 908"current_path" "current_role" "current_time" "current_timestamp"
890"authorization" "avg" "begin" "close" "cobol" "commit" 909"current_user" "extract" "localtime" "localtimestamp" "lower" "max"
891"continue" "count" "declare" "double" "end" "escape" 910"min" "mod" "nullif" "octet_length" "overlay" "placing" "session_user"
892"exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" 911"substring" "sum" "system_user" "translate" "treat" "trim" "upper"
893"key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" 912"user"
894"precision" "primary" "procedure" "references" "rollback" 913))
895"schema" "section" "some" "sqlcode" "sqlerror" "sum" "work" 914
896 915 (ansi-non-reserved (sql-keywords-re
897) t) "\\b"))) 916"ada" "asensitive" "assignment" "asymmetric" "atomic" "between"
898 (ansi-reserved-words (eval-when-compile 917"bitvar" "called" "catalog_name" "chain" "character_set_catalog"
899 (concat "\\b" 918"character_set_name" "character_set_schema" "checked" "class_origin"
900 (regexp-opt '( 919"cobol" "collation_catalog" "collation_name" "collation_schema"
901 920"column_name" "command_function" "command_function_code" "committed"
902"all" "and" "any" "as" "asc" "between" "by" "check" "create" 921"condition_number" "connection_name" "constraint_catalog"
903"current" "default" "delete" "desc" "distinct" "exists" "float" "for" 922"constraint_name" "constraint_schema" "contains" "cursor_name"
904"from" "grant" "group" "having" "in" "insert" "into" "is" 923"datetime_interval_code" "datetime_interval_precision" "defined"
905"like" "not" "null" "of" "on" "option" "or" "order" "privileges" 924"definer" "dispatch" "dynamic_function" "dynamic_function_code"
906"public" "select" "set" "table" "to" "union" "unique" 925"existing" "exists" "final" "fortran" "generated" "granted"
907"update" "user" "values" "view" "where" "with" 926"hierarchy" "hold" "implementation" "infix" "insensitive" "instance"
908 927"instantiable" "invoker" "key_member" "key_type" "length" "m"
909) t) "\\b"))) 928"message_length" "message_octet_length" "message_text" "method" "more"
910 (ansi-types (eval-when-compile 929"mumps" "name" "nullable" "number" "options" "overlaps" "overriding"
911 (concat "\\b" 930"parameter_mode" "parameter_name" "parameter_ordinal_position"
912 (regexp-opt '( 931"parameter_specific_catalog" "parameter_specific_name"
913 932"parameter_specific_schema" "pascal" "pli" "position" "repeatable"
914;; ANSI Keywords that look like types 933"returned_length" "returned_octet_length" "returned_sqlstate"
915"character" "cursor" "dec" "int" "real" 934"routine_catalog" "routine_name" "routine_schema" "row_count" "scale"
916;; ANSI Reserved Word that look like types 935"schema_name" "security" "self" "sensitive" "serializable"
917"char" "integer" "smallint" 936"server_name" "similar" "simple" "source" "specific_name" "style"
918 937"subclass_origin" "sublist" "symmetric" "system" "table_name"
919) t) "\\b")))) 938"transaction_active" "transactions_committed"
920 (list (cons ansi-keywords 'font-lock-keyword-face) 939"transactions_rolled_back" "transform" "transforms" "trigger_catalog"
921 (cons ansi-reserved-words 'font-lock-keyword-face) 940"trigger_name" "trigger_schema" "type" "uncommitted" "unnamed"
922 (cons ansi-types 'font-lock-type-face))) 941"user_defined_type_catalog" "user_defined_type_name"
942"user_defined_type_schema"
943))
944
945 (ansi-reserved (sql-keywords-re
946"absolute" "action" "add" "admin" "after" "aggregate" "alias" "all"
947"allocate" "alter" "and" "any" "are" "as" "asc" "assertion" "at"
948"authorization" "before" "begin" "both" "breadth" "by" "call"
949"cascade" "cascaded" "case" "catalog" "check" "class" "close"
950"collate" "collation" "column" "commit" "completion" "connect"
951"connection" "constraint" "constraints" "constructor" "continue"
952"corresponding" "create" "cross" "cube" "current" "cursor" "cycle"
953"data" "day" "deallocate" "declare" "default" "deferrable" "deferred"
954"delete" "depth" "deref" "desc" "describe" "descriptor" "destroy"
955"destructor" "deterministic" "diagnostics" "dictionary" "disconnect"
956"distinct" "domain" "drop" "dynamic" "each" "else" "end" "equals"
957"escape" "every" "except" "exception" "exec" "execute" "external"
958"false" "fetch" "first" "for" "foreign" "found" "free" "from" "full"
959"function" "general" "get" "global" "go" "goto" "grant" "group"
960"grouping" "having" "host" "hour" "identity" "ignore" "immediate" "in"
961"indicator" "initialize" "initially" "inner" "inout" "input" "insert"
962"intersect" "into" "is" "isolation" "iterate" "join" "key" "language"
963"last" "lateral" "leading" "left" "less" "level" "like" "limit"
964"local" "locator" "map" "match" "minute" "modifies" "modify" "module"
965"month" "names" "natural" "new" "next" "no" "none" "not" "null" "of"
966"off" "old" "on" "only" "open" "operation" "option" "or" "order"
967"ordinality" "out" "outer" "output" "pad" "parameter" "parameters"
968"partial" "path" "postfix" "prefix" "preorder" "prepare" "preserve"
969"primary" "prior" "privileges" "procedure" "public" "read" "reads"
970"recursive" "references" "referencing" "relative" "restrict" "result"
971"return" "returns" "revoke" "right" "role" "rollback" "rollup"
972"routine" "rows" "savepoint" "schema" "scroll" "search" "second"
973"section" "select" "sequence" "session" "set" "sets" "size" "some"
974"space" "specific" "specifictype" "sql" "sqlexception" "sqlstate"
975"sqlwarning" "start" "state" "statement" "static" "structure" "table"
976"temporary" "terminate" "than" "then" "timezone_hour"
977"timezone_minute" "to" "trailing" "transaction" "translation"
978"trigger" "true" "under" "union" "unique" "unknown" "unnest" "update"
979"usage" "using" "value" "values" "variable" "view" "when" "whenever"
980"where" "with" "without" "work" "write" "year"
981))
982
983 (ansi-types (sql-keywords-re
984"array" "binary" "bit" "blob" "boolean" "char" "character" "clob"
985"date" "dec" "decimal" "double" "float" "int" "integer" "interval"
986"large" "national" "nchar" "nclob" "numeric" "object" "precision"
987"real" "ref" "row" "scope" "smallint" "time" "timestamp" "varchar"
988"varying" "zone"
989)))
990
991 `((,ansi-non-reserved . font-lock-keyword-face)
992 (,ansi-reserved . font-lock-keyword-face)
993 (,ansi-funcs . font-lock-builtin-face)
994 (,ansi-types . font-lock-type-face)))
923 995
924 "ANSI SQL keywords used by font-lock. 996 "ANSI SQL keywords used by font-lock.
925 997
@@ -930,66 +1002,156 @@ you define your own sql-mode-ansi-font-lock-keywords. You may want to
930add functions and PL/SQL keywords.") 1002add functions and PL/SQL keywords.")
931 1003
932(defvar sql-mode-oracle-font-lock-keywords 1004(defvar sql-mode-oracle-font-lock-keywords
933 (let ((oracle-keywords (eval-when-compile 1005 (let ((oracle-functions (sql-keywords-re
934 (concat "\\b" 1006"abs" "acos" "add_months" "ascii" "asciistr" "asin" "atan" "atan2"
935 (regexp-opt '( 1007"avg" "bfilename" "bin_to_num" "bitand" "cast" "ceil" "chartorowid"
936;; Oracle (+ANSI) SQL keywords 1008"chr" "coalesce" "compose" "concat" "convert" "corr" "cos" "cosh"
937 1009"count" "covar_pop" "covar_samp" "cume_dist" "current_date"
938; ANSI keywords 1010"current_timestamp" "current_user" "dbtimezone" "decode" "decompose"
939"authorization" "avg" "begin" "close" "cobol" "commit" 1011"dense_rank" "depth" "deref" "dump" "empty_clob" "existsnode" "exp"
940"continue" "count" "declare" "double" "end" "escape" 1012"extract" "extractvalue" "first" "first_value" "floor" "following"
941"exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" 1013"from_tz" "greatest" "group_id" "grouping_id" "hextoraw" "initcap"
942"key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" 1014"instr" "lag" "last" "last_day" "last_value" "lead" "least" "length"
943"precision" "primary" "procedure" "references" "rollback" 1015"ln" "localtimestamp" "lower" "lpad" "ltrim" "make_ref" "max" "min"
944"schema" "section" "some" "sqlcode" "sqlerror" "sum" "work" 1016"mod" "months_between" "new_time" "next_day" "nls_charset_decl_len"
945 1017"nls_charset_id" "nls_charset_name" "nls_initcap" "nls_lower"
946; ANSI reserved words 1018"nls_upper" "nlssort" "ntile" "nullif" "numtodsinterval"
947"all" "and" "any" "as" "asc" "between" "by" "check" "create" 1019"numtoyminterval" "nvl" "nvl2" "over" "path" "percent_rank"
948"current" "default" "delete" "desc" "distinct" "exists" "float" "for" 1020"percentile_cont" "percentile_disc" "power" "preceding" "rank"
949"from" "grant" "group" "having" "in" "insert" "into" "is" 1021"ratio_to_report" "rawtohex" "rawtonhex" "reftohex" "regr_"
950"like" "not" "null" "of" "on" "option" "or" "order" "privileges" 1022"regr_avgx" "regr_avgy" "regr_count" "regr_intercept" "regr_r2"
951"public" "select" "set" "table" "to" "union" "unique" 1023"regr_slope" "regr_sxx" "regr_sxy" "regr_syy" "replace" "round"
952"update" "user" "values" "view" "where" "with" 1024"row_number" "rowidtochar" "rowidtonchar" "rpad" "rtrim"
953 1025"sessiontimezone" "sign" "sin" "sinh" "soundex" "sqrt" "stddev"
954"access" "add" "admin" "after" "allocate" "alter" "analyze" "archive" 1026"stddev_pop" "stddev_samp" "substr" "sum" "sys_connect_by_path"
955"archivelog" "audit" "authid" "backup" "become" "before" "block" 1027"sys_context" "sys_dburigen" "sys_extract_utc" "sys_guid" "sys_typeid"
956"body" "cache" "cancel" "cascade" "change" "checkpoint" "cluster" 1028"sys_xmlagg" "sys_xmlgen" "sysdate" "systimestamp" "tan" "tanh"
957"comment" "compile" "compress" "compute" "connect" "constraint" 1029"to_char" "to_clob" "to_date" "to_dsinterval" "to_lob" "to_multi_byte"
958"constraints" "contents" "controlfile" "cross" "currval" "cycle" 1030"to_nchar" "to_nclob" "to_number" "to_single_byte" "to_timestamp"
959"database" "datafile" "dba" "deterministic" "disable" "dismount" 1031"to_timestamp_tz" "to_yminterval" "translate" "treat" "trim" "trunc"
960"drop" "dump" "each" "else" "else" "elsif" "enable" "events" "except" 1032"tz_offset" "uid" "unbounded" "unistr" "updatexml" "upper" "user"
961"exceptions" "exclusive" "execute" "exit" "explain" "extent" 1033"userenv" "var_pop" "var_samp" "variance" "vsize" "width_bucket" "xml"
962"externally" "false" "file" "flush" "force" "freelist" "freelists" 1034"xmlagg" "xmlattribute" "xmlcolattval" "xmlconcat" "xmlelement"
963"full" "function" "global" "grant" "groups" "identified" "if" 1035"xmlforest" "xmlsequence" "xmltransform"
964"immediate" "including" "increment" "index" "initial" "initrans" 1036))
965"inner" "instance" "intersect" "join" "layer" "left" "level" "link" 1037
966"lists" "lock" "logfile" "long" "loop" "manage" "manual" 1038 (oracle-keywords (sql-keywords-re
967"maxdatafiles" "maxextents" "maxinistances" "maxlogfiles" 1039"abort" "access" "accessed" "account" "activate" "add" "admin"
968"maxloghistory" "maxlogmembers" "maxtrans" "maxvalue" "merge" 1040"advise" "after" "agent" "aggregate" "all" "allocate" "allow" "alter"
969"minextents" "minus" "minvalue" "mode" "modify" "mount" "natural" 1041"always" "analyze" "ancillary" "and" "any" "apply" "archive"
970"new" "next" "nextval" "noarchivelog" "noaudit" "nocache" "nocompress" 1042"archivelog" "array" "as" "asc" "associate" "at" "attribute"
971"nocycle" "nomaxvalue" "nominvalue" "none" "noorder" "noresetlogs" 1043"attributes" "audit" "authenticated" "authid" "authorization" "auto"
972"normal" "nosort" "nowait" "off" "offline" "old" "online" "only" 1044"autoallocate" "automatic" "availability" "backup" "before" "begin"
973"optimal" "others" "out" "outer" "over" "own" "package" "parallel" 1045"behalf" "between" "binding" "bitmap" "block" "blocksize" "body"
974"parallel_enable" "pctfree" "pctincrease" "pctused" "plan" "pragma" 1046"both" "buffer_pool" "build" "by" "cache" "call" "cancel"
975"preserve" "prior" "private" "profile" "quota" "raise" "raw" "read" 1047"cascade" "case" "category" "certificate" "chained" "change" "check"
976"recover" "referencing" "rename" "replace" "resetlogs" "resource" 1048"checkpoint" "child" "chunk" "class" "clear" "clone" "close" "cluster"
977"restrict_references" "restricted" "return" "returning" "reuse" 1049"column" "column_value" "columns" "comment" "commit" "committed"
978"revoke" "right" "rnds" "rnps" "role" "roles" "row" "rowlabel" 1050"compatibility" "compile" "complete" "composite_limit" "compress"
979"rownum" "rows" "savepoint" "scn" "segment" "sequence" "session" 1051"compute" "connect" "connect_time" "consider" "consistent"
980"share" "shared" "size" "snapshot" "sort" "statement_id" "statistics" 1052"constraint" "constraints" "constructor" "contents" "context"
981"stop" "storage" "subtype" "successful" "switch" "synonym" "sysdate" 1053"continue" "controlfile" "corruption" "cost" "cpu_per_call"
982"system" "tables" "tablespace" "temporary" "then" "thread" "tracing" 1054"cpu_per_session" "create" "cross" "cube" "current" "currval" "cycle"
983"transaction" "trigger" "triggers" "true" "truncate" "type" "uid" 1055"dangling" "data" "database" "datafile" "datafiles" "day" "ddl"
984"under" "unlimited" "until" "use" "using" "validate" "when" "while" 1056"deallocate" "debug" "default" "deferrable" "deferred" "definer"
985"wnds" "wnps" "write" 1057"delay" "delete" "demand" "desc" "determines" "deterministic"
986 1058"dictionary" "dimension" "directory" "disable" "disassociate"
987) t) "\\b"))) 1059"disconnect" "distinct" "distinguished" "distributed" "dml" "drop"
988 (oracle-warning-words (eval-when-compile 1060"each" "element" "else" "enable" "end" "equals_path" "escape"
989 (concat "\\b" 1061"estimate" "except" "exceptions" "exchange" "excluding" "exists"
990 (regexp-opt '( 1062"expire" "explain" "extent" "external" "externally"
991;; PLSQL defined exceptions 1063"failed_login_attempts" "fast" "file" "final" "finish" "flush" "for"
992 1064"force" "foreign" "freelist" "freelists" "freepools" "fresh" "from"
1065"full" "function" "functions" "generated" "global" "global_name"
1066"globally" "grant" "group" "grouping" "groups" "guard" "hash"
1067"hashkeys" "having" "heap" "hierarchy" "id" "identified" "identifier"
1068"idle_time" "immediate" "in" "including" "increment" "index" "indexed"
1069"indexes" "indextype" "indextypes" "indicator" "initial" "initialized"
1070"initially" "initrans" "inner" "insert" "instance" "instantiable"
1071"instead" "intersect" "into" "invalidate" "is" "isolation" "java"
1072"join" "keep" "key" "kill" "language" "left" "less" "level"
1073"levels" "library" "like" "like2" "like4" "likec" "limit" "link"
1074"list" "lob" "local" "location" "locator" "lock" "log" "logfile"
1075"logging" "logical" "logical_reads_per_call"
1076"logical_reads_per_session" "managed" "management" "manual" "map"
1077"mapping" "master" "matched" "materialized" "maxdatafiles"
1078"maxextents" "maximize" "maxinstances" "maxlogfiles" "maxloghistory"
1079"maxlogmembers" "maxsize" "maxtrans" "maxvalue" "member" "memory"
1080"merge" "migrate" "minextents" "minimize" "minimum" "minus" "minvalue"
1081"mode" "modify" "monitoring" "month" "mount" "move" "movement" "name"
1082"named" "natural" "nested" "never" "new" "next" "nextval" "no"
1083"noarchivelog" "noaudit" "nocache" "nocompress" "nocopy" "nocycle"
1084"nodelay" "noforce" "nologging" "nomapping" "nomaxvalue" "nominimize"
1085"nominvalue" "nomonitoring" "none" "noorder" "noparallel" "norely"
1086"noresetlogs" "noreverse" "normal" "norowdependencies" "nosort"
1087"noswitch" "not" "nothing" "notimeout" "novalidate" "nowait" "null"
1088"nulls" "object" "of" "off" "offline" "oidindex" "old" "on" "online"
1089"only" "open" "operator" "optimal" "option" "or" "order"
1090"organization" "out" "outer" "outline" "overflow" "overriding"
1091"package" "packages" "parallel" "parallel_enable" "parameters"
1092"parent" "partition" "partitions" "password" "password_grace_time"
1093"password_life_time" "password_lock_time" "password_reuse_max"
1094"password_reuse_time" "password_verify_function" "pctfree"
1095"pctincrease" "pctthreshold" "pctused" "pctversion" "percent"
1096"performance" "permanent" "pfile" "physical" "pipelined" "plan"
1097"post_transaction" "pragma" "prebuilt" "preserve" "primary" "private"
1098"private_sga" "privileges" "procedure" "profile" "protection" "public"
1099"purge" "query" "quiesce" "quota" "range" "read" "reads" "rebuild"
1100"records_per_block" "recover" "recovery" "recycle" "reduced" "ref"
1101"references" "referencing" "refresh" "register" "reject" "relational"
1102"rely" "rename" "reset" "resetlogs" "resize" "resolve" "resolver"
1103"resource" "restrict" "restrict_references" "restricted" "result"
1104"resumable" "resume" "retention" "return" "returning" "reuse"
1105"reverse" "revoke" "rewrite" "right" "rnds" "rnps" "role" "roles"
1106"rollback" "rollup" "row" "rowdependencies" "rownum" "rows" "sample"
1107"savepoint" "scan" "schema" "scn" "scope" "segment" "select"
1108"selectivity" "self" "sequence" "serializable" "session"
1109"sessions_per_user" "set" "sets" "settings" "shared" "shared_pool"
1110"shrink" "shutdown" "siblings" "sid" "single" "size" "skip" "some"
1111"sort" "source" "space" "specification" "spfile" "split" "standby"
1112"start" "statement_id" "static" "statistics" "stop" "storage" "store"
1113"structure" "subpartition" "subpartitions" "substitutable"
1114"successful" "supplemental" "suspend" "switch" "switchover" "synonym"
1115"sys" "system" "table" "tables" "tablespace" "tempfile" "template"
1116"temporary" "test" "than" "then" "thread" "through" "time_zone"
1117"timeout" "to" "trace" "transaction" "trigger" "triggers" "truncate"
1118"trust" "type" "types" "unarchived" "under" "under_path" "undo"
1119"uniform" "union" "unique" "unlimited" "unlock" "unquiesce"
1120"unrecoverable" "until" "unusable" "unused" "update" "upgrade" "usage"
1121"use" "using" "validate" "validation" "value" "values" "variable"
1122"varray" "version" "view" "wait" "when" "whenever" "where" "with"
1123"without" "wnds" "wnps" "work" "write" "xmldata" "xmlschema" "xmltype"
1124))
1125
1126 (oracle-types (sql-keywords-re
1127"bfile" "blob" "byte" "char" "character" "clob" "date" "dec" "decimal"
1128"double" "float" "int" "integer" "interval" "long" "national" "nchar"
1129"nclob" "number" "numeric" "nvarchar2" "precision" "raw" "real"
1130"rowid" "second" "smallint" "time" "timestamp" "urowid" "varchar"
1131"varchar2" "varying" "year" "zone"
1132))
1133
1134 (plsql-functions (sql-keywords-re
1135"%bulk_rowcount" "%found" "%isopen" "%notfound" "%rowcount" "%rowtype"
1136"%type" "extend" "prior"
1137))
1138
1139 (plsql-keywords (sql-keywords-re
1140"autonomous_transaction" "bulk" "char_base" "collect" "constant"
1141"cursor" "declare" "do" "elsif" "exception_init" "execute" "exit"
1142"extends" "false" "fetch" "forall" "goto" "hour" "if" "interface"
1143"loop" "minute" "number_base" "ocirowid" "opaque" "others" "rowtype"
1144"separate" "serially_reusable" "sql" "sqlcode" "sqlerrm" "subtype"
1145"the" "timezone_abbr" "timezone_hour" "timezone_minute"
1146"timezone_region" "true" "varrying" "while"
1147))
1148
1149 (plsql-type (sql-keywords-re
1150"binary_integer" "boolean" "naturaln" "pls_integer" "positive"
1151"positiven" "record" "signtype" "string"
1152))
1153
1154 (plsql-warning (sql-keywords-re
993"access_into_null" "case_not_found" "collection_is_null" 1155"access_into_null" "case_not_found" "collection_is_null"
994"cursor_already_open" "dup_val_on_index" "invalid_cursor" 1156"cursor_already_open" "dup_val_on_index" "invalid_cursor"
995"invalid_number" "login_denied" "no_data_found" "not_logged_on" 1157"invalid_number" "login_denied" "no_data_found" "not_logged_on"
@@ -997,15 +1159,11 @@ add functions and PL/SQL keywords.")
997"subscript_beyond_count" "subscript_outside_limit" "sys_invalid_rowid" 1159"subscript_beyond_count" "subscript_outside_limit" "sys_invalid_rowid"
998"timeout_on_resource" "too_many_rows" "value_error" "zero_divide" 1160"timeout_on_resource" "too_many_rows" "value_error" "zero_divide"
999"exception" "notfound" 1161"exception" "notfound"
1162))
1000 1163
1001) t) "\\b"))) 1164 (sqlplus-commands
1002 1165 (eval-when-compile (concat "^\\(\\("
1003 (oracle-sqlplus-commands 1166 (regexp-opt '(
1004 (eval-when-compile
1005 (concat "^\\(\\("
1006 (regexp-opt '(
1007;; SQL*Plus commands
1008
1009"@" "@@" "accept" "append" "archive" "attribute" "break" 1167"@" "@@" "accept" "append" "archive" "attribute" "break"
1010"btitle" "change" "clear" "column" "connect" "copy" "define" 1168"btitle" "change" "clear" "column" "connect" "copy" "define"
1011"del" "describe" "disconnect" "edit" "execute" "exit" "get" "help" 1169"del" "describe" "disconnect" "edit" "execute" "exit" "get" "help"
@@ -1040,73 +1198,16 @@ add functions and PL/SQL keywords.")
1040 "timi\\(ng\\)?\\|trim\\(out\\)?\\|trims\\(pool\\)?\\|" 1198 "timi\\(ng\\)?\\|trim\\(out\\)?\\|trims\\(pool\\)?\\|"
1041 "und\\(erline\\)?\\|ver\\(ify\\)?\\|wra\\(p\\)?\\)\\)\\)" 1199 "und\\(erline\\)?\\|ver\\(ify\\)?\\|wra\\(p\\)?\\)\\)\\)"
1042 "\\b.*$" 1200 "\\b.*$"
1043 ))) 1201 ))))
1044 1202
1045 (oracle-types 1203 `((,sqlplus-commands . font-lock-doc-face)
1046 (eval-when-compile 1204 (,oracle-functions . font-lock-builtin-face)
1047 (concat "\\b" 1205 (,oracle-keywords . font-lock-keyword-face)
1048 (regexp-opt '( 1206 (,oracle-types . font-lock-type-face)
1049;; Oracle Keywords that look like types 1207 (,plsql-functions . font-lock-builtin-face)
1050;; Oracle Reserved Words that look like types 1208 (,plsql-keywords . font-lock-keyword-face)
1051 1209 (,plsql-type . font-lock-type-face)
1052"bfile" "binary_integer" "blob" "boolean" "byte" "char" "character" 1210 (,plsql-warning . font-lock-warning-face)))
1053"clob" "date" "day" "dec" "decimal" "double" "float" "int" "integer"
1054"interval" "local" "long" "month" "natural" "naturaln" "nchar" "nclob"
1055"number" "numeric" "nvarchar2" "pls_integer" "positive" "positiven"
1056"precision" "raw" "real" "rowid" "second" "signtype" "smallint"
1057"string" "time" "timestamp" "urowid" "varchar" "varchar2" "year"
1058"zone"
1059
1060) t) "\\b")))
1061 (oracle-builtin-functions (eval-when-compile
1062 (concat "\\b"
1063 (regexp-opt '(
1064;; Misc Oracle builtin functions
1065
1066"abs" "acos" "add_months" "ascii" "asciistr" "asin" "atan" "atan2"
1067"avg" "bfilename" "bin_to_num" "bitand" "case" "cast" "ceil"
1068"chartorowid" "chr" "coalesce" "compose" "concat" "convert" "corr"
1069"cos" "cosh" "count" "covar_pop" "covar_samp" "cume_dist"
1070"current_date" "current_timestamp" "current_user" "dbtimezone"
1071"decode" "decompose" "dense_rank" "depth" "deref" "dump" "empty_blob"
1072"empty_clob" "existsnode" "exp" "extract" "extractvalue" "first"
1073"first_value" "floor" "from_tz" "greatest" "group_id" "grouping"
1074"grouping_id" "hextoraw" "initcap" "instr" "lag" "last" "last_day"
1075"last_value" "lead" "least" "length" "ln" "localtimestamp" "log"
1076"lower" "lpad" "ltrim" "make_ref" "max" "min" "mod" "months_between"
1077"nchr" "new_time" "next_day" "nls_charset_decl_len" "nls_charset_id"
1078"nls_charset_name" "nls_initcap" "nls_lower" "nlssort" "nls_upper"
1079"ntile" "nullif" "numtodsinterval" "numtoyminterval" "nvl" "nvl2"
1080"path" "percent_rank" "percentile_cont" "percentile_disc" "power"
1081"rank" "ratio_to_report" "rawtohex" "rawtonhex" "ref" "reftohex"
1082"regr_slope" "regr_intercept" "regr_count" "regr_r2" "regr_avgx"
1083"regr_avgy" "regr_sxx" "regr_syy" "regr_sxy" "round"
1084"row_number" "rowidtochar" "rowidtonchar" "rpad" "rtrim"
1085"sessiontimezone" "sign" "sin" "sinh" "soundex" "sqrt" "stddev"
1086"stddev_pop" "stddev_samp" "substr" "sum" "sys_connect_by_path"
1087"sys_context" "sys_dburigen" "sys_extract_utc" "sys_guid" "sys_typeid"
1088"sys_xmlagg" "sys_xmlgen" "sysdate" "systimestamp" "tan" "tanh"
1089"to_char" "to_clob" "to_date" "to_dsinterval" "to_lob" "to_multi_byte"
1090"to_nchar" "to_nclob" "to_number" "to_single_byte" "to_timestamp"
1091"to_timestamp_tz" "to_yminterval" "translate" "treat" "trim" "trunc"
1092"tz_offset" "uid" "unistr" "updatexml" "upper" "user" "userenv"
1093"value" "var_pop" "var_samp" "variance" "vsize" "width_bucket"
1094"xmlagg" "xmlcolattval" "xmlconcat" "xmlelement" "xmlforest"
1095"xmlsequence" "xmltransform"
1096
1097) t) "\\b"))))
1098 (list (cons oracle-sqlplus-commands 'font-lock-doc-face)
1099 (cons oracle-keywords 'font-lock-keyword-face)
1100 (cons oracle-warning-words 'font-lock-warning-face)
1101 ;; XEmacs doesn't have font-lock-builtin-face
1102 (if (string-match "XEmacs\\|Lucid" emacs-version)
1103 (cons oracle-builtin-functions 'font-lock-preprocessor-face)
1104 ;; GNU Emacs 19 doesn't have it either
1105 (if (string-match "GNU Emacs 19" emacs-version)
1106 (cons oracle-builtin-functions 'font-lock-keyword-face)
1107 ;; Emacs
1108 (cons oracle-builtin-functions 'font-lock-builtin-face)))
1109 (cons oracle-types 'font-lock-type-face)))
1110 1211
1111 "Oracle SQL keywords used by font-lock. 1212 "Oracle SQL keywords used by font-lock.
1112 1213
@@ -1117,42 +1218,84 @@ you define your own sql-mode-oracle-font-lock-keywords. You may want
1117to add functions and PL/SQL keywords.") 1218to add functions and PL/SQL keywords.")
1118 1219
1119(defvar sql-mode-postgres-font-lock-keywords 1220(defvar sql-mode-postgres-font-lock-keywords
1120 (let ((postgres-reserved-words (eval-when-compile 1221 (let ((pg-funcs (sql-keywords-re
1121 (concat "\\b" 1222"abbrev" "abs" "acos" "age" "area" "ascii" "asin" "atab2" "atan"
1122 (regexp-opt '( 1223"atan2" "avg" "bit_length" "both" "broadcast" "btrim" "cbrt" "ceil"
1123"language" 1224"center" "char_length" "chr" "coalesce" "col_description" "convert"
1124) t) "\\b"))) 1225"cos" "cot" "count" "current_database" "current_date" "current_schema"
1125 (postgres-types (eval-when-compile 1226"current_schemas" "current_setting" "current_time" "current_timestamp"
1126 (concat "\\b" 1227"current_user" "currval" "date_part" "date_trunc" "decode" "degrees"
1127 (regexp-opt '( 1228"diameter" "encode" "exp" "extract" "floor" "get_bit" "get_byte"
1128 1229"has_database_privilege" "has_function_privilege"
1129"bool" "box" "circle" "char" "char2" "char4" "char8" "char16" "date" 1230"has_language_privilege" "has_schema_privilege" "has_table_privilege"
1130"float4" "float8" "int2" "int4" "int8" "line" "lseg" "money" "path" 1231"height" "host" "initcap" "isclosed" "isfinite" "isopen" "leading"
1131"point" "polygon" "serial" "text" "time" "timespan" "timestamp" "varchar" 1232"length" "ln" "localtime" "localtimestamp" "log" "lower" "lpad"
1132 1233"ltrim" "masklen" "max" "min" "mod" "netmask" "network" "nextval"
1133) t)"\\b"))) 1234"now" "npoints" "nullif" "obj_description" "octet_length" "overlay"
1134 (postgres-builtin-functions (eval-when-compile 1235"pclose" "pg_client_encoding" "pg_function_is_visible"
1135 (concat "\\b" 1236"pg_get_constraintdef" "pg_get_indexdef" "pg_get_ruledef"
1136 (regexp-opt '( 1237"pg_get_userbyid" "pg_get_viewdef" "pg_opclass_is_visible"
1137;; Misc Postgres builtin functions 1238"pg_operator_is_visible" "pg_table_is_visible" "pg_type_is_visible"
1138 1239"pi" "popen" "position" "pow" "quote_ident" "quote_literal" "radians"
1139"abstime" "age" "area" "box" "center" "date_part" "date_trunc" 1240"radius" "random" "repeat" "replace" "round" "rpad" "rtrim"
1140"datetime" "dexp" "diameter" "dpow" "float" "float4" "height" 1241"session_user" "set_bit" "set_byte" "set_config" "set_masklen"
1141"initcap" "integer" "isclosed" "isfinite" "isoldpath" "isopen" 1242"setval" "sign" "sin" "split_part" "sqrt" "stddev" "strpos" "substr"
1142"length" "lower" "lpad" "ltrim" "pclose" "point" "points" "popen" 1243"substring" "sum" "tan" "timeofday" "to_ascii" "to_char" "to_date"
1143"position" "radius" "reltime" "revertpoly" "rpad" "rtrim" "substr" 1244"to_hex" "to_number" "to_timestamp" "trailing" "translate" "trim"
1144"substring" "text" "timespan" "translate" "trim" "upgradepath" 1245"trunc" "upper" "variance" "version" "width"
1145"upgradepoly" "upper" "varchar" "width" 1246))
1146 1247
1147) t) "\\b")))) 1248 (pg-reserved (sql-keywords-re
1148 (append sql-mode-ansi-font-lock-keywords 1249"abort" "access" "add" "after" "aggregate" "alignment" "all" "alter"
1149 (list (cons postgres-reserved-words 'font-lock-keyword-face) 1250"analyze" "and" "any" "as" "asc" "assignment" "authorization"
1150 ;; XEmacs doesn't have 'font-lock-builtin-face 1251"backward" "basetype" "before" "begin" "between" "binary" "by" "cache"
1151 (if (string-match "XEmacs\\|Lucid" emacs-version) 1252"called" "cascade" "case" "cast" "characteristics" "check"
1152 (cons postgres-builtin-functions 'font-lock-preprocessor-face) 1253"checkpoint" "class" "close" "cluster" "column" "comment" "commit"
1153 ;; Emacs 1254"committed" "commutator" "constraint" "constraints" "conversion"
1154 (cons postgres-builtin-functions 'font-lock-builtin-face)) 1255"copy" "create" "createdb" "createuser" "cursor" "cycle" "database"
1155 (cons postgres-types 'font-lock-type-face)))) 1256"deallocate" "declare" "default" "deferrable" "deferred" "definer"
1257"delete" "delimiter" "desc" "distinct" "do" "domain" "drop" "each"
1258"element" "else" "encoding" "encrypted" "end" "escape" "except"
1259"exclusive" "execute" "exists" "explain" "extended" "external" "false"
1260"fetch" "finalfunc" "for" "force" "foreign" "forward" "freeze" "from"
1261"full" "function" "grant" "group" "gtcmp" "handler" "hashes" "having"
1262"immediate" "immutable" "implicit" "in" "increment" "index" "inherits"
1263"initcond" "initially" "input" "insensitive" "insert" "instead"
1264"internallength" "intersect" "into" "invoker" "is" "isnull"
1265"isolation" "join" "key" "language" "leftarg" "level" "like" "limit"
1266"listen" "load" "local" "location" "lock" "ltcmp" "main" "match"
1267"maxvalue" "merges" "minvalue" "mode" "move" "natural" "negator"
1268"next" "nocreatedb" "nocreateuser" "none" "not" "nothing" "notify"
1269"notnull" "null" "of" "offset" "oids" "on" "only" "operator" "or"
1270"order" "output" "owner" "partial" "passedbyvalue" "password" "plain"
1271"prepare" "primary" "prior" "privileges" "procedural" "procedure"
1272"public" "read" "recheck" "references" "reindex" "relative" "rename"
1273"reset" "restrict" "returns" "revoke" "rightarg" "rollback" "row"
1274"rule" "schema" "scroll" "security" "select" "sequence" "serializable"
1275"session" "set" "sfunc" "share" "show" "similar" "some" "sort1"
1276"sort2" "stable" "start" "statement" "statistics" "storage" "strict"
1277"stype" "sysid" "table" "temp" "template" "temporary" "then" "to"
1278"transaction" "trigger" "true" "truncate" "trusted" "type"
1279"unencrypted" "union" "unique" "unknown" "unlisten" "until" "update"
1280"usage" "user" "using" "vacuum" "valid" "validator" "values"
1281"variable" "verbose" "view" "volatile" "when" "where" "with" "without"
1282"work"
1283))
1284
1285 (pg-types (sql-keywords-re
1286"anyarray" "bigint" "bigserial" "bit" "boolean" "box" "bytea" "char"
1287"character" "cidr" "circle" "cstring" "date" "decimal" "double"
1288"float4" "float8" "inet" "int2" "int4" "int8" "integer" "internal"
1289"interval" "language_handler" "line" "lseg" "macaddr" "money"
1290"numeric" "oid" "opaque" "path" "point" "polygon" "precision" "real"
1291"record" "regclass" "regoper" "regoperator" "regproc" "regprocedure"
1292"regtype" "serial" "serial4" "serial8" "smallint" "text" "time"
1293"timestamp" "varchar" "varying" "void" "zone"
1294)))
1295
1296 `((,pg-funcs . font-lock-builtin-face)
1297 (,pg-reserved . font-lock-keyword-face)
1298 (,pg-types . font-lock-type-face)))
1156 1299
1157 "Postgres SQL keywords used by font-lock. 1300 "Postgres SQL keywords used by font-lock.
1158 1301
@@ -1162,10 +1305,7 @@ function `regexp-opt'. Therefore, take a look at the source before
1162you define your own sql-mode-postgres-font-lock-keywords.") 1305you define your own sql-mode-postgres-font-lock-keywords.")
1163 1306
1164(defvar sql-mode-linter-font-lock-keywords 1307(defvar sql-mode-linter-font-lock-keywords
1165 (let ((linter-keywords (eval-when-compile 1308 (let ((linter-keywords (sql-keywords-re
1166 (concat "\\b"
1167 (regexp-opt '(
1168
1169"autocommit" "autoinc" "autorowid" "cancel" "cascade" "channel" 1309"autocommit" "autoinc" "autorowid" "cancel" "cascade" "channel"
1170"committed" "count" "countblob" "cross" "current" "data" "database" 1310"committed" "count" "countblob" "cross" "current" "data" "database"
1171"datafile" "datafiles" "datesplit" "dba" "dbname" "default" "deferred" 1311"datafile" "datafiles" "datesplit" "dba" "dbname" "default" "deferred"
@@ -1190,12 +1330,9 @@ you define your own sql-mode-postgres-font-lock-keywords.")
1190"trigger_info_size" "true" "trunc" "uncommitted" "unicode" "unknown" 1330"trigger_info_size" "true" "trunc" "uncommitted" "unicode" "unknown"
1191"unlimited" "unlisted" "user" "utf8" "value" "varying" "volumes" 1331"unlimited" "unlisted" "user" "utf8" "value" "varying" "volumes"
1192"wait" "windows_code" "workspace" "write" "xml" 1332"wait" "windows_code" "workspace" "write" "xml"
1333))
1193 1334
1194) t) "\\b"))) 1335 (linter-reserved (sql-keywords-re
1195 (linter-reserved-words (eval-when-compile
1196 (concat "\\b"
1197 (regexp-opt '(
1198
1199"access" "action" "add" "address" "after" "all" "alter" "always" "and" 1336"access" "action" "add" "address" "after" "all" "alter" "always" "and"
1200"any" "append" "as" "asc" "ascic" "async" "at_begin" "at_end" "audit" 1337"any" "append" "as" "asc" "ascic" "async" "at_begin" "at_end" "audit"
1201"aud_obj_name_len" "backup" "base" "before" "between" "blobfile" 1338"aud_obj_name_len" "backup" "base" "before" "between" "blobfile"
@@ -1213,22 +1350,16 @@ you define your own sql-mode-postgres-font-lock-keywords.")
1213"start" "stop" "sync" "synchronize" "synonym" "sysdate" "table" "then" 1350"start" "stop" "sync" "synchronize" "synonym" "sysdate" "table" "then"
1214"to" "union" "unique" "unlock" "until" "update" "using" "values" 1351"to" "union" "unique" "unlock" "until" "update" "using" "values"
1215"view" "when" "where" "with" "without" 1352"view" "when" "where" "with" "without"
1353))
1216 1354
1217) t) "\\b"))) 1355 (linter-types (sql-keywords-re
1218 (linter-types (eval-when-compile
1219 (concat "\\b"
1220 (regexp-opt '(
1221
1222"bigint" "bitmap" "blob" "boolean" "char" "character" "date" 1356"bigint" "bitmap" "blob" "boolean" "char" "character" "date"
1223"datetime" "dec" "decimal" "double" "float" "int" "integer" "nchar" 1357"datetime" "dec" "decimal" "double" "float" "int" "integer" "nchar"
1224"number" "numeric" "real" "smallint" "varbyte" "varchar" "byte" 1358"number" "numeric" "real" "smallint" "varbyte" "varchar" "byte"
1225"cursor" "long" 1359"cursor" "long"
1360))
1226 1361
1227) t) "\\b"))) 1362 (linter-functions (sql-keywords-re
1228 (linter-builtin-functions (eval-when-compile
1229 (concat "\\b"
1230 (regexp-opt '(
1231
1232"abs" "acos" "asin" "atan" "atan2" "avg" "ceil" "cos" "cosh" "divtime" 1363"abs" "acos" "asin" "atan" "atan2" "avg" "ceil" "cos" "cosh" "divtime"
1233"exp" "floor" "getbits" "getblob" "getbyte" "getlong" "getraw" 1364"exp" "floor" "getbits" "getblob" "getbyte" "getlong" "getraw"
1234"getstr" "gettext" "getword" "hextoraw" "lenblob" "length" "log" 1365"getstr" "gettext" "getword" "hextoraw" "lenblob" "length" "log"
@@ -1239,20 +1370,12 @@ you define your own sql-mode-postgres-font-lock-keywords.")
1239"to_gmtime" "to_localtime" "to_number" "trim" "upper" "decode" 1370"to_gmtime" "to_localtime" "to_number" "trim" "upper" "decode"
1240"substr" "substring" "chr" "dayname" "days" "greatest" "hex" "initcap" 1371"substr" "substring" "chr" "dayname" "days" "greatest" "hex" "initcap"
1241"instr" "least" "multime" "replace" "width" 1372"instr" "least" "multime" "replace" "width"
1373)))
1242 1374
1243) t) "\\b")))) 1375 `((,linter-keywords . font-lock-keyword-face)
1244 (append sql-mode-ansi-font-lock-keywords 1376 (,linter-reserved . font-lock-keyword-face)
1245 (list (cons linter-keywords 'font-lock-keywords-face) 1377 (,linter-functions . font-lock-builtin-face)
1246 (cons linter-reserved-words 'font-lock-keyword-face) 1378 (,linter-types . font-lock-type-face)))
1247 ;; XEmacs doesn't have font-lock-builtin-face
1248 (if (string-match "XEmacs\\|Lucid" emacs-version)
1249 (cons linter-builtin-functions 'font-lock-preprocessor-face)
1250 ;; GNU Emacs 19 doesn't have it either
1251 (if (string-match "GNU Emacs 19" emacs-version)
1252 (cons linter-builtin-functions 'font-lock-keywords-face)
1253 ;; Emacs
1254 (cons linter-builtin-functions 'font-lock-builtin-face)))
1255 (cons linter-types 'font-lock-type-face))))
1256 1379
1257 "Linter SQL keywords used by font-lock. 1380 "Linter SQL keywords used by font-lock.
1258 1381
@@ -1261,21 +1384,18 @@ regular expressions are created during compilation by calling the
1261function `regexp-opt'.") 1384function `regexp-opt'.")
1262 1385
1263(defvar sql-mode-ms-font-lock-keywords 1386(defvar sql-mode-ms-font-lock-keywords
1264 (let ((ms-reserved-words (eval-when-compile 1387 (let ((ms-reserved (sql-keywords-re
1265 (concat "\\b"
1266 (regexp-opt '(
1267
1268"absolute" "add" "all" "alter" "and" "any" "as" "asc" "authorization" 1388"absolute" "add" "all" "alter" "and" "any" "as" "asc" "authorization"
1269"avg" "backup" "begin" "between" "break" "browse" "bulk" "by" 1389"avg" "backup" "begin" "between" "break" "browse" "bulk" "by"
1270"cascade" "case" "check" "checkpoint" "close" "clustered" "coalesce" 1390"cascade" "case" "check" "checkpoint" "close" "clustered" "coalesce"
1271"column" "commit" "committed" "compute" "confirm" "constraint" 1391"column" "commit" "committed" "compute" "confirm" "constraint"
1272"contains" "containstable" "continue" "controlrow" "convert" "count" 1392"contains" "containstable" "continue" "controlrow" "convert" "count"
1273"create" "cross" "current" "current_date" "current_time" 1393"create" "cross" "current" "current_date" "current_time"
1274"current_timestamp" "current_user" "database" "deallocate" 1394"current_timestamp" "current_user" "database" "deallocate" "declare"
1275"declare" "default" "delete" "deny" "desc" "disk" "distinct" 1395"default" "delete" "deny" "desc" "disk" "distinct" "distributed"
1276"distributed" "double" "drop" "dummy" "dump" "else" "end" "errlvl" 1396"double" "drop" "dummy" "dump" "else" "end" "errlvl" "errorexit"
1277"errorexit" "escape" "except" "exec" "execute" "exists" "exit" "fetch" 1397"escape" "except" "exec" "execute" "exists" "exit" "fetch" "file"
1278"file" "fillfactor" "first" "floppy" "for" "foreign" "freetext" 1398"fillfactor" "first" "floppy" "for" "foreign" "freetext"
1279"freetexttable" "from" "full" "goto" "grant" "group" "having" 1399"freetexttable" "from" "full" "goto" "grant" "group" "having"
1280"holdlock" "identity" "identity_insert" "identitycol" "if" "in" 1400"holdlock" "identity" "identity_insert" "identitycol" "if" "in"
1281"index" "inner" "insert" "intersect" "into" "is" "isolation" "join" 1401"index" "inner" "insert" "intersect" "into" "is" "isolation" "join"
@@ -1295,29 +1415,21 @@ function `regexp-opt'.")
1295"textsize" "then" "to" "top" "tran" "transaction" "trigger" "truncate" 1415"textsize" "then" "to" "top" "tran" "transaction" "trigger" "truncate"
1296"tsequal" "uncommitted" "union" "unique" "update" "updatetext" 1416"tsequal" "uncommitted" "union" "unique" "update" "updatetext"
1297"updlock" "use" "user" "values" "view" "waitfor" "when" "where" 1417"updlock" "use" "user" "values" "view" "waitfor" "when" "where"
1298"while" "with" "work" "writetext" 1418"while" "with" "work" "writetext" "collate" "function" "openxml"
1299"collate" "function" "openxml" "returns" 1419"returns"
1300 1420))
1301) t) "\\b")))
1302 (ms-types (eval-when-compile
1303 (concat "\\b"
1304 (regexp-opt '(
1305 1421
1422 (ms-types (sql-keywords-re
1306"binary" "bit" "char" "character" "cursor" "datetime" "dec" "decimal" 1423"binary" "bit" "char" "character" "cursor" "datetime" "dec" "decimal"
1307"double" "float" "image" "int" "integer" "money" "national" "nchar" 1424"double" "float" "image" "int" "integer" "money" "national" "nchar"
1308"ntext" "numeric" "numeric" "nvarchar" "precision" "real" 1425"ntext" "numeric" "numeric" "nvarchar" "precision" "real"
1309"smalldatetime" "smallint" "smallmoney" "text" "timestamp" "tinyint" 1426"smalldatetime" "smallint" "smallmoney" "text" "timestamp" "tinyint"
1310"uniqueidentifier" "varbinary" "varchar" "varying" 1427"uniqueidentifier" "varbinary" "varchar" "varying"
1311 1428))
1312) t) "\\b")))
1313 1429
1314 (ms-vars "\\b@[a-zA-Z0-9_]*\\b") 1430 (ms-vars "\\b@[a-zA-Z0-9_]*\\b")
1315 1431
1316 (ms-builtin-functions (eval-when-compile 1432 (ms-functions (sql-keywords-re
1317 (concat "\\b"
1318 (regexp-opt '(
1319;; Misc MS builtin functions
1320
1321"@@connections" "@@cpu_busy" "@@cursor_rows" "@@datefirst" "@@dbts" 1433"@@connections" "@@cpu_busy" "@@cursor_rows" "@@datefirst" "@@dbts"
1322"@@error" "@@fetch_status" "@@identity" "@@idle" "@@io_busy" 1434"@@error" "@@fetch_status" "@@identity" "@@idle" "@@io_busy"
1323"@@langid" "@@language" "@@lock_timeout" "@@max_connections" 1435"@@langid" "@@language" "@@lock_timeout" "@@max_connections"
@@ -1346,14 +1458,12 @@ function `regexp-opt'.")
1346"suser_id" "suser_name" "suser_sid" "suser_sname" "system_user" "tan" 1458"suser_id" "suser_name" "suser_sid" "suser_sname" "system_user" "tan"
1347"textptr" "textvalid" "typeproperty" "unicode" "upper" "user" 1459"textptr" "textvalid" "typeproperty" "unicode" "upper" "user"
1348"user_id" "user_name" "var" "varp" "year" 1460"user_id" "user_name" "var" "varp" "year"
1461))
1349 1462
1350) t) "\\b"))) 1463 (ms-commands
1351
1352 (ms-config-commands
1353 (eval-when-compile 1464 (eval-when-compile
1354 (concat "^\\(\\(set\\s-+\\(" 1465 (concat "^\\(\\(set\\s-+\\("
1355 (regexp-opt '( 1466 (regexp-opt '(
1356
1357"datefirst" "dateformat" "deadlock_priority" "lock_timeout" 1467"datefirst" "dateformat" "deadlock_priority" "lock_timeout"
1358"concat_null_yields_null" "cursor_close_on_commit" 1468"concat_null_yields_null" "cursor_close_on_commit"
1359"disable_def_cnst_chk" "fips_flagger" "identity_insert" "language" 1469"disable_def_cnst_chk" "fips_flagger" "identity_insert" "language"
@@ -1364,19 +1474,14 @@ function `regexp-opt'.")
1364"ansi_warnings" "forceplan" "showplan_all" "showplan_text" 1474"ansi_warnings" "forceplan" "showplan_all" "showplan_text"
1365"statistics" "implicit_transactions" "remote_proc_transactions" 1475"statistics" "implicit_transactions" "remote_proc_transactions"
1366"transaction" "xact_abort" 1476"transaction" "xact_abort"
1367
1368) t) 1477) t)
1369 "\\)\\)\\|go\\s-*\\|use\\s-+\\|setuser\\s-+\\|dbcc\\s-+\\).*$")))) 1478 "\\)\\)\\|go\\s-*\\|use\\s-+\\|setuser\\s-+\\|dbcc\\s-+\\).*$"))))
1370 1479
1371 (list (cons ms-config-commands 'font-lock-doc-face) 1480 `((,ms-commands . font-lock-doc-face)
1372 (cons ms-reserved-words 'font-lock-keyword-face) 1481 (,ms-reserved . font-lock-keyword-face)
1373 ;; XEmacs doesn't have 'font-lock-builtin-face 1482 (,ms-functions . font-lock-builtin-face)
1374 (if (string-match "XEmacs\\|Lucid" emacs-version) 1483 (,ms-vars . font-lock-variable-name-face)
1375 (cons ms-builtin-functions 'font-lock-preprocessor-face) 1484 (,ms-types . font-lock-type-face)))
1376 ;; Emacs
1377 (cons ms-builtin-functions 'font-lock-builtin-face))
1378 (cons ms-vars 'font-lock-variable-name-face)
1379 (cons ms-types 'font-lock-type-face)))
1380 1485
1381 "Microsoft SQLServer SQL keywords used by font-lock. 1486 "Microsoft SQLServer SQL keywords used by font-lock.
1382 1487
@@ -1385,7 +1490,7 @@ regular expressions are created during compilation by calling the
1385function `regexp-opt'. Therefore, take a look at the source before 1490function `regexp-opt'. Therefore, take a look at the source before
1386you define your own sql-mode-ms-font-lock-keywords.") 1491you define your own sql-mode-ms-font-lock-keywords.")
1387 1492
1388(defvar sql-mode-sybase-font-lock-keywords sql-mode-ansi-font-lock-keywords 1493(defvar sql-mode-sybase-font-lock-keywords nil
1389 "Sybase SQL keywords used by font-lock. 1494 "Sybase SQL keywords used by font-lock.
1390 1495
1391This variable is used by `sql-mode' and `sql-interactive-mode'. The 1496This variable is used by `sql-mode' and `sql-interactive-mode'. The
@@ -1393,7 +1498,7 @@ regular expressions are created during compilation by calling the
1393function `regexp-opt'. Therefore, take a look at the source before 1498function `regexp-opt'. Therefore, take a look at the source before
1394you define your own sql-mode-sybase-font-lock-keywords.") 1499you define your own sql-mode-sybase-font-lock-keywords.")
1395 1500
1396(defvar sql-mode-informix-font-lock-keywords sql-mode-ansi-font-lock-keywords 1501(defvar sql-mode-informix-font-lock-keywords nil
1397 "Informix SQL keywords used by font-lock. 1502 "Informix SQL keywords used by font-lock.
1398 1503
1399This variable is used by `sql-mode' and `sql-interactive-mode'. The 1504This variable is used by `sql-mode' and `sql-interactive-mode'. The
@@ -1401,7 +1506,7 @@ regular expressions are created during compilation by calling the
1401function `regexp-opt'. Therefore, take a look at the source before 1506function `regexp-opt'. Therefore, take a look at the source before
1402you define your own sql-mode-informix-font-lock-keywords.") 1507you define your own sql-mode-informix-font-lock-keywords.")
1403 1508
1404(defvar sql-mode-interbase-font-lock-keywords sql-mode-ansi-font-lock-keywords 1509(defvar sql-mode-interbase-font-lock-keywords nil
1405 "Interbase SQL keywords used by font-lock. 1510 "Interbase SQL keywords used by font-lock.
1406 1511
1407This variable is used by `sql-mode' and `sql-interactive-mode'. The 1512This variable is used by `sql-mode' and `sql-interactive-mode'. The
@@ -1409,7 +1514,7 @@ regular expressions are created during compilation by calling the
1409function `regexp-opt'. Therefore, take a look at the source before 1514function `regexp-opt'. Therefore, take a look at the source before
1410you define your own sql-mode-interbase-font-lock-keywords.") 1515you define your own sql-mode-interbase-font-lock-keywords.")
1411 1516
1412(defvar sql-mode-ingres-font-lock-keywords sql-mode-ansi-font-lock-keywords 1517(defvar sql-mode-ingres-font-lock-keywords nil
1413 "Ingres SQL keywords used by font-lock. 1518 "Ingres SQL keywords used by font-lock.
1414 1519
1415This variable is used by `sql-mode' and `sql-interactive-mode'. The 1520This variable is used by `sql-mode' and `sql-interactive-mode'. The
@@ -1417,7 +1522,7 @@ regular expressions are created during compilation by calling the
1417function `regexp-opt'. Therefore, take a look at the source before 1522function `regexp-opt'. Therefore, take a look at the source before
1418you define your own sql-mode-interbase-font-lock-keywords.") 1523you define your own sql-mode-interbase-font-lock-keywords.")
1419 1524
1420(defvar sql-mode-solid-font-lock-keywords sql-mode-ansi-font-lock-keywords 1525(defvar sql-mode-solid-font-lock-keywords nil
1421 "Solid SQL keywords used by font-lock. 1526 "Solid SQL keywords used by font-lock.
1422 1527
1423This variable is used by `sql-mode' and `sql-interactive-mode'. The 1528This variable is used by `sql-mode' and `sql-interactive-mode'. The
@@ -1425,7 +1530,76 @@ regular expressions are created during compilation by calling the
1425function `regexp-opt'. Therefore, take a look at the source before 1530function `regexp-opt'. Therefore, take a look at the source before
1426you define your own sql-mode-solid-font-lock-keywords.") 1531you define your own sql-mode-solid-font-lock-keywords.")
1427 1532
1428(defvar sql-mode-mysql-font-lock-keywords sql-mode-ansi-font-lock-keywords 1533(defvar sql-mode-mysql-font-lock-keywords
1534 (let ((mysql-funcs (sql-keywords-re
1535"ascii" "avg" "bdmpolyfromtext" "bdmpolyfromwkb" "bdpolyfromtext"
1536"bdpolyfromwkb" "benchmark" "bin" "bit_and" "bit_length" "bit_or"
1537"bit_xor" "both" "cast" "char_length" "character_length" "coalesce"
1538"concat" "concat_ws" "connection_id" "conv" "convert" "count"
1539"curdate" "current_date" "current_time" "current_timestamp" "curtime"
1540"elt" "encrypt" "export_set" "field" "find_in_set" "found_rows" "from"
1541"geomcollfromtext" "geomcollfromwkb" "geometrycollectionfromtext"
1542"geometrycollectionfromwkb" "geometryfromtext" "geometryfromwkb"
1543"geomfromtext" "geomfromwkb" "get_lock" "group_concat" "hex" "ifnull"
1544"instr" "interval" "isnull" "last_insert_id" "lcase" "leading"
1545"length" "linefromtext" "linefromwkb" "linestringfromtext"
1546"linestringfromwkb" "load_file" "locate" "lower" "lpad" "ltrim"
1547"make_set" "master_pos_wait" "max" "mid" "min" "mlinefromtext"
1548"mlinefromwkb" "mpointfromtext" "mpointfromwkb" "mpolyfromtext"
1549"mpolyfromwkb" "multilinestringfromtext" "multilinestringfromwkb"
1550"multipointfromtext" "multipointfromwkb" "multipolygonfromtext"
1551"multipolygonfromwkb" "now" "nullif" "oct" "octet_length" "ord"
1552"pointfromtext" "pointfromwkb" "polyfromtext" "polyfromwkb"
1553"polygonfromtext" "polygonfromwkb" "position" "quote" "rand"
1554"release_lock" "repeat" "replace" "reverse" "rpad" "rtrim" "soundex"
1555"space" "std" "stddev" "substring" "substring_index" "sum" "sysdate"
1556"trailing" "trim" "ucase" "unix_timestamp" "upper" "user" "variance"
1557))
1558
1559 (mysql-keywords (sql-keywords-re
1560"action" "add" "after" "against" "all" "alter" "and" "as" "asc"
1561"auto_increment" "avg_row_length" "bdb" "between" "by" "cascade"
1562"case" "change" "character" "check" "checksum" "close" "collate"
1563"collation" "column" "columns" "comment" "committed" "concurrent"
1564"constraint" "create" "cross" "data" "database" "default"
1565"delay_key_write" "delayed" "delete" "desc" "directory" "disable"
1566"distinct" "distinctrow" "do" "drop" "dumpfile" "duplicate" "else"
1567"enable" "enclosed" "end" "escaped" "exists" "fields" "first" "for"
1568"force" "foreign" "from" "full" "fulltext" "global" "group" "handler"
1569"having" "heap" "high_priority" "if" "ignore" "in" "index" "infile"
1570"inner" "insert" "insert_method" "into" "is" "isam" "isolation" "join"
1571"key" "keys" "last" "left" "level" "like" "limit" "lines" "load"
1572"local" "lock" "low_priority" "match" "max_rows" "merge" "min_rows"
1573"mode" "modify" "mrg_myisam" "myisam" "natural" "next" "no" "not"
1574"null" "offset" "oj" "on" "open" "optionally" "or" "order" "outer"
1575"outfile" "pack_keys" "partial" "password" "prev" "primary"
1576"procedure" "quick" "raid0" "raid_type" "read" "references" "rename"
1577"repeatable" "restrict" "right" "rollback" "rollup" "row_format"
1578"savepoint" "select" "separator" "serializable" "session" "set"
1579"share" "show" "sql_big_result" "sql_buffer_result" "sql_cache"
1580"sql_calc_found_rows" "sql_no_cache" "sql_small_result" "starting"
1581"straight_join" "striped" "table" "tables" "temporary" "terminated"
1582"then" "to" "transaction" "truncate" "type" "uncommitted" "union"
1583"unique" "unlock" "update" "use" "using" "values" "when" "where"
1584"with" "write" "xor"
1585))
1586
1587 (mysql-types (sql-keywords-re
1588"bigint" "binary" "bit" "blob" "bool" "boolean" "char" "curve" "date"
1589"datetime" "dec" "decimal" "double" "enum" "fixed" "float" "geometry"
1590"geometrycollection" "int" "integer" "line" "linearring" "linestring"
1591"longblob" "longtext" "mediumblob" "mediumint" "mediumtext"
1592"multicurve" "multilinestring" "multipoint" "multipolygon"
1593"multisurface" "national" "numeric" "point" "polygon" "precision"
1594"real" "smallint" "surface" "text" "time" "timestamp" "tinyblob"
1595"tinyint" "tinytext" "unsigned" "varchar" "year" "year2" "year4"
1596"zerofill"
1597)))
1598
1599 `((,mysql-funcs . font-lock-builtin-face)
1600 (,mysql-keywords . font-lock-keyword-face)
1601 (,mysql-types . font-lock-type-face)))
1602
1429 "MySQL SQL keywords used by font-lock. 1603 "MySQL SQL keywords used by font-lock.
1430 1604
1431This variable is used by `sql-mode' and `sql-interactive-mode'. The 1605This variable is used by `sql-mode' and `sql-interactive-mode'. The
@@ -1433,7 +1607,7 @@ regular expressions are created during compilation by calling the
1433function `regexp-opt'. Therefore, take a look at the source before 1607function `regexp-opt'. Therefore, take a look at the source before
1434you define your own sql-mode-mysql-font-lock-keywords.") 1608you define your own sql-mode-mysql-font-lock-keywords.")
1435 1609
1436(defvar sql-mode-sqlite-font-lock-keywords sql-mode-ansi-font-lock-keywords 1610(defvar sql-mode-sqlite-font-lock-keywords nil
1437 "SQLite SQL keywords used by font-lock. 1611 "SQLite SQL keywords used by font-lock.
1438 1612
1439This variable is used by `sql-mode' and `sql-interactive-mode'. The 1613This variable is used by `sql-mode' and `sql-interactive-mode'. The
@@ -1441,7 +1615,7 @@ regular expressions are created during compilation by calling the
1441function `regexp-opt'. Therefore, take a look at the source before 1615function `regexp-opt'. Therefore, take a look at the source before
1442you define your own sql-mode-sqlite-font-lock-keywords.") 1616you define your own sql-mode-sqlite-font-lock-keywords.")
1443 1617
1444(defvar sql-mode-db2-font-lock-keywords sql-mode-ansi-font-lock-keywords 1618(defvar sql-mode-db2-font-lock-keywords nil
1445 "DB2 SQL keywords used by font-lock. 1619 "DB2 SQL keywords used by font-lock.
1446 1620
1447This variable is used by `sql-mode' and `sql-interactive-mode'. The 1621This variable is used by `sql-mode' and `sql-interactive-mode'. The
@@ -1463,16 +1637,16 @@ highlighting rules in sql-mode.")
1463(defun sql-product-feature (feature &optional product) 1637(defun sql-product-feature (feature &optional product)
1464 "Lookup `feature' needed to support the current SQL product. 1638 "Lookup `feature' needed to support the current SQL product.
1465 1639
1466See \[sql-product-support] for a list of products and supported features." 1640See \[sql-product-alist] for a list of products and supported features."
1467 (cadr 1641 (plist-get
1468 (memq feature 1642 (cdr (assoc (or product sql-product)
1469 (assoc (or product sql-product) 1643 sql-product-alist))
1470 sql-product-support)))) 1644 feature))
1471 1645
1472(defun sql-product-font-lock (keywords-only imenu) 1646(defun sql-product-font-lock (keywords-only imenu)
1473 "Sets `font-lock-defaults' and `font-lock-keywords' based on 1647 "Sets `font-lock-defaults' and `font-lock-keywords' based on
1474the product-specific keywords and syntax-alists defined in 1648the product-specific keywords and syntax-alists defined in
1475`sql-product-support'." 1649`sql-product-alist'."
1476 (let 1650 (let
1477 ;; Get the product-specific syntax-alist. 1651 ;; Get the product-specific syntax-alist.
1478 ((syntax-alist 1652 ((syntax-alist
@@ -1483,27 +1657,69 @@ the product-specific keywords and syntax-alists defined in
1483 ;; Get the product-specific keywords. 1657 ;; Get the product-specific keywords.
1484 (setq sql-mode-font-lock-keywords 1658 (setq sql-mode-font-lock-keywords
1485 (append 1659 (append
1486 (eval (sql-product-feature :font-lock)) 1660 (unless (eq sql-product 'ansi)
1661 (eval (sql-product-feature :font-lock)))
1662 ;; Always highlight ANSI keywords
1663 (eval (sql-product-feature :font-lock 'ansi))
1664 ;; Fontify object names in CREATE, DROP and ALTER DDL
1665 ;; statements
1487 (list sql-mode-font-lock-object-name))) 1666 (list sql-mode-font-lock-object-name)))
1488 1667
1489 ;; Setup font-lock. (What is the minimum we should have to do 1668 ;; Setup font-lock. Force re-parsing of `font-lock-defaults'.
1490 ;; here?) 1669 (set (make-local-variable 'font-lock-set-defaults) nil)
1491 (setq font-lock-set-defaults nil 1670 (setq font-lock-defaults (list 'sql-mode-font-lock-keywords
1492 font-lock-keywords sql-mode-font-lock-keywords
1493 font-lock-defaults (list 'sql-mode-font-lock-keywords
1494 keywords-only t syntax-alist)) 1671 keywords-only t syntax-alist))
1495 1672
1673 ;; Force font lock to reinitialize if it is already on
1674 ;; Otherwise, we can wait until it can be started.
1675 (when (and (fboundp 'font-lock-mode)
1676 font-lock-mode)
1677 (font-lock-mode-internal nil)
1678 (font-lock-mode-internal t))
1679
1680 (add-hook 'font-lock-mode-hook
1681 (lambda ()
1682 ;; Provide defaults for new font-lock faces.
1683 (defvar font-lock-builtin-face
1684 (if (boundp 'font-lock-preprocessor-face)
1685 font-lock-preprocessor-face
1686 font-lock-keyword-face))
1687 (defvar font-lock-doc-face font-lock-string-face))
1688 nil t)
1689
1496 ;; Setup imenu; it needs the same syntax-alist. 1690 ;; Setup imenu; it needs the same syntax-alist.
1497 (when imenu 1691 (when imenu
1498 (setq imenu-syntax-alist syntax-alist)))) 1692 (setq imenu-syntax-alist syntax-alist))))
1499 1693
1500;;;###autoload 1694;;;###autoload
1501(defun sql-add-product-keywords (product keywords) 1695(defun sql-add-product-keywords (product keywords &optional append)
1502 "Append a `font-lock-keywords' entry to the existing entries defined 1696 "Add highlighting KEYWORDS for SQL PRODUCT.
1503 for the specified `product'." 1697
1504 1698PRODUCT should be a symbol, the name of a sql product, such as
1505 (let ((font-lock (sql-product-feature :font-lock product))) 1699`oracle'. KEYWORDS should be a list; see the variable
1506 (set font-lock (append (eval font-lock) (list keywords))))) 1700`font-lock-keywords'. By default they are added at the beginning
1701of the current highlighting list. If optional argument APPEND is
1702`set', they are used to replace the current highlighting list.
1703If APPEND is any other non-nil value, they are added at the end
1704of the current highlighting list.
1705
1706For example:
1707
1708 (sql-add-product-keywords 'ms
1709 '((\"\\\\b\\\\w+_t\\\\b\" . font-lock-type-face)))
1710
1711adds a fontification pattern to fontify identifiers ending in
1712`_t' as data types."
1713
1714 (let ((font-lock (sql-product-feature :font-lock product))
1715 old)
1716 (setq old (eval font-lock))
1717 (set font-lock
1718 (if (eq append 'set)
1719 keywords
1720 (if append
1721 (append old keywords)
1722 (append keywords old))))))
1507 1723
1508 1724
1509 1725
@@ -1517,10 +1733,6 @@ selected."
1517 ;; Setup font-lock 1733 ;; Setup font-lock
1518 (sql-product-font-lock nil t) 1734 (sql-product-font-lock nil t)
1519 1735
1520 ;; Force fontification, if its enabled.
1521 (if font-lock-mode
1522 (font-lock-fontify-buffer))
1523
1524 ;; Set the mode name to include the product. 1736 ;; Set the mode name to include the product.
1525 (setq mode-name (concat "SQL[" (prin1-to-string sql-product) "]")))) 1737 (setq mode-name (concat "SQL[" (prin1-to-string sql-product) "]"))))
1526 1738
@@ -1528,7 +1740,7 @@ selected."
1528 "Set `sql-product' to product and enable appropriate 1740 "Set `sql-product' to product and enable appropriate
1529highlighting." 1741highlighting."
1530 (interactive "SEnter SQL product: ") 1742 (interactive "SEnter SQL product: ")
1531 (when (not (assoc product sql-product-support)) 1743 (when (not (assoc product sql-product-alist))
1532 (error "SQL product %s is not supported; treated as ANSI" product) 1744 (error "SQL product %s is not supported; treated as ANSI" product)
1533 (setq product 'ansi)) 1745 (setq product 'ansi))
1534 1746
@@ -1952,6 +2164,19 @@ Every newline in STRING will be preceded with a space and a backslash."
1952 (interactive) 2164 (interactive)
1953 (sql-send-region (point-min) (point-max))) 2165 (sql-send-region (point-min) (point-max)))
1954 2166
2167(defun sql-send-string (str)
2168 "Send a string to the SQL process."
2169 (interactive "sSQL Text: ")
2170 (if (buffer-live-p sql-buffer)
2171 (save-excursion
2172 (comint-send-string sql-buffer str)
2173 (comint-send-string sql-buffer "\n")
2174 (message "Sent string to buffer %s." (buffer-name sql-buffer))
2175 (if sql-pop-to-buffer-after-send-region
2176 (pop-to-buffer sql-buffer)
2177 (display-buffer sql-buffer)))
2178 (message "No SQL process started.")))
2179
1955(defun sql-toggle-pop-to-buffer-after-send-region (&optional value) 2180(defun sql-toggle-pop-to-buffer-after-send-region (&optional value)
1956 "Toggle `sql-pop-to-buffer-after-send-region'. 2181 "Toggle `sql-pop-to-buffer-after-send-region'.
1957 2182
@@ -2611,6 +2836,8 @@ parameters and command options."
2611 (setq params (append params (list sql-database)))) 2836 (setq params (append params (list sql-database))))
2612 (if (not (string= "" sql-server)) 2837 (if (not (string= "" sql-server))
2613 (setq params (append (list "-h" sql-server) params))) 2838 (setq params (append (list "-h" sql-server) params)))
2839 (if (not (string= "" sql-user))
2840 (setq params (append (list "-U" sql-user) params)))
2614 (set-buffer (apply 'make-comint "SQL" sql-postgres-program 2841 (set-buffer (apply 'make-comint "SQL" sql-postgres-program
2615 nil params)))) 2842 nil params))))
2616 2843