sql.el 192 KB
Newer Older
Richard M. Stallman's avatar
Richard M. Stallman committed
1 2
;;; sql.el --- specialized comint.el for SQL interpreters

3
;; Copyright (C) 1998-2011  Free Software Foundation, Inc.
Richard M. Stallman's avatar
Richard M. Stallman committed
4

5
;; Author: Alex Schroeder <alex@gnu.org>
Richard M. Stallman's avatar
Richard M. Stallman committed
6
;; Maintainer: Michael Mauger <mmaug@yahoo.com>
7
;; Version: 3.0
8
;; Keywords: comm languages processes
9
;; URL: http://savannah.gnu.org/projects/emacs/
Richard M. Stallman's avatar
Richard M. Stallman committed
10 11 12

;; This file is part of GNU Emacs.

13
;; GNU Emacs is free software: you can redistribute it and/or modify
Richard M. Stallman's avatar
Richard M. Stallman committed
14
;; it under the terms of the GNU General Public License as published by
15 16
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
Richard M. Stallman's avatar
Richard M. Stallman committed
17 18 19 20 21 22 23

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
24
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
Richard M. Stallman's avatar
Richard M. Stallman committed
25 26 27

;;; Commentary:

28
;; Please send bug reports and bug fixes to the mailing list at
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
;; help-gnu-emacs@gnu.org.  If you want to subscribe to the mailing
;; list, see the web page at
;; http://lists.gnu.org/mailman/listinfo/help-gnu-emacs for
;; instructions.  I monitor this list actively.  If you send an e-mail
;; to Alex Schroeder it usually makes it to me when Alex has a chance
;; to forward them along (Thanks, Alex).

;; This file provides a sql-mode and a sql-interactive-mode.  The
;; original goals were two simple modes providing syntactic
;; highlighting.  The interactive mode had to provide a command-line
;; history; the other mode had to provide "send region/buffer to SQL
;; interpreter" functions.  "simple" in this context means easy to
;; use, easy to maintain and little or no bells and whistles.  This
;; has changed somewhat as experience with the mode has accumulated.

;; Support for different flavors of SQL and command interpreters was
;; available in early versions of sql.el.  This support has been
;; extended and formalized in later versions.  Part of the impetus for
;; the improved support of SQL flavors was borne out of the current
48
;; maintainers consulting experience.  In the past twenty years, I
49 50
;; have used Oracle, Sybase, Informix, MySQL, Postgres, and SQLServer.
;; On some assignments, I have used two or more of these concurrently.
Richard M. Stallman's avatar
Richard M. Stallman committed
51 52 53 54

;; If anybody feels like extending this sql mode, take a look at the
;; above mentioned modes and write a sqlx-mode on top of this one.  If
;; this proves to be difficult, please suggest changes that will
55 56
;; facilitate your plans.  Facilities have been provided to add
;; products and product-specific configuration.
Richard M. Stallman's avatar
Richard M. Stallman committed
57 58

