diff options
| author | Michael R. Mauger | 2017-03-20 23:26:53 -0400 |
|---|---|---|
| committer | Michael R. Mauger | 2017-03-20 23:26:53 -0400 |
| commit | c5a31f8292c94d19b80a3dbe0b3026693cc1090e (patch) | |
| tree | 65a556fc731bb7b07ce9f20dbd103bec3e01d2b3 | |
| parent | 715962e5c416b62c1deea0bec16c88ae9c63674e (diff) | |
| download | emacs-c5a31f8292c94d19b80a3dbe0b3026693cc1090e.tar.gz emacs-c5a31f8292c94d19b80a3dbe0b3026693cc1090e.zip | |
* lisp/progmodes/sql.el: Version 3.6
(sql-login-params): Added :must-match for completition of
`server' and `database' login parameters.
(sql-sqlite-login-params, sql-postgres-login-params): Set
:must-match to `confirm'.
(sql-get-login-ext): Use :must-match value to control
`read-file-name' or `completing-read'.
(sql-connect): Added optional BUF-NAME parameter; Reworked
connection variable processing; Pass buffer name to
`sql-product-interactive'.
(sql-product-interactive): Pass buffer name along.
(sql-comint): Add optional BUF-NAME and calculate reasonable default.
(sql-comint-oracle, sql-sybase-comint, sql-comint-informix)
(sql-comint-sqlite, sql-comint-mysql, sql-comint-solid)
(sql-comint-ingres, sql-comint-ms, sql-comint-postgres)
(sql-comint-interbase, sql-comint-db2, sql-comint-linter)
(sql-comint-vertica): Add optional BUF-NAME, pass to
`sql-comint'.
(sql-oracle--list-oracle-name): New function.
(sql-oracle-list-all): Use it.
(sql-oracle-completion-object): Enhanced.
| -rw-r--r-- | lisp/progmodes/sql.el | 215 |
1 files changed, 127 insertions, 88 deletions
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 68ca37207ef..b176e52950c 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: Alex Schroeder <alex@gnu.org> | 5 | ;; Author: Alex Schroeder <alex@gnu.org> |
| 6 | ;; Maintainer: Michael Mauger <michael@mauger.com> | 6 | ;; Maintainer: Michael Mauger <michael@mauger.com> |
| 7 | ;; Version: 3.5 | 7 | ;; Version: 3.6 |
| 8 | ;; Keywords: comm languages processes | 8 | ;; Keywords: comm languages processes |
| 9 | ;; URL: http://savannah.gnu.org/projects/emacs/ | 9 | ;; URL: http://savannah.gnu.org/projects/emacs/ |
| 10 | 10 | ||
| @@ -156,7 +156,7 @@ | |||
| 156 | ;; (sql-set-product-feature 'xyz | 156 | ;; (sql-set-product-feature 'xyz |
| 157 | ;; :sqli-options 'my-sql-xyz-options)) | 157 | ;; :sqli-options 'my-sql-xyz-options)) |
| 158 | 158 | ||
| 159 | ;; (defun my-sql-comint-xyz (product options) | 159 | ;; (defun my-sql-comint-xyz (product options &optional buf-name) |
| 160 | ;; "Connect ti XyzDB in a comint buffer." | 160 | ;; "Connect ti XyzDB in a comint buffer." |
| 161 | ;; | 161 | ;; |
| 162 | ;; ;; Do something with `sql-user', `sql-password', | 162 | ;; ;; Do something with `sql-user', `sql-password', |
| @@ -172,7 +172,7 @@ | |||
| 172 | ;; (if (not (string= "" sql-server)) | 172 | ;; (if (not (string= "" sql-server)) |
| 173 | ;; (list "-S" sql-server)) | 173 | ;; (list "-S" sql-server)) |
| 174 | ;; options))) | 174 | ;; options))) |
| 175 | ;; (sql-comint product params))) | 175 | ;; (sql-comint product params buf-name))) |
| 176 | ;; | 176 | ;; |
| 177 | ;; (sql-set-product-feature 'xyz | 177 | ;; (sql-set-product-feature 'xyz |
| 178 | ;; :sqli-comint-func 'my-sql-comint-xyz) | 178 | ;; :sqli-comint-func 'my-sql-comint-xyz) |
| @@ -220,6 +220,7 @@ | |||
| 220 | ;; incorrectly enabled by default | 220 | ;; incorrectly enabled by default |
| 221 | ;; Roman Scherer <roman.scherer@nugg.ad> -- Connection documentation | 221 | ;; Roman Scherer <roman.scherer@nugg.ad> -- Connection documentation |
| 222 | ;; Mark Wilkinson <wilkinsonmr@gmail.com> -- file-local variables ignored | 222 | ;; Mark Wilkinson <wilkinsonmr@gmail.com> -- file-local variables ignored |
| 223 | ;; Simen Heggestøyl <simenheg@gmail.com> -- Postgres database completion | ||
| 223 | ;; | 224 | ;; |
| 224 | 225 | ||
| 225 | 226 | ||
| @@ -317,6 +318,7 @@ file. Since that is a plaintext file, this could be dangerous." | |||
| 317 | (list :tag "completion" | 318 | (list :tag "completion" |
| 318 | (const :format "" server) | 319 | (const :format "" server) |
| 319 | (const :format "" :completion) | 320 | (const :format "" :completion) |
| 321 | (const :format "" :must-match) | ||
| 320 | (restricted-sexp | 322 | (restricted-sexp |
| 321 | :match-alternatives (listp stringp)))) | 323 | :match-alternatives (listp stringp)))) |
| 322 | (choice :tag "database" | 324 | (choice :tag "database" |
| @@ -332,9 +334,10 @@ file. Since that is a plaintext file, this could be dangerous." | |||
| 332 | regexp) | 334 | regexp) |
| 333 | (list :tag "completion" | 335 | (list :tag "completion" |
| 334 | (const :format "" database) | 336 | (const :format "" database) |
| 335 | (const :format "" :completion) | 337 | (const :format "" :completion) |
| 336 | (restricted-sexp | 338 | (const :format "" :must-match) |
| 337 | :match-alternatives (listp stringp)))) | 339 | (restricted-sexp |
| 340 | :match-alternatives (listp stringp)))) | ||
| 338 | (const port))) | 341 | (const port))) |
| 339 | 342 | ||
| 340 | ;; SQL Product support | 343 | ;; SQL Product support |
| @@ -936,7 +939,8 @@ Starts `sql-interactive-mode' after doing some setup." | |||
| 936 | :version "20.8" | 939 | :version "20.8" |
| 937 | :group 'SQL) | 940 | :group 'SQL) |
| 938 | 941 | ||
| 939 | (defcustom sql-sqlite-login-params '((database :file nil)) | 942 | (defcustom sql-sqlite-login-params '((database :file nil |
| 943 | :must-match confirm)) | ||
| 940 | "List of login parameters needed to connect to SQLite." | 944 | "List of login parameters needed to connect to SQLite." |
| 941 | :type 'sql-login-params | 945 | :type 'sql-login-params |
| 942 | :version "26.1" | 946 | :version "26.1" |
| @@ -1079,7 +1083,8 @@ add your name with a \"-U\" prefix (such as \"-Umark\") to the list." | |||
| 1079 | `((user :default ,(user-login-name)) | 1083 | `((user :default ,(user-login-name)) |
| 1080 | (database :default ,(user-login-name) | 1084 | (database :default ,(user-login-name) |
| 1081 | :completion ,(completion-table-dynamic | 1085 | :completion ,(completion-table-dynamic |
| 1082 | (lambda (_) (sql-postgres-list-databases)))) | 1086 | (lambda (_) (sql-postgres-list-databases))) |
| 1087 | :must-match confirm) | ||
| 1083 | server) | 1088 | server) |
| 1084 | "List of login parameters needed to connect to Postgres." | 1089 | "List of login parameters needed to connect to Postgres." |
| 1085 | :type 'sql-login-params | 1090 | :type 'sql-login-params |
| @@ -2957,7 +2962,9 @@ value. (The property value is used as the PREDICATE argument to | |||
| 2957 | ((plist-member plist :file) | 2962 | ((plist-member plist :file) |
| 2958 | (let ((file-name | 2963 | (let ((file-name |
| 2959 | (read-file-name prompt | 2964 | (read-file-name prompt |
| 2960 | (file-name-directory last-value) default 'confirm | 2965 | (file-name-directory last-value) |
| 2966 | default | ||
| 2967 | (plist-get plist :must-match) | ||
| 2961 | (file-name-nondirectory last-value) | 2968 | (file-name-nondirectory last-value) |
| 2962 | (when (plist-get plist :file) | 2969 | (when (plist-get plist :file) |
| 2963 | `(lambda (f) | 2970 | `(lambda (f) |
| @@ -2971,8 +2978,13 @@ value. (The property value is used as the PREDICATE argument to | |||
| 2971 | (expand-file-name file-name)))) | 2978 | (expand-file-name file-name)))) |
| 2972 | 2979 | ||
| 2973 | ((plist-member plist :completion) | 2980 | ((plist-member plist :completion) |
| 2974 | (completing-read prompt-def (plist-get plist :completion) nil t | 2981 | (completing-read prompt-def |
| 2975 | last-value history-var default)) | 2982 | (plist-get plist :completion) |
| 2983 | nil | ||
| 2984 | (plist-get plist :must-match) | ||
| 2985 | last-value | ||
| 2986 | history-var | ||
| 2987 | default)) | ||
| 2976 | 2988 | ||
| 2977 | ((plist-get plist :number) | 2989 | ((plist-get plist :number) |
| 2978 | (read-number prompt (or default last-value 0))) | 2990 | (read-number prompt (or default last-value 0))) |
| @@ -4034,7 +4046,7 @@ Sentinels will always get the two parameters PROCESS and EVENT." | |||
| 4034 | nil t initial 'sql-connection-history default))) | 4046 | nil t initial 'sql-connection-history default))) |
| 4035 | 4047 | ||
| 4036 | ;;;###autoload | 4048 | ;;;###autoload |
| 4037 | (defun sql-connect (connection &optional new-name) | 4049 | (defun sql-connect (connection &optional buf-name) |
| 4038 | "Connect to an interactive session using CONNECTION settings. | 4050 | "Connect to an interactive session using CONNECTION settings. |
| 4039 | 4051 | ||
| 4040 | See `sql-connection-alist' to see how to define connections and | 4052 | See `sql-connection-alist' to see how to define connections and |
| @@ -4046,7 +4058,7 @@ is specified in the connection settings." | |||
| 4046 | ;; Prompt for the connection from those defined in the alist | 4058 | ;; Prompt for the connection from those defined in the alist |
| 4047 | (interactive | 4059 | (interactive |
| 4048 | (if sql-connection-alist | 4060 | (if sql-connection-alist |
| 4049 | (list (sql-read-connection "Connection: " nil '(nil)) | 4061 | (list (sql-read-connection "Connection: ") |
| 4050 | current-prefix-arg) | 4062 | current-prefix-arg) |
| 4051 | (user-error "No SQL Connections defined"))) | 4063 | (user-error "No SQL Connections defined"))) |
| 4052 | 4064 | ||
| @@ -4055,16 +4067,16 @@ is specified in the connection settings." | |||
| 4055 | ;; Was one selected | 4067 | ;; Was one selected |
| 4056 | (when connection | 4068 | (when connection |
| 4057 | ;; Get connection settings | 4069 | ;; Get connection settings |
| 4058 | (let ((connect-set (assoc-string connection sql-connection-alist t))) | 4070 | (let ((connect-set (cdr (assoc-string connection sql-connection-alist t)))) |
| 4059 | ;; Settings are defined | 4071 | ;; Settings are defined |
| 4060 | (if connect-set | 4072 | (if connect-set |
| 4061 | ;; Set the desired parameters | 4073 | ;; Set the desired parameters |
| 4062 | (let (param-var login-params set-params rem-params) | 4074 | (let (param-var login-params set-vars rem-vars) |
| 4063 | ;; Set the parameters and start the interactive session | 4075 | ;; Set the parameters and start the interactive session |
| 4064 | (mapc | 4076 | (dolist (vv connect-set) |
| 4065 | (lambda (vv) | 4077 | (let ((var (car vv)) |
| 4066 | (set-default (car vv) (eval (cadr vv)))) | 4078 | (val (cadr vv))) |
| 4067 | (cdr connect-set)) | 4079 | (set-default var (eval val)))) |
| 4068 | (setq-default sql-connection connection) | 4080 | (setq-default sql-connection connection) |
| 4069 | 4081 | ||
| 4070 | ;; :sqli-login params variable | 4082 | ;; :sqli-login params variable |
| @@ -4072,32 +4084,33 @@ is specified in the connection settings." | |||
| 4072 | (sql-get-product-feature sql-product :sqli-login nil t)) | 4084 | (sql-get-product-feature sql-product :sqli-login nil t)) |
| 4073 | 4085 | ||
| 4074 | ;; :sqli-login params value | 4086 | ;; :sqli-login params value |
| 4075 | (setq login-params | 4087 | (setq login-params (symbol-value param-var)) |
| 4076 | (sql-get-product-feature sql-product :sqli-login)) | ||
| 4077 | 4088 | ||
| 4078 | ;; Params in the connection | 4089 | ;; Params set in the connection |
| 4079 | (setq set-params | 4090 | (setq set-vars |
| 4080 | (mapcar | 4091 | (mapcar |
| 4081 | (lambda (v) | 4092 | (lambda (v) |
| 4082 | (pcase (car v) | 4093 | (pcase (car v) |
| 4083 | (`sql-user 'user) | 4094 | (`sql-user 'user) |
| 4084 | (`sql-password 'password) | 4095 | (`sql-password 'password) |
| 4085 | (`sql-server 'server) | 4096 | (`sql-server 'server) |
| 4086 | (`sql-database 'database) | 4097 | (`sql-database 'database) |
| 4087 | (`sql-port 'port) | 4098 | (`sql-port 'port) |
| 4088 | (s s))) | 4099 | (s s))) |
| 4089 | (cdr connect-set))) | 4100 | connect-set)) |
| 4090 | 4101 | ||
| 4091 | ;; the remaining params (w/o the connection params) | 4102 | ;; the remaining params (w/o the connection params) |
| 4092 | (setq rem-params | 4103 | (setq rem-vars |
| 4093 | (sql-for-each-login login-params | 4104 | (sql-for-each-login login-params |
| 4094 | (lambda (token plist) | 4105 | (lambda (var vals) |
| 4095 | (unless (member token set-params) | 4106 | (unless (member var set-vars) |
| 4096 | (if plist (cons token plist) token))))) | 4107 | (if vals (cons var vals) var))))) |
| 4097 | 4108 | ||
| 4098 | ;; Start the SQLi session with revised list of login parameters | 4109 | ;; Start the SQLi session with revised list of login parameters |
| 4099 | (eval `(let ((,param-var ',rem-params)) | 4110 | (eval `(let ((,param-var ',rem-vars)) |
| 4100 | (sql-product-interactive ',sql-product ',new-name)))) | 4111 | (sql-product-interactive |
| 4112 | ',sql-product | ||
| 4113 | ',(or buf-name (format "<%s>" connection)))))) | ||
| 4101 | 4114 | ||
| 4102 | (user-error "SQL Connection <%s> does not exist" connection) | 4115 | (user-error "SQL Connection <%s> does not exist" connection) |
| 4103 | nil))) | 4116 | nil))) |
| @@ -4241,7 +4254,10 @@ the call to \\[sql-product-interactive] with | |||
| 4241 | default-directory))) | 4254 | default-directory))) |
| 4242 | (funcall (sql-get-product-feature product :sqli-comint-func) | 4255 | (funcall (sql-get-product-feature product :sqli-comint-func) |
| 4243 | product | 4256 | product |
| 4244 | (sql-get-product-feature product :sqli-options))) | 4257 | (sql-get-product-feature product :sqli-options) |
| 4258 | (if (and new-name (string-prefix-p "SQL" new-name t)) | ||
| 4259 | new-name | ||
| 4260 | (concat "SQL: " new-name)))) | ||
| 4245 | 4261 | ||
| 4246 | ;; Set SQLi mode. | 4262 | ;; Set SQLi mode. |
| 4247 | (let ((sql-interactive-product product)) | 4263 | (let ((sql-interactive-product product)) |
| @@ -4249,8 +4265,6 @@ the call to \\[sql-product-interactive] with | |||
| 4249 | 4265 | ||
| 4250 | ;; Set the new buffer name | 4266 | ;; Set the new buffer name |
| 4251 | (setq new-sqli-buffer (current-buffer)) | 4267 | (setq new-sqli-buffer (current-buffer)) |
| 4252 | (when new-name | ||
| 4253 | (sql-rename-buffer new-name)) | ||
| 4254 | (set (make-local-variable 'sql-buffer) | 4268 | (set (make-local-variable 'sql-buffer) |
| 4255 | (buffer-name new-sqli-buffer)) | 4269 | (buffer-name new-sqli-buffer)) |
| 4256 | 4270 | ||
| @@ -4284,29 +4298,41 @@ the call to \\[sql-product-interactive] with | |||
| 4284 | (current-buffer))))) | 4298 | (current-buffer))))) |
| 4285 | (user-error "No default SQL product defined. Set `sql-product'."))) | 4299 | (user-error "No default SQL product defined. Set `sql-product'."))) |
| 4286 | 4300 | ||
| 4287 | (defun sql-comint (product params) | 4301 | (defun sql-comint (product params &optional buf-name) |
| 4288 | "Set up a comint buffer to run the SQL processor. | 4302 | "Set up a comint buffer to run the SQL processor. |
| 4289 | 4303 | ||
| 4290 | PRODUCT is the SQL product. PARAMS is a list of strings which are | 4304 | PRODUCT is the SQL product. PARAMS is a list of strings which are |
| 4291 | passed as command line arguments." | 4305 | passed as command line arguments. BUF-NAME is the name of the new |
| 4292 | (let ((program (sql-get-product-feature product :sqli-program)) | 4306 | buffer. If nil, a name is chosen for it." |
| 4293 | (buf-name "SQL")) | 4307 | |
| 4308 | (let ((program (sql-get-product-feature product :sqli-program))) | ||
| 4294 | ;; Make sure we can find the program. `executable-find' does not | 4309 | ;; Make sure we can find the program. `executable-find' does not |
| 4295 | ;; work for remote hosts; we suppress the check there. | 4310 | ;; work for remote hosts; we suppress the check there. |
| 4296 | (unless (or (file-remote-p default-directory) | 4311 | (unless (or (file-remote-p default-directory) |
| 4297 | (executable-find program)) | 4312 | (executable-find program)) |
| 4298 | (error "Unable to locate SQL program `%s'" program)) | 4313 | (error "Unable to locate SQL program `%s'" program)) |
| 4314 | |||
| 4299 | ;; Make sure buffer name is unique. | 4315 | ;; Make sure buffer name is unique. |
| 4300 | (when (sql-buffer-live-p (format "*%s*" buf-name)) | 4316 | ;; if not specified, try *SQL* then *SQL-product*, then *SQL-product1*, ... |
| 4301 | (setq buf-name (format "SQL-%s" product)) | 4317 | ;; otherwise, use *buf-name* |
| 4302 | (when (sql-buffer-live-p (format "*%s*" buf-name)) | 4318 | (if buf-name |
| 4303 | (let ((i 1)) | 4319 | (unless (string-match-p "\\`[*].*[*]\\'" buf-name) |
| 4304 | (while (sql-buffer-live-p | 4320 | (setq buf-name (concat "*" buf-name "*"))) |
| 4305 | (format "*%s*" | 4321 | (setq buf-name "*SQL*") |
| 4306 | (setq buf-name (format "SQL-%s%d" product i)))) | 4322 | (when (sql-buffer-live-p buf-name) |
| 4307 | (setq i (1+ i)))))) | 4323 | (setq buf-name (format "*SQL-%s*" product))) |
| 4308 | (set-buffer | 4324 | (let ((i 1)) |
| 4309 | (apply #'make-comint buf-name program nil params)))) | 4325 | (while (sql-buffer-live-p buf-name) |
| 4326 | (setq buf-name (format "*SQL-%s%d*" product i) | ||
| 4327 | i (1+ i))))) | ||
| 4328 | (set-text-properties 0 (length buf-name) nil buf-name) | ||
| 4329 | |||
| 4330 | ;; Start the command interpreter in the buffer | ||
| 4331 | ;; PROC-NAME is BUF-NAME without enclosing asterisks | ||
| 4332 | (let ((proc-name (replace-regexp-in-string "\\`[*]\\(.*\\)[*]\\'" "\\1" buf-name))) | ||
| 4333 | (set-buffer | ||
| 4334 | (apply #'make-comint-in-buffer | ||
| 4335 | proc-name buf-name program nil params))))) | ||
| 4310 | 4336 | ||
| 4311 | ;;;###autoload | 4337 | ;;;###autoload |
| 4312 | (defun sql-oracle (&optional buffer) | 4338 | (defun sql-oracle (&optional buffer) |
| @@ -4340,7 +4366,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4340 | (interactive "P") | 4366 | (interactive "P") |
| 4341 | (sql-product-interactive 'oracle buffer)) | 4367 | (sql-product-interactive 'oracle buffer)) |
| 4342 | 4368 | ||
| 4343 | (defun sql-comint-oracle (product options) | 4369 | (defun sql-comint-oracle (product options &optional buf-name) |
| 4344 | "Create comint buffer and connect to Oracle." | 4370 | "Create comint buffer and connect to Oracle." |
| 4345 | ;; Produce user/password@database construct. Password without user | 4371 | ;; Produce user/password@database construct. Password without user |
| 4346 | ;; is meaningless; database without user/password is meaningless, | 4372 | ;; is meaningless; database without user/password is meaningless, |
| @@ -4357,7 +4383,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4357 | (if parameter | 4383 | (if parameter |
| 4358 | (setq parameter (append options (list parameter))) | 4384 | (setq parameter (append options (list parameter))) |
| 4359 | (setq parameter options)) | 4385 | (setq parameter options)) |
| 4360 | (sql-comint product parameter) | 4386 | (sql-comint product parameter buf-name) |
| 4361 | ;; Set process coding system to agree with the interpreter | 4387 | ;; Set process coding system to agree with the interpreter |
| 4362 | (setq nlslang (or (getenv "NLS_LANG") "") | 4388 | (setq nlslang (or (getenv "NLS_LANG") "") |
| 4363 | coding (dolist (cs | 4389 | coding (dolist (cs |
| @@ -4454,20 +4480,25 @@ The default comes from `process-coding-system-alist' and | |||
| 4454 | ;; Restore the changed settings | 4480 | ;; Restore the changed settings |
| 4455 | (sql-redirect sqlbuf saved-settings)) | 4481 | (sql-redirect sqlbuf saved-settings)) |
| 4456 | 4482 | ||
| 4483 | (defun sql-oracle--list-object-name (obj-name) | ||
| 4484 | (format "CASE WHEN REGEXP_LIKE (%s, q'/^[A-Z0-9_#$]+$/','c') THEN %s ELSE '\"'|| %s ||'\"' END " | ||
| 4485 | obj-name obj-name obj-name)) | ||
| 4486 | |||
| 4457 | (defun sql-oracle-list-all (sqlbuf outbuf enhanced _table-name) | 4487 | (defun sql-oracle-list-all (sqlbuf outbuf enhanced _table-name) |
| 4458 | ;; Query from USER_OBJECTS or ALL_OBJECTS | 4488 | ;; Query from USER_OBJECTS or ALL_OBJECTS |
| 4459 | (let ((settings (sql-oracle-save-settings sqlbuf)) | 4489 | (let ((settings (sql-oracle-save-settings sqlbuf)) |
| 4460 | (simple-sql | 4490 | (simple-sql |
| 4461 | (concat | 4491 | (concat |
| 4462 | "SELECT INITCAP(x.object_type) AS SQL_EL_TYPE " | 4492 | "SELECT INITCAP(x.object_type) AS SQL_EL_TYPE " |
| 4463 | ", x.object_name AS SQL_EL_NAME " | 4493 | ", " (sql-oracle--list-object-name "x.object_name") " AS SQL_EL_NAME " |
| 4464 | "FROM user_objects x " | 4494 | "FROM user_objects x " |
| 4465 | "WHERE x.object_type NOT LIKE '%% BODY' " | 4495 | "WHERE x.object_type NOT LIKE '%% BODY' " |
| 4466 | "ORDER BY 2, 1;")) | 4496 | "ORDER BY 2, 1;")) |
| 4467 | (enhanced-sql | 4497 | (enhanced-sql |
| 4468 | (concat | 4498 | (concat |
| 4469 | "SELECT INITCAP(x.object_type) AS SQL_EL_TYPE " | 4499 | "SELECT INITCAP(x.object_type) AS SQL_EL_TYPE " |
| 4470 | ", x.owner ||'.'|| x.object_name AS SQL_EL_NAME " | 4500 | ", " (sql-oracle--list-object-name "x.owner") |
| 4501 | " ||'.'|| " (sql-oracle--list-object-name "x.object_name") " AS SQL_EL_NAME " | ||
| 4471 | "FROM all_objects x " | 4502 | "FROM all_objects x " |
| 4472 | "WHERE x.object_type NOT LIKE '%% BODY' " | 4503 | "WHERE x.object_type NOT LIKE '%% BODY' " |
| 4473 | "AND x.owner <> 'SYS' " | 4504 | "AND x.owner <> 'SYS' " |
| @@ -4524,9 +4555,15 @@ See the distinct values in ALL_OBJECTS.OBJECT_TYPE for possible values." | |||
| 4524 | (concat | 4555 | (concat |
| 4525 | "SELECT CHR(1)||" | 4556 | "SELECT CHR(1)||" |
| 4526 | (if schema | 4557 | (if schema |
| 4527 | (format "owner||'.'||object_name AS o FROM all_objects WHERE owner = %s AND " | 4558 | (concat "CASE WHEN REGEXP_LIKE (owner, q'/^[A-Z0-9_#$]+$/','c') THEN owner ELSE '\"'|| owner ||'\"' END " |
| 4528 | (sql-str-literal (upcase schema))) | 4559 | "||'.'||" |
| 4529 | "object_name AS o FROM user_objects WHERE ") | 4560 | "CASE WHEN REGEXP_LIKE (object_name, q'/^[A-Z0-9_#$]+$/','c') THEN object_name ELSE '\"'|| object_name ||'\"' END " |
| 4561 | " AS o FROM all_objects " | ||
| 4562 | (format "WHERE owner = %s AND " | ||
| 4563 | (sql-str-literal (if (string-match "^[\"]\\(.+\\)[\"]$" schema) | ||
| 4564 | (match-string 1 schema) (upcase schema))))) | ||
| 4565 | (concat "CASE WHEN REGEXP_LIKE (object_name, q'/^[A-Z0-9_#$]+$/','c') THEN object_name ELSE '\"'|| object_name ||'\"' END " | ||
| 4566 | " AS o FROM user_objects WHERE ")) | ||
| 4530 | "temporary = 'N' AND generated = 'N' AND secondary = 'N' AND " | 4567 | "temporary = 'N' AND generated = 'N' AND secondary = 'N' AND " |
| 4531 | "object_type IN (" | 4568 | "object_type IN (" |
| 4532 | (mapconcat (function sql-str-literal) sql-oracle-completion-types ",") | 4569 | (mapconcat (function sql-str-literal) sql-oracle-completion-types ",") |
| @@ -4566,7 +4603,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4566 | (interactive "P") | 4603 | (interactive "P") |
| 4567 | (sql-product-interactive 'sybase buffer)) | 4604 | (sql-product-interactive 'sybase buffer)) |
| 4568 | 4605 | ||
| 4569 | (defun sql-comint-sybase (product options) | 4606 | (defun sql-comint-sybase (product options &optional buf-name) |
| 4570 | "Create comint buffer and connect to Sybase." | 4607 | "Create comint buffer and connect to Sybase." |
| 4571 | ;; Put all parameters to the program (if defined) in a list and call | 4608 | ;; Put all parameters to the program (if defined) in a list and call |
| 4572 | ;; make-comint. | 4609 | ;; make-comint. |
| @@ -4581,7 +4618,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4581 | (if (not (string= "" sql-server)) | 4618 | (if (not (string= "" sql-server)) |
| 4582 | (list "-S" sql-server)) | 4619 | (list "-S" sql-server)) |
| 4583 | options))) | 4620 | options))) |
| 4584 | (sql-comint product params))) | 4621 | (sql-comint product params buf-name))) |
| 4585 | 4622 | ||
| 4586 | 4623 | ||
| 4587 | 4624 | ||
| @@ -4615,7 +4652,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4615 | (interactive "P") | 4652 | (interactive "P") |
| 4616 | (sql-product-interactive 'informix buffer)) | 4653 | (sql-product-interactive 'informix buffer)) |
| 4617 | 4654 | ||
| 4618 | (defun sql-comint-informix (product options) | 4655 | (defun sql-comint-informix (product options &optional buf-name) |
| 4619 | "Create comint buffer and connect to Informix." | 4656 | "Create comint buffer and connect to Informix." |
| 4620 | ;; username and password are ignored. | 4657 | ;; username and password are ignored. |
| 4621 | (let ((db (if (string= "" sql-database) | 4658 | (let ((db (if (string= "" sql-database) |
| @@ -4623,7 +4660,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4623 | (if (string= "" sql-server) | 4660 | (if (string= "" sql-server) |
| 4624 | sql-database | 4661 | sql-database |
| 4625 | (concat sql-database "@" sql-server))))) | 4662 | (concat sql-database "@" sql-server))))) |
| 4626 | (sql-comint product (append `(,db "-") options)))) | 4663 | (sql-comint product (append `(,db "-") options) buf-name))) |
| 4627 | 4664 | ||
| 4628 | 4665 | ||
| 4629 | 4666 | ||
| @@ -4661,7 +4698,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4661 | (interactive "P") | 4698 | (interactive "P") |
| 4662 | (sql-product-interactive 'sqlite buffer)) | 4699 | (sql-product-interactive 'sqlite buffer)) |
| 4663 | 4700 | ||
| 4664 | (defun sql-comint-sqlite (product options) | 4701 | (defun sql-comint-sqlite (product options &optional buf-name) |
| 4665 | "Create comint buffer and connect to SQLite." | 4702 | "Create comint buffer and connect to SQLite." |
| 4666 | ;; Put all parameters to the program (if defined) in a list and call | 4703 | ;; Put all parameters to the program (if defined) in a list and call |
| 4667 | ;; make-comint. | 4704 | ;; make-comint. |
| @@ -4669,7 +4706,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4669 | (append options | 4706 | (append options |
| 4670 | (if (not (string= "" sql-database)) | 4707 | (if (not (string= "" sql-database)) |
| 4671 | `(,(expand-file-name sql-database)))))) | 4708 | `(,(expand-file-name sql-database)))))) |
| 4672 | (sql-comint product params))) | 4709 | (sql-comint product params buf-name))) |
| 4673 | 4710 | ||
| 4674 | (defun sql-sqlite-completion-object (sqlbuf _schema) | 4711 | (defun sql-sqlite-completion-object (sqlbuf _schema) |
| 4675 | (sql-redirect-value sqlbuf ".tables" "\\sw\\(?:\\sw\\|\\s_\\)*" 0)) | 4712 | (sql-redirect-value sqlbuf ".tables" "\\sw\\(?:\\sw\\|\\s_\\)*" 0)) |
| @@ -4710,7 +4747,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4710 | (interactive "P") | 4747 | (interactive "P") |
| 4711 | (sql-product-interactive 'mysql buffer)) | 4748 | (sql-product-interactive 'mysql buffer)) |
| 4712 | 4749 | ||
| 4713 | (defun sql-comint-mysql (product options) | 4750 | (defun sql-comint-mysql (product options &optional buf-name) |
| 4714 | "Create comint buffer and connect to MySQL." | 4751 | "Create comint buffer and connect to MySQL." |
| 4715 | ;; Put all parameters to the program (if defined) in a list and call | 4752 | ;; Put all parameters to the program (if defined) in a list and call |
| 4716 | ;; make-comint. | 4753 | ;; make-comint. |
| @@ -4727,7 +4764,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4727 | (list (concat "--host=" sql-server))) | 4764 | (list (concat "--host=" sql-server))) |
| 4728 | (if (not (string= "" sql-database)) | 4765 | (if (not (string= "" sql-database)) |
| 4729 | (list sql-database))))) | 4766 | (list sql-database))))) |
| 4730 | (sql-comint product params))) | 4767 | (sql-comint product params buf-name))) |
| 4731 | 4768 | ||
| 4732 | 4769 | ||
| 4733 | 4770 | ||
| @@ -4762,7 +4799,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4762 | (interactive "P") | 4799 | (interactive "P") |
| 4763 | (sql-product-interactive 'solid buffer)) | 4800 | (sql-product-interactive 'solid buffer)) |
| 4764 | 4801 | ||
| 4765 | (defun sql-comint-solid (product options) | 4802 | (defun sql-comint-solid (product options &optional buf-name) |
| 4766 | "Create comint buffer and connect to Solid." | 4803 | "Create comint buffer and connect to Solid." |
| 4767 | ;; Put all parameters to the program (if defined) in a list and call | 4804 | ;; Put all parameters to the program (if defined) in a list and call |
| 4768 | ;; make-comint. | 4805 | ;; make-comint. |
| @@ -4775,7 +4812,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4775 | (string= "" sql-password))) | 4812 | (string= "" sql-password))) |
| 4776 | (list sql-user sql-password)) | 4813 | (list sql-user sql-password)) |
| 4777 | options))) | 4814 | options))) |
| 4778 | (sql-comint product params))) | 4815 | (sql-comint product params buf-name))) |
| 4779 | 4816 | ||
| 4780 | 4817 | ||
| 4781 | 4818 | ||
| @@ -4809,14 +4846,15 @@ The default comes from `process-coding-system-alist' and | |||
| 4809 | (interactive "P") | 4846 | (interactive "P") |
| 4810 | (sql-product-interactive 'ingres buffer)) | 4847 | (sql-product-interactive 'ingres buffer)) |
| 4811 | 4848 | ||
| 4812 | (defun sql-comint-ingres (product options) | 4849 | (defun sql-comint-ingres (product options &optional buf-name) |
| 4813 | "Create comint buffer and connect to Ingres." | 4850 | "Create comint buffer and connect to Ingres." |
| 4814 | ;; username and password are ignored. | 4851 | ;; username and password are ignored. |
| 4815 | (sql-comint product | 4852 | (sql-comint product |
| 4816 | (append (if (string= "" sql-database) | 4853 | (append (if (string= "" sql-database) |
| 4817 | nil | 4854 | nil |
| 4818 | (list sql-database)) | 4855 | (list sql-database)) |
| 4819 | options))) | 4856 | options) |
| 4857 | buf-name)) | ||
| 4820 | 4858 | ||
| 4821 | 4859 | ||
| 4822 | 4860 | ||
| @@ -4852,7 +4890,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4852 | (interactive "P") | 4890 | (interactive "P") |
| 4853 | (sql-product-interactive 'ms buffer)) | 4891 | (sql-product-interactive 'ms buffer)) |
| 4854 | 4892 | ||
| 4855 | (defun sql-comint-ms (product options) | 4893 | (defun sql-comint-ms (product options &optional buf-name) |
| 4856 | "Create comint buffer and connect to Microsoft SQL Server." | 4894 | "Create comint buffer and connect to Microsoft SQL Server." |
| 4857 | ;; Put all parameters to the program (if defined) in a list and call | 4895 | ;; Put all parameters to the program (if defined) in a list and call |
| 4858 | ;; make-comint. | 4896 | ;; make-comint. |
| @@ -4875,7 +4913,7 @@ The default comes from `process-coding-system-alist' and | |||
| 4875 | ;; If -P is passed to ISQL as the last argument without a | 4913 | ;; If -P is passed to ISQL as the last argument without a |
| 4876 | ;; password, it's considered null. | 4914 | ;; password, it's considered null. |
| 4877 | `(,@params "-P")))) | 4915 | `(,@params "-P")))) |
| 4878 | (sql-comint product params))) | 4916 | (sql-comint product params buf-name))) |
| 4879 | 4917 | ||
| 4880 | 4918 | ||
| 4881 | 4919 | ||
| @@ -4916,7 +4954,7 @@ Try to set `comint-output-filter-functions' like this: | |||
| 4916 | (interactive "P") | 4954 | (interactive "P") |
| 4917 | (sql-product-interactive 'postgres buffer)) | 4955 | (sql-product-interactive 'postgres buffer)) |
| 4918 | 4956 | ||
| 4919 | (defun sql-comint-postgres (product options) | 4957 | (defun sql-comint-postgres (product options &optional buf-name) |
| 4920 | "Create comint buffer and connect to Postgres." | 4958 | "Create comint buffer and connect to Postgres." |
| 4921 | ;; username and password are ignored. Mark Stosberg suggests to add | 4959 | ;; username and password are ignored. Mark Stosberg suggests to add |
| 4922 | ;; the database at the end. Jason Beegan suggests using --pset and | 4960 | ;; the database at the end. Jason Beegan suggests using --pset and |
| @@ -4934,7 +4972,7 @@ Try to set `comint-output-filter-functions' like this: | |||
| 4934 | options | 4972 | options |
| 4935 | (if (not (string= "" sql-database)) | 4973 | (if (not (string= "" sql-database)) |
| 4936 | (list sql-database))))) | 4974 | (list sql-database))))) |
| 4937 | (sql-comint product params))) | 4975 | (sql-comint product params buf-name))) |
| 4938 | 4976 | ||
| 4939 | (defun sql-postgres-completion-object (sqlbuf schema) | 4977 | (defun sql-postgres-completion-object (sqlbuf schema) |
| 4940 | (sql-redirect sqlbuf "\\t on") | 4978 | (sql-redirect sqlbuf "\\t on") |
| @@ -5004,7 +5042,7 @@ The default comes from `process-coding-system-alist' and | |||
| 5004 | (interactive "P") | 5042 | (interactive "P") |
| 5005 | (sql-product-interactive 'interbase buffer)) | 5043 | (sql-product-interactive 'interbase buffer)) |
| 5006 | 5044 | ||
| 5007 | (defun sql-comint-interbase (product options) | 5045 | (defun sql-comint-interbase (product options &optional buf-name) |
| 5008 | "Create comint buffer and connect to Interbase." | 5046 | "Create comint buffer and connect to Interbase." |
| 5009 | ;; Put all parameters to the program (if defined) in a list and call | 5047 | ;; Put all parameters to the program (if defined) in a list and call |
| 5010 | ;; make-comint. | 5048 | ;; make-comint. |
| @@ -5017,7 +5055,7 @@ The default comes from `process-coding-system-alist' and | |||
| 5017 | (if (not (string= "" sql-user)) | 5055 | (if (not (string= "" sql-user)) |
| 5018 | (list "-u" sql-user)) | 5056 | (list "-u" sql-user)) |
| 5019 | options))) | 5057 | options))) |
| 5020 | (sql-comint product params))) | 5058 | (sql-comint product params buf-name))) |
| 5021 | 5059 | ||
| 5022 | 5060 | ||
| 5023 | 5061 | ||
| @@ -5056,11 +5094,11 @@ The default comes from `process-coding-system-alist' and | |||
| 5056 | (interactive "P") | 5094 | (interactive "P") |
| 5057 | (sql-product-interactive 'db2 buffer)) | 5095 | (sql-product-interactive 'db2 buffer)) |
| 5058 | 5096 | ||
| 5059 | (defun sql-comint-db2 (product options) | 5097 | (defun sql-comint-db2 (product options &optional buf-name) |
| 5060 | "Create comint buffer and connect to DB2." | 5098 | "Create comint buffer and connect to DB2." |
| 5061 | ;; Put all parameters to the program (if defined) in a list and call | 5099 | ;; Put all parameters to the program (if defined) in a list and call |
| 5062 | ;; make-comint. | 5100 | ;; make-comint. |
| 5063 | (sql-comint product options)) | 5101 | (sql-comint product options buf-name)) |
| 5064 | 5102 | ||
| 5065 | ;;;###autoload | 5103 | ;;;###autoload |
| 5066 | (defun sql-linter (&optional buffer) | 5104 | (defun sql-linter (&optional buffer) |
| @@ -5094,7 +5132,7 @@ buffer. | |||
| 5094 | (interactive "P") | 5132 | (interactive "P") |
| 5095 | (sql-product-interactive 'linter buffer)) | 5133 | (sql-product-interactive 'linter buffer)) |
| 5096 | 5134 | ||
| 5097 | (defun sql-comint-linter (product options) | 5135 | (defun sql-comint-linter (product options &optional buf-name) |
| 5098 | "Create comint buffer and connect to Linter." | 5136 | "Create comint buffer and connect to Linter." |
| 5099 | ;; Put all parameters to the program (if defined) in a list and call | 5137 | ;; Put all parameters to the program (if defined) in a list and call |
| 5100 | ;; make-comint. | 5138 | ;; make-comint. |
| @@ -5109,7 +5147,7 @@ buffer. | |||
| 5109 | options))) | 5147 | options))) |
| 5110 | (cl-letf (((getenv "LINTER_MBX") | 5148 | (cl-letf (((getenv "LINTER_MBX") |
| 5111 | (unless (string= "" sql-database) sql-database))) | 5149 | (unless (string= "" sql-database) sql-database))) |
| 5112 | (sql-comint product params)))) | 5150 | (sql-comint product params buf-name)))) |
| 5113 | 5151 | ||
| 5114 | 5152 | ||
| 5115 | 5153 | ||
| @@ -5132,7 +5170,7 @@ The default value disables the internal pager." | |||
| 5132 | :type 'sql-login-params | 5170 | :type 'sql-login-params |
| 5133 | :group 'SQL) | 5171 | :group 'SQL) |
| 5134 | 5172 | ||
| 5135 | (defun sql-comint-vertica (product options) | 5173 | (defun sql-comint-vertica (product options &optional buf-name) |
| 5136 | "Create comint buffer and connect to Vertica." | 5174 | "Create comint buffer and connect to Vertica." |
| 5137 | (sql-comint product | 5175 | (sql-comint product |
| 5138 | (nconc | 5176 | (nconc |
| @@ -5144,7 +5182,8 @@ The default value disables the internal pager." | |||
| 5144 | (list "-w" sql-password)) | 5182 | (list "-w" sql-password)) |
| 5145 | (and (not (string= "" sql-user)) | 5183 | (and (not (string= "" sql-user)) |
| 5146 | (list "-U" sql-user)) | 5184 | (list "-U" sql-user)) |
| 5147 | options))) | 5185 | options) |
| 5186 | buf-name)) | ||
| 5148 | 5187 | ||
| 5149 | ;;;###autoload | 5188 | ;;;###autoload |
| 5150 | (defun sql-vertica (&optional buffer) | 5189 | (defun sql-vertica (&optional buffer) |