Mercurial > emacs
comparison lisp/progmodes/sql.el @ 51893:1a294cfb1636
Version 1.8.0 of sql-mode.
Simplify selection of SQL products to define highlighting and
interactive mode. Includes detailed instructions on adding support
for new products.
(sql-product): New variable. Identifies SQL product for use in highlighting and
interactive mode.
(sql-interactive-product): New variable. SQL product for sql-interactive-mode.
(sql-product-support): New variable. Specifies product-specific parameters to
drive highlighting and interactive mode.
(sql-imenu-generic-expression): Add more object types.
(sql-sqlite-options): Correct comment.
(sql-ms-program): Use "osql" rather than "isql".
(sql-prompt-regexp, sql-prompt-length): Update comment.
(sql-mode-menu): Add "Start SQLi session" entry. Replace Highlighting submenu
with Product menu. Fix Send Region entry.
(sql-mode-abbrev-table): Add abbreviations. Support of SYSTEM-FLAG on
define-abbrev. Support was removed with last check-in; it now handles older
Emacsen without the SYSTEM-FLAG.
(sql-mode-font-lock-object-name): Add font-lock pattern for object names.
(sql-mode-ansi-font-lock-keywords): Set as default value.
(sql-mode-oracle-font-lock-keywords): Set as default value. Support Oracle 9i
keywords.
(sql-mode-postgres-font-lock-keywords): Set as default value.
(sql-mode-linter-font-lock-keywords): Set as default value.
(sql-mode-ms-font-lock-keywords): New variable. Support Microsoft SQLServer
2000.
(sql-mode-sybase-font-lock-keywords)
(sql-mode-interbase-font-lock-keywords)
(sql-mode-sqlite-font-lock-keywords)
(sql-mode-strong-font-lock-keywords)
(sql-mode-mysql-font-lock-keywords)
(sql-mode-db2-font-lock-keywords): New variables. Default to ANSI keywords.
(sql-mode-font-lock-defaults): Update comment.
(sql-product-feature): New function. Returns feature associated with a product
from `sql-product-support' alist.
(sql-product-font-lock): New function. Set font-lock support based on
`sql-product'.
(sql-add-product-keywords): New function. Add font-lock rules to
product-specific keyword variables.
(sql-set-product): New function. Set `sql-product' and apply appropriate
font-lock highlighting.
(sql-highlight-product): New function. Set font-lock support based on a
product. Also set mode name to include product name.
(sql-highlight-ansi-keywords, sql-highlight-oracle-keywords)
(sql-highlight-postgres-keywords, sql-highlight-linter-keywords):
Use `sql-set-product'.
(sql-highlight-ms-keywords)
(sql-highlight-sybase-keywords)
(sql-highlight-interbase-keywords)
(sql-highlight-strong-keywords)
(sql-highlight-mysql-keywords)
(sql-highlight-sqlite-keywords)
(sql-highlight-db2-keywords): New functions. Use `sql-set-product'.
(sql-get-login): Prompt in the same order as the tokens.
(sql-mode): Uses `sql-product-highlight' and `sql-product-font-lock'.
(sql-product-interactive): New function. Common portions of product-specific
interactive mode wrappers.
(sql-interactive-mode): Rewritten to use product features.
(sql-oracle, sql-sybase, sql-informix, sql-sqlite, sql-mysql)
(sql-solid, sql-ingres, sql-ms, sql-postgres, sql-interbase)
(sql-db2, sql-linter): Use `sql-product-interactive'.
(sql-connect-oracle, sql-connect-sybase, sql-connect-informix)
(sql-connect-sqlite, sql-connect-mysql, sql-connect-solid)
(sql-connect-ingres, sql-connect-postgres)
(sql-connect-interbase, sql-connect-db2, sql-connect-linter): New functions.
Format command line parameters and invoke comint on the appropriate interpreter.
Code was in the corresponding `sql-xyz' function before.
(sql-connect-ms): New function. Support -E argument to use operating system
credentials for authentication.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Sun, 13 Jul 2003 17:19:18 +0000 |
parents | ead411a37669 |
children | 3da2cf447bf9 |
comparison
equal
deleted
inserted
replaced
51892:3146f91c8c99 | 51893:1a294cfb1636 |
---|---|
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 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Alex Schroeder <alex@gnu.org> | 5 ;; Author: Alex Schroeder <alex@gnu.org> |
6 ;; Maintainer: Alex Schroeder <alex@gnu.org> | 6 ;; Maintainer: Alex Schroeder <alex@gnu.org> |
7 ;; Version: 1.7.0 | 7 ;; Version: 1.8.0 |
8 ;; Keywords: comm languages processes | 8 ;; Keywords: comm languages processes |
9 ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode | 9 ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode |
10 | 10 |
11 ;; This file is part of GNU Emacs. | 11 ;; This file is part of GNU Emacs. |
12 | 12 |
76 ;; and the custom package | 76 ;; and the custom package |
77 ;; <URL:http://www.dina.kvl.dk/~abraham/custom/>. | 77 ;; <URL:http://www.dina.kvl.dk/~abraham/custom/>. |
78 | 78 |
79 ;;; Bugs: | 79 ;;; Bugs: |
80 | 80 |
81 ;; Using sql-ms (isql by Microsoft): When commands with syntax errors | 81 ;; sql-ms now uses osql instead of isql. Osql flushes its error |
82 ;; or execution errors are executed, there is no server feedback. | 82 ;; stream more frequently than isql so that error messages are |
83 ;; This happens in stored procedures for example. The server messages | 83 ;; available. There is no prompt and some output still is buffered. |
84 ;; only appear after the process is exited. This makes things | 84 ;; This improves the interaction under Emacs but it still is somewhat |
85 ;; somewhat unreliable. | 85 ;; awkward. |
86 | |
87 ;; Quoted identifiers are not supported for hilighting. Most | |
88 ;; databases support the use of double quoted strings in place of | |
89 ;; identifiers; ms (Microsoft SQLServer) also supports identifiers | |
90 ;; enclosed within brackets []. | |
86 | 91 |
87 ;; ChangeLog available on request. | 92 ;; ChangeLog available on request. |
88 | 93 |
89 ;;; To Do: | 94 ;;; Product Support: |
90 | 95 |
91 ;; Add better hilight support for other brands; there is a bias towards | 96 ;; Set the variable `sql-product' to the product you usually use. If |
92 ;; Oracle because that's what I use at work. Anybody else just send in | 97 ;; you occasionally use another product, for certain files, add a |
93 ;; your lists of reserved words, keywords and builtin functions! As | 98 ;; comment on the first line of the file saying |
94 ;; long as I don't receive any feedback, everything is hilighted with | 99 ;; -*- sql-product: mysql -*- |
95 ;; ANSI keywords only. I received the list of ANSI keywords from a | 100 ;; See section "File Variables" in the Emacs manual for more info. |
96 ;; user; if you know of any changes, let me know. | 101 |
97 | 102 ;;; Adding another product: |
98 ;; Add different hilighting levels. | 103 |
104 ;; To add support for additional SQL products the following steps | |
105 ;; must be followed ("xyz" is the name of the product in the examples | |
106 ;; below): | |
107 | |
108 ;; 1) Add the product to `sql-product' choice list. | |
109 | |
110 ;; (const :tag "XyzDB" xyz) | |
111 | |
112 ;; 2) Add an entry to the `sql-product-support' list. | |
113 | |
114 ;; (xyz | |
115 ;; :font-lock sql-mode-xyz-font-lock-keywords | |
116 ;; :sqli-login (user password server database) | |
117 ;; :sqli-connect sql-connect-xyz | |
118 ;; :sqli-prompt-regexp "^xyzdb> " | |
119 ;; :sqli-prompt-length 7 | |
120 ;; :sqli-input-sender nil | |
121 ;; :syntax-alist ((?# . "w"))) | |
122 | |
123 ;; 3) Add customizable values for the product interpreter and options. | |
124 | |
125 ;; ;; Customization for XyzDB | |
126 ;; | |
127 ;; (defcustom sql-xyz-program "ixyz" | |
128 ;; "*Command to start ixyz by XyzDB." | |
129 ;; :type 'file | |
130 ;; :group 'SQL) | |
131 ;; | |
132 ;; (defcustom sql-xyz-options '("-X" "-Y" "-Z") | |
133 ;; "*List of additional options for `sql-xyz-program'." | |
134 ;; :type '(repeat string) | |
135 ;; :group 'SQL) | |
136 | |
137 ;; 4) Add an entry to SQL->Product submenu. | |
138 | |
139 ;; ["XyzDB" sql-highlight-xyz-keywords | |
140 ;; :style radio | |
141 ;; :selected (eq sql-product 'xyz)] | |
142 | |
143 ;; 5) Add the font-lock specifications. At a minimum, default to | |
144 ;; using ANSI keywords. See sql-mode-oracle-font-lock-keywords for | |
145 ;; a more complex example. | |
146 | |
147 ;; (defvar sql-mode-xyz-font-lock-keywords sql-mode-ansi-font-lock-keywords | |
148 ;; "XyzDB SQL keywords used by font-lock.") | |
149 | |
150 ;; 6) Add a product highlighting function. | |
151 | |
152 ;; (defun sql-highlight-xyz-keywords () | |
153 ;; "Highlight XyzDB keywords." | |
154 ;; (interactive) | |
155 ;; (sql-set-product 'xyz)) | |
156 | |
157 ;; 7) Add an autoloaded SQLi function. | |
158 | |
159 ;; ;;;###autoload | |
160 ;; (defun sql-xyz () | |
161 ;; "Run ixyz by XyzDB as an inferior process." | |
162 ;; (interactive) | |
163 ;; (sql-product-interactive 'xyz)) | |
164 | |
165 ;; 8) Add a connect function which formats the command line arguments | |
166 ;; and starts the product interpreter in a comint buffer. See the | |
167 ;; existing connect functions for examples of the types of | |
168 ;; processing available. | |
169 | |
170 ;; (defun sql-connect-xyz () | |
171 ;; "Create comint buffer and connect to XyzDB using the login | |
172 ;; parameters and command options." | |
173 ;; | |
174 ;; ;; Do something with `sql-user', `sql-password', | |
175 ;; ;; `sql-database', and `sql-server'. | |
176 ;; (let ((params sql-xyz-options)) | |
177 ;; (if (not (string= "" sql-server)) | |
178 ;; (setq params (append (list "-S" sql-server) params))) | |
179 ;; (if (not (string= "" sql-database)) | |
180 ;; (setq params (append (list "-D" sql-database) params))) | |
181 ;; (if (not (string= "" sql-password)) | |
182 ;; (setq params (append (list "-P" sql-password) params))) | |
183 ;; (if (not (string= "" sql-user)) | |
184 ;; (setq params (append (list "-U" sql-user) params))) | |
185 ;; (set-buffer (apply 'make-comint "SQL" sql-xyz-program | |
186 ;; nil params)))) | |
187 | |
188 ;; 9) Save and compile sql.el. | |
99 | 189 |
100 ;;; Thanks to all the people who helped me out: | 190 ;;; Thanks to all the people who helped me out: |
101 | 191 |
102 ;; Kai Blauberg <kai.blauberg@metla.fi> | 192 ;; Kai Blauberg <kai.blauberg@metla.fi> |
103 ;; <ibalaban@dalet.com> | 193 ;; <ibalaban@dalet.com> |
104 ;; Yair Friedman <yfriedma@JohnBryce.Co.Il> | 194 ;; Yair Friedman <yfriedma@JohnBryce.Co.Il> |
105 ;; Gregor Zych <zych@pool.informatik.rwth-aachen.de> | 195 ;; Gregor Zych <zych@pool.informatik.rwth-aachen.de> |
106 ;; nino <nino@inform.dk> | 196 ;; nino <nino@inform.dk> |
107 ;; Berend de Boer <berend@pobox.com> | 197 ;; Berend de Boer <berend@pobox.com> |
198 ;; Michael Mauger <mmaug@yahoo.com> | |
108 | 199 |
109 | 200 |
110 | 201 |
111 ;;; Code: | 202 ;;; Code: |
112 | 203 |
113 (require 'comint) | 204 (require 'comint) |
114 ;; Need the following to allow GNU Emacs 19 to compile the file. | 205 ;; Need the following to allow GNU Emacs 19 to compile the file. |
115 (require 'regexp-opt) | 206 (eval-when-compile |
207 (require 'regexp-opt)) | |
116 (require 'custom) | 208 (require 'custom) |
117 | 209 |
118 ;;; Allow customization | 210 ;;; Allow customization |
119 | 211 |
120 (defgroup SQL nil | 212 (defgroup SQL nil |
121 "Running a SQL interpreter from within Emacs buffers" | 213 "Running a SQL interpreter from within Emacs buffers" |
122 :version "20.4" | 214 :version "20.4" |
123 :group 'processes) | 215 :group 'processes) |
124 | 216 |
125 ;; These three variables will be used as defaults, if set. | 217 ;; These four variables will be used as defaults, if set. |
126 | 218 |
127 (defcustom sql-user "" | 219 (defcustom sql-user "" |
128 "*Default username." | 220 "*Default username." |
129 :type 'string | 221 :type 'string |
130 :group 'SQL) | 222 :group 'SQL) |
144 | 236 |
145 (defcustom sql-server "" | 237 (defcustom sql-server "" |
146 "*Default server or host." | 238 "*Default server or host." |
147 :type 'string | 239 :type 'string |
148 :group 'SQL) | 240 :group 'SQL) |
241 | |
242 ;; SQL Product support | |
243 (defcustom sql-product 'ansi | |
244 "*Select the SQL database product used so that buffers can be | |
245 highlighted properly when you open them." | |
246 :type '(choice (const :tag "ANSI" ansi) | |
247 (const :tag "DB2" db2) | |
248 (const :tag "Informix" informix) | |
249 (const :tag "Ingres" ingres) | |
250 (const :tag "Interbase" interbase) | |
251 (const :tag "Linter" linter) | |
252 (const :tag "Microsoft" ms) | |
253 (const :tag "MySQL" mysql) | |
254 (const :tag "Oracle" oracle) | |
255 (const :tag "PostGres" postgres) | |
256 (const :tag "Solid" solid) | |
257 (const :tag "SQLite" sqlite) | |
258 (const :tag "Sybase" sybase)) | |
259 :group 'SQL) | |
260 | |
261 (defvar sql-interactive-product nil | |
262 "Product under `sql-interactive-mode'.") | |
263 | |
264 (defvar sql-product-support | |
265 '((ansi | |
266 :font-lock sql-mode-ansi-font-lock-keywords) | |
267 (db2 | |
268 :font-lock sql-mode-db2-font-lock-keywords | |
269 :sqli-login nil | |
270 :sqli-connect sql-connect-db2 | |
271 :sqli-prompt-regexp "^db2 => " | |
272 :sqli-prompt-length 7) | |
273 (informix | |
274 :font-lock sql-mode-informix-font-lock-keywords | |
275 :sqli-login (database) | |
276 :sqli-connect sql-connect-informix | |
277 :sqli-prompt-regexp "^SQL> " | |
278 :sqli-prompt-length 5) | |
279 (ingres | |
280 :font-lock sql-mode-ingres-font-lock-keywords | |
281 :sqli-login (database) | |
282 :sqli-connect sql-connect-ingres | |
283 :sqli-prompt-regexp "^\* " | |
284 :sqli-prompt-length 2) | |
285 (interbase | |
286 :font-lock sql-mode-interbase-font-lock-keywords | |
287 :sqli-login (user password database) | |
288 :sqli-connect sql-connect-interbase | |
289 :sqli-prompt-regexp "^SQL> " | |
290 :sqli-prompt-length 5) | |
291 (linter | |
292 :font-lock sql-mode-linter-font-lock-keywords | |
293 :sqli-login (user password database server) | |
294 :sqli-connect sql-connect-linter | |
295 :sqli-prompt-regexp "^SQL>" | |
296 :sqli-prompt-length 4) | |
297 (ms | |
298 :font-lock sql-mode-ms-font-lock-keywords | |
299 :sqli-login (user password server database) | |
300 :sqli-connect sql-connect-ms | |
301 :sqli-prompt-regexp "^[0-9]*>" | |
302 :sqli-prompt-length 5 | |
303 :syntax-alist ((?@ . "w"))) | |
304 (mysql | |
305 :font-lock sql-mode-mysql-font-lock-keywords | |
306 :sqli-login (user password database server) | |
307 :sqli-connect sql-connect-mysql | |
308 :sqli-prompt-regexp "^mysql> " | |
309 :sqli-prompt-length 6) | |
310 (oracle | |
311 :font-lock sql-mode-oracle-font-lock-keywords | |
312 :sqli-login (user password database) | |
313 :sqli-connect sql-connect-oracle | |
314 :sqli-prompt-regexp "^SQL> " | |
315 :sqli-prompt-length 5 | |
316 :syntax-alist ((?$ . "w") (?# . "w"))) | |
317 (postgres | |
318 :font-lock sql-mode-postgres-font-lock-keywords | |
319 :sqli-login (database server) | |
320 :sqli-connect sql-connect-postgres | |
321 :sqli-prompt-regexp "^.*> *" | |
322 :sqli-prompt-length 5) | |
323 (solid | |
324 :font-lock sql-mode-solid-font-lock-keywords | |
325 :sqli-login (user password server) | |
326 :sqli-connect sql-connect-solid | |
327 :sqli-prompt-regexp "^" | |
328 :sqli-prompt-length 0) | |
329 (sqlite | |
330 :font-lock sql-mode-sqlite-font-lock-keywords | |
331 :sqli-login (user password server database) | |
332 :sqli-connect sql-connect-sqlite | |
333 :sqli-prompt-regexp "^sqlite> " | |
334 :sqli-prompt-length 8) | |
335 (sybase | |
336 :font-lock sql-mode-sybase-font-lock-keywords | |
337 :sqli-login (server user password database) | |
338 :sqli-connect sql-connect-sybase | |
339 :sqli-prompt-regexp "^SQL> " | |
340 :sqli-prompt-length 5 | |
341 :syntax-alist ((?@ . "w"))) | |
342 ) | |
343 "This variable contains a list of product features for each of the | |
344 SQL products handled by `sql-mode'. Without an entry in this list a | |
345 product will not be properly highlighted and will not support | |
346 `sql-interactive-mode'. | |
347 | |
348 Each element in the list is in the following format: | |
349 | |
350 \(PRODUCT FEATURE VALUE ...) | |
351 | |
352 where PRODUCT is the appropriate value of `sql-product'. The product | |
353 name is then followed by FEATURE-VALUE pairs. If a FEATURE is not | |
354 specified, its VALUE is treated as nil. FEATURE must be one of the | |
355 following: | |
356 | |
357 :font-lock name of the variable containing the product | |
358 specific font lock highlighting patterns. | |
359 | |
360 :sqli-login a list of login parameters (i.e., user, | |
361 password, database and server) needed to | |
362 connect to the database. | |
363 | |
364 :sqli-connect the name of a function which accepts no | |
365 parameters that will use the values of | |
366 `sql-user', `sql-password', | |
367 `sql-database' and `sql-server' to open a | |
368 comint buffer and connect to the | |
369 database. Do product specific | |
370 configuration of comint in this function. | |
371 | |
372 :sqli-prompt-regexp a regular expression string that matches the | |
373 prompt issued by the product interpreter. | |
374 | |
375 :sqli-prompt-length the length of the prompt on the line. | |
376 | |
377 :syntax-alist an alist of syntax table entries to enable | |
378 special character treatment by font-lock and | |
379 imenu. ") | |
149 | 380 |
150 ;; misc customization of sql.el behaviour | 381 ;; misc customization of sql.el behaviour |
151 | 382 |
152 (defcustom sql-electric-stuff nil | 383 (defcustom sql-electric-stuff nil |
153 "Treat some input as electric. | 384 "Treat some input as electric. |
175 :group 'SQL) | 406 :group 'SQL) |
176 | 407 |
177 ;; imenu support for sql-mode. | 408 ;; imenu support for sql-mode. |
178 | 409 |
179 (defvar sql-imenu-generic-expression | 410 (defvar sql-imenu-generic-expression |
180 '(("Tables" "^\\s-*create\\s-+table\\s-+\\(\\w+\\)" 1) | 411 ;; Items are in reverse order because they are rendered in reverse. |
181 ("Indexes" "^\\s-*create\\s-+index\\s-+\\(\\w+\\)" 1)) | 412 '(("Rules/Defaults" "^\\s-*create\\s-+\\(rule\\|default\\)\\s-+\\(\\w+\\)" 2) |
413 ("Sequences" "^\\s-*create\\s-+sequence\\s-+\\(\\w+\\)" 1) | |
414 ("Triggers" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?trigger\\s-+\\(\\w+\\)" 3) | |
415 ("Functions" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?function\\s-+\\(\\w+\\)" 3) | |
416 ("Procedures" "^\\s-*\\(create\\s-+\\(or\\s-+replace\\s-+\\)?\\)?proc\\(edure\\)?\\s-+\\(\\w+\\)" 4) | |
417 ("Packages" "^\\s-*create\\s-+\\(or\\s-+replace\\s-+\\)?package\\s-+\\(body\\s-+\\)?\\(\\w+\\)" 3) | |
418 ("Indexes" "^\\s-*create\\s-+index\\s-+\\(\\w+\\)" 1) | |
419 ("Tables/Views" "^\\s-*create\\s-+\\(\\(global\\s-+\\)?\\(temporary\\s-+\\)?table\\|view\\)\\s-+\\(\\w+\\)" 4)) | |
182 "Define interesting points in the SQL buffer for `imenu'. | 420 "Define interesting points in the SQL buffer for `imenu'. |
183 | 421 |
184 This is used to set `imenu-generic-expression' when SQL mode is | 422 This is used to set `imenu-generic-expression' when SQL mode is |
185 entered. Subsequent changes to sql-imenu-generic-expression will not | 423 entered. Subsequent changes to sql-imenu-generic-expression will not |
186 affect existing SQL buffers because imenu-generic-expression is a | 424 affect existing SQL buffers because imenu-generic-expression is a |
272 The program can also specify a TCP connection. See `make-comint'." | 510 The program can also specify a TCP connection. See `make-comint'." |
273 :type 'file | 511 :type 'file |
274 :group 'SQL) | 512 :group 'SQL) |
275 | 513 |
276 (defcustom sql-sqlite-options nil | 514 (defcustom sql-sqlite-options nil |
277 "*List of additional options for `sql-mysql-program'. | 515 "*List of additional options for `sql-sqlite-program'. |
278 The following list of options is reported to make things work | 516 The following list of options is reported to make things work |
279 on Windows: \"-C\" \"-t\" \"-f\" \"-n\"." | 517 on Windows: \"-C\" \"-t\" \"-f\" \"-n\"." |
280 :type '(repeat string) | 518 :type '(repeat string) |
281 :version "20.8" | 519 :version "20.8" |
282 :group 'SQL) | 520 :group 'SQL) |
351 :type 'file | 589 :type 'file |
352 :group 'SQL) | 590 :group 'SQL) |
353 | 591 |
354 ;; Customization for Microsoft | 592 ;; Customization for Microsoft |
355 | 593 |
356 (defcustom sql-ms-program "isql" | 594 (defcustom sql-ms-program "osql" |
357 "*Command to start isql by Microsoft. | 595 "*Command to start osql by Microsoft. |
358 | 596 |
359 Starts `sql-interactive-mode' after doing some setup. | 597 Starts `sql-interactive-mode' after doing some setup. |
360 | 598 |
361 The program can also specify a TCP connection. See `make-comint'." | 599 The program can also specify a TCP connection. See `make-comint'." |
362 :type 'file | 600 :type 'file |
466 the local value of `sql-buffer' using \\[sql-set-sqli-buffer].") | 704 the local value of `sql-buffer' using \\[sql-set-sqli-buffer].") |
467 | 705 |
468 (defvar sql-prompt-regexp nil | 706 (defvar sql-prompt-regexp nil |
469 "Prompt used to initialize `comint-prompt-regexp'. | 707 "Prompt used to initialize `comint-prompt-regexp'. |
470 | 708 |
471 You can change `comint-prompt-regexp' on `sql-interactive-mode-hook'.") | 709 You can change `sql-prompt-regexp' on `sql-interactive-mode-hook'.") |
472 | 710 |
473 (defvar sql-prompt-length 0 | 711 (defvar sql-prompt-length 0 |
474 "Prompt used to set `left-margin' in `sql-interactive-mode'. | 712 "Prompt used to set `left-margin' in `sql-interactive-mode'. |
475 | 713 |
476 You can change it on `sql-interactive-mode-hook'.") | 714 You can change `sql-prompt-length' on `sql-interactive-mode-hook'.") |
477 | 715 |
478 (defvar sql-alternate-buffer-name nil | 716 (defvar sql-alternate-buffer-name nil |
479 "Buffer-local string used to possibly rename the SQLi buffer. | 717 "Buffer-local string used to possibly rename the SQLi buffer. |
480 | 718 |
481 Used by `sql-rename-buffer'.") | 719 Used by `sql-rename-buffer'.") |
516 '("SQL" | 754 '("SQL" |
517 ["Send Paragraph" sql-send-paragraph (and (buffer-live-p sql-buffer) | 755 ["Send Paragraph" sql-send-paragraph (and (buffer-live-p sql-buffer) |
518 (get-buffer-process sql-buffer))] | 756 (get-buffer-process sql-buffer))] |
519 ["Send Region" sql-send-region (and (or (and (boundp 'mark-active); Emacs | 757 ["Send Region" sql-send-region (and (or (and (boundp 'mark-active); Emacs |
520 mark-active) | 758 mark-active) |
521 (mark)); XEmacs | 759 (mark t)); XEmacs |
522 (buffer-live-p sql-buffer) | 760 (buffer-live-p sql-buffer) |
523 (get-buffer-process sql-buffer))] | 761 (get-buffer-process sql-buffer))] |
524 ["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer) | 762 ["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer) |
525 (get-buffer-process sql-buffer))] | 763 (get-buffer-process sql-buffer))] |
764 ["--" nil nil] | |
765 ["Start SQLi session" sql-product-interactive (sql-product-feature :sqli-connect)] | |
526 ["Show SQLi buffer" sql-show-sqli-buffer t] | 766 ["Show SQLi buffer" sql-show-sqli-buffer t] |
527 ["Set SQLi buffer" sql-set-sqli-buffer t] | 767 ["Set SQLi buffer" sql-set-sqli-buffer t] |
528 ["Pop to SQLi buffer after send" | 768 ["Pop to SQLi buffer after send" |
529 sql-toggle-pop-to-buffer-after-send-region | 769 sql-toggle-pop-to-buffer-after-send-region |
530 :style toggle | 770 :style toggle |
531 :selected sql-pop-to-buffer-after-send-region] | 771 :selected sql-pop-to-buffer-after-send-region] |
532 ("Highlighting" | 772 ["--" nil nil] |
533 ["ANSI SQL keywords" sql-highlight-ansi-keywords t] | 773 ("Product" |
534 ["Oracle keywords" sql-highlight-oracle-keywords t] | 774 ["ANSI" sql-highlight-ansi-keywords |
535 ["Postgres keywords" sql-highlight-postgres-keywords t] | 775 :style radio |
536 ["Linter keywords" sql-highlight-linter-keywords t] | 776 :selected (eq sql-product 'ansi)] |
777 ["DB2" sql-highlight-db2-keywords | |
778 :style radio | |
779 :selected (eq sql-product 'db2)] | |
780 ["Informix" sql-highlight-informix-keywords | |
781 :style radio | |
782 :selected (eq sql-product 'informix)] | |
783 ["Ingres" sql-highlight-ingres-keywords | |
784 :style radio | |
785 :selected (eq sql-product 'ingres)] | |
786 ["Interbase" sql-highlight-interbase-keywords | |
787 :style radio | |
788 :selected (eq sql-product 'interbase)] | |
789 ["Linter" sql-highlight-linter-keywords | |
790 :style radio | |
791 :selected (eq sql-product 'linter)] | |
792 ["Microsoft" sql-highlight-ms-keywords | |
793 :style radio | |
794 :selected (eq sql-product 'ms)] | |
795 ["MySQL" sql-highlight-mysql-keywords | |
796 :style radio | |
797 :selected (eq sql-product 'mysql)] | |
798 ["Oracle" sql-highlight-oracle-keywords | |
799 :style radio | |
800 :selected (eq sql-product 'oracle)] | |
801 ["Postgres" sql-highlight-postgres-keywords | |
802 :style radio | |
803 :selected (eq sql-product 'postgres)] | |
804 ["Solid" sql-highlight-solid-keywords | |
805 :style radio | |
806 :selected (eq sql-product 'solid)] | |
807 ["SQLite" sql-highlight-sqlite-keywords | |
808 :style radio | |
809 :selected (eq sql-product 'sqlite)] | |
810 ["Sybase" sql-highlight-sybase-keywords | |
811 :style radio | |
812 :selected (eq sql-product 'sybase)] | |
537 ))) | 813 ))) |
538 | 814 |
539 ;; easy menu for sql-interactive-mode. | 815 ;; easy menu for sql-interactive-mode. |
540 | 816 |
541 (easy-menu-define | 817 (easy-menu-define |
549 | 825 |
550 (defvar sql-mode-abbrev-table nil | 826 (defvar sql-mode-abbrev-table nil |
551 "Abbrev table used in `sql-mode' and `sql-interactive-mode'.") | 827 "Abbrev table used in `sql-mode' and `sql-interactive-mode'.") |
552 (if sql-mode-abbrev-table | 828 (if sql-mode-abbrev-table |
553 () | 829 () |
554 (let ((wrapper)) | 830 (let ((nargs (cdr (subr-arity (symbol-function 'define-abbrev)))) |
555 (define-abbrev-table 'sql-mode-abbrev-table ()) | 831 d-a) |
556 (define-abbrev sql-mode-abbrev-table "ins" "insert") | 832 ;; In Emacs 21.3+, provide SYSTEM-FLAG to define-abbrev. |
557 (define-abbrev sql-mode-abbrev-table "upd" "update") | 833 (setq d-a |
558 (define-abbrev sql-mode-abbrev-table "del" "delete") | 834 (if (>= nargs 6) |
559 (define-abbrev sql-mode-abbrev-table "sel" "select"))) | 835 '(lambda (name expansion) (define-abbrev sql-mode-abbrev-table name expansion nil 0 t)) |
836 '(lambda (name expansion) (define-abbrev sql-mode-abbrev-table name expansion)))) | |
837 | |
838 (define-abbrev-table 'sql-mode-abbrev-table nil) | |
839 (funcall d-a "ins" "insert") | |
840 (funcall d-a "upd" "update") | |
841 (funcall d-a "del" "delete") | |
842 (funcall d-a "sel" "select") | |
843 (funcall d-a "proc" "procedure") | |
844 (funcall d-a "func" "function") | |
845 (funcall d-a "cr" "create"))) | |
560 | 846 |
561 ;; Syntax Table | 847 ;; Syntax Table |
562 | 848 |
563 (defvar sql-mode-syntax-table | 849 (defvar sql-mode-syntax-table |
564 (let ((table (make-syntax-table))) | 850 (let ((table (make-syntax-table))) |
579 table) | 865 table) |
580 "Syntax table used in `sql-mode' and `sql-interactive-mode'.") | 866 "Syntax table used in `sql-mode' and `sql-interactive-mode'.") |
581 | 867 |
582 ;; Font lock support | 868 ;; Font lock support |
583 | 869 |
584 (defvar sql-mode-ansi-font-lock-keywords nil | 870 (defvar sql-mode-font-lock-object-name |
871 (list (concat "^\\s-*\\(create\\(\\s-+or\\s-+replace\\)?\\|drop\\|alter\\)?\\s-+" | |
872 "\\(\\(global\\s-+\\)?\\(temporary\\s-+\\)?table\\|view\\|package\\(\\s-+body\\)?\\|" | |
873 "proc\\(edure\\)?\\|function\\|trigger\\|sequence\\|rule\\|default\\)\\s-+\\(\\w+\\)") | |
874 8 'font-lock-function-name-face) | |
875 | |
876 "Pattern to match the names of top-level objects in a CREATE, | |
877 DROP or ALTER statement. | |
878 | |
879 The format of variable should be a valid `font-lock-keywords' | |
880 entry.") | |
881 | |
882 (defvar sql-mode-ansi-font-lock-keywords | |
883 (let ((ansi-keywords (eval-when-compile | |
884 (concat "\\b" | |
885 (regexp-opt '( | |
886 | |
887 "authorization" "avg" "begin" "close" "cobol" "commit" | |
888 "continue" "count" "declare" "double" "end" "escape" | |
889 "exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" | |
890 "key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" | |
891 "precision" "primary" "procedure" "references" "rollback" | |
892 "schema" "section" "some" "sqlcode" "sqlerror" "sum" "work" | |
893 | |
894 ) t) "\\b"))) | |
895 (ansi-reserved-words (eval-when-compile | |
896 (concat "\\b" | |
897 (regexp-opt '( | |
898 | |
899 "all" "and" "any" "as" "asc" "between" "by" "check" "create" | |
900 "current" "default" "delete" "desc" "distinct" "exists" "float" "for" | |
901 "from" "grant" "group" "having" "in" "insert" "into" "is" | |
902 "like" "not" "null" "of" "on" "option" "or" "order" "privileges" | |
903 "public" "select" "set" "table" "to" "union" "unique" | |
904 "update" "user" "values" "view" "where" "with" | |
905 | |
906 ) t) "\\b"))) | |
907 (ansi-types (eval-when-compile | |
908 (concat "\\b" | |
909 (regexp-opt '( | |
910 | |
911 ;; ANSI Keywords that look like types | |
912 "character" "cursor" "dec" "int" "real" | |
913 ;; ANSI Reserved Word that look like types | |
914 "char" "integer" "smallint" | |
915 | |
916 ) t) "\\b")))) | |
917 (list (cons ansi-keywords 'font-lock-keyword-face) | |
918 (cons ansi-reserved-words 'font-lock-keyword-face) | |
919 (cons ansi-types 'font-lock-type-face))) | |
920 | |
585 "ANSI SQL keywords used by font-lock. | 921 "ANSI SQL keywords used by font-lock. |
586 | 922 |
587 This variable is used by `sql-mode' and `sql-interactive-mode'. The | 923 This variable is used by `sql-mode' and `sql-interactive-mode'. The |
588 regular expressions are created during compilation by calling the | 924 regular expressions are created during compilation by calling the |
589 function `regexp-opt'. Therefore, take a look at the source before | 925 function `regexp-opt'. Therefore, take a look at the source before |
590 you define your own sql-mode-ansi-font-lock-keywords. You may want to | 926 you define your own sql-mode-ansi-font-lock-keywords. You may want to |
591 add functions and PL/SQL keywords.") | 927 add functions and PL/SQL keywords.") |
592 (if sql-mode-ansi-font-lock-keywords | 928 |
593 () | 929 (defvar sql-mode-oracle-font-lock-keywords |
594 (let ((ansi-keywords (eval-when-compile | 930 (let ((oracle-keywords (eval-when-compile |
595 (concat "\\b" | 931 (concat "\\b" |
596 (regexp-opt '( | 932 (regexp-opt '( |
933 ;; Oracle (+ANSI) SQL keywords | |
934 | |
935 ; ANSI keywords | |
597 "authorization" "avg" "begin" "close" "cobol" "commit" | 936 "authorization" "avg" "begin" "close" "cobol" "commit" |
598 "continue" "count" "declare" "double" "end" "escape" | 937 "continue" "count" "declare" "double" "end" "escape" |
599 "exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" | 938 "exec" "fetch" "foreign" "fortran" "found" "go" "goto" "indicator" |
600 "key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" | 939 "key" "language" "max" "min" "module" "numeric" "open" "pascal" "pli" |
601 "precision" "primary" "procedure" "references" "rollback" | 940 "precision" "primary" "procedure" "references" "rollback" |
602 "schema" "section" "some" "sqlcode" "sqlerror" "sum" "work") t) "\\b"))) | 941 "schema" "section" "some" "sqlcode" "sqlerror" "sum" "work" |
603 (ansi-reserved-words (eval-when-compile | 942 |
604 (concat "\\b" | 943 ; ANSI reserved words |
605 (regexp-opt '( | |
606 "all" "and" "any" "as" "asc" "between" "by" "check" "create" | 944 "all" "and" "any" "as" "asc" "between" "by" "check" "create" |
607 "current" "default" "delete" "desc" "distinct" "exists" "float" "for" | 945 "current" "default" "delete" "desc" "distinct" "exists" "float" "for" |
608 "from" "grant" "group" "having" "in" "insert" "into" "is" | 946 "from" "grant" "group" "having" "in" "insert" "into" "is" |
609 "like" "not" "null" "of" "on" "option" "or" "order" "privileges" | 947 "like" "not" "null" "of" "on" "option" "or" "order" "privileges" |
610 "public" "select" "set" "table" "to" "union" "unique" | 948 "public" "select" "set" "table" "to" "union" "unique" |
611 "update" "user" "values" "view" "where" "with") t) "\\b"))) | 949 "update" "user" "values" "view" "where" "with" |
612 (ansi-types (eval-when-compile | 950 |
613 (concat "\\b" | 951 "access" "add" "admin" "after" "allocate" "alter" "analyze" "archive" |
614 (regexp-opt '( | 952 "archivelog" "audit" "authid" "backup" "become" "before" "block" |
615 ;; ANSI Keywords that look like types | 953 "body" "cache" "cancel" "cascade" "change" "checkpoint" "cluster" |
616 "character" "cursor" "dec" "int" "real" | 954 "comment" "compile" "compress" "compute" "connect" "constraint" |
617 ;; ANSI Reserved Word that look like types | 955 "constraints" "contents" "controlfile" "cross" "currval" "cycle" |
618 "char" "integer" "smallint" ) t) "\\b")))) | 956 "database" "datafile" "dba" "deterministic" "disable" "dismount" |
619 (setq sql-mode-ansi-font-lock-keywords | 957 "drop" "dump" "each" "else" "else" "elsif" "enable" "events" "except" |
620 (list (cons ansi-keywords 'font-lock-function-name-face) | 958 "exceptions" "exclusive" "execute" "exit" "explain" "extent" |
621 (cons ansi-reserved-words 'font-lock-keyword-face) | 959 "externally" "false" "file" "flush" "force" "freelist" "freelists" |
622 (cons ansi-types 'font-lock-type-face))))) | 960 "full" "function" "global" "grant" "groups" "identified" "if" |
623 | 961 "immediate" "including" "increment" "index" "initial" "initrans" |
624 (defvar sql-mode-oracle-font-lock-keywords nil | 962 "inner" "instance" "intersect" "join" "layer" "left" "level" "link" |
963 "lists" "lock" "logfile" "long" "loop" "manage" "manual" | |
964 "maxdatafiles" "maxextents" "maxinistances" "maxlogfiles" | |
965 "maxloghistory" "maxlogmembers" "maxtrans" "maxvalue" "merge" | |
966 "minextents" "minus" "minvalue" "mode" "modify" "mount" "natural" | |
967 "new" "next" "nextval" "noarchivelog" "noaudit" "nocache" "nocompress" | |
968 "nocycle" "nomaxvalue" "nominvalue" "none" "noorder" "noresetlogs" | |
969 "normal" "nosort" "nowait" "off" "offline" "old" "online" "only" | |
970 "optimal" "others" "out" "outer" "over" "own" "package" "parallel" | |
971 "parallel_enable" "pctfree" "pctincrease" "pctused" "plan" "pragma" | |
972 "preserve" "prior" "private" "profile" "quota" "raise" "raw" "read" | |
973 "recover" "referencing" "rename" "replace" "resetlogs" "resource" | |
974 "restrict_references" "restricted" "return" "returning" "reuse" | |
975 "revoke" "right" "rnds" "rnps" "role" "roles" "row" "rowlabel" | |
976 "rownum" "rows" "savepoint" "scn" "segment" "sequence" "session" | |
977 "share" "shared" "size" "snapshot" "sort" "statement_id" "statistics" | |
978 "stop" "storage" "subtype" "successful" "switch" "synonym" "sysdate" | |
979 "system" "tables" "tablespace" "temporary" "then" "thread" "tracing" | |
980 "transaction" "trigger" "triggers" "true" "truncate" "type" "uid" | |
981 "under" "unlimited" "until" "use" "using" "validate" "when" "while" | |
982 "wnds" "wnps" "write" | |
983 | |
984 ) t) "\\b"))) | |
985 (oracle-warning-words (eval-when-compile | |
986 (concat "\\b" | |
987 (regexp-opt '( | |
988 ;; PLSQL defined exceptions | |
989 | |
990 "access_into_null" "case_not_found" "collection_is_null" | |
991 "cursor_already_open" "dup_val_on_index" "invalid_cursor" | |
992 "invalid_number" "login_denied" "no_data_found" "not_logged_on" | |
993 "program_error" "rowtype_mismatch" "self_is_null" "storage_error" | |
994 "subscript_beyond_count" "subscript_outside_limit" "sys_invalid_rowid" | |
995 "timeout_on_resource" "too_many_rows" "value_error" "zero_divide" | |
996 "exception" "notfound" | |
997 | |
998 ) t) "\\b"))) | |
999 | |
1000 (oracle-sqlplus-commands | |
1001 (eval-when-compile | |
1002 (concat "^\\(\\(" | |
1003 (regexp-opt '( | |
1004 ;; SQL*Plus commands | |
1005 | |
1006 "@" "@@" "accept" "append" "archive" "attribute" "break" | |
1007 "btitle" "change" "clear" "column" "connect" "copy" "define" | |
1008 "del" "describe" "disconnect" "edit" "execute" "exit" "get" "help" | |
1009 "host" "input" "list" "password" "pause" "print" "prompt" "recover" | |
1010 "remark" "repfooter" "repheader" "run" "save" "show" "shutdown" | |
1011 "spool" "start" "startup" "store" "timing" "ttitle" "undefine" | |
1012 "variable" "whenever" | |
1013 | |
1014 ) t) | |
1015 | |
1016 "\\)\\|" | |
1017 "\\(compute\\s-+\\(avg\\|cou\\|min\\|max\\|num\\|sum\\|std\\|var\\)\\)\\|" | |
1018 "\\(set\\s-+\\(appi\\(nfo\\)?\\|array\\(size\\)?\\|" | |
1019 "auto\\(commit\\)?\\|autop\\(rint\\)?\\|autorecovery\\|" | |
1020 "autot\\(race\\)?\\|blo\\(ckterminator\\)?\\|cmds\\(ep\\)?\\|" | |
1021 "colsep\\|com\\(patibility\\)?\\|con\\(cat\\)?\\|" | |
1022 "copyc\\(ommit\\)?\\|copytypecheck\\|def\\(ine\\)?\\|" | |
1023 "describe\\|echo\\|editf\\(ile\\)?\\|emb\\(edded\\)?\\|" | |
1024 "esc\\(ape\\)?\\|feed\\(back\\)?\\|flagger\\|" | |
1025 "flu\\(sh\\)?\\|hea\\(ding\\)?\\|heads\\(ep\\)?\\|" | |
1026 "instance\\|lin\\(esize\\)?\\|lobof\\(fset\\)?\\|" | |
1027 "logsource\\|long\\|longc\\(hunksize\\)?\\|mark\\(up\\)?\\|" | |
1028 "newp\\(age\\)?\\|null\\|numf\\(ormat\\)?\\|" | |
1029 "num\\(width\\)?\\|pages\\(ize\\)?\\|pau\\(se\\)?\\|" | |
1030 "recsep\\|recsepchar\\|serverout\\(put\\)?\\|" | |
1031 "shift\\(inout\\)?\\|show\\(mode\\)?\\|" | |
1032 "sqlbl\\(anklines\\)?\\|sqlc\\(ase\\)?\\|" | |
1033 "sqlco\\(ntinue\\)?\\|sqln\\(umber\\)?\\|" | |
1034 "sqlpluscompat\\(ibility\\)?\\|sqlpre\\(fix\\)?\\|" | |
1035 "sqlp\\(rompt\\)?\\|sqlt\\(erminator\\)?\\|" | |
1036 "suf\\(fix\\)?\\|tab\\|term\\(out\\)?\\|ti\\(me\\)?\\|" | |
1037 "timi\\(ng\\)?\\|trim\\(out\\)?\\|trims\\(pool\\)?\\|" | |
1038 "und\\(erline\\)?\\|ver\\(ify\\)?\\|wra\\(p\\)?\\)\\)\\)" | |
1039 "\\b.*$" | |
1040 ))) | |
1041 | |
1042 (oracle-types | |
1043 (eval-when-compile | |
1044 (concat "\\b" | |
1045 (regexp-opt '( | |
1046 ;; Oracle Keywords that look like types | |
1047 ;; Oracle Reserved Words that look like types | |
1048 | |
1049 "bfile" "binary_integer" "blob" "boolean" "byte" "char" "character" | |
1050 "clob" "date" "day" "dec" "decimal" "double" "float" "int" "integer" | |
1051 "interval" "local" "long" "month" "natural" "naturaln" "nchar" "nclob" | |
1052 "number" "numeric" "nvarchar2" "pls_integer" "positive" "positiven" | |
1053 "precision" "raw" "real" "rowid" "second" "signtype" "smallint" | |
1054 "string" "time" "timestamp" "urowid" "varchar" "varchar2" "year" | |
1055 "zone" | |
1056 | |
1057 ) t) "\\b"))) | |
1058 (oracle-builtin-functions (eval-when-compile | |
1059 (concat "\\b" | |
1060 (regexp-opt '( | |
1061 ;; Misc Oracle builtin functions | |
1062 | |
1063 "abs" "acos" "add_months" "ascii" "asciistr" "asin" "atan" "atan2" | |
1064 "avg" "bfilename" "bin_to_num" "bitand" "case" "cast" "ceil" | |
1065 "chartorowid" "chr" "coalesce" "compose" "concat" "convert" "corr" | |
1066 "cos" "cosh" "count" "covar_pop" "covar_samp" "cume_dist" | |
1067 "current_date" "current_timestamp" "current_user" "dbtimezone" | |
1068 "decode" "decompose" "dense_rank" "depth" "deref" "dump" "empty_blob" | |
1069 "empty_clob" "existsnode" "exp" "extract" "extractvalue" "first" | |
1070 "first_value" "floor" "from_tz" "greatest" "group_id" "grouping" | |
1071 "grouping_id" "hextoraw" "initcap" "instr" "lag" "last" "last_day" | |
1072 "last_value" "lead" "least" "length" "ln" "localtimestamp" "log" | |
1073 "lower" "lpad" "ltrim" "make_ref" "max" "min" "mod" "months_between" | |
1074 "nchr" "new_time" "next_day" "nls_charset_decl_len" "nls_charset_id" | |
1075 "nls_charset_name" "nls_initcap" "nls_lower" "nlssort" "nls_upper" | |
1076 "ntile" "nullif" "numtodsinterval" "numtoyminterval" "nvl" "nvl2" | |
1077 "path" "percent_rank" "percentile_cont" "percentile_disc" "power" | |
1078 "rank" "ratio_to_report" "rawtohex" "rawtonhex" "ref" "reftohex" | |
1079 "regr_slope" "regr_intercept" "regr_count" "regr_r2" "regr_avgx" | |
1080 "regr_avgy" "regr_sxx" "regr_syy" "regr_sxy" "round" | |
1081 "row_number" "rowidtochar" "rowidtonchar" "rpad" "rtrim" | |
1082 "sessiontimezone" "sign" "sin" "sinh" "soundex" "sqrt" "stddev" | |
1083 "stddev_pop" "stddev_samp" "substr" "sum" "sys_connect_by_path" | |
1084 "sys_context" "sys_dburigen" "sys_extract_utc" "sys_guid" "sys_typeid" | |
1085 "sys_xmlagg" "sys_xmlgen" "sysdate" "systimestamp" "tan" "tanh" | |
1086 "to_char" "to_clob" "to_date" "to_dsinterval" "to_lob" "to_multi_byte" | |
1087 "to_nchar" "to_nclob" "to_number" "to_single_byte" "to_timestamp" | |
1088 "to_timestamp_tz" "to_yminterval" "translate" "treat" "trim" "trunc" | |
1089 "tz_offset" "uid" "unistr" "updatexml" "upper" "user" "userenv" | |
1090 "value" "var_pop" "var_samp" "variance" "vsize" "width_bucket" | |
1091 "xmlagg" "xmlcolattval" "xmlconcat" "xmlelement" "xmlforest" | |
1092 "xmlsequence" "xmltransform" | |
1093 | |
1094 ) t) "\\b")))) | |
1095 (list (cons oracle-sqlplus-commands 'font-lock-doc-face) | |
1096 (cons oracle-keywords 'font-lock-keyword-face) | |
1097 (cons oracle-warning-words 'font-lock-warning-face) | |
1098 ;; XEmacs doesn't have font-lock-builtin-face | |
1099 (if (string-match "XEmacs\\|Lucid" emacs-version) | |
1100 (cons oracle-builtin-functions 'font-lock-preprocessor-face) | |
1101 ;; GNU Emacs 19 doesn't have it either | |
1102 (if (string-match "GNU Emacs 19" emacs-version) | |
1103 (cons oracle-builtin-functions 'font-lock-keyword-face) | |
1104 ;; Emacs | |
1105 (cons oracle-builtin-functions 'font-lock-builtin-face))) | |
1106 (cons oracle-types 'font-lock-type-face))) | |
1107 | |
625 "Oracle SQL keywords used by font-lock. | 1108 "Oracle SQL keywords used by font-lock. |
626 | 1109 |
627 This variable is used by `sql-mode' and `sql-interactive-mode'. The | 1110 This variable is used by `sql-mode' and `sql-interactive-mode'. The |
628 regular expressions are created during compilation by calling the | 1111 regular expressions are created during compilation by calling the |
629 function `regexp-opt'. Therefore, take a look at the source before | 1112 function `regexp-opt'. Therefore, take a look at the source before |
630 you define your own sql-mode-oracle-font-lock-keywords. You may want | 1113 you define your own sql-mode-oracle-font-lock-keywords. You may want |
631 to add functions and PL/SQL keywords.") | 1114 to add functions and PL/SQL keywords.") |
632 (if sql-mode-oracle-font-lock-keywords | 1115 |
633 () | 1116 (defvar sql-mode-postgres-font-lock-keywords |
634 (let ((oracle-keywords (eval-when-compile | |
635 (concat "\\b" | |
636 (regexp-opt '( | |
637 "admin" "after" "allocate" "analyze" "archive" "archivelog" "backup" | |
638 "become" "before" "block" "body" "cache" "cancel" "cascade" "change" | |
639 "checkpoint" "compile" "constraint" "constraints" "contents" | |
640 "controlfile" "cycle" "database" "datafile" "dba" "disable" "dismount" | |
641 "dump" "each" "else" "elsif" "enable" "events" "except" "exceptions" | |
642 "execute" "exit" "explain" "extent" "externally" "false" "flush" "force" | |
643 "freelist" "freelists" "function" "groups" "if" "including" "initrans" | |
644 "instance" "layer" "link" "lists" "logfile" "loop" "manage" "manual" | |
645 "maxdatafiles" "maxinistances" "maxlogfiles" "maxloghistory" | |
646 "maxlogmembers" "maxtrans" "maxvalue" "minextents" "minvalue" "mount" | |
647 "new" "next" "noarchivelog" "nocache" "nocycle" "nomaxvalue" | |
648 "nominvalue" "none" "noorder" "noresetlogs" "normal" "nosort" "off" | |
649 "old" "only" "optimal" "others" "out" "own" "package" "parallel" | |
650 "pctincrease" "pctused" "plan" "pragma" "private" "profile" "quota" | |
651 "raise" "read" "recover" "referencing" "resetlogs" "restrict_references" | |
652 "restricted" "return" "returning" "reuse" "rnds" "rnps" "role" "roles" | |
653 "savepoint" "scn" "segment" "sequence" "shared" "snapshot" "sort" | |
654 "statement_id" "statistics" "stop" "storage" "subtype" "switch" "system" | |
655 "tables" "tablespace" "temporary" "thread" "time" "tracing" | |
656 "transaction" "triggers" "true" "truncate" "type" "under" "unlimited" | |
657 "until" "use" "using" "when" "while" "wnds" "wnps" "write") t) "\\b"))) | |
658 (oracle-warning-words (eval-when-compile | |
659 (concat "\\b" | |
660 (regexp-opt '( | |
661 "cursor_already_open" "dup_val_on_index" "exception" "invalid_cursor" | |
662 "invalid_number" "login_denied" "no_data_found" "not_logged_on" | |
663 "notfound" "others" "pragma" "program_error" "storage_error" | |
664 "timeout_on_resource" "too_many_rows" "transaction_backed_out" | |
665 "value_error" "zero_divide") t) "\\b"))) | |
666 (oracle-reserved-words (eval-when-compile | |
667 (concat "\\b" | |
668 (regexp-opt '( | |
669 "access" "add" "alter" "audit" "cluster" "column" "comment" "compress" | |
670 "connect" "drop" "else" "exclusive" "file" "grant" | |
671 "identified" "immediate" "increment" "index" "initial" "intersect" | |
672 "level" "lock" "long" "maxextents" "minus" "mode" "modify" "noaudit" | |
673 "nocompress" "nowait" "number" "offline" "online" "pctfree" "prior" | |
674 "raw" "rename" "resource" "revoke" "row" "rowlabel" "rownum" | |
675 "rows" "session" "share" "size" "start" "successful" "synonym" "sysdate" | |
676 "then" "trigger" "uid" "validate" "whenever") t) "\\b"))) | |
677 (oracle-types (eval-when-compile | |
678 (concat "\\b" | |
679 (regexp-opt '( | |
680 ;; Oracle Keywords that look like types | |
681 ;; Oracle Reserved Words that look like types | |
682 "binary_integer" "blob" "boolean" "constant" "date" "decimal" "rowid" | |
683 "varchar" "varchar2") t) "\\b"))) | |
684 (oracle-builtin-functions (eval-when-compile | |
685 (concat "\\b" | |
686 (regexp-opt '( | |
687 ;; Misc Oracle builtin functions | |
688 "abs" "add_months" "ascii" "avg" "ceil" "chartorowid" "chr" "concat" | |
689 "convert" "cos" "cosh" "count" "currval" "decode" "dump" "exp" "floor" | |
690 "glb" "greatest" "greatest_lb" "hextoraw" "initcap" "instr" "instrb" | |
691 "last_day" "least" "least_ub" "length" "lengthb" "ln" "log" "lower" | |
692 "lpad" "ltrim" "lub" "max" "min" "mod" "months_between" "new_time" | |
693 "next_day" "nextval" "nls_initcap" "nls_lower" "nls_upper" "nlssort" | |
694 "nvl" "power" "rawtohex" "replace" "round" "rowidtochar" "rpad" | |
695 "rtrim" "sign" "sin" "sinh" "soundex" "sqlcode" "sqlerrm" "sqrt" | |
696 "stddev" "sum" "substr" "substrb" "tan" "tanh" "to_char" | |
697 "to_date" "to_label" "to_multi_byte" "to_number" "to_single_byte" | |
698 "translate" "trim" "trunc" "uid" "upper" "userenv" "variance" "vsize") t) "\\b")))) | |
699 (setq sql-mode-oracle-font-lock-keywords | |
700 (append sql-mode-ansi-font-lock-keywords | |
701 (list (cons oracle-keywords 'font-lock-function-name-face) | |
702 (cons oracle-warning-words 'font-lock-warning-face) | |
703 (cons oracle-reserved-words 'font-lock-keyword-face) | |
704 ;; XEmacs doesn't have font-lock-builtin-face | |
705 (if (string-match "XEmacs\\|Lucid" emacs-version) | |
706 (cons oracle-builtin-functions 'font-lock-preprocessor-face) | |
707 ;; GNU Emacs 19 doesn't have it either | |
708 (if (string-match "GNU Emacs 19" emacs-version) | |
709 (cons oracle-builtin-functions 'font-lock-function-name-face) | |
710 ;; Emacs | |
711 (cons oracle-builtin-functions 'font-lock-builtin-face))) | |
712 (cons oracle-types 'font-lock-type-face)))))) | |
713 | |
714 (defvar sql-mode-postgres-font-lock-keywords nil | |
715 "Postgres SQL keywords used by font-lock. | |
716 | |
717 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
718 regular expressions are created during compilation by calling the | |
719 function `regexp-opt'. Therefore, take a look at the source before | |
720 you define your own sql-mode-postgres-font-lock-keywords.") | |
721 | |
722 (if sql-mode-postgres-font-lock-keywords | |
723 () | |
724 (let ((postgres-reserved-words (eval-when-compile | 1117 (let ((postgres-reserved-words (eval-when-compile |
725 (concat "\\b" | 1118 (concat "\\b" |
726 (regexp-opt '( | 1119 (regexp-opt '( |
727 "language" | 1120 "language" |
728 ) t) "\\b"))) | 1121 ) t) "\\b"))) |
729 (postgres-types (eval-when-compile | 1122 (postgres-types (eval-when-compile |
730 (concat "\\b" | 1123 (concat "\\b" |
731 (regexp-opt '( | 1124 (regexp-opt '( |
1125 | |
732 "bool" "box" "circle" "char" "char2" "char4" "char8" "char16" "date" | 1126 "bool" "box" "circle" "char" "char2" "char4" "char8" "char16" "date" |
733 "float4" "float8" "int2" "int4" "int8" "line" "lseg" "money" "path" | 1127 "float4" "float8" "int2" "int4" "int8" "line" "lseg" "money" "path" |
734 "point" "polygon" "serial" "text" "time" "timespan" "timestamp" "varchar" | 1128 "point" "polygon" "serial" "text" "time" "timespan" "timestamp" "varchar" |
1129 | |
735 ) t)"\\b"))) | 1130 ) t)"\\b"))) |
736 (postgres-builtin-functions (eval-when-compile | 1131 (postgres-builtin-functions (eval-when-compile |
737 (concat "\\b" | 1132 (concat "\\b" |
738 (regexp-opt '( | 1133 (regexp-opt '( |
739 ;; Misc Postgres builtin functions | 1134 ;; Misc Postgres builtin functions |
1135 | |
740 "abstime" "age" "area" "box" "center" "date_part" "date_trunc" | 1136 "abstime" "age" "area" "box" "center" "date_part" "date_trunc" |
741 "datetime" "dexp" "diameter" "dpow" "float" "float4" "height" | 1137 "datetime" "dexp" "diameter" "dpow" "float" "float4" "height" |
742 "initcap" "integer" "isclosed" "isfinite" "isoldpath" "isopen" | 1138 "initcap" "integer" "isclosed" "isfinite" "isoldpath" "isopen" |
743 "length" "lower" "lpad" "ltrim" "pclose" "point" "points" "popen" | 1139 "length" "lower" "lpad" "ltrim" "pclose" "point" "points" "popen" |
744 "position" "radius" "reltime" "revertpoly" "rpad" "rtrim" "substr" | 1140 "position" "radius" "reltime" "revertpoly" "rpad" "rtrim" "substr" |
745 "substring" "text" "timespan" "translate" "trim" "upgradepath" | 1141 "substring" "text" "timespan" "translate" "trim" "upgradepath" |
746 "upgradepoly" "upper" "varchar" "width" | 1142 "upgradepoly" "upper" "varchar" "width" |
1143 | |
747 ) t) "\\b")))) | 1144 ) t) "\\b")))) |
748 (setq sql-mode-postgres-font-lock-keywords | |
749 (append sql-mode-ansi-font-lock-keywords | 1145 (append sql-mode-ansi-font-lock-keywords |
750 (list (cons postgres-reserved-words 'font-lock-keyword-face) | 1146 (list (cons postgres-reserved-words 'font-lock-keyword-face) |
751 ;; XEmacs doesn't have 'font-lock-builtin-face | 1147 ;; XEmacs doesn't have 'font-lock-builtin-face |
752 (if (string-match "XEmacs\\|Lucid" emacs-version) | 1148 (if (string-match "XEmacs\\|Lucid" emacs-version) |
753 (cons postgres-builtin-functions 'font-lock-preprocessor-face) | 1149 (cons postgres-builtin-functions 'font-lock-preprocessor-face) |
754 ;; Emacs | 1150 ;; Emacs |
755 (cons postgres-builtin-functions 'font-lock-builtin-face)) | 1151 (cons postgres-builtin-functions 'font-lock-builtin-face)) |
756 (cons postgres-types 'font-lock-type-face)))))) | 1152 (cons postgres-types 'font-lock-type-face)))) |
757 | 1153 |
758 | 1154 "Postgres SQL keywords used by font-lock. |
759 (defvar sql-mode-linter-font-lock-keywords nil | |
760 "Linter SQL keywords used by font-lock. | |
761 | 1155 |
762 This variable is used by `sql-mode' and `sql-interactive-mode'. The | 1156 This variable is used by `sql-mode' and `sql-interactive-mode'. The |
763 regular expressions are created during compilation by calling the | 1157 regular expressions are created during compilation by calling the |
764 function `regexp-opt'.") | 1158 function `regexp-opt'. Therefore, take a look at the source before |
765 | 1159 you define your own sql-mode-postgres-font-lock-keywords.") |
766 (if sql-mode-linter-font-lock-keywords | 1160 |
767 () | 1161 (defvar sql-mode-linter-font-lock-keywords |
768 (let ((linter-keywords (eval-when-compile | 1162 (let ((linter-keywords (eval-when-compile |
769 (concat "\\b" | 1163 (concat "\\b" |
770 (regexp-opt '( | 1164 (regexp-opt '( |
1165 | |
771 "autocommit" "autoinc" "autorowid" "cancel" "cascade" "channel" | 1166 "autocommit" "autoinc" "autorowid" "cancel" "cascade" "channel" |
772 "committed" "count" "countblob" "cross" "current" "data" "database" | 1167 "committed" "count" "countblob" "cross" "current" "data" "database" |
773 "datafile" "datafiles" "datesplit" "dba" "dbname" "default" "deferred" | 1168 "datafile" "datafiles" "datesplit" "dba" "dbname" "default" "deferred" |
774 "denied" "description" "device" "difference" "directory" "error" | 1169 "denied" "description" "device" "difference" "directory" "error" |
775 "escape" "euc" "exclusive" "external" "extfile" "false" "file" | 1170 "escape" "euc" "exclusive" "external" "extfile" "false" "file" |
790 "startup" "statement" "station" "success" "sys_guid" "tables" "test" | 1185 "startup" "statement" "station" "success" "sys_guid" "tables" "test" |
791 "timeout" "trace" "transaction" "translation" "trigger" | 1186 "timeout" "trace" "transaction" "translation" "trigger" |
792 "trigger_info_size" "true" "trunc" "uncommitted" "unicode" "unknown" | 1187 "trigger_info_size" "true" "trunc" "uncommitted" "unicode" "unknown" |
793 "unlimited" "unlisted" "user" "utf8" "value" "varying" "volumes" | 1188 "unlimited" "unlisted" "user" "utf8" "value" "varying" "volumes" |
794 "wait" "windows_code" "workspace" "write" "xml" | 1189 "wait" "windows_code" "workspace" "write" "xml" |
1190 | |
795 ) t) "\\b"))) | 1191 ) t) "\\b"))) |
796 (linter-reserved-words (eval-when-compile | 1192 (linter-reserved-words (eval-when-compile |
797 (concat "\\b" | 1193 (concat "\\b" |
798 (regexp-opt '( | 1194 (regexp-opt '( |
1195 | |
799 "access" "action" "add" "address" "after" "all" "alter" "always" "and" | 1196 "access" "action" "add" "address" "after" "all" "alter" "always" "and" |
800 "any" "append" "as" "asc" "ascic" "async" "at_begin" "at_end" "audit" | 1197 "any" "append" "as" "asc" "ascic" "async" "at_begin" "at_end" "audit" |
801 "aud_obj_name_len" "backup" "base" "before" "between" "blobfile" | 1198 "aud_obj_name_len" "backup" "base" "before" "between" "blobfile" |
802 "blobfiles" "blobpct" "brief" "browse" "by" "case" "cast" "check" | 1199 "blobfiles" "blobpct" "brief" "browse" "by" "case" "cast" "check" |
803 "clear" "close" "column" "comment" "commit" "connect" "contains" | 1200 "clear" "close" "column" "comment" "commit" "connect" "contains" |
811 "purge" "rebuild" "resource" "restrict" "revoke" "right" "role" | 1208 "purge" "rebuild" "resource" "restrict" "revoke" "right" "role" |
812 "rollback" "rownum" "select" "session" "set" "share" "shutdown" | 1209 "rollback" "rownum" "select" "session" "set" "share" "shutdown" |
813 "start" "stop" "sync" "synchronize" "synonym" "sysdate" "table" "then" | 1210 "start" "stop" "sync" "synchronize" "synonym" "sysdate" "table" "then" |
814 "to" "union" "unique" "unlock" "until" "update" "using" "values" | 1211 "to" "union" "unique" "unlock" "until" "update" "using" "values" |
815 "view" "when" "where" "with" "without" | 1212 "view" "when" "where" "with" "without" |
1213 | |
816 ) t) "\\b"))) | 1214 ) t) "\\b"))) |
817 (linter-types (eval-when-compile | 1215 (linter-types (eval-when-compile |
818 (concat "\\b" | 1216 (concat "\\b" |
819 (regexp-opt '( | 1217 (regexp-opt '( |
1218 | |
820 "bigint" "bitmap" "blob" "boolean" "char" "character" "date" | 1219 "bigint" "bitmap" "blob" "boolean" "char" "character" "date" |
821 "datetime" "dec" "decimal" "double" "float" "int" "integer" "nchar" | 1220 "datetime" "dec" "decimal" "double" "float" "int" "integer" "nchar" |
822 "number" "numeric" "real" "smallint" "varbyte" "varchar" "byte" | 1221 "number" "numeric" "real" "smallint" "varbyte" "varchar" "byte" |
823 "cursor" "long" | 1222 "cursor" "long" |
1223 | |
824 ) t) "\\b"))) | 1224 ) t) "\\b"))) |
825 (linter-builtin-functions (eval-when-compile | 1225 (linter-builtin-functions (eval-when-compile |
826 (concat "\\b" | 1226 (concat "\\b" |
827 (regexp-opt '( | 1227 (regexp-opt '( |
1228 | |
828 "abs" "acos" "asin" "atan" "atan2" "avg" "ceil" "cos" "cosh" "divtime" | 1229 "abs" "acos" "asin" "atan" "atan2" "avg" "ceil" "cos" "cosh" "divtime" |
829 "exp" "floor" "getbits" "getblob" "getbyte" "getlong" "getraw" | 1230 "exp" "floor" "getbits" "getblob" "getbyte" "getlong" "getraw" |
830 "getstr" "gettext" "getword" "hextoraw" "lenblob" "length" "log" | 1231 "getstr" "gettext" "getword" "hextoraw" "lenblob" "length" "log" |
831 "lower" "lpad" "ltrim" "max" "min" "mod" "monthname" "nvl" | 1232 "lower" "lpad" "ltrim" "max" "min" "mod" "monthname" "nvl" |
832 "octet_length" "power" "rand" "rawtohex" "repeat_string" | 1233 "octet_length" "power" "rand" "rawtohex" "repeat_string" |
833 "right_substr" "round" "rpad" "rtrim" "sign" "sin" "sinh" "soundex" | 1234 "right_substr" "round" "rpad" "rtrim" "sign" "sin" "sinh" "soundex" |
834 "sqrt" "sum" "tan" "tanh" "timeint_to_days" "to_char" "to_date" | 1235 "sqrt" "sum" "tan" "tanh" "timeint_to_days" "to_char" "to_date" |
835 "to_gmtime" "to_localtime" "to_number" "trim" "upper" "decode" | 1236 "to_gmtime" "to_localtime" "to_number" "trim" "upper" "decode" |
836 "substr" "substring" "chr" "dayname" "days" "greatest" "hex" "initcap" | 1237 "substr" "substring" "chr" "dayname" "days" "greatest" "hex" "initcap" |
837 "instr" "least" "multime" "replace" "width" | 1238 "instr" "least" "multime" "replace" "width" |
1239 | |
838 ) t) "\\b")))) | 1240 ) t) "\\b")))) |
839 (setq sql-mode-linter-font-lock-keywords | |
840 (append sql-mode-ansi-font-lock-keywords | 1241 (append sql-mode-ansi-font-lock-keywords |
841 (list (cons linter-keywords 'font-lock-function-name-face) | 1242 (list (cons linter-keywords 'font-lock-keywords-face) |
842 (cons linter-reserved-words 'font-lock-keyword-face) | 1243 (cons linter-reserved-words 'font-lock-keyword-face) |
843 ;; XEmacs doesn't have font-lock-builtin-face | 1244 ;; XEmacs doesn't have font-lock-builtin-face |
844 (if (string-match "XEmacs\\|Lucid" emacs-version) | 1245 (if (string-match "XEmacs\\|Lucid" emacs-version) |
845 (cons linter-builtin-functions 'font-lock-preprocessor-face) | 1246 (cons linter-builtin-functions 'font-lock-preprocessor-face) |
846 ;; GNU Emacs 19 doesn't have it either | 1247 ;; GNU Emacs 19 doesn't have it either |
847 (if (string-match "GNU Emacs 19" emacs-version) | 1248 (if (string-match "GNU Emacs 19" emacs-version) |
848 (cons linter-builtin-functions 'font-lock-function-name-face) | 1249 (cons linter-builtin-functions 'font-lock-keywords-face) |
849 ;; Emacs | 1250 ;; Emacs |
850 (cons linter-builtin-functions 'font-lock-builtin-face))) | 1251 (cons linter-builtin-functions 'font-lock-builtin-face))) |
851 (cons linter-types 'font-lock-type-face)))))) | 1252 (cons linter-types 'font-lock-type-face)))) |
852 | 1253 |
853 (defvar sql-mode-font-lock-keywords sql-mode-ansi-font-lock-keywords | 1254 "Linter SQL keywords used by font-lock. |
1255 | |
1256 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
1257 regular expressions are created during compilation by calling the | |
1258 function `regexp-opt'.") | |
1259 | |
1260 (defvar sql-mode-ms-font-lock-keywords | |
1261 (let ((ms-reserved-words (eval-when-compile | |
1262 (concat "\\b" | |
1263 (regexp-opt '( | |
1264 | |
1265 "absolute" "add" "all" "alter" "and" "any" "as" "asc" "authorization" | |
1266 "avg" "backup" "begin" "between" "break" "browse" "bulk" "by" | |
1267 "cascade" "case" "check" "checkpoint" "close" "clustered" "coalesce" | |
1268 "column" "commit" "committed" "compute" "confirm" "constraint" | |
1269 "contains" "containstable" "continue" "controlrow" "convert" "count" | |
1270 "create" "cross" "current" "current_date" "current_time" | |
1271 "current_timestamp" "current_user" "database" "deallocate" | |
1272 "declare" "default" "delete" "deny" "desc" "disk" "distinct" | |
1273 "distributed" "double" "drop" "dummy" "dump" "else" "end" "errlvl" | |
1274 "errorexit" "escape" "except" "exec" "execute" "exists" "exit" "fetch" | |
1275 "file" "fillfactor" "first" "floppy" "for" "foreign" "freetext" | |
1276 "freetexttable" "from" "full" "goto" "grant" "group" "having" | |
1277 "holdlock" "identity" "identity_insert" "identitycol" "if" "in" | |
1278 "index" "inner" "insert" "intersect" "into" "is" "isolation" "join" | |
1279 "key" "kill" "last" "left" "level" "like" "lineno" "load" "max" "min" | |
1280 "mirrorexit" "national" "next" "nocheck" "nolock" "nonclustered" "not" | |
1281 "null" "nullif" "of" "off" "offsets" "on" "once" "only" "open" | |
1282 "opendatasource" "openquery" "openrowset" "option" "or" "order" | |
1283 "outer" "output" "over" "paglock" "percent" "perm" "permanent" "pipe" | |
1284 "plan" "precision" "prepare" "primary" "print" "prior" "privileges" | |
1285 "proc" "procedure" "processexit" "public" "raiserror" "read" | |
1286 "readcommitted" "readpast" "readtext" "readuncommitted" "reconfigure" | |
1287 "references" "relative" "repeatable" "repeatableread" "replication" | |
1288 "restore" "restrict" "return" "revoke" "right" "rollback" "rowcount" | |
1289 "rowguidcol" "rowlock" "rule" "save" "schema" "select" "serializable" | |
1290 "session_user" "set" "shutdown" "some" "statistics" "sum" | |
1291 "system_user" "table" "tablock" "tablockx" "tape" "temp" "temporary" | |
1292 "textsize" "then" "to" "top" "tran" "transaction" "trigger" "truncate" | |
1293 "tsequal" "uncommitted" "union" "unique" "update" "updatetext" | |
1294 "updlock" "use" "user" "values" "view" "waitfor" "when" "where" | |
1295 "while" "with" "work" "writetext" | |
1296 "collate" "function" "openxml" "returns" | |
1297 | |
1298 ) t) "\\b"))) | |
1299 (ms-types (eval-when-compile | |
1300 (concat "\\b" | |
1301 (regexp-opt '( | |
1302 | |
1303 "binary" "bit" "char" "character" "cursor" "datetime" "dec" "decimal" | |
1304 "double" "float" "image" "int" "integer" "money" "national" "nchar" | |
1305 "ntext" "numeric" "numeric" "nvarchar" "precision" "real" | |
1306 "smalldatetime" "smallint" "smallmoney" "text" "timestamp" "tinyint" | |
1307 "uniqueidentifier" "varbinary" "varchar" "varying" | |
1308 | |
1309 ) t) "\\b"))) | |
1310 | |
1311 (ms-vars "\\b@[a-zA-Z0-9_]*\\b") | |
1312 | |
1313 (ms-builtin-functions (eval-when-compile | |
1314 (concat "\\b" | |
1315 (regexp-opt '( | |
1316 ;; Misc MS builtin functions | |
1317 | |
1318 "@@connections" "@@cpu_busy" "@@cursor_rows" "@@datefirst" "@@dbts" | |
1319 "@@error" "@@fetch_status" "@@identity" "@@idle" "@@io_busy" | |
1320 "@@langid" "@@language" "@@lock_timeout" "@@max_connections" | |
1321 "@@max_precision" "@@nestlevel" "@@options" "@@pack_received" | |
1322 "@@pack_sent" "@@packet_errors" "@@procid" "@@remserver" "@@rowcount" | |
1323 "@@servername" "@@servicename" "@@spid" "@@textsize" "@@timeticks" | |
1324 "@@total_errors" "@@total_read" "@@total_write" "@@trancount" | |
1325 "@@version" "abs" "acos" "and" "app_name" "ascii" "asin" "atan" "atn2" | |
1326 "avg" "case" "cast" "ceiling" "char" "charindex" "coalesce" | |
1327 "col_length" "col_name" "columnproperty" "containstable" "convert" | |
1328 "cos" "cot" "count" "current_timestamp" "current_user" "cursor_status" | |
1329 "databaseproperty" "datalength" "dateadd" "datediff" "datename" | |
1330 "datepart" "day" "db_id" "db_name" "degrees" "difference" "exp" | |
1331 "file_id" "file_name" "filegroup_id" "filegroup_name" | |
1332 "filegroupproperty" "fileproperty" "floor" "formatmessage" | |
1333 "freetexttable" "fulltextcatalogproperty" "fulltextserviceproperty" | |
1334 "getansinull" "getdate" "grouping" "host_id" "host_name" "ident_incr" | |
1335 "ident_seed" "identity" "index_col" "indexproperty" "is_member" | |
1336 "is_srvrolemember" "isdate" "isnull" "isnumeric" "left" "len" "log" | |
1337 "log10" "lower" "ltrim" "max" "min" "month" "nchar" "newid" "nullif" | |
1338 "object_id" "object_name" "objectproperty" "openquery" "openrowset" | |
1339 "parsename" "patindex" "patindex" "permissions" "pi" "power" | |
1340 "quotename" "radians" "rand" "replace" "replicate" "reverse" "right" | |
1341 "round" "rtrim" "session_user" "sign" "sin" "soundex" "space" "sqrt" | |
1342 "square" "stats_date" "stdev" "stdevp" "str" "stuff" "substring" "sum" | |
1343 "suser_id" "suser_name" "suser_sid" "suser_sname" "system_user" "tan" | |
1344 "textptr" "textvalid" "typeproperty" "unicode" "upper" "user" | |
1345 "user_id" "user_name" "var" "varp" "year" | |
1346 | |
1347 ) t) "\\b"))) | |
1348 | |
1349 (ms-config-commands | |
1350 (eval-when-compile | |
1351 (concat "^\\(\\(set\\s-+\\(" | |
1352 (regexp-opt '( | |
1353 | |
1354 "datefirst" "dateformat" "deadlock_priority" "lock_timeout" | |
1355 "concat_null_yields_null" "cursor_close_on_commit" | |
1356 "disable_def_cnst_chk" "fips_flagger" "identity_insert" "language" | |
1357 "offsets" "quoted_identifier" "arithabort" "arithignore" "fmtonly" | |
1358 "nocount" "noexec" "numeric_roundabort" "parseonly" | |
1359 "query_governor_cost_limit" "rowcount" "textsize" "ansi_defaults" | |
1360 "ansi_null_dflt_off" "ansi_null_dflt_on" "ansi_nulls" "ansi_padding" | |
1361 "ansi_warnings" "forceplan" "showplan_all" "showplan_text" | |
1362 "statistics" "implicit_transactions" "remote_proc_transactions" | |
1363 "transaction" "xact_abort" | |
1364 | |
1365 ) t) | |
1366 "\\)\\)\\|go\\s-*\\|use\\s-+\\|setuser\\s-+\\|dbcc\\s-+\\).*$")))) | |
1367 | |
1368 (list (cons ms-config-commands 'font-lock-doc-face) | |
1369 (cons ms-reserved-words 'font-lock-keyword-face) | |
1370 ;; XEmacs doesn't have 'font-lock-builtin-face | |
1371 (if (string-match "XEmacs\\|Lucid" emacs-version) | |
1372 (cons ms-builtin-functions 'font-lock-preprocessor-face) | |
1373 ;; Emacs | |
1374 (cons ms-builtin-functions 'font-lock-builtin-face)) | |
1375 (cons ms-vars 'font-lock-variable-name-face) | |
1376 (cons ms-types 'font-lock-type-face))) | |
1377 | |
1378 "Microsoft SQLServer SQL keywords used by font-lock. | |
1379 | |
1380 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
1381 regular expressions are created during compilation by calling the | |
1382 function `regexp-opt'. Therefore, take a look at the source before | |
1383 you define your own sql-mode-ms-font-lock-keywords.") | |
1384 | |
1385 (defvar sql-mode-sybase-font-lock-keywords sql-mode-ansi-font-lock-keywords | |
1386 "Sybase SQL keywords used by font-lock. | |
1387 | |
1388 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
1389 regular expressions are created during compilation by calling the | |
1390 function `regexp-opt'. Therefore, take a look at the source before | |
1391 you define your own sql-mode-sybase-font-lock-keywords.") | |
1392 | |
1393 (defvar sql-mode-informix-font-lock-keywords sql-mode-ansi-font-lock-keywords | |
1394 "Informix SQL keywords used by font-lock. | |
1395 | |
1396 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
1397 regular expressions are created during compilation by calling the | |
1398 function `regexp-opt'. Therefore, take a look at the source before | |
1399 you define your own sql-mode-informix-font-lock-keywords.") | |
1400 | |
1401 (defvar sql-mode-interbase-font-lock-keywords sql-mode-ansi-font-lock-keywords | |
1402 "Interbase SQL keywords used by font-lock. | |
1403 | |
1404 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
1405 regular expressions are created during compilation by calling the | |
1406 function `regexp-opt'. Therefore, take a look at the source before | |
1407 you define your own sql-mode-interbase-font-lock-keywords.") | |
1408 | |
1409 (defvar sql-mode-ingres-font-lock-keywords sql-mode-ansi-font-lock-keywords | |
1410 "Ingres SQL keywords used by font-lock. | |
1411 | |
1412 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
1413 regular expressions are created during compilation by calling the | |
1414 function `regexp-opt'. Therefore, take a look at the source before | |
1415 you define your own sql-mode-interbase-font-lock-keywords.") | |
1416 | |
1417 (defvar sql-mode-solid-font-lock-keywords sql-mode-ansi-font-lock-keywords | |
1418 "Solid SQL keywords used by font-lock. | |
1419 | |
1420 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
1421 regular expressions are created during compilation by calling the | |
1422 function `regexp-opt'. Therefore, take a look at the source before | |
1423 you define your own sql-mode-solid-font-lock-keywords.") | |
1424 | |
1425 (defvar sql-mode-mysql-font-lock-keywords sql-mode-ansi-font-lock-keywords | |
1426 "MySQL SQL keywords used by font-lock. | |
1427 | |
1428 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
1429 regular expressions are created during compilation by calling the | |
1430 function `regexp-opt'. Therefore, take a look at the source before | |
1431 you define your own sql-mode-mysql-font-lock-keywords.") | |
1432 | |
1433 (defvar sql-mode-sqlite-font-lock-keywords sql-mode-ansi-font-lock-keywords | |
1434 "SQLite SQL keywords used by font-lock. | |
1435 | |
1436 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
1437 regular expressions are created during compilation by calling the | |
1438 function `regexp-opt'. Therefore, take a look at the source before | |
1439 you define your own sql-mode-sqlite-font-lock-keywords.") | |
1440 | |
1441 (defvar sql-mode-db2-font-lock-keywords sql-mode-ansi-font-lock-keywords | |
1442 "DB2 SQL keywords used by font-lock. | |
1443 | |
1444 This variable is used by `sql-mode' and `sql-interactive-mode'. The | |
1445 regular expressions are created during compilation by calling the | |
1446 function `regexp-opt'. Therefore, take a look at the source before | |
1447 you define your own sql-mode-db2-font-lock-keywords.") | |
1448 | |
1449 (defvar sql-mode-font-lock-keywords nil | |
854 "SQL keywords used by font-lock. | 1450 "SQL keywords used by font-lock. |
855 | 1451 |
856 This variable defaults to `sql-mode-ansi-font-lock-keywords'. This is | 1452 Setting this variable directly no longer has any affect. Use |
857 used for the default `font-lock-defaults' value in `sql-mode'. This | 1453 `sql-product' and `sql-add-product-keywords' to control the |
858 can be changed by some entry functions to provide more hilighting.") | 1454 highlighting rules in sql-mode.") |
859 | 1455 |
860 | 1456 |
861 | 1457 |
1458 ;;; SQL Product support functions | |
1459 | |
1460 (defun sql-product-feature (feature &optional product) | |
1461 "Lookup `feature' needed to support the current SQL product. | |
1462 | |
1463 See \[sql-product-support] for a list of products and supported features." | |
1464 (cadr | |
1465 (memq feature | |
1466 (assoc (or product sql-product) | |
1467 sql-product-support)))) | |
1468 | |
1469 (defun sql-product-font-lock (keywords-only imenu) | |
1470 "Sets `font-lock-defaults' and `font-lock-keywords' based on | |
1471 the product-specific keywords and syntax-alists defined in | |
1472 `sql-product-support'." | |
1473 (let | |
1474 ;; Get the product-specific syntax-alist. | |
1475 ((syntax-alist | |
1476 (append | |
1477 (sql-product-feature :syntax-alist) | |
1478 '((?_ . "w") (?. . "w"))))) | |
1479 | |
1480 ;; Get the product-specific keywords. | |
1481 (setq sql-mode-font-lock-keywords | |
1482 (append | |
1483 (eval (sql-product-feature :font-lock)) | |
1484 (list sql-mode-font-lock-object-name))) | |
1485 | |
1486 ;; Setup font-lock. (What is the minimum we should have to do | |
1487 ;; here?) | |
1488 (setq font-lock-set-defaults nil | |
1489 font-lock-keywords sql-mode-font-lock-keywords | |
1490 font-lock-defaults (list 'sql-mode-font-lock-keywords | |
1491 keywords-only t syntax-alist)) | |
1492 | |
1493 ;; Setup imenu; it needs the same syntax-alist. | |
1494 (when imenu | |
1495 (setq imenu-syntax-alist syntax-alist)))) | |
1496 | |
1497 ;;;###autoload | |
1498 (defun sql-add-product-keywords (product keywords) | |
1499 "Append a `font-lock-keywords' entry to the existing entries defined | |
1500 for the specified `product'." | |
1501 | |
1502 (let ((font-lock (sql-product-feature :font-lock product))) | |
1503 (set font-lock (append (eval font-lock) (list keywords))))) | |
1504 | |
1505 | |
1506 | |
862 ;;; Functions to switch highlighting | 1507 ;;; Functions to switch highlighting |
863 | 1508 |
1509 (defun sql-highlight-product () | |
1510 "Turns on the appropriate font highlighting for the SQL product | |
1511 selected." | |
1512 | |
1513 (when (eq major-mode 'sql-mode) | |
1514 ;; Setup font-lock | |
1515 (sql-product-font-lock nil t) | |
1516 | |
1517 ;; Force fontification, if its enabled. | |
1518 (if font-lock-mode | |
1519 (font-lock-fontify-buffer)) | |
1520 | |
1521 ;; Set the mode name to include the product. | |
1522 (setq mode-name (concat "SQL[" (prin1-to-string sql-product) "]")))) | |
1523 | |
1524 (defun sql-set-product (product) | |
1525 "Set `sql-product' to product and enable appropriate | |
1526 highlighting." | |
1527 (interactive "SEnter SQL product: ") | |
1528 (when (not (assoc product sql-product-support)) | |
1529 (error "SQL product %s is not supported; treated as ANSI" product) | |
1530 (setq product 'ansi)) | |
1531 | |
1532 ;; Save product setting and fontify. | |
1533 (setq sql-product product) | |
1534 (sql-highlight-product)) | |
1535 | |
864 (defun sql-highlight-oracle-keywords () | 1536 (defun sql-highlight-oracle-keywords () |
865 "Highlight Oracle keywords. | 1537 "Highlight Oracle keywords." |
866 Basically, this just sets `font-lock-keywords' appropriately." | 1538 (interactive) |
867 (interactive) | 1539 (sql-set-product 'oracle)) |
868 (setq font-lock-keywords sql-mode-oracle-font-lock-keywords) | |
869 (font-lock-fontify-buffer)) | |
870 | 1540 |
871 (defun sql-highlight-postgres-keywords () | 1541 (defun sql-highlight-postgres-keywords () |
872 "Highlight Postgres keywords. | 1542 "Highlight Postgres keywords." |
873 Basically, this just sets `font-lock-keywords' appropriately." | 1543 (interactive) |
874 (interactive) | 1544 (sql-set-product 'postgres)) |
875 (setq font-lock-keywords sql-mode-postgres-font-lock-keywords) | |
876 (font-lock-fontify-buffer)) | |
877 | 1545 |
878 (defun sql-highlight-linter-keywords () | 1546 (defun sql-highlight-linter-keywords () |
879 "Highlight LINTER keywords. | 1547 "Highlight LINTER keywords." |
880 Basically, this just sets `font-lock-keywords' appropriately." | 1548 (interactive) |
881 (interactive) | 1549 (sql-set-product 'linter)) |
882 (setq font-lock-keywords sql-mode-linter-font-lock-keywords) | 1550 |
883 (font-lock-fontify-buffer)) | 1551 (defun sql-highlight-ms-keywords () |
1552 "Highlight Microsoft SQLServer keywords." | |
1553 (interactive) | |
1554 (sql-set-product 'ms)) | |
884 | 1555 |
885 (defun sql-highlight-ansi-keywords () | 1556 (defun sql-highlight-ansi-keywords () |
886 "Highlight ANSI SQL keywords. | 1557 "Highlight ANSI SQL keywords." |
887 Basically, this just sets `font-lock-keywords' appropriately." | 1558 (interactive) |
888 (interactive) | 1559 (sql-set-product 'ansi)) |
889 (setq font-lock-keywords sql-mode-ansi-font-lock-keywords) | 1560 |
890 (font-lock-fontify-buffer)) | 1561 (defun sql-highlight-sybase-keywords () |
1562 "Highlight Sybase SQL keywords." | |
1563 (interactive) | |
1564 (sql-set-product 'sybase)) | |
1565 | |
1566 (defun sql-highlight-informix-keywords () | |
1567 "Highlight Informix SQL keywords." | |
1568 (interactive) | |
1569 (sql-set-product 'informix)) | |
1570 | |
1571 (defun sql-highlight-interbase-keywords () | |
1572 "Highlight Interbase SQL keywords." | |
1573 (interactive) | |
1574 (sql-set-product 'interbase)) | |
1575 | |
1576 (defun sql-highlight-ingres-keywords () | |
1577 "Highlight Ingres SQL keywords." | |
1578 (interactive) | |
1579 (sql-set-product 'ingres)) | |
1580 | |
1581 (defun sql-highlight-solid-keywords () | |
1582 "Highlight Solid SQL keywords." | |
1583 (interactive) | |
1584 (sql-set-product 'solid)) | |
1585 | |
1586 (defun sql-highlight-mysql-keywords () | |
1587 "Highlight MySQL SQL keywords." | |
1588 (interactive) | |
1589 (sql-set-product 'mysql)) | |
1590 | |
1591 (defun sql-highlight-sqlite-keywords () | |
1592 "Highlight SQLite SQL keywords." | |
1593 (interactive) | |
1594 (sql-set-product 'sqlite)) | |
1595 | |
1596 (defun sql-highlight-db2-keywords () | |
1597 "Highlight DB2 SQL keywords." | |
1598 (interactive) | |
1599 (sql-set-product 'db2)) | |
891 | 1600 |
892 | 1601 |
893 | 1602 |
894 ;;; Compatibility functions | 1603 ;;; Compatibility functions |
895 | 1604 |
951 Oracle: \\[sql-oracle] | 1660 Oracle: \\[sql-oracle] |
952 Informix: \\[sql-informix] | 1661 Informix: \\[sql-informix] |
953 Sybase: \\[sql-sybase] | 1662 Sybase: \\[sql-sybase] |
954 Ingres: \\[sql-ingres] | 1663 Ingres: \\[sql-ingres] |
955 Microsoft: \\[sql-ms] | 1664 Microsoft: \\[sql-ms] |
1665 DB2: \\[sql-db2] | |
956 Interbase: \\[sql-interbase] | 1666 Interbase: \\[sql-interbase] |
957 Linter: \\[sql-linter] | 1667 Linter: \\[sql-linter] |
958 | 1668 |
959 But we urge you to choose a free implementation instead of these. | 1669 But we urge you to choose a free implementation instead of these. |
960 | 1670 |
997 | 1707 |
998 Parameter WHAT is a list of the arguments passed to this function. | 1708 Parameter WHAT is a list of the arguments passed to this function. |
999 The function asks for the username if WHAT contains symbol `user', for | 1709 The function asks for the username if WHAT contains symbol `user', for |
1000 the password if it contains symbol `password', for the server if it | 1710 the password if it contains symbol `password', for the server if it |
1001 contains symbol `server', and for the database if it contains symbol | 1711 contains symbol `server', and for the database if it contains symbol |
1002 `database'. | 1712 `database'. The members of WHAT are processed in the order in which |
1713 they are provided. | |
1003 | 1714 |
1004 In order to ask the user for username, password and database, call the | 1715 In order to ask the user for username, password and database, call the |
1005 function like this: (sql-get-login 'user 'password 'database)." | 1716 function like this: (sql-get-login 'user 'password 'database)." |
1006 (interactive) | 1717 (interactive) |
1007 (if (memq 'user what) | 1718 (while what |
1719 (cond | |
1720 ((eq (car what) 'user) ; user | |
1008 (setq sql-user | 1721 (setq sql-user |
1009 (read-from-minibuffer "User: " sql-user nil nil | 1722 (read-from-minibuffer "User: " sql-user nil nil |
1010 sql-user-history))) | 1723 sql-user-history))) |
1011 (if (memq 'password what) | 1724 ((eq (car what) 'password) ; password |
1012 (setq sql-password | 1725 (setq sql-password |
1013 (sql-read-passwd "Password: " sql-password))) | 1726 (sql-read-passwd "Password: " sql-password))) |
1014 (if (memq 'server what) | 1727 ((eq (car what) 'server) ; server |
1015 (setq sql-server | 1728 (setq sql-server |
1016 (read-from-minibuffer "Server: " sql-server nil nil | 1729 (read-from-minibuffer "Server: " sql-server nil nil |
1017 sql-server-history))) | 1730 sql-server-history))) |
1018 (if (memq 'database what) | 1731 ((eq (car what) 'database) ; database |
1019 (setq sql-database | 1732 (setq sql-database |
1020 (read-from-minibuffer "Database: " sql-database nil nil | 1733 (read-from-minibuffer "Database: " sql-database nil nil |
1021 sql-database-history)))) | 1734 sql-database-history)))) |
1735 (setq what (cdr what)))) | |
1022 | 1736 |
1023 (defun sql-find-sqli-buffer () | 1737 (defun sql-find-sqli-buffer () |
1024 "Return the current default SQLi buffer or nil. | 1738 "Return the current default SQLi buffer or nil. |
1025 In order to qualify, the SQLi buffer must be alive, | 1739 In order to qualify, the SQLi buffer must be alive, |
1026 be in `sql-interactive-mode' and have a process." | 1740 be in `sql-interactive-mode' and have a process." |