;; sql-interactive-mode is used to interact with a SQL interpreter
59
;; process in a SQLi buffer (usually called `*SQL*').  The SQLi buffer
60 61 62
;; is created by calling a SQL interpreter-specific entry function or
;; sql-product-interactive.  Do *not* call sql-interactive-mode by
;; itself.
Richard M. Stallman's avatar
Richard M. Stallman committed
63 64

;; The list of currently supported interpreters and the corresponding
65
;; entry function used to create the SQLi buffers is shown with
Richard M. Stallman's avatar
Richard M. Stallman committed
66 67 68 69 70 71 72 73
;; `sql-help' (M-x sql-help).

;; Since sql-interactive-mode is built on top of the general
;; command-interpreter-in-a-buffer mode (comint mode), it shares a
;; common base functionality, and a common set of bindings, with all
;; modes derived from comint mode.  This makes these modes easier to
;; use.

74 75
;; sql-mode can be used to keep editing SQL statements.  The SQL
;; statements can be sent to the SQL process in the SQLi buffer.
Richard M. Stallman's avatar
Richard M. Stallman committed
76 77

;; For documentation on the functionality provided by comint mode, and
78
;; the hooks available for customizing it, see the file `comint.el'.
Richard M. Stallman's avatar
Richard M. Stallman committed
79

80 81
;; Hint for newbies: take a look at `dabbrev-expand', `abbrev-mode', and
;; `imenu-add-menubar-index'.
Richard M. Stallman's avatar
Richard M. Stallman committed
82 83 84 85 86 87 88 89 90 91 92

;;; Requirements for Emacs 19.34:

;; If you are using Emacs 19.34, you will have to get and install
;; the file regexp-opt.el
;; <URL:ftp://ftp.ifi.uio.no/pub/emacs/emacs-20.3/lisp/emacs-lisp/regexp-opt.el>
;; and the custom package
;; <URL:http://www.dina.kvl.dk/~abraham/custom/>.

;;; Bugs:

93 94 95 96 97 98
;; sql-ms now uses osql instead of isql.  Osql flushes its error
;; stream more frequently than isql so that error messages are
;; available.  There is no prompt and some output still is buffered.
;; This improves the interaction under Emacs but it still is somewhat
;; awkward.

Paul Eggert's avatar
Paul Eggert committed
99
;; Quoted identifiers are not supported for highlighting.  Most
100 101 102
;; databases support the use of double quoted strings in place of
;; identifiers; ms (Microsoft SQLServer) also supports identifiers
;; enclosed within brackets [].
Richard M. Stallman's avatar
Richard M. Stallman committed
103

104 105 106 107 108 109
;;; Product Support:

;; To add support for additional SQL products the following steps
;; must be followed ("xyz" is the name of the product in the examples
;; below):

Michael Mauger's avatar
Michael Mauger committed
110
;; 1) Add the product to the list of known products.
111

Michael Mauger's avatar
Michael Mauger committed
112 113
;;     (sql-add-product 'xyz "XyzDB"
;;     	                '(:free-software t))
114

Michael Mauger's avatar
Michael Mauger committed
115 116 117
;; 2) Define font lock settings.  All ANSI keywords will be
;;    highlighted automatically, so only product specific keywords
;;    need to be defined here.
118

Michael Mauger's avatar
Michael Mauger committed
119 120 121 122
;;     (defvar my-sql-mode-xyz-font-lock-keywords
;;       '(("\\b\\(red\\|orange\\|yellow\\)\\b"
;;          . font-lock-keyword-face))
;;       "XyzDB SQL keywords used by font-lock.")
123

Michael Mauger's avatar
Michael Mauger committed
124 125 126
;;     (sql-set-product-feature 'xyz
;;                              :font-lock
;;                              'my-sql-mode-xyz-font-lock-keywords)
127

Michael Mauger's avatar
Michael Mauger committed
128 129 130 131
;; 3) Define any special syntax characters including comments and
;;    identifier characters.

;;     (sql-set-product-feature 'xyz
132
;;                              :syntax-alist ((?# . "_")))
Michael Mauger's avatar
Michael Mauger committed
133 134 135 136 137 138

;; 4) Define the interactive command interpreter for the database
;;    product.

;;     (defcustom my-sql-xyz-program "ixyz"
;;       "Command to start ixyz by XyzDB."
139 140 141
;;       :type 'file
;;       :group 'SQL)
;;
Michael Mauger's avatar
Michael Mauger committed
142 143 144 145 146 147 148 149 150 151 152
;;     (sql-set-product-feature 'xyz
;;                              :sqli-program 'my-sql-xyz-program)
;;     (sql-set-product-feature 'xyz
;;                              :prompt-regexp "^xyzdb> ")
;;     (sql-set-product-feature 'xyz
;;                              :prompt-length 7)

;; 5) Define login parameters and command line formatting.

;;     (defcustom my-sql-xyz-login-params '(user password server database)
;;       "Login parameters to needed to connect to XyzDB."
153
;;       :type 'sql-login-params
154
;;       :group 'SQL)
Michael Mauger's avatar
Michael Mauger committed
155 156 157
;;
;;     (sql-set-product-feature 'xyz
;;                              :sqli-login 'my-sql-xyz-login-params)
158

Michael Mauger's avatar
Michael Mauger committed
159 160 161 162 163 164 165
;;     (defcustom my-sql-xyz-options '("-X" "-Y" "-Z")
;;       "List of additional options for `sql-xyz-program'."
;;       :type '(repeat string)
;;       :group 'SQL)
;;
;;     (sql-set-product-feature 'xyz
;;                              :sqli-options 'my-sql-xyz-options))
166

167
;;     (defun my-sql-comint-xyz (product options)
Michael Mauger's avatar
Michael Mauger committed
168
;;       "Connect ti XyzDB in a comint buffer."
169 170 171
;;
;;         ;; Do something with `sql-user', `sql-password',
;;         ;; `sql-database', and `sql-server'.
Michael Mauger's avatar
Michael Mauger committed
172
;;         (let ((params options))
173 174 175 176 177 178 179 180
;;           (if (not (string= "" sql-server))
;;              (setq params (append (list "-S" sql-server) params)))
;;           (if (not (string= "" sql-database))
;;               (setq params (append (list "-D" sql-database) params)))
;;           (if (not (string= "" sql-password))
;;               (setq params (append (list "-P" sql-password) params)))
;;           (if (not (string= "" sql-user))
;;               (setq params (append (list "-U" sql-user) params)))
181
;;           (sql-comint product params)))
Michael Mauger's avatar
Michael Mauger committed
182 183
;;
;;     (sql-set-product-feature 'xyz
184
;;                              :sqli-comint-func 'my-sql-comint-xyz)
185

186
;; 6) Define a convenience function to invoke the SQL interpreter.
Michael Mauger's avatar
Michael Mauger committed
187

Michael Mauger's avatar
Michael Mauger committed
188
;;     (defun my-sql-xyz (&optional buffer)
Michael Mauger's avatar
Michael Mauger committed
189
;;       "Run ixyz by XyzDB as an inferior process."
Michael Mauger's avatar
Michael Mauger committed
190 191
;;       (interactive "P")
;;       (sql-product-interactive 'xyz buffer))
192

Juanma Barranquero's avatar
Juanma Barranquero committed
193 194
;;; To Do:

Michael Mauger's avatar
Michael Mauger committed
195 196 197
;; Improve keyword highlighting for individual products.  I have tried
;; to update those database that I use.  Feel free to send me updates,
;; or direct me to the reference manuals for your favorite database.
Juanma Barranquero's avatar
Juanma Barranquero committed
198

Michael Mauger's avatar
Michael Mauger committed
199 200 201 202 203 204 205 206
;; When there are no keywords defined, the ANSI keywords are
;; highlighted.  ANSI keywords are highlighted even if the keyword is
;; not used for your current product.  This should help identify
;; portability concerns.

;; Add different highlighting levels.

;; Add support for listing available tables or the columns in a table.
Richard M. Stallman's avatar
Richard M. Stallman committed
207 208 209

;;; Thanks to all the people who helped me out:

Michael Mauger's avatar
Michael Mauger committed
210
;; Alex Schroeder <alex@gnu.org> -- the original author
Richard M. Stallman's avatar
Richard M. Stallman committed
211 212 213 214
;; Kai Blauberg <kai.blauberg@metla.fi>
;; <ibalaban@dalet.com>
;; Yair Friedman <yfriedma@JohnBryce.Co.Il>
;; Gregor Zych <zych@pool.informatik.rwth-aachen.de>
215
;; nino <nino@inform.dk>
216
;; Berend de Boer <berend@pobox.com>
217
;; Adam Jenkins <adam@thejenkins.org>
218 219 220
;; Michael Mauger <mmaug@yahoo.com> -- improved product support
;; Drew Adams <drew.adams@oracle.com> -- Emacs 20 support
;; Harald Maier <maierh@myself.com> -- sql-send-string
Michael Mauger's avatar
Michael Mauger committed
221
;; Stefan Monnier <monnier@iro.umontreal.ca> -- font-lock corrections; code polish
222

Richard M. Stallman's avatar
Richard M. Stallman committed
223 224 225 226 227 228


;;; Code:

(require 'comint)
;; Need the following to allow GNU Emacs 19 to compile the file.
229 230
(eval-when-compile
  (require 'regexp-opt))
Richard M. Stallman's avatar
Richard M. Stallman committed
231
(require 'custom)
232
(require 'thingatpt)
233
(eval-when-compile ;; needed in Emacs 19, 20
234
  (setq max-specpdl-size (max max-specpdl-size 2000)))
Richard M. Stallman's avatar
Richard M. Stallman committed
235

236 237 238 239 240 241 242 243
(defun sql-signum (n)
  "Return 1, 0, or -1 to identify the sign of N."
  (cond
   ((not (numberp n)) nil)
   ((< n 0) -1)
   ((> n 0) 1)
   (t 0)))

244 245 246 247
(defvar font-lock-keyword-face)
(defvar font-lock-set-defaults)
(defvar font-lock-string-face)

Richard M. Stallman's avatar
Richard M. Stallman committed
248 249 250
;;; Allow customization

(defgroup SQL nil
251
  "Running a SQL interpreter from within Emacs buffers."
Dave Love's avatar
Dave Love committed
252
  :version "20.4"
Michael Mauger's avatar
Michael Mauger committed
253
  :group 'languages
Richard M. Stallman's avatar
Richard M. Stallman committed
254 255
  :group 'processes)

256
;; These four variables will be used as defaults, if set.
Richard M. Stallman's avatar
Richard M. Stallman committed
257 258

(defcustom sql-user ""
Michael Mauger's avatar
Michael Mauger committed
259
  "Default username."
Richard M. Stallman's avatar
Richard M. Stallman committed
260
  :type 'string
261 262
  :group 'SQL
  :safe 'stringp)
Richard M. Stallman's avatar
Richard M. Stallman committed
263 264

(defcustom sql-password ""
Michael Mauger's avatar
Michael Mauger committed
265
  "Default password.
Richard M. Stallman's avatar
Richard M. Stallman committed
266 267 268 269

Storing your password in a textfile such as ~/.emacs could be dangerous.
Customizing your password will store it in your ~/.emacs file."
  :type 'string
270 271
  :group 'SQL
  :risky t)
Richard M. Stallman's avatar
Richard M. Stallman committed
272 273

(defcustom sql-database ""
Michael Mauger's avatar
Michael Mauger committed
274
  "Default database."
Richard M. Stallman's avatar
Richard M. Stallman committed
275
  :type 'string
276 277
  :group 'SQL
  :safe 'stringp)
Richard M. Stallman's avatar
Richard M. Stallman committed
278 279

(defcustom sql-server ""
Michael Mauger's avatar
Michael Mauger committed
280
  "Default server or host."
Richard M. Stallman's avatar
Richard M. Stallman committed
281
  :type 'string
282 283
  :group 'SQL
  :safe 'stringp)
Michael Mauger's avatar
Michael Mauger committed
284

Michael Mauger's avatar
Michael Mauger committed
285 286
(defcustom sql-port 0
  "Default port."
287
  :version "24.1"
Michael Mauger's avatar
Michael Mauger committed
288
  :type 'number
289 290
  :group 'SQL
  :safe 'numberp)
Richard M. Stallman's avatar
Richard M. Stallman committed
291

292 293 294 295
;; Login parameter type

(define-widget 'sql-login-params 'lazy
  "Widget definition of the login parameters list"
296 297 298
  ;; FIXME: does not implement :default property for the user,
  ;; database and server options.  Anybody have some guidance on how to
  ;; do this.
299 300 301 302 303 304 305 306 307 308 309 310 311 312
  :tag "Login Parameters"
  :type '(repeat (choice
                  (const user)
                  (const password)
                  (choice :tag "server"
                          (const server)
                          (list :tag "file"
                                (const :format "" server)
                                (const :format "" :file)
                                regexp)
                          (list :tag "completion"
                                (const :format "" server)
                                (const :format "" :completion)
                                (restricted-sexp
313
                                 :match-alternatives (listp stringp))))
314 315 316 317 318 319 320 321 322 323
                  (choice :tag "database"
                          (const database)
                          (list :tag "file"
                                (const :format "" database)
                                (const :format "" :file)
                                regexp)
                          (list :tag "completion"
                                (const :format "" database)
                                (const :format "" :completion)
                                (restricted-sexp
324
                                 :match-alternatives (listp stringp))))
325 326
                  (const port))))

327 328 329 330 331
;; SQL Product support

(defvar sql-interactive-product nil
  "Product under `sql-interactive-mode'.")

332 333 334
(defvar sql-connection nil
  "Connection name if interactive session started by `sql-connect'.")

335
(defvar sql-product-alist
336
  '((ansi
337
     :name "ANSI"
338 339
     :font-lock sql-mode-ansi-font-lock-keywords
     :statement sql-ansi-statement-starters)
Michael Mauger's avatar
Michael Mauger committed
340

341
    (db2
342
     :name "DB2"
343
     :font-lock sql-mode-db2-font-lock-keywords
Michael Mauger's avatar
Michael Mauger committed
344 345 346
     :sqli-program sql-db2-program
     :sqli-options sql-db2-options
     :sqli-login sql-db2-login-params
347
     :sqli-comint-func sql-comint-db2
Michael Mauger's avatar
Michael Mauger committed
348 349
     :prompt-regexp "^db2 => "
     :prompt-length 7
350
     :prompt-cont-regexp "^db2 (cont\.) => "
Michael Mauger's avatar
Michael Mauger committed
351 352
     :input-filter sql-escape-newlines-filter)

353
    (informix
Michael Mauger's avatar
Michael Mauger committed
354
     :name "Informix"
355
     :font-lock sql-mode-informix-font-lock-keywords
Michael Mauger's avatar
Michael Mauger committed
356 357 358
     :sqli-program sql-informix-program
     :sqli-options sql-informix-options
     :sqli-login sql-informix-login-params
359
     :sqli-comint-func sql-comint-informix
Michael Mauger's avatar
Michael Mauger committed
360 361 362 363
     :prompt-regexp "^> "
     :prompt-length 2
     :syntax-alist ((?{ . "<") (?} . ">")))

364
    (ingres
Michael Mauger's avatar
Michael Mauger committed
365
     :name "Ingres"
366
     :font-lock sql-mode-ingres-font-lock-keywords
Michael Mauger's avatar
Michael Mauger committed
367 368 369
     :sqli-program sql-ingres-program
     :sqli-options sql-ingres-options
     :sqli-login sql-ingres-login-params
370
     :sqli-comint-func sql-comint-ingres
Michael Mauger's avatar
Michael Mauger committed
371
     :prompt-regexp "^\* "
372 373
     :prompt-length 2
     :prompt-cont-regexp "^\* ")
Michael Mauger's avatar
Michael Mauger committed
374

375
    (interbase
Michael Mauger's avatar
Michael Mauger committed
376
     :name "Interbase"
377
     :font-lock sql-mode-interbase-font-lock-keywords
Michael Mauger's avatar
Michael Mauger committed
378 379 380
     :sqli-program sql-interbase-program
     :sqli-options sql-interbase-options
     :sqli-login sql-interbase-login-params
381
     :sqli-comint-func sql-comint-interbase
Michael Mauger's avatar
Michael Mauger committed
382 383 384
     :prompt-regexp "^SQL> "
     :prompt-length 5)

385
    (linter
Michael Mauger's avatar
Michael Mauger committed
386
     :name "Linter"
387
     :font-lock sql-mode-linter-font-lock-keywords
Michael Mauger's avatar
Michael Mauger committed
388 389 390
     :sqli-program sql-linter-program
     :sqli-options sql-linter-options
     :sqli-login sql-linter-login-params
391
     :sqli-comint-func sql-comint-linter
Michael Mauger's avatar
Michael Mauger committed
392 393 394
     :prompt-regexp "^SQL>"
     :prompt-length 4)

395
    (ms
Michael Mauger's avatar
Michael Mauger committed
396
     :name "Microsoft"
397
     :font-lock sql-mode-ms-font-lock-keywords
Michael Mauger's avatar
Michael Mauger committed
398 399 400
     :sqli-program sql-ms-program
     :sqli-options sql-ms-options
     :sqli-login sql-ms-login-params
401
     :sqli-comint-func sql-comint-ms
Michael Mauger's avatar
Michael Mauger committed
402 403
     :prompt-regexp "^[0-9]*>"
     :prompt-length 5
404
     :syntax-alist ((?@ . "_"))
Michael Mauger's avatar
Michael Mauger committed
405 406
     :terminator ("^go" . "go"))

407
    (mysql
408
     :name "MySQL"
Michael Mauger's avatar
Michael Mauger committed
409
     :free-software t
410
     :font-lock sql-mode-mysql-font-lock-keywords
Michael Mauger's avatar
Michael Mauger committed
411 412 413
     :sqli-program sql-mysql-program
     :sqli-options sql-mysql-options
     :sqli-login sql-mysql-login-params
414
     :sqli-comint-func sql-comint-mysql
415 416
     :list-all "SHOW TABLES;"
     :list-table "DESCRIBE %s;"
Michael Mauger's avatar
Michael Mauger committed
417 418
     :prompt-regexp "^mysql> "
     :prompt-length 6
419
     :prompt-cont-regexp "^    -> "
420
     :syntax-alist ((?# . "< b"))
Michael Mauger's avatar
Michael Mauger committed
421 422
     :input-filter sql-remove-tabs-filter)

423
    (oracle
Michael Mauger's avatar
Michael Mauger committed
424
     :name "Oracle"
425
     :font-lock sql-mode-oracle-font-lock-keywords
Michael Mauger's avatar
Michael Mauger committed
426 427 428
     :sqli-program sql-oracle-program
     :sqli-options sql-oracle-options
     :sqli-login sql-oracle-login-params
429
     :sqli-comint-func sql-comint-oracle
430 431 432
     :list-all sql-oracle-list-all
     :list-table sql-oracle-list-table
     :completion-object sql-oracle-completion-object
Michael Mauger's avatar
Michael Mauger committed
433 434
     :prompt-regexp "^SQL> "
     :prompt-length 5
435 436 437 438
     :prompt-cont-regexp "^\\s-*[[:digit:]]+  "
     :statement sql-oracle-statement-starters
     :syntax-alist ((?$ . "_") (?# . "_"))
     :terminator ("\\(^/\\|;\\)$" . "/")
Michael Mauger's avatar
Michael Mauger committed
439 440
     :input-filter sql-placeholders-filter)

441
    (postgres
Michael Mauger's avatar
Michael Mauger committed
442 443
     :name "Postgres"
     :free-software t
444
     :font-lock sql-mode-postgres-font-lock-keywords
Michael Mauger's avatar
Michael Mauger committed
445 446 447
     :sqli-program sql-postgres-program
     :sqli-options sql-postgres-options
     :sqli-login sql-postgres-login-params
448
     :sqli-comint-func sql-comint-postgres
449 450
     :list-all ("\\d+" . "\\dS+")
     :list-table ("\\d+ %s" . "\\dS+ %s")
451 452
     :completion-object sql-postgres-completion-object
     :prompt-regexp "^\\w*=[#>] "
Michael Mauger's avatar
Michael Mauger committed
453
     :prompt-length 5
454
     :prompt-cont-regexp "^\\w*[-(][#>] "
Michael Mauger's avatar
Michael Mauger committed
455
     :input-filter sql-remove-tabs-filter
456
     :terminator ("\\(^\\s-*\\\\g$\\|;\\)" . "\\g"))
Michael Mauger's avatar
Michael Mauger committed
457

458
    (solid
Michael Mauger's avatar
Michael Mauger committed
459
     :name "Solid"
460
     :font-lock sql-mode-solid-font-lock-keywords
Michael Mauger's avatar
Michael Mauger committed
461 462 463
     :sqli-program sql-solid-program
     :sqli-options sql-solid-options
     :sqli-login sql-solid-login-params
464
     :sqli-comint-func sql-comint-solid
Michael Mauger's avatar
Michael Mauger committed
465 466 467
     :prompt-regexp "^"
     :prompt-length 0)

468
    (sqlite
469
     :name "SQLite"
Michael Mauger's avatar
Michael Mauger committed
470
     :free-software t
471
     :font-lock sql-mode-sqlite-font-lock-keywords
Michael Mauger's avatar
Michael Mauger committed
472 473 474
     :sqli-program sql-sqlite-program
     :sqli-options sql-sqlite-options
     :sqli-login sql-sqlite-login-params
475
     :sqli-comint-func sql-comint-sqlite
476 477
     :list-all ".tables"
     :list-table ".schema %s"
478
     :completion-object sql-sqlite-completion-object
Michael Mauger's avatar
Michael Mauger committed
479
     :prompt-regexp "^sqlite> "
480
     :prompt-length 8
481
     :prompt-cont-regexp "^   \.\.\.> "
482
     :terminator ";")
Michael Mauger's avatar
Michael Mauger committed
483

484
    (sybase
Michael Mauger's avatar
Michael Mauger committed
485
     :name "Sybase"
486
     :font-lock sql-mode-sybase-font-lock-keywords
Michael Mauger's avatar
Michael Mauger committed
487 488 489
     :sqli-program sql-sybase-program
     :sqli-options sql-sybase-options
     :sqli-login sql-sybase-login-params
490
     :sqli-comint-func sql-comint-sybase
Michael Mauger's avatar
Michael Mauger committed
491 492
     :prompt-regexp "^SQL> "
     :prompt-length 5
493
     :syntax-alist ((?@ . "_"))
Michael Mauger's avatar
Michael Mauger committed
494
     :terminator ("^go" . "go"))
495
    )
Michael Mauger's avatar
Michael Mauger committed
496 497 498 499
  "An alist of product specific configuration settings.

Without an entry in this list a product will not be properly
highlighted and will not support `sql-interactive-mode'.
500 501 502 503 504

Each element in the list is in the following format:

 \(PRODUCT FEATURE VALUE ...)

Michael Mauger's avatar
Michael Mauger committed
505 506 507 508 509 510 511 512 513
where PRODUCT is the appropriate value of `sql-product'.  The
product name is then followed by FEATURE-VALUE pairs.  If a
FEATURE is not specified, its VALUE is treated as nil.  FEATURE
may be any one of the following:

 :name                  string containing the displayable name of
                        the product.

 :free-software         is the product Free (as in Freedom) software?
514 515 516 517

 :font-lock             name of the variable containing the product
                        specific font lock highlighting patterns.

Michael Mauger's avatar
Michael Mauger committed
518 519 520 521 522
 :sqli-program          name of the variable containing the product
                        specific interactive program name.

 :sqli-options          name of the variable containing the list
                        of product specific options.
523

Michael Mauger's avatar
Michael Mauger committed
524 525 526 527 528
 :sqli-login            name of the variable containing the list of
                        login parameters (i.e., user, password,
                        database and server) needed to connect to
                        the database.

529
 :sqli-comint-func      name of a function which accepts no
530 531
                        parameters that will use the values of
                        `sql-user', `sql-password',
532 533 534 535 536
                        `sql-database', `sql-server' and
                        `sql-port' to open a comint buffer and
                        connect to the database.  Do product
                        specific configuration of comint in this
                        function.
537

538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
 :list-all              Command string or function which produces
                        a listing of all objects in the database.
                        If it's a cons cell, then the car
                        produces the standard list of objects and
                        the cdr produces an enhanced list of
                        objects.  What \"enhanced\" means is
                        dependent on the SQL product and may not
                        exist.  In general though, the
                        \"enhanced\" list should include visible
                        objects from other schemas.

 :list-table            Command string or function which produces
                        a detailed listing of a specific database
                        table.  If its a cons cell, then the car
                        produces the standard list and the cdr
                        produces an enhanced list.

555 556 557 558 559 560 561 562 563 564 565 566 567 568
 :completion-object     A function that returns a list of
                        objects.  Called with a single
                        parameter--if nil then list objects
                        accessible in the current schema, if
                        not-nil it is the name of a schema whose
                        objects should be listed.

 :completion-column     A function that returns a list of
                        columns.  Called with a single
                        parameter--if nil then list objects
                        accessible in the current schema, if
                        not-nil it is the name of a schema whose
                        objects should be listed.

Michael Mauger's avatar
Michael Mauger committed
569
 :prompt-regexp         regular expression string that matches
570
                        the prompt issued by the product
Michael Mauger's avatar
Michael Mauger committed
571 572 573 574
                        interpreter.

 :prompt-length         length of the prompt on the line.

575 576 577 578
 :prompt-cont-regexp    regular expression string that matches
                        the continuation prompt issued by the
                        product interpreter.

Michael Mauger's avatar
Michael Mauger committed
579 580 581 582 583 584 585
 :input-filter          function which can filter strings sent to
                        the command interpreter.  It is also used
                        by the `sql-send-string',
                        `sql-send-region', `sql-send-paragraph'
                        and `sql-send-buffer' functions.  The
                        function is passed the string sent to the
                        command interpreter and must return the
586 587
                        filtered string.  May also be a list of
                        such functions.
Michael Mauger's avatar
Michael Mauger committed
588

589 590 591
 :statement             name of a variable containing a regexp that
                        matches the beginning of SQL statements.

Michael Mauger's avatar
Michael Mauger committed
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610
 :terminator            the terminator to be sent after a
                        `sql-send-string', `sql-send-region',
                        `sql-send-paragraph' and
                        `sql-send-buffer' command.  May be the
                        literal string or a cons of a regexp to
                        match an existing terminator in the
                        string and the terminator to be used if
                        its absent.  By default \";\".

 :syntax-alist          alist of syntax table entries to enable
                        special character treatment by font-lock
                        and imenu.

Other features can be stored but they will be ignored.  However,
you can develop new functionality which is product independent by
using `sql-get-product-feature' to lookup the product specific
settings.")

(defvar sql-indirect-features
611
  '(:font-lock :sqli-program :sqli-options :sqli-login :statement))
612

613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637
(defcustom sql-connection-alist nil
  "An alist of connection parameters for interacting with a SQL
  product.

Each element of the alist is as follows:

  \(CONNECTION \(SQL-VARIABLE VALUE) ...)

Where CONNECTION is a symbol identifying the connection, SQL-VARIABLE
is the symbol name of a SQL mode variable, and VALUE is the value to
be assigned to the variable.

The most common SQL-VARIABLE settings associated with a connection
are:

  `sql-product'
  `sql-user'
  `sql-password'
  `sql-port'
  `sql-server'
  `sql-database'

If a SQL-VARIABLE is part of the connection, it will not be
prompted for during login."

638
  :type `(alist :key-type (string :tag "Connection")
639 640 641 642 643 644 645 646 647 648 649 650 651 652
                :value-type
                (set
                 (group (const :tag "Product"  sql-product)
                        (choice
                         ,@(mapcar (lambda (prod-info)
                                     `(const :tag
                                             ,(or (plist-get (cdr prod-info) :name)
                                                  (capitalize (symbol-name (car prod-info))))
                                             (quote ,(car prod-info))))
                                   sql-product-alist)))
                 (group (const :tag "Username" sql-user)     string)
                 (group (const :tag "Password" sql-password) string)
                 (group (const :tag "Server"   sql-server)   string)
                 (group (const :tag "Database" sql-database) string)
653 654 655 656 657
                 (group (const :tag "Port"     sql-port)     integer)
                 (repeat :inline t
                         (list :tab "Other"
                               (symbol :tag " Variable Symbol")
                               (sexp   :tag "Value Expression")))))
658 659 660
  :version "24.1"
  :group 'SQL)

661
(defcustom sql-product 'ansi
Michael Mauger's avatar
Michael Mauger committed
662
  "Select the SQL database product used so that buffers can be
663 664 665 666 667 668 669 670
highlighted properly when you open them."
  :type `(choice
          ,@(mapcar (lambda (prod-info)
                      `(const :tag
                              ,(or (plist-get (cdr prod-info) :name)
                                   (capitalize (symbol-name (car prod-info))))
                              ,(car prod-info)))
                    sql-product-alist))
671 672
  :group 'SQL
  :safe 'symbolp)
Michael Mauger's avatar
Michael Mauger committed
673
(defvaralias 'sql-dialect 'sql-product)
Michael Mauger's avatar
Michael Mauger committed
674

Paul Eggert's avatar
Paul Eggert committed
675
;; misc customization of sql.el behavior
676

677 678 679 680 681 682 683 684 685
(defcustom sql-electric-stuff nil
  "Treat some input as electric.
If set to the symbol `semicolon', then hitting `;' will send current
input in the SQLi buffer to the process.
If set to the symbol `go', then hitting `go' on a line by itself will
send current input in the SQLi buffer to the process.
If set to nil, then you must use \\[comint-send-input] in order to send
current input in the SQLi buffer to the process."
  :type '(choice (const :tag "Nothing" nil)
686
		 (const :tag "The semicolon `;'" semicolon)
687 688 689 690
		 (const :tag "The string `go' by itself" go))
  :version "20.8"
  :group 'SQL)

Michael Mauger's avatar
Michael Mauger committed
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718
(defcustom sql-send-terminator nil
  "When non-nil, add a terminator to text sent to the SQL interpreter.

When text is sent to the SQL interpreter (via `sql-send-string',
`sql-send-region', `sql-send-paragraph' or `sql-send-buffer'), a
command terminator can be automatically sent as well.  The
terminator is not sent, if the string sent already ends with the
terminator.

If this value is t, then the default command terminator for the
SQL interpreter is sent.  If this value is a string, then the
string is sent.

If the value is a cons cell of the form (PAT . TERM), then PAT is
a regexp used to match the terminator in the string and TERM is
the terminator to be sent.  This form is useful if the SQL
interpreter has more than one way of submitting a SQL command.
The PAT regexp can match any of them, and TERM is the way we do
it automatically."

  :type '(choice (const  :tag "No Terminator" nil)
		 (const  :tag "Default Terminator" t)
		 (string :tag "Terminator String")
		 (cons   :tag "Terminator Pattern and String"
			 (string :tag "Terminator Pattern")
			 (string :tag "Terminator String")))
  :version "22.2"
  :group 'SQL)
Richard M. Stallman's avatar
Richard M. Stallman committed
719

720 721 722 723 724 725 726
(defvar sql-contains-names nil
  "When non-nil, the current buffer contains database names.

Globally should be set to nil; it will be non-nil in `sql-mode',
`sql-interactive-mode' and list all buffers.")


Michael Mauger's avatar
Michael Mauger committed
727 728 729 730 731 732 733 734 735
(defcustom sql-pop-to-buffer-after-send-region nil
  "When non-nil, pop to the buffer SQL statements are sent to.

After a call to `sql-sent-string', `sql-send-region',
`sql-send-paragraph' or `sql-send-buffer', the window is split
and the SQLi buffer is shown.  If this variable is not nil, that
buffer's window will be selected by calling `pop-to-buffer'.  If
this variable is nil, that buffer is shown using
`display-buffer'."
736 737 738
  :type 'boolean
  :group 'SQL)

739 740 741
;; imenu support for sql-mode.

(defvar sql-imenu-generic-expression
742
  ;; Items are in reverse order because they are rendered in reverse.
743 744 745 746 747 748
  '(("Rules/Defaults" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*\\(rule\\|default\\)\\s-+\\(\\w+\\)" 3)
    ("Sequences" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*sequence\\s-+\\(\\w+\\)" 2)
    ("Triggers" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*trigger\\s-+\\(\\w+\\)" 2)
    ("Functions" "^\\s-*\\(create\\s-+\\(\\w+\\s-+\\)*\\)?function\\s-+\\(\\w+\\)" 3)
    ("Procedures" "^\\s-*\\(create\\s-+\\(\\w+\\s-+\\)*\\)?proc\\(edure\\)?\\s-+\\(\\w+\\)" 4)
    ("Packages" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*package\\s-+\\(body\\s-+\\)?\\(\\w+\\)" 3)
Michael Mauger's avatar
Michael Mauger committed
749
    ("Types" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*type\\s-+\\(body\\s-+\\)?\\(\\w+\\)" 3)
750 751
    ("Indexes" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*index\\s-+\\(\\w+\\)" 2)
    ("Tables/Views" "^\\s-*create\\s-+\\(\\w+\\s-+\\)*\\(table\\|view\\)\\s-+\\(\\w+\\)" 3))
752 753
  "Define interesting points in the SQL buffer for `imenu'.

754
This is used to set `imenu-generic-expression' when SQL mode is
755 756 757
entered.  Subsequent changes to `sql-imenu-generic-expression' will
not affect existing SQL buffers because imenu-generic-expression is
a local variable.")
758 759 760

;; history file

761
(defcustom sql-input-ring-file-name nil
Michael Mauger's avatar
Michael Mauger committed
762
  "If non-nil, name of the file to read/write input history.
763

764 765 766 767 768 769
You have to set this variable if you want the history of your commands
saved from one Emacs session to the next.  If this variable is set,
exiting the SQL interpreter in an SQLi buffer will write the input
history to the specified file.  Starting a new process in a SQLi buffer
will read the input history from the specified file.

770 771 772 773
This is used to initialize `comint-input-ring-file-name'.

Note that the size of the input history is determined by the variable
`comint-input-ring-size'."
774 775 776 777 778
  :type '(choice (const :tag "none" nil)
		 (file))
  :group 'SQL)

(defcustom sql-input-ring-separator "\n--\n"
Michael Mauger's avatar
Michael Mauger committed
779
  "Separator between commands in the history file.
780 781 782 783 784

If set to \"\\n\", each line in the history file will be interpreted as
one command.  Multi-line commands are split into several commands when
the input ring is initialized from a history file.

785 786 787 788 789 790
This variable used to initialize `comint-input-ring-separator'.
`comint-input-ring-separator' is part of Emacs 21; if your Emacs
does not have it, setting `sql-input-ring-separator' will have no
effect.  In that case multiline commands will be split into several
commands when the input history is read, as if you had set
`sql-input-ring-separator' to \"\\n\"."
Richard M. Stallman's avatar
Richard M. Stallman committed
791 792 793 794 795 796
  :type 'string
  :group 'SQL)

;; The usual hooks

(defcustom sql-interactive-mode-hook '()
Michael Mauger's avatar
Michael Mauger committed
797
  "Hook for customizing `sql-interactive-mode'."
Richard M. Stallman's avatar
Richard M. Stallman committed
798 799 800 801
  :type 'hook
  :group 'SQL)

(defcustom sql-mode-hook '()
Michael Mauger's avatar
Michael Mauger committed
802
  "Hook for customizing `sql-mode'."
Richard M. Stallman's avatar
Richard M. Stallman committed
803 804 805
  :type 'hook
  :group 'SQL)

806
(defcustom sql-set-sqli-hook '()
Michael Mauger's avatar
Michael Mauger committed
807
  "Hook for reacting to changes of `sql-buffer'.
808 809 810 811 812 813

This is called by `sql-set-sqli-buffer' when the value of `sql-buffer'
is changed."
  :type 'hook
  :group 'SQL)

814 815 816 817 818 819 820 821 822 823 824 825 826
;; Customization for ANSI

(defcustom sql-ansi-statement-starters (regexp-opt '(
 "create" "alter" "drop"
 "select" "insert" "update" "delete" "merge"
 "grant" "revoke"
))
  "Regexp of keywords that start SQL commands

All products share this list; products should define a regexp to
identify additional keywords in a variable defined by
the :statement feature.")

827
;; Customization for Oracle
Richard M. Stallman's avatar
Richard M. Stallman committed
828 829

(defcustom sql-oracle-program "sqlplus"
Michael Mauger's avatar
Michael Mauger committed
830
  "Command to start sqlplus by Oracle.
Richard M. Stallman's avatar
Richard M. Stallman committed
831 832 833

Starts `sql-interactive-mode' after doing some setup.

834 835 836
On Windows, \"sqlplus\" usually starts the sqlplus \"GUI\".  In order
to start the sqlplus console, use \"plus33\" or something similar.
You will find the file in your Orant\\bin directory."
837 838 839
  :type 'file
  :group 'SQL)

840
(defcustom sql-oracle-options nil
Michael Mauger's avatar
Michael Mauger committed
841
  "List of additional options for `sql-oracle-program'."
842 843 844 845
  :type '(repeat string)
  :version "20.8"
  :group 'SQL)

Michael Mauger's avatar
Michael Mauger committed
846 847
(defcustom sql-oracle-login-params '(user password database)
  "List of login parameters needed to connect to Oracle."
848
  :type 'sql-login-params
Michael Mauger's avatar
Michael Mauger committed
849 850 851
  :version "24.1"
  :group 'SQL)

852 853 854
(defcustom sql-oracle-statement-starters (regexp-opt '("declare" "begin" "with"))
  "Additional statement starting keywords in Oracle.")

Michael Mauger's avatar
Michael Mauger committed
855 856 857 858 859
(defcustom sql-oracle-scan-on t
  "Non-nil if placeholders should be replaced in Oracle SQLi.

When non-nil, Emacs will scan text sent to sqlplus and prompt
for replacement text for & placeholders as sqlplus does.  This
860
is needed on Windows where SQL*Plus output is buffered and the
Michael Mauger's avatar
Michael Mauger committed
861 862
prompts are not shown until after the text is entered.

863 864 865
You need to issue the following command in SQL*Plus to be safe:

    SET DEFINE OFF
Michael Mauger's avatar
Michael Mauger committed
866

867
In older versions of SQL*Plus, this was the SET SCAN OFF command."
Michael Mauger's avatar
Michael Mauger committed
868 869 870
  :type 'boolean
  :group 'SQL)

871 872
;; Customization for SQLite

Michael Mauger's avatar
Michael Mauger committed
873 874 875
(defcustom sql-sqlite-program (or (executable-find "sqlite3")
                                  (executable-find "sqlite")
                                  "sqlite")
Michael Mauger's avatar
Michael Mauger committed
876
  "Command to start SQLite.
877

Michael Mauger's avatar
Michael Mauger committed
878
Starts `sql-interactive-mode' after doing some setup."
879 880 881 882
  :type 'file
  :group 'SQL)

(defcustom sql-sqlite-options nil
Michael Mauger's avatar
Michael Mauger committed
883
  "List of additional options for `sql-sqlite-program'."
884 885 886 887
  :type '(repeat string)
  :version "20.8"
  :group 'SQL)

Michael Mauger's avatar
Michael Mauger committed
888
(defcustom sql-sqlite-login-params '((database :file ".*\\.\\(db\\|sqlite[23]?\\)"))
Michael Mauger's avatar
Michael Mauger committed
889
  "List of login parameters needed to connect to SQLite."
890
  :type 'sql-login-params
Michael Mauger's avatar
Michael Mauger committed
891 892 893
  :version "24.1"
  :group 'SQL)

894
;; Customization for MySQL
895 896

(defcustom sql-mysql-program "mysql"
Michael Mauger's avatar
Michael Mauger committed
897
  "Command to start mysql by TcX.
898

Michael Mauger's avatar
Michael Mauger committed
899
Starts `sql-interactive-mode' after doing some setup."
900 901 902
  :type 'file
  :group 'SQL)

903
(defcustom sql-mysql-options nil
Michael Mauger's avatar
Michael Mauger committed
904
  "List of additional options for `sql-mysql-program'.
905 906
The following list of options is reported to make things work
on Windows: \"-C\" \"-t\" \"-f\" \"-n\"."
907 908 909 910
  :type '(repeat string)
  :version "20.8"
  :group 'SQL)

Michael Mauger's avatar
Michael Mauger committed
911
(defcustom sql-mysql-login-params '(user password database server)
912
  "List of login parameters needed to connect to MySQL."
913
  :type 'sql-login-params
Michael Mauger's avatar
Michael Mauger committed
914 915 916
  :version "24.1"
  :group 'SQL)

917
;; Customization for Solid
918 919

(defcustom sql-solid-program "solsql"
Michael Mauger's avatar
Michael Mauger committed
920
  "Command to start SOLID SQL Editor.
921

Michael Mauger's avatar
Michael Mauger committed
922
Starts `sql-interactive-mode' after doing some setup."
Richard M. Stallman's avatar
Richard M. Stallman committed
923 924 925
  :type 'file
  :group 'SQL)

Michael Mauger's avatar
Michael Mauger committed
926 927
(defcustom sql-solid-login-params '(user password server)
  "List of login parameters needed to connect to Solid."
928
  :type 'sql-login-params
Michael Mauger's avatar
Michael Mauger committed
929 930 931
  :version "24.1"
  :group 'SQL)

932
;; Customization for Sybase
Richard M. Stallman's avatar
Richard M. Stallman committed
933 934

(defcustom sql-sybase-program "isql"
935
  "Command to start isql by Sybase.
Richard M. Stallman's avatar
Richard M. Stallman committed
936

Michael Mauger's avatar
Michael Mauger committed
937
Starts `sql-interactive-mode' after doing some setup."
Richard M. Stallman's avatar
Richard M. Stallman committed
938 939 940
  :type 'file
  :group 'SQL)

941
(defcustom sql-sybase-options nil
Michael Mauger's avatar
Michael Mauger committed
942
  "List of additional options for `sql-sybase-program'.
943 944 945 946 947
Some versions of isql might require the -n option in order to work."
  :type '(repeat string)
  :version "20.8"
  :group 'SQL)

Michael Mauger's avatar
Michael Mauger committed
948 949
(defcustom sql-sybase-login-params '(server user password database)
  "List of login parameters needed to connect to Sybase."
950
  :type 'sql-login-params
Michael Mauger's avatar
Michael Mauger committed
951 952 953
  :version "24.1"
  :group 'SQL)

954
;; Customization for Informix
Richard M. Stallman's avatar
Richard M. Stallman committed
955 956

(defcustom sql-informix-program "dbaccess"
Michael Mauger's avatar
Michael Mauger committed
957
  "Command to start dbaccess by Informix.
Richard M. Stallman's avatar
Richard M. Stallman committed
958

Michael Mauger's avatar
Michael Mauger committed
959
Starts `sql-interactive-mode' after doing some setup."
Richard M. Stallman's avatar
Richard M. Stallman committed
960 961 962
  :type 'file
  :group 'SQL)

Michael Mauger's avatar
Michael Mauger committed
963 964
(defcustom sql-informix-login-params '(database)
  "List of login parameters needed to connect to Informix."
965
  :type 'sql-login-params
Michael Mauger's avatar
Michael Mauger committed
966 967 968
  :version "24.1"
  :group 'SQL)

969
;; Customization for Ingres
Richard M. Stallman's avatar
Richard M. Stallman committed
970 971

(defcustom sql-ingres-program "sql"
Michael Mauger's avatar
Michael Mauger committed
972
  "Command to start sql by Ingres.
Richard M. Stallman's avatar
Richard M. Stallman committed
973

Michael Mauger's avatar
Michael Mauger committed
974
Starts `sql-interactive-mode' after doing some setup."
Richard M. Stallman's avatar
Richard M. Stallman committed
975 976 977
  :type 'file
  :group 'SQL)

Michael Mauger's avatar
Michael Mauger committed
978 979
(defcustom sql-ingres-login-params '(database)
  "List of login parameters needed to connect to Ingres."
980
  :type 'sql-login-params
Michael Mauger's avatar
Michael Mauger committed
981 982 983
  :version "24.1"
  :group 'SQL)

984
;; Customization for Microsoft
Richard M. Stallman's avatar
Richard M. Stallman committed
985

986
(defcustom sql-ms-program "osql"
Michael Mauger's avatar
Michael Mauger committed
987
  "Command to start osql by Microsoft.
Richard M. Stallman's avatar
Richard M. Stallman committed
988

Michael Mauger's avatar
Michael Mauger committed
989
Starts `sql-interactive-mode' after doing some setup."
Richard M. Stallman's avatar
Richard M. Stallman committed
990 991 992
  :type 'file
  :group 'SQL)

Juanma Barranquero's avatar
Juanma Barranquero committed
993 994
(defcustom sql-ms-options '("-w" "300" "-n")
  ;; -w is the linesize
Michael Mauger's avatar
Michael Mauger committed
995
  "List of additional options for `sql-ms-program'."
Juanma Barranquero's avatar
Juanma Barranquero committed
996
  :type '(repeat string)
997
  :version "22.1"
Juanma Barranquero's avatar
Juanma Barranquero committed
998 999
  :group 'SQL)

Michael Mauger's avatar
Michael Mauger committed
1000 1001
(defcustom sql-ms-login-params '(user password server database)
  "List of login parameters needed to connect to Microsoft."
1002
  :type 'sql-login-params
Michael Mauger's avatar
Michael Mauger committed
1003 1004 1005
  :version "24.1"
  :group 'SQL)

1006
;; Customization for Postgres
Richard M. Stallman's avatar
Richard M. Stallman committed
1007 1008

(defcustom sql-postgres-program "psql"
1009
  "Command to start psql by Postgres.
Richard M. Stallman's avatar
Richard M. Stallman committed
1010

Michael Mauger's avatar
Michael Mauger committed
1011
Starts `sql-interactive-mode' after doing some setup."
Richard M. Stallman's avatar
Richard M. Stallman committed
1012 1013 1014
  :type 'file
  :group 'SQL)

1015
(defcustom sql-postgres-options '("-P" "pager=off")
Michael Mauger's avatar
Michael Mauger committed
1016
  "List of additional options for `sql-postgres-program'.
Gerd Moellmann's avatar
Gerd Moellmann committed
1017 1018 1019 1020 1021 1022
The default setting includes the -P option which breaks older versions
of the psql client (such as version 6.5.3).  The -P option is equivalent
to the --pset option.  If you want the psql to prompt you for a user
name, add the string \"-u\" to the list of options.  If you want to
provide a user name on the command line (newer versions such as 7.1),
add your name with a \"-U\" prefix (such as \"-Umark\") to the list."
1023 1024 1025 1026
  :type '(repeat string)
  :version "20.8"
  :group 'SQL)

1027 1028 1029
(defcustom sql-postgres-login-params `((user :default ,(user-login-name))
                                       (database :default ,(user-login-name))
                                       server)
Michael Mauger's avatar
Michael Mauger committed
1030
  "List of login parameters needed to connect to Postgres."
1031
  :type 'sql-login-params
Michael Mauger's avatar
Michael Mauger committed
1032 1033 1034
  :version "24.1"
  :group 'SQL)

1035 1036 1037
;; Customization for Interbase

(defcustom sql-interbase-program "isql"
Michael Mauger's avatar
Michael Mauger committed
1038
  "Command to start isql by Interbase.