diff options
| author | Kenichi Handa | 2010-09-16 11:11:13 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2010-09-16 11:11:13 +0900 |
| commit | 38d50547c2a8195bed0aaeafbbc4c0f277d4e416 (patch) | |
| tree | 388416c9f2cc4746d0d2d9e525a50a6c2f00f3d4 /lisp/progmodes/sql.el | |
| parent | fa3f60399014127e711f3f438004950cba0bddb9 (diff) | |
| parent | 6139f995addcb8fce63deb30c7ed0e6f2b618b02 (diff) | |
| download | emacs-38d50547c2a8195bed0aaeafbbc4c0f277d4e416.tar.gz emacs-38d50547c2a8195bed0aaeafbbc4c0f277d4e416.zip | |
merge trunk
Diffstat (limited to 'lisp/progmodes/sql.el')
| -rw-r--r-- | lisp/progmodes/sql.el | 701 |
1 files changed, 487 insertions, 214 deletions
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index e44504688f2..e9860c5fa71 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | ;; Author: Alex Schroeder <alex@gnu.org> | 6 | ;; Author: Alex Schroeder <alex@gnu.org> |
| 7 | ;; Maintainer: Michael Mauger <mmaug@yahoo.com> | 7 | ;; Maintainer: Michael Mauger <mmaug@yahoo.com> |
| 8 | ;; Version: 2.5 | 8 | ;; Version: 2.7 |
| 9 | ;; Keywords: comm languages processes | 9 | ;; Keywords: comm languages processes |
| 10 | ;; URL: http://savannah.gnu.org/cgi-bin/viewcvs/emacs/emacs/lisp/progmodes/sql.el | 10 | ;; URL: http://savannah.gnu.org/cgi-bin/viewcvs/emacs/emacs/lisp/progmodes/sql.el |
| 11 | ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode | 11 | ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?SqlMode |
| @@ -187,10 +187,10 @@ | |||
| 187 | 187 | ||
| 188 | ;; 6) Define a convienence function to invoke the SQL interpreter. | 188 | ;; 6) Define a convienence function to invoke the SQL interpreter. |
| 189 | 189 | ||
| 190 | ;; (defun my-sql-xyz () | 190 | ;; (defun my-sql-xyz (&optional buffer) |
| 191 | ;; "Run ixyz by XyzDB as an inferior process." | 191 | ;; "Run ixyz by XyzDB as an inferior process." |
| 192 | ;; (interactive) | 192 | ;; (interactive "P") |
| 193 | ;; (sql-product-interactive 'xyz)) | 193 | ;; (sql-product-interactive 'xyz buffer)) |
| 194 | 194 | ||
| 195 | ;;; To Do: | 195 | ;;; To Do: |
| 196 | 196 | ||
| @@ -275,8 +275,8 @@ Customizing your password will store it in your ~/.emacs file." | |||
| 275 | :group 'SQL | 275 | :group 'SQL |
| 276 | :safe 'stringp) | 276 | :safe 'stringp) |
| 277 | 277 | ||
| 278 | (defcustom sql-port nil | 278 | (defcustom sql-port 0 |
| 279 | "Default server or host." | 279 | "Default port." |
| 280 | :version "24.1" | 280 | :version "24.1" |
| 281 | :type 'number | 281 | :type 'number |
| 282 | :group 'SQL | 282 | :group 'SQL |
| @@ -430,9 +430,9 @@ Customizing your password will store it in your ~/.emacs file." | |||
| 430 | :sqli-comint-func sql-comint-postgres | 430 | :sqli-comint-func sql-comint-postgres |
| 431 | :prompt-regexp "^.*=[#>] " | 431 | :prompt-regexp "^.*=[#>] " |
| 432 | :prompt-length 5 | 432 | :prompt-length 5 |
| 433 | :prompt-cont-regexp "^.*-[#>] " | 433 | :prompt-cont-regexp "^.*[-(][#>] " |
| 434 | :input-filter sql-remove-tabs-filter | 434 | :input-filter sql-remove-tabs-filter |
| 435 | :terminator ("\\(^[\\]g\\|;\\)" . ";")) | 435 | :terminator ("\\(^\\s-*\\\\g\\|;\\)" . ";")) |
| 436 | 436 | ||
| 437 | (solid | 437 | (solid |
| 438 | :name "Solid" | 438 | :name "Solid" |
| @@ -551,7 +551,6 @@ settings.") | |||
| 551 | (defvar sql-indirect-features | 551 | (defvar sql-indirect-features |
| 552 | '(:font-lock :sqli-program :sqli-options :sqli-login)) | 552 | '(:font-lock :sqli-program :sqli-options :sqli-login)) |
| 553 | 553 | ||
| 554 | ;;;###autoload | ||
| 555 | (defcustom sql-connection-alist nil | 554 | (defcustom sql-connection-alist nil |
| 556 | "An alist of connection parameters for interacting with a SQL | 555 | "An alist of connection parameters for interacting with a SQL |
| 557 | product. | 556 | product. |
| @@ -600,7 +599,6 @@ prompted for during login." | |||
| 600 | :version "24.1" | 599 | :version "24.1" |
| 601 | :group 'SQL) | 600 | :group 'SQL) |
| 602 | 601 | ||
| 603 | ;;;###autoload | ||
| 604 | (defcustom sql-product 'ansi | 602 | (defcustom sql-product 'ansi |
| 605 | "Select the SQL database product used so that buffers can be | 603 | "Select the SQL database product used so that buffers can be |
| 606 | highlighted properly when you open them." | 604 | highlighted properly when you open them." |
| @@ -613,6 +611,7 @@ highlighted properly when you open them." | |||
| 613 | sql-product-alist)) | 611 | sql-product-alist)) |
| 614 | :group 'SQL | 612 | :group 'SQL |
| 615 | :safe 'symbolp) | 613 | :safe 'symbolp) |
| 614 | (defvaralias 'sql-dialect 'sql-product) | ||
| 616 | 615 | ||
| 617 | ;; misc customization of sql.el behaviour | 616 | ;; misc customization of sql.el behaviour |
| 618 | 617 | ||
| @@ -788,7 +787,9 @@ to be safe: | |||
| 788 | 787 | ||
| 789 | ;; Customization for SQLite | 788 | ;; Customization for SQLite |
| 790 | 789 | ||
| 791 | (defcustom sql-sqlite-program "sqlite3" | 790 | (defcustom sql-sqlite-program (or (executable-find "sqlite3") |
| 791 | (executable-find "sqlite") | ||
| 792 | "sqlite") | ||
| 792 | "Command to start SQLite. | 793 | "Command to start SQLite. |
| 793 | 794 | ||
| 794 | Starts `sql-interactive-mode' after doing some setup." | 795 | Starts `sql-interactive-mode' after doing some setup." |
| @@ -801,7 +802,7 @@ Starts `sql-interactive-mode' after doing some setup." | |||
| 801 | :version "20.8" | 802 | :version "20.8" |
| 802 | :group 'SQL) | 803 | :group 'SQL) |
| 803 | 804 | ||
| 804 | (defcustom sql-sqlite-login-params '((database :file ".*\\.db")) | 805 | (defcustom sql-sqlite-login-params '((database :file ".*\\.\\(db\\|sqlite[23]?\\)")) |
| 805 | "List of login parameters needed to connect to SQLite." | 806 | "List of login parameters needed to connect to SQLite." |
| 806 | :type 'sql-login-params | 807 | :type 'sql-login-params |
| 807 | :version "24.1" | 808 | :version "24.1" |
| @@ -1022,9 +1023,6 @@ Starts `sql-interactive-mode' after doing some setup." | |||
| 1022 | (defvar sql-server-history nil | 1023 | (defvar sql-server-history nil |
| 1023 | "History of servers used.") | 1024 | "History of servers used.") |
| 1024 | 1025 | ||
| 1025 | (defvar sql-port-history nil | ||
| 1026 | "History of ports used.") | ||
| 1027 | |||
| 1028 | ;; Passwords are not kept in a history. | 1026 | ;; Passwords are not kept in a history. |
| 1029 | 1027 | ||
| 1030 | (defvar sql-buffer nil | 1028 | (defvar sql-buffer nil |
| @@ -1054,6 +1052,25 @@ You can change `sql-prompt-length' on `sql-interactive-mode-hook'.") | |||
| 1054 | 1052 | ||
| 1055 | Used by `sql-rename-buffer'.") | 1053 | Used by `sql-rename-buffer'.") |
| 1056 | 1054 | ||
| 1055 | (defun sql-buffer-live-p (buffer &optional product) | ||
| 1056 | "Returns non-nil if the process associated with buffer is live. | ||
| 1057 | |||
| 1058 | BUFFER can be a buffer object or a buffer name. The buffer must | ||
| 1059 | be a live buffer, have an running process attached to it, be in | ||
| 1060 | `sql-interactive-mode', and, if PRODUCT is specified, it's | ||
| 1061 | `sql-product' must match." | ||
| 1062 | |||
| 1063 | (when buffer | ||
| 1064 | (setq buffer (get-buffer buffer)) | ||
| 1065 | (and buffer | ||
| 1066 | (buffer-live-p buffer) | ||
| 1067 | (get-buffer-process buffer) | ||
| 1068 | (comint-check-proc buffer) | ||
| 1069 | (with-current-buffer buffer | ||
| 1070 | (and (derived-mode-p 'sql-product-interactive) | ||
| 1071 | (or (not product) | ||
| 1072 | (eq product sql-product))))))) | ||
| 1073 | |||
| 1057 | ;; Keymap for sql-interactive-mode. | 1074 | ;; Keymap for sql-interactive-mode. |
| 1058 | 1075 | ||
| 1059 | (defvar sql-interactive-mode-map | 1076 | (defvar sql-interactive-mode-map |
| @@ -1091,15 +1108,11 @@ Based on `comint-mode-map'.") | |||
| 1091 | sql-mode-menu sql-mode-map | 1108 | sql-mode-menu sql-mode-map |
| 1092 | "Menu for `sql-mode'." | 1109 | "Menu for `sql-mode'." |
| 1093 | `("SQL" | 1110 | `("SQL" |
| 1094 | ["Send Paragraph" sql-send-paragraph (and (buffer-live-p sql-buffer) | 1111 | ["Send Paragraph" sql-send-paragraph (sql-buffer-live-p sql-buffer)] |
| 1095 | (get-buffer-process sql-buffer))] | ||
| 1096 | ["Send Region" sql-send-region (and mark-active | 1112 | ["Send Region" sql-send-region (and mark-active |
| 1097 | (buffer-live-p sql-buffer) | 1113 | (sql-buffer-live-p sql-buffer))] |
| 1098 | (get-buffer-process sql-buffer))] | 1114 | ["Send Buffer" sql-send-buffer (sql-buffer-live-p sql-buffer)] |
| 1099 | ["Send Buffer" sql-send-buffer (and (buffer-live-p sql-buffer) | 1115 | ["Send String" sql-send-string (sql-buffer-live-p sql-buffer)] |
| 1100 | (get-buffer-process sql-buffer))] | ||
| 1101 | ["Send String" sql-send-string (and (buffer-live-p sql-buffer) | ||
| 1102 | (get-buffer-process sql-buffer))] | ||
| 1103 | "--" | 1116 | "--" |
| 1104 | ["Start SQLi session" sql-product-interactive | 1117 | ["Start SQLi session" sql-product-interactive |
| 1105 | :visible (not sql-connection-alist) | 1118 | :visible (not sql-connection-alist) |
| @@ -1364,7 +1377,7 @@ to add functions and PL/SQL keywords.") | |||
| 1364 | ;; Oracle SQL*Plus Commands | 1377 | ;; Oracle SQL*Plus Commands |
| 1365 | (cons | 1378 | (cons |
| 1366 | (concat | 1379 | (concat |
| 1367 | "^\\(?:\\(?:" (regexp-opt '( | 1380 | "^\\s-*\\(?:\\(?:" (regexp-opt '( |
| 1368 | "@" "@@" "accept" "append" "archive" "attribute" "break" | 1381 | "@" "@@" "accept" "append" "archive" "attribute" "break" |
| 1369 | "btitle" "change" "clear" "column" "connect" "copy" "define" | 1382 | "btitle" "change" "clear" "column" "connect" "copy" "define" |
| 1370 | "del" "describe" "disconnect" "edit" "execute" "exit" "get" "help" | 1383 | "del" "describe" "disconnect" "edit" "execute" "exit" "get" "help" |
| @@ -1403,7 +1416,7 @@ to add functions and PL/SQL keywords.") | |||
| 1403 | "\\)\\b.*" | 1416 | "\\)\\b.*" |
| 1404 | ) | 1417 | ) |
| 1405 | 'font-lock-doc-face) | 1418 | 'font-lock-doc-face) |
| 1406 | '("^[ \t]*rem\\(?:ark\\)?.*" . font-lock-comment-face) | 1419 | '("^\\s-*rem\\(?:ark\\)?\\>.*" . font-lock-comment-face) |
| 1407 | 1420 | ||
| 1408 | ;; Oracle Functions | 1421 | ;; Oracle Functions |
| 1409 | (sql-font-lock-keywords-builder 'font-lock-builtin-face nil | 1422 | (sql-font-lock-keywords-builder 'font-lock-builtin-face nil |
| @@ -1585,81 +1598,153 @@ to add functions and PL/SQL keywords.") | |||
| 1585 | (defvar sql-mode-postgres-font-lock-keywords | 1598 | (defvar sql-mode-postgres-font-lock-keywords |
| 1586 | (eval-when-compile | 1599 | (eval-when-compile |
| 1587 | (list | 1600 | (list |
| 1588 | ;; Postgres Functions | 1601 | ;; Postgres psql commands |
| 1602 | '("^\\s-*\\\\.*$" . font-lock-doc-face) | ||
| 1603 | |||
| 1604 | ;; Postgres unreserved words but may have meaning | ||
| 1605 | (sql-font-lock-keywords-builder 'font-lock-builtin-face nil "a" | ||
| 1606 | "abs" "absent" "according" "ada" "alias" "allocate" "are" "array_agg" | ||
| 1607 | "asensitive" "atomic" "attribute" "attributes" "avg" "base64" | ||
| 1608 | "bernoulli" "bit_length" "bitvar" "blob" "blocked" "bom" "breadth" "c" | ||
| 1609 | "call" "cardinality" "catalog_name" "ceil" "ceiling" "char_length" | ||
| 1610 | "character_length" "character_set_catalog" "character_set_name" | ||
| 1611 | "character_set_schema" "characters" "checked" "class_origin" "clob" | ||
| 1612 | "cobol" "collation" "collation_catalog" "collation_name" | ||
| 1613 | "collation_schema" "collect" "column_name" "columns" | ||
| 1614 | "command_function" "command_function_code" "completion" "condition" | ||
| 1615 | "condition_number" "connect" "connection_name" "constraint_catalog" | ||
| 1616 | "constraint_name" "constraint_schema" "constructor" "contains" | ||
| 1617 | "control" "convert" "corr" "corresponding" "count" "covar_pop" | ||
| 1618 | "covar_samp" "cube" "cume_dist" "current_default_transform_group" | ||
| 1619 | "current_path" "current_transform_group_for_type" "cursor_name" | ||
| 1620 | "datalink" "datetime_interval_code" "datetime_interval_precision" "db" | ||
| 1621 | "defined" "degree" "dense_rank" "depth" "deref" "derived" "describe" | ||
| 1622 | "descriptor" "destroy" "destructor" "deterministic" "diagnostics" | ||
| 1623 | "disconnect" "dispatch" "dlnewcopy" "dlpreviouscopy" "dlurlcomplete" | ||
| 1624 | "dlurlcompleteonly" "dlurlcompletewrite" "dlurlpath" "dlurlpathonly" | ||
| 1625 | "dlurlpathwrite" "dlurlscheme" "dlurlserver" "dlvalue" "dynamic" | ||
| 1626 | "dynamic_function" "dynamic_function_code" "element" "empty" | ||
| 1627 | "end-exec" "equals" "every" "exception" "exec" "existing" "exp" "file" | ||
| 1628 | "filter" "final" "first_value" "flag" "floor" "fortran" "found" "free" | ||
| 1629 | "fs" "fusion" "g" "general" "generated" "get" "go" "goto" "grouping" | ||
| 1630 | "hex" "hierarchy" "host" "id" "ignore" "implementation" "import" | ||
| 1631 | "indent" "indicator" "infix" "initialize" "instance" "instantiable" | ||
| 1632 | "integrity" "intersection" "iterate" "k" "key_member" "key_type" "lag" | ||
| 1633 | "last_value" "lateral" "lead" "length" "less" "library" "like_regex" | ||
| 1634 | "link" "ln" "locator" "lower" "m" "map" "matched" "max" | ||
| 1635 | "max_cardinality" "member" "merge" "message_length" | ||
| 1636 | "message_octet_length" "message_text" "method" "min" "mod" "modifies" | ||
| 1637 | "modify" "module" "more" "multiset" "mumps" "namespace" "nclob" | ||
| 1638 | "nesting" "new" "nfc" "nfd" "nfkc" "nfkd" "nil" "normalize" | ||
| 1639 | "normalized" "nth_value" "ntile" "nullable" "number" | ||
| 1640 | "occurrences_regex" "octet_length" "octets" "old" "open" "operation" | ||
| 1641 | "ordering" "ordinality" "others" "output" "overriding" "p" "pad" | ||
| 1642 | "parameter" "parameter_mode" "parameter_name" | ||
| 1643 | "parameter_ordinal_position" "parameter_specific_catalog" | ||
| 1644 | "parameter_specific_name" "parameter_specific_schema" "parameters" | ||
| 1645 | "pascal" "passing" "passthrough" "percent_rank" "percentile_cont" | ||
| 1646 | "percentile_disc" "permission" "pli" "position_regex" "postfix" | ||
| 1647 | "power" "prefix" "preorder" "public" "rank" "reads" "recovery" "ref" | ||
| 1648 | "referencing" "regr_avgx" "regr_avgy" "regr_count" "regr_intercept" | ||
| 1649 | "regr_r2" "regr_slope" "regr_sxx" "regr_sxy" "regr_syy" "requiring" | ||
| 1650 | "respect" "restore" "result" "return" "returned_cardinality" | ||
| 1651 | "returned_length" "returned_octet_length" "returned_sqlstate" "rollup" | ||
| 1652 | "routine" "routine_catalog" "routine_name" "routine_schema" | ||
| 1653 | "row_count" "row_number" "scale" "schema_name" "scope" "scope_catalog" | ||
| 1654 | "scope_name" "scope_schema" "section" "selective" "self" "sensitive" | ||
| 1655 | "server_name" "sets" "size" "source" "space" "specific" | ||
| 1656 | "specific_name" "specifictype" "sql" "sqlcode" "sqlerror" | ||
| 1657 | "sqlexception" "sqlstate" "sqlwarning" "sqrt" "state" "static" | ||
| 1658 | "stddev_pop" "stddev_samp" "structure" "style" "subclass_origin" | ||
| 1659 | "sublist" "submultiset" "substring_regex" "sum" "system_user" "t" | ||
| 1660 | "table_name" "tablesample" "terminate" "than" "ties" "timezone_hour" | ||
| 1661 | "timezone_minute" "token" "top_level_count" "transaction_active" | ||
| 1662 | "transactions_committed" "transactions_rolled_back" "transform" | ||
| 1663 | "transforms" "translate" "translate_regex" "translation" | ||
| 1664 | "trigger_catalog" "trigger_name" "trigger_schema" "trim_array" | ||
| 1665 | "uescape" "under" "unlink" "unnamed" "unnest" "untyped" "upper" "uri" | ||
| 1666 | "usage" "user_defined_type_catalog" "user_defined_type_code" | ||
| 1667 | "user_defined_type_name" "user_defined_type_schema" "var_pop" | ||
| 1668 | "var_samp" "varbinary" "variable" "whenever" "width_bucket" "within" | ||
| 1669 | "xmlagg" "xmlbinary" "xmlcast" "xmlcomment" "xmldeclaration" | ||
| 1670 | "xmldocument" "xmlexists" "xmliterate" "xmlnamespaces" "xmlquery" | ||
| 1671 | "xmlschema" "xmltable" "xmltext" "xmlvalidate" | ||
| 1672 | ) | ||
| 1673 | |||
| 1674 | ;; Postgres non-reserved words | ||
| 1589 | (sql-font-lock-keywords-builder 'font-lock-builtin-face nil | 1675 | (sql-font-lock-keywords-builder 'font-lock-builtin-face nil |
| 1590 | "abbrev" "abs" "acos" "age" "area" "ascii" "asin" "atab2" "atan" | 1676 | "abort" "absolute" "access" "action" "add" "admin" "after" "aggregate" |
| 1591 | "atan2" "avg" "bit_length" "both" "broadcast" "btrim" "cbrt" "ceil" | 1677 | "also" "alter" "always" "assertion" "assignment" "at" "backward" |
| 1592 | "center" "char_length" "chr" "coalesce" "col_description" "convert" | 1678 | "before" "begin" "between" "by" "cache" "called" "cascade" "cascaded" |
| 1593 | "cos" "cot" "count" "current_database" "current_date" "current_schema" | 1679 | "catalog" "chain" "characteristics" "checkpoint" "class" "close" |
| 1594 | "current_schemas" "current_setting" "current_time" "current_timestamp" | 1680 | "cluster" "coalesce" "comment" "comments" "commit" "committed" |
| 1595 | "current_user" "currval" "date_part" "date_trunc" "decode" "degrees" | 1681 | "configuration" "connection" "constraints" "content" "continue" |
| 1596 | "diameter" "encode" "exp" "extract" "floor" "get_bit" "get_byte" | 1682 | "conversion" "copy" "cost" "createdb" "createrole" "createuser" "csv" |
| 1597 | "has_database_privilege" "has_function_privilege" | 1683 | "current" "cursor" "cycle" "data" "database" "day" "deallocate" "dec" |
| 1598 | "has_language_privilege" "has_schema_privilege" "has_table_privilege" | 1684 | "declare" "defaults" "deferred" "definer" "delete" "delimiter" |
| 1599 | "height" "host" "initcap" "isclosed" "isfinite" "isopen" "leading" | 1685 | "delimiters" "dictionary" "disable" "discard" "document" "domain" |
| 1600 | "length" "ln" "localtime" "localtimestamp" "log" "lower" "lpad" | 1686 | "drop" "each" "enable" "encoding" "encrypted" "enum" "escape" |
| 1601 | "ltrim" "masklen" "max" "min" "mod" "netmask" "network" "nextval" | 1687 | "exclude" "excluding" "exclusive" "execute" "exists" "explain" |
| 1602 | "now" "npoints" "nullif" "obj_description" "octet_length" "overlay" | 1688 | "external" "extract" "family" "first" "float" "following" "force" |
| 1603 | "pclose" "pg_client_encoding" "pg_function_is_visible" | 1689 | "forward" "function" "functions" "global" "granted" "greatest" |
| 1604 | "pg_get_constraintdef" "pg_get_indexdef" "pg_get_ruledef" | 1690 | "handler" "header" "hold" "hour" "identity" "if" "immediate" |
| 1605 | "pg_get_userbyid" "pg_get_viewdef" "pg_opclass_is_visible" | 1691 | "immutable" "implicit" "including" "increment" "index" "indexes" |
| 1606 | "pg_operator_is_visible" "pg_table_is_visible" "pg_type_is_visible" | 1692 | "inherit" "inherits" "inline" "inout" "input" "insensitive" "insert" |
| 1607 | "pi" "popen" "position" "pow" "quote_ident" "quote_literal" "radians" | 1693 | "instead" "invoker" "isolation" "key" "language" "large" "last" |
| 1608 | "radius" "random" "repeat" "replace" "round" "rpad" "rtrim" | 1694 | "lc_collate" "lc_ctype" "least" "level" "listen" "load" "local" |
| 1609 | "session_user" "set_bit" "set_byte" "set_config" "set_masklen" | 1695 | "location" "lock" "login" "mapping" "match" "maxvalue" "minute" |
| 1610 | "setval" "sign" "sin" "split_part" "sqrt" "stddev" "strpos" "substr" | 1696 | "minvalue" "mode" "month" "move" "name" "names" "national" "nchar" |
| 1611 | "substring" "sum" "tan" "timeofday" "to_ascii" "to_char" "to_date" | 1697 | "next" "no" "nocreatedb" "nocreaterole" "nocreateuser" "noinherit" |
| 1612 | "to_hex" "to_number" "to_timestamp" "trailing" "translate" "trim" | 1698 | "nologin" "none" "nosuperuser" "nothing" "notify" "nowait" "nullif" |
| 1613 | "trunc" "upper" "variance" "version" "width" | 1699 | "nulls" "object" "of" "oids" "operator" "option" "options" "out" |
| 1700 | "overlay" "owned" "owner" "parser" "partial" "partition" "password" | ||
| 1701 | "plans" "position" "preceding" "prepare" "prepared" "preserve" "prior" | ||
| 1702 | "privileges" "procedural" "procedure" "quote" "range" "read" | ||
| 1703 | "reassign" "recheck" "recursive" "reindex" "relative" "release" | ||
| 1704 | "rename" "repeatable" "replace" "replica" "reset" "restart" "restrict" | ||
| 1705 | "returns" "revoke" "role" "rollback" "row" "rows" "rule" "savepoint" | ||
| 1706 | "schema" "scroll" "search" "second" "security" "sequence" "sequences" | ||
| 1707 | "serializable" "server" "session" "set" "setof" "share" "show" | ||
| 1708 | "simple" "stable" "standalone" "start" "statement" "statistics" | ||
| 1709 | "stdin" "stdout" "storage" "strict" "strip" "substring" "superuser" | ||
| 1710 | "sysid" "system" "tables" "tablespace" "temp" "template" "temporary" | ||
| 1711 | "transaction" "treat" "trigger" "trim" "truncate" "trusted" "type" | ||
| 1712 | "unbounded" "uncommitted" "unencrypted" "unknown" "unlisten" "until" | ||
| 1713 | "update" "vacuum" "valid" "validator" "value" "values" "version" | ||
| 1714 | "view" "volatile" "whitespace" "work" "wrapper" "write" | ||
| 1715 | "xmlattributes" "xmlconcat" "xmlelement" "xmlforest" "xmlparse" | ||
| 1716 | "xmlpi" "xmlroot" "xmlserialize" "year" "yes" | ||
| 1614 | ) | 1717 | ) |
| 1718 | |||
| 1615 | ;; Postgres Reserved | 1719 | ;; Postgres Reserved |
| 1616 | (sql-font-lock-keywords-builder 'font-lock-keyword-face nil | 1720 | (sql-font-lock-keywords-builder 'font-lock-keyword-face nil |
| 1617 | "abort" "access" "add" "after" "aggregate" "alignment" "all" "alter" | 1721 | "all" "analyse" "analyze" "and" "any" "array" "asc" "as" "asymmetric" |
| 1618 | "analyze" "and" "any" "as" "asc" "assignment" "authorization" | 1722 | "authorization" "binary" "both" "case" "cast" "check" "collate" |
| 1619 | "backward" "basetype" "before" "begin" "between" "binary" "by" "cache" | 1723 | "column" "concurrently" "constraint" "create" "cross" |
| 1620 | "called" "cascade" "case" "cast" "characteristics" "check" | 1724 | "current_catalog" "current_date" "current_role" "current_schema" |
| 1621 | "checkpoint" "class" "close" "cluster" "column" "comment" "commit" | 1725 | "current_time" "current_timestamp" "current_user" "default" |
| 1622 | "committed" "commutator" "constraint" "constraints" "conversion" | 1726 | "deferrable" "desc" "distinct" "do" "else" "end" "except" "false" |
| 1623 | "copy" "create" "createdb" "createuser" "cursor" "cycle" "database" | 1727 | "fetch" "foreign" "for" "freeze" "from" "full" "grant" "group" |
| 1624 | "deallocate" "declare" "default" "deferrable" "deferred" "definer" | 1728 | "having" "ilike" "initially" "inner" "in" "intersect" "into" "isnull" |
| 1625 | "delete" "delimiter" "desc" "distinct" "do" "domain" "drop" "each" | 1729 | "is" "join" "leading" "left" "like" "limit" "localtime" |
| 1626 | "element" "else" "encoding" "encrypted" "end" "escape" "except" | 1730 | "localtimestamp" "natural" "notnull" "not" "null" "off" "offset" |
| 1627 | "exclusive" "execute" "exists" "explain" "extended" "external" "false" | 1731 | "only" "on" "order" "or" "outer" "overlaps" "over" "placing" "primary" |
| 1628 | "fetch" "finalfunc" "for" "force" "foreign" "forward" "freeze" "from" | 1732 | "references" "returning" "right" "select" "session_user" "similar" |
| 1629 | "full" "function" "grant" "group" "gtcmp" "handler" "hashes" "having" | 1733 | "some" "symmetric" "table" "then" "to" "trailing" "true" "union" |
| 1630 | "immediate" "immutable" "implicit" "in" "increment" "index" "inherits" | 1734 | "unique" "user" "using" "variadic" "verbose" "when" "where" "window" |
| 1631 | "initcond" "initially" "input" "insensitive" "insert" "instead" | 1735 | "with" |
| 1632 | "internallength" "intersect" "into" "invoker" "is" "isnull" | ||
| 1633 | "isolation" "join" "key" "language" "leftarg" "level" "like" "limit" | ||
| 1634 | "listen" "load" "local" "location" "lock" "ltcmp" "main" "match" | ||
| 1635 | "maxvalue" "merges" "minvalue" "mode" "move" "natural" "negator" | ||
| 1636 | "next" "nocreatedb" "nocreateuser" "none" "not" "nothing" "notify" | ||
| 1637 | "notnull" "null" "of" "offset" "oids" "on" "only" "operator" "or" | ||
| 1638 | "order" "output" "owner" "partial" "passedbyvalue" "password" "plain" | ||
| 1639 | "prepare" "primary" "prior" "privileges" "procedural" "procedure" | ||
| 1640 | "public" "read" "recheck" "references" "reindex" "relative" "rename" | ||
| 1641 | "reset" "restrict" "returns" "revoke" "rightarg" "rollback" "row" | ||
| 1642 | "rule" "schema" "scroll" "security" "select" "sequence" "serializable" | ||
| 1643 | "session" "set" "sfunc" "share" "show" "similar" "some" "sort1" | ||
| 1644 | "sort2" "stable" "start" "statement" "statistics" "storage" "strict" | ||
| 1645 | "stype" "sysid" "table" "temp" "template" "temporary" "then" "to" | ||
| 1646 | "transaction" "trigger" "true" "truncate" "trusted" "type" | ||
| 1647 | "unencrypted" "union" "unique" "unknown" "unlisten" "until" "update" | ||
| 1648 | "usage" "user" "using" "vacuum" "valid" "validator" "values" | ||
| 1649 | "variable" "verbose" "view" "volatile" "when" "where" "with" "without" | ||
| 1650 | "work" | ||
| 1651 | ) | 1736 | ) |
| 1652 | 1737 | ||
| 1653 | ;; Postgres Data Types | 1738 | ;; Postgres Data Types |
| 1654 | (sql-font-lock-keywords-builder 'font-lock-type-face nil | 1739 | (sql-font-lock-keywords-builder 'font-lock-type-face nil |
| 1655 | "anyarray" "bigint" "bigserial" "bit" "boolean" "box" "bytea" "char" | 1740 | "bigint" "bigserial" "bit" "bool" "boolean" "box" "bytea" "char" |
| 1656 | "character" "cidr" "circle" "cstring" "date" "decimal" "double" | 1741 | "character" "cidr" "circle" "date" "decimal" "double" "float4" |
| 1657 | "float4" "float8" "inet" "int2" "int4" "int8" "integer" "internal" | 1742 | "float8" "inet" "int" "int2" "int4" "int8" "integer" "interval" "line" |
| 1658 | "interval" "language_handler" "line" "lseg" "macaddr" "money" | 1743 | "lseg" "macaddr" "money" "numeric" "path" "point" "polygon" |
| 1659 | "numeric" "oid" "opaque" "path" "point" "polygon" "precision" "real" | 1744 | "precision" "real" "serial" "serial4" "serial8" "smallint" "text" |
| 1660 | "record" "regclass" "regoper" "regoperator" "regproc" "regprocedure" | 1745 | "time" "timestamp" "timestamptz" "timetz" "tsquery" "tsvector" |
| 1661 | "regtype" "serial" "serial4" "serial8" "smallint" "text" "time" | 1746 | "txid_snapshot" "uuid" "varbit" "varchar" "varying" "without" |
| 1662 | "timestamp" "varchar" "varying" "void" "zone" | 1747 | "xml" "zone" |
| 1663 | ))) | 1748 | ))) |
| 1664 | 1749 | ||
| 1665 | "Postgres SQL keywords used by font-lock. | 1750 | "Postgres SQL keywords used by font-lock. |
| @@ -1979,6 +2064,9 @@ you define your own `sql-mode-mysql-font-lock-keywords'.") | |||
| 1979 | (defvar sql-mode-sqlite-font-lock-keywords | 2064 | (defvar sql-mode-sqlite-font-lock-keywords |
| 1980 | (eval-when-compile | 2065 | (eval-when-compile |
| 1981 | (list | 2066 | (list |
| 2067 | ;; SQLite commands | ||
| 2068 | '("^[.].*$" . font-lock-doc-face) | ||
| 2069 | |||
| 1982 | ;; SQLite Keyword | 2070 | ;; SQLite Keyword |
| 1983 | (sql-font-lock-keywords-builder 'font-lock-keyword-face nil | 2071 | (sql-font-lock-keywords-builder 'font-lock-keyword-face nil |
| 1984 | "abort" "action" "add" "after" "all" "alter" "analyze" "and" "as" | 2072 | "abort" "action" "add" "after" "all" "alter" "analyze" "and" "as" |
| @@ -2493,29 +2581,31 @@ function like this: (sql-get-login 'user 'password 'database)." | |||
| 2493 | 2581 | ||
| 2494 | ((eq token 'port) ; port | 2582 | ((eq token 'port) ; port |
| 2495 | (setq sql-port | 2583 | (setq sql-port |
| 2496 | (read-number "Port: " sql-port)))))) | 2584 | (read-number "Port: " (if (numberp sql-port) |
| 2497 | what)) | 2585 | sql-port |
| 2586 | 0))))))) | ||
| 2587 | what)) | ||
| 2498 | 2588 | ||
| 2499 | (defun sql-find-sqli-buffer () | 2589 | (defun sql-find-sqli-buffer () |
| 2500 | "Returns the current default SQLi buffer or nil. | 2590 | "Returns the name of the current default SQLi buffer or nil. |
| 2501 | In order to qualify, the SQLi buffer must be alive, | 2591 | In order to qualify, the SQLi buffer must be alive, be in |
| 2502 | be in `sql-interactive-mode' and have a process." | 2592 | `sql-interactive-mode' and have a process." |
| 2503 | (let ((default-buffer (default-value 'sql-buffer))) | 2593 | (let ((buf sql-buffer) |
| 2504 | (if (and (buffer-live-p default-buffer) | 2594 | (prod sql-product)) |
| 2505 | (get-buffer-process default-buffer)) | 2595 | (or |
| 2506 | default-buffer | 2596 | ;; Current sql-buffer, if there is one. |
| 2507 | (save-current-buffer | 2597 | (and (sql-buffer-live-p buf prod) |
| 2508 | (let ((buflist (buffer-list)) | 2598 | buf) |
| 2509 | (found)) | 2599 | ;; Global sql-buffer |
| 2510 | (while (not (or (null buflist) | 2600 | (and (setq buf (default-value 'sql-buffer)) |
| 2511 | found)) | 2601 | (sql-buffer-live-p buf prod) |
| 2512 | (let ((candidate (car buflist))) | 2602 | buf) |
| 2513 | (set-buffer candidate) | 2603 | ;; Look thru each buffer |
| 2514 | (if (and (derived-mode-p 'sql-interactive-mode) | 2604 | (car (apply 'append |
| 2515 | (get-buffer-process candidate)) | 2605 | (mapcar (lambda (b) |
| 2516 | (setq found candidate)) | 2606 | (and (sql-buffer-live-p b prod) |
| 2517 | (setq buflist (cdr buflist)))) | 2607 | (list (buffer-name b)))) |
| 2518 | found))))) | 2608 | (buffer-list))))))) |
| 2519 | 2609 | ||
| 2520 | (defun sql-set-sqli-buffer-generally () | 2610 | (defun sql-set-sqli-buffer-generally () |
| 2521 | "Set SQLi buffer for all SQL buffers that have none. | 2611 | "Set SQLi buffer for all SQL buffers that have none. |
| @@ -2527,16 +2617,17 @@ using `sql-find-sqli-buffer'. If `sql-buffer' is set, | |||
| 2527 | (interactive) | 2617 | (interactive) |
| 2528 | (save-excursion | 2618 | (save-excursion |
| 2529 | (let ((buflist (buffer-list)) | 2619 | (let ((buflist (buffer-list)) |
| 2530 | (default-sqli-buffer (sql-find-sqli-buffer))) | 2620 | (default-buffer (sql-find-sqli-buffer))) |
| 2531 | (setq-default sql-buffer default-sqli-buffer) | 2621 | (setq-default sql-buffer default-buffer) |
| 2532 | (while (not (null buflist)) | 2622 | (while (not (null buflist)) |
| 2533 | (let ((candidate (car buflist))) | 2623 | (let ((candidate (car buflist))) |
| 2534 | (set-buffer candidate) | 2624 | (set-buffer candidate) |
| 2535 | (if (and (derived-mode-p 'sql-mode) | 2625 | (if (and (derived-mode-p 'sql-mode) |
| 2536 | (not (buffer-live-p sql-buffer))) | 2626 | (not (sql-buffer-live-p sql-buffer))) |
| 2537 | (progn | 2627 | (progn |
| 2538 | (setq sql-buffer default-sqli-buffer) | 2628 | (setq sql-buffer default-buffer) |
| 2539 | (run-hooks 'sql-set-sqli-hook)))) | 2629 | (when default-buffer |
| 2630 | (run-hooks 'sql-set-sqli-hook))))) | ||
| 2540 | (setq buflist (cdr buflist)))))) | 2631 | (setq buflist (cdr buflist)))))) |
| 2541 | 2632 | ||
| 2542 | (defun sql-set-sqli-buffer () | 2633 | (defun sql-set-sqli-buffer () |
| @@ -2554,19 +2645,13 @@ If you call it from anywhere else, it sets the global copy of | |||
| 2554 | (interactive) | 2645 | (interactive) |
| 2555 | (let ((default-buffer (sql-find-sqli-buffer))) | 2646 | (let ((default-buffer (sql-find-sqli-buffer))) |
| 2556 | (if (null default-buffer) | 2647 | (if (null default-buffer) |
| 2557 | (error "There is no suitable SQLi buffer")) | 2648 | (error "There is no suitable SQLi buffer") |
| 2558 | (let ((new-buffer | 2649 | (let ((new-buffer (read-buffer "New SQLi buffer: " default-buffer t))) |
| 2559 | (get-buffer | 2650 | (if (null (sql-buffer-live-p new-buffer)) |
| 2560 | (read-buffer "New SQLi buffer: " default-buffer t)))) | 2651 | (error "Buffer %s is not a working SQLi buffer" new-buffer) |
| 2561 | (if (null (get-buffer-process new-buffer)) | 2652 | (when new-buffer |
| 2562 | (error "Buffer %s has no process" (buffer-name new-buffer))) | 2653 | (setq sql-buffer new-buffer) |
| 2563 | (if (null (with-current-buffer new-buffer | 2654 | (run-hooks 'sql-set-sqli-hook))))))) |
| 2564 | (equal major-mode 'sql-interactive-mode))) | ||
| 2565 | (error "Buffer %s is no SQLi buffer" (buffer-name new-buffer))) | ||
| 2566 | (if new-buffer | ||
| 2567 | (progn | ||
| 2568 | (setq sql-buffer new-buffer) | ||
| 2569 | (run-hooks 'sql-set-sqli-hook)))))) | ||
| 2570 | 2655 | ||
| 2571 | (defun sql-show-sqli-buffer () | 2656 | (defun sql-show-sqli-buffer () |
| 2572 | "Show the name of current SQLi buffer. | 2657 | "Show the name of current SQLi buffer. |
| @@ -2574,11 +2659,11 @@ If you call it from anywhere else, it sets the global copy of | |||
| 2574 | This is the buffer SQL strings are sent to. It is stored in the | 2659 | This is the buffer SQL strings are sent to. It is stored in the |
| 2575 | variable `sql-buffer'. See `sql-help' on how to create such a buffer." | 2660 | variable `sql-buffer'. See `sql-help' on how to create such a buffer." |
| 2576 | (interactive) | 2661 | (interactive) |
| 2577 | (if (null (buffer-live-p sql-buffer)) | 2662 | (if (null (buffer-live-p (get-buffer sql-buffer))) |
| 2578 | (message "%s has no SQLi buffer set." (buffer-name (current-buffer))) | 2663 | (message "%s has no SQLi buffer set." (buffer-name (current-buffer))) |
| 2579 | (if (null (get-buffer-process sql-buffer)) | 2664 | (if (null (get-buffer-process sql-buffer)) |
| 2580 | (message "Buffer %s has no process." (buffer-name sql-buffer)) | 2665 | (message "Buffer %s has no process." sql-buffer) |
| 2581 | (message "Current SQLi buffer is %s." (buffer-name sql-buffer))))) | 2666 | (message "Current SQLi buffer is %s." sql-buffer)))) |
| 2582 | 2667 | ||
| 2583 | (defun sql-make-alternate-buffer-name () | 2668 | (defun sql-make-alternate-buffer-name () |
| 2584 | "Return a string that can be used to rename a SQLi buffer. | 2669 | "Return a string that can be used to rename a SQLi buffer. |
| @@ -2610,8 +2695,9 @@ server/database name." | |||
| 2610 | (unless (string= "" sql-user) | 2695 | (unless (string= "" sql-user) |
| 2611 | (list "/" sql-user))) | 2696 | (list "/" sql-user))) |
| 2612 | ((eq token 'port) | 2697 | ((eq token 'port) |
| 2613 | (unless (= 0 sql-port) | 2698 | (unless (or (not (numberp sql-port)) |
| 2614 | (list ":" sql-port))) | 2699 | (= 0 sql-port)) |
| 2700 | (list ":" (number-to-string sql-port)))) | ||
| 2615 | ((eq token 'server) | 2701 | ((eq token 'server) |
| 2616 | (unless (string= "" sql-server) | 2702 | (unless (string= "" sql-server) |
| 2617 | (list "." | 2703 | (list "." |
| @@ -2619,7 +2705,7 @@ server/database name." | |||
| 2619 | (file-name-nondirectory sql-server) | 2705 | (file-name-nondirectory sql-server) |
| 2620 | sql-server)))) | 2706 | sql-server)))) |
| 2621 | ((eq token 'database) | 2707 | ((eq token 'database) |
| 2622 | (when (string= "" sql-database) | 2708 | (unless (string= "" sql-database) |
| 2623 | (list "@" | 2709 | (list "@" |
| 2624 | (if (eq type :file) | 2710 | (if (eq type :file) |
| 2625 | (file-name-nondirectory sql-database) | 2711 | (file-name-nondirectory sql-database) |
| @@ -2649,10 +2735,32 @@ server/database name." | |||
| 2649 | ;; Use the name we've got | 2735 | ;; Use the name we've got |
| 2650 | name)))) | 2736 | name)))) |
| 2651 | 2737 | ||
| 2652 | (defun sql-rename-buffer () | 2738 | (defun sql-rename-buffer (&optional new-name) |
| 2653 | "Rename a SQLi buffer." | 2739 | "Rename a SQL interactive buffer. |
| 2654 | (interactive) | 2740 | |
| 2655 | (rename-buffer (format "*SQL: %s*" sql-alternate-buffer-name) t)) | 2741 | Prompts for the new name if command is preceeded by |
| 2742 | \\[universal-argument]. If no buffer name is provided, then the | ||
| 2743 | `sql-alternate-buffer-name' is used. | ||
| 2744 | |||
| 2745 | The actual buffer name set will be \"*SQL: NEW-NAME*\". If | ||
| 2746 | NEW-NAME is empty, then the buffer name will be \"*SQL*\"." | ||
| 2747 | (interactive "P") | ||
| 2748 | |||
| 2749 | (if (not (derived-mode-p 'sql-interactive-mode)) | ||
| 2750 | (message "Current buffer is not a SQL interactive buffer") | ||
| 2751 | |||
| 2752 | (setq sql-alternate-buffer-name | ||
| 2753 | (cond | ||
| 2754 | ((stringp new-name) new-name) | ||
| 2755 | ((consp new-name) | ||
| 2756 | (read-string "Buffer name (\"*SQL: XXX*\"; enter `XXX'): " | ||
| 2757 | sql-alternate-buffer-name)) | ||
| 2758 | (t sql-alternate-buffer-name))) | ||
| 2759 | |||
| 2760 | (rename-buffer (if (string= "" sql-alternate-buffer-name) | ||
| 2761 | "*SQL*" | ||
| 2762 | (format "*SQL: %s*" sql-alternate-buffer-name)) | ||
| 2763 | t))) | ||
| 2656 | 2764 | ||
| 2657 | (defun sql-copy-column () | 2765 | (defun sql-copy-column () |
| 2658 | "Copy current column to the end of buffer. | 2766 | "Copy current column to the end of buffer. |
| @@ -2801,7 +2909,7 @@ to force the output from the query to appear on a new line." | |||
| 2801 | 2909 | ||
| 2802 | (let ((comint-input-sender-no-newline nil) | 2910 | (let ((comint-input-sender-no-newline nil) |
| 2803 | (s (replace-regexp-in-string "[[:space:]\n\r]+\\'" "" str))) | 2911 | (s (replace-regexp-in-string "[[:space:]\n\r]+\\'" "" str))) |
| 2804 | (if (buffer-live-p sql-buffer) | 2912 | (if (sql-buffer-live-p sql-buffer) |
| 2805 | (progn | 2913 | (progn |
| 2806 | ;; Ignore the hoping around... | 2914 | ;; Ignore the hoping around... |
| 2807 | (save-excursion | 2915 | (save-excursion |
| @@ -2814,7 +2922,7 @@ to force the output from the query to appear on a new line." | |||
| 2814 | (if sql-send-terminator | 2922 | (if sql-send-terminator |
| 2815 | (sql-send-magic-terminator sql-buffer s sql-send-terminator)) | 2923 | (sql-send-magic-terminator sql-buffer s sql-send-terminator)) |
| 2816 | 2924 | ||
| 2817 | (message "Sent string to buffer %s." (buffer-name sql-buffer)))) | 2925 | (message "Sent string to buffer %s." sql-buffer))) |
| 2818 | 2926 | ||
| 2819 | ;; Display the sql buffer | 2927 | ;; Display the sql buffer |
| 2820 | (if sql-pop-to-buffer-after-send-region | 2928 | (if sql-pop-to-buffer-after-send-region |
| @@ -2893,6 +3001,91 @@ If given the optional parameter VALUE, sets | |||
| 2893 | 3001 | ||
| 2894 | 3002 | ||
| 2895 | 3003 | ||
| 3004 | ;;; Redirect output functions | ||
| 3005 | |||
| 3006 | (defun sql-redirect (command combuf &optional outbuf save-prior) | ||
| 3007 | "Execute the SQL command and send output to OUTBUF. | ||
| 3008 | |||
| 3009 | COMBUF must be an active SQL interactive buffer. OUTBUF may be | ||
| 3010 | an existing buffer, or the name of a non-existing buffer. If | ||
| 3011 | omitted the output is sent to a temporary buffer which will be | ||
| 3012 | killed after the command completes. COMMAND should be a string | ||
| 3013 | of commands accepted by the SQLi program." | ||
| 3014 | |||
| 3015 | (with-current-buffer combuf | ||
| 3016 | (let ((buf (get-buffer-create (or outbuf " *SQL-Redirect*"))) | ||
| 3017 | (proc (get-buffer-process (current-buffer))) | ||
| 3018 | (comint-prompt-regexp (sql-get-product-feature sql-product | ||
| 3019 | :prompt-regexp)) | ||
| 3020 | (start nil)) | ||
| 3021 | (with-current-buffer buf | ||
| 3022 | (unless save-prior | ||
| 3023 | (erase-buffer)) | ||
| 3024 | (goto-char (point-max)) | ||
| 3025 | (setq start (point))) | ||
| 3026 | |||
| 3027 | ;; Run the command | ||
| 3028 | (comint-redirect-send-command-to-process command buf proc nil t) | ||
| 3029 | (while (null comint-redirect-completed) | ||
| 3030 | (accept-process-output nil 1)) | ||
| 3031 | |||
| 3032 | ;; Remove echo if there was one | ||
| 3033 | (with-current-buffer buf | ||
| 3034 | (goto-char start) | ||
| 3035 | (when (looking-at (concat "^" (regexp-quote command) "[\\n]")) | ||
| 3036 | (delete-region (match-beginning 0) (match-end 0))) | ||
| 3037 | (goto-char start))))) | ||
| 3038 | |||
| 3039 | (defun sql-redirect-value (command combuf regexp &optional regexp-groups) | ||
| 3040 | "Execute the SQL command and return part of result. | ||
| 3041 | |||
| 3042 | COMBUF must be an active SQL interactive buffer. COMMAND should | ||
| 3043 | be a string of commands accepted by the SQLi program. From the | ||
| 3044 | output, the REGEXP is repeatedly matched and the list of | ||
| 3045 | REGEXP-GROUPS submatches is returned. This behaves much like | ||
| 3046 | \\[comint-redirect-results-list-from-process] but instead of | ||
| 3047 | returning a single submatch it returns a list of each submatch | ||
| 3048 | for each match." | ||
| 3049 | |||
| 3050 | (let ((outbuf " *SQL-Redirect-values*") | ||
| 3051 | (results nil)) | ||
| 3052 | (sql-redirect command combuf outbuf nil) | ||
| 3053 | (with-current-buffer outbuf | ||
| 3054 | (while (re-search-forward regexp nil t) | ||
| 3055 | (push | ||
| 3056 | (cond | ||
| 3057 | ;; no groups-return all of them | ||
| 3058 | ((null regexp-groups) | ||
| 3059 | (let ((i 1) | ||
| 3060 | (r nil)) | ||
| 3061 | (while (match-beginning i) | ||
| 3062 | (push (match-string i) r)) | ||
| 3063 | (nreverse r))) | ||
| 3064 | ;; one group specified | ||
| 3065 | ((numberp regexp-groups) | ||
| 3066 | (match-string regexp-groups)) | ||
| 3067 | ;; (buffer-substring-no-properties | ||
| 3068 | ;; (match-beginning regexp-groups) | ||
| 3069 | ;; (match-end regexp-groups))) | ||
| 3070 | ;; list of numbers; return the specified matches only | ||
| 3071 | ((consp regexp-groups) | ||
| 3072 | (mapcar (lambda (c) | ||
| 3073 | (cond | ||
| 3074 | ((numberp c) (match-string c)) | ||
| 3075 | ((stringp c) (match-substitute-replacement c)) | ||
| 3076 | (t (error "sql-redirect-value: unknown REGEXP-GROUPS value - %s" c)))) | ||
| 3077 | regexp-groups)) | ||
| 3078 | ;; String is specified; return replacement string | ||
| 3079 | ((stringp regexp-groups) | ||
| 3080 | (match-substitute-replacement regexp-groups)) | ||
| 3081 | (t | ||
| 3082 | (error "sql-redirect-value: unknown REGEXP-GROUPS value - %s" | ||
| 3083 | regexp-groups))) | ||
| 3084 | results))) | ||
| 3085 | (nreverse results))) | ||
| 3086 | |||
| 3087 | |||
| 3088 | |||
| 2896 | ;;; SQL mode -- uses SQL interactive mode | 3089 | ;;; SQL mode -- uses SQL interactive mode |
| 2897 | 3090 | ||
| 2898 | ;;;###autoload | 3091 | ;;;###autoload |
| @@ -3063,7 +3256,7 @@ you entered, right above the output it created. | |||
| 3063 | (setq local-abbrev-table sql-mode-abbrev-table) | 3256 | (setq local-abbrev-table sql-mode-abbrev-table) |
| 3064 | (setq abbrev-all-caps 1) | 3257 | (setq abbrev-all-caps 1) |
| 3065 | ;; Exiting the process will call sql-stop. | 3258 | ;; Exiting the process will call sql-stop. |
| 3066 | (set-process-sentinel (get-buffer-process sql-buffer) 'sql-stop) | 3259 | (set-process-sentinel (get-buffer-process (current-buffer)) 'sql-stop) |
| 3067 | ;; Save the connection name | 3260 | ;; Save the connection name |
| 3068 | (make-local-variable 'sql-connection) | 3261 | (make-local-variable 'sql-connection) |
| 3069 | ;; Create a usefull name for renaming this buffer later. | 3262 | ;; Create a usefull name for renaming this buffer later. |
| @@ -3248,49 +3441,57 @@ optionally is saved to the user's init file." | |||
| 3248 | ;;; Entry functions for different SQL interpreters. | 3441 | ;;; Entry functions for different SQL interpreters. |
| 3249 | 3442 | ||
| 3250 | ;;;###autoload | 3443 | ;;;###autoload |
| 3251 | (defun sql-product-interactive (&optional product) | 3444 | (defun sql-product-interactive (&optional product new-name) |
| 3252 | "Run PRODUCT interpreter as an inferior process. | 3445 | "Run PRODUCT interpreter as an inferior process. |
| 3253 | 3446 | ||
| 3254 | If buffer `*SQL*' exists but no process is running, make a new process. | 3447 | If buffer `*SQL*' exists but no process is running, make a new process. |
| 3255 | If buffer exists and a process is running, just switch to buffer `*SQL*'. | 3448 | If buffer exists and a process is running, just switch to buffer `*SQL*'. |
| 3256 | 3449 | ||
| 3450 | To specify the SQL product, prefix the call with | ||
| 3451 | \\[universal-argument]. To set the buffer name as well, prefix | ||
| 3452 | the call to \\[sql-product-interactive] with | ||
| 3453 | \\[universal-argument] \\[universal-argument]. | ||
| 3454 | |||
| 3257 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | 3455 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
| 3258 | (interactive "P") | 3456 | (interactive "P") |
| 3259 | 3457 | ||
| 3458 | ;; Handle universal arguments if specified | ||
| 3459 | (when (not (or executing-kbd-macro noninteractive)) | ||
| 3460 | (when (and (consp product) | ||
| 3461 | (not (cdr product)) | ||
| 3462 | (numberp (car product))) | ||
| 3463 | (when (>= (car product) 16) | ||
| 3464 | (when (not new-name) | ||
| 3465 | (setq new-name '(4))) | ||
| 3466 | (setq product '(4))))) | ||
| 3467 | |||
| 3468 | ;; Get the value of product that we need | ||
| 3260 | (setq product | 3469 | (setq product |
| 3261 | (cond | 3470 | (cond |
| 3262 | ((equal product '(4)) ; Universal arg, prompt for product | 3471 | ((equal product '(4)) ; C-u, prompt for product |
| 3263 | (intern (completing-read "SQL product: " | 3472 | (intern (completing-read "SQL product: " |
| 3264 | (mapcar (lambda (info) (symbol-name (car info))) | 3473 | (mapcar (lambda (info) (symbol-name (car info))) |
| 3265 | sql-product-alist) | 3474 | sql-product-alist) |
| 3266 | nil 'require-match | 3475 | nil 'require-match |
| 3267 | (or (and sql-product (symbol-name sql-product)) "ansi")))) | 3476 | (or (and sql-product |
| 3477 | (symbol-name sql-product)) | ||
| 3478 | "ansi")))) | ||
| 3268 | ((and product ; Product specified | 3479 | ((and product ; Product specified |
| 3269 | (symbolp product)) product) | 3480 | (symbolp product)) product) |
| 3270 | (t sql-product))) ; Default to sql-product | 3481 | (t sql-product))) ; Default to sql-product |
| 3271 | 3482 | ||
| 3483 | ;; If we have a product and it has a interactive mode | ||
| 3272 | (if product | 3484 | (if product |
| 3273 | (when (sql-get-product-feature product :sqli-comint-func) | 3485 | (when (sql-get-product-feature product :sqli-comint-func) |
| 3274 | (if (and sql-buffer | 3486 | ;; If no new name specified, fall back on sql-buffer if its for |
| 3275 | (buffer-live-p sql-buffer) | 3487 | ;; the same product |
| 3276 | (comint-check-proc sql-buffer)) | 3488 | (if (and (not new-name) |
| 3489 | (sql-buffer-live-p sql-buffer product)) | ||
| 3277 | (pop-to-buffer sql-buffer) | 3490 | (pop-to-buffer sql-buffer) |
| 3278 | 3491 | ||
| 3279 | ;; Is the current buffer in sql-mode and | 3492 | ;; We have a new name or sql-buffer doesn't exist or match |
| 3280 | ;; there is a buffer local setting of sql-buffer | 3493 | ;; Start by remembering where we start |
| 3281 | (let* ((start-buffer | 3494 | (let* ((start-buffer (current-buffer)) |
| 3282 | (and (derived-mode-p 'sql-mode) | ||
| 3283 | (current-buffer))) | ||
| 3284 | (start-sql-buffer | ||
| 3285 | (and start-buffer | ||
| 3286 | (let (found) | ||
| 3287 | (dolist (var (buffer-local-variables)) | ||
| 3288 | (and (consp var) | ||
| 3289 | (eq (car var) 'sql-buffer) | ||
| 3290 | (buffer-live-p (cdr var)) | ||
| 3291 | (get-buffer-process (cdr var)) | ||
| 3292 | (setq found (cdr var)))) | ||
| 3293 | found))) | ||
| 3294 | new-sqli-buffer) | 3495 | new-sqli-buffer) |
| 3295 | 3496 | ||
| 3296 | ;; Get credentials. | 3497 | ;; Get credentials. |
| @@ -3303,15 +3504,19 @@ If buffer exists and a process is running, just switch to buffer `*SQL*'. | |||
| 3303 | (sql-get-product-feature product :sqli-options)) | 3504 | (sql-get-product-feature product :sqli-options)) |
| 3304 | 3505 | ||
| 3305 | ;; Set SQLi mode. | 3506 | ;; Set SQLi mode. |
| 3306 | (setq sql-interactive-product product | 3507 | (setq new-sqli-buffer (current-buffer)) |
| 3307 | new-sqli-buffer (current-buffer) | 3508 | (let ((sql-interactive-product product)) |
| 3308 | sql-buffer new-sqli-buffer) | 3509 | (sql-interactive-mode)) |
| 3309 | (sql-interactive-mode) | 3510 | |
| 3511 | ;; Set the new buffer name | ||
| 3512 | (when new-name | ||
| 3513 | (sql-rename-buffer new-name)) | ||
| 3310 | 3514 | ||
| 3311 | ;; Set `sql-buffer' in the start buffer | 3515 | ;; Set `sql-buffer' in the new buffer and the start buffer |
| 3312 | (when (and start-buffer (not start-sql-buffer)) | 3516 | (setq sql-buffer (buffer-name new-sqli-buffer)) |
| 3313 | (with-current-buffer start-buffer | 3517 | (with-current-buffer start-buffer |
| 3314 | (setq sql-buffer new-sqli-buffer))) | 3518 | (setq sql-buffer (buffer-name new-sqli-buffer)) |
| 3519 | (run-hooks 'sql-set-sqli-hook)) | ||
| 3315 | 3520 | ||
| 3316 | ;; All done. | 3521 | ;; All done. |
| 3317 | (message "Login...done") | 3522 | (message "Login...done") |
| @@ -3323,12 +3528,22 @@ If buffer exists and a process is running, just switch to buffer `*SQL*'. | |||
| 3323 | 3528 | ||
| 3324 | PRODUCT is the SQL product. PARAMS is a list of strings which are | 3529 | PRODUCT is the SQL product. PARAMS is a list of strings which are |
| 3325 | passed as command line arguments." | 3530 | passed as command line arguments." |
| 3326 | (let ((program (sql-get-product-feature product :sqli-program))) | 3531 | (let ((program (sql-get-product-feature product :sqli-program)) |
| 3532 | (buf-name "SQL")) | ||
| 3533 | ;; Make sure buffer name is unique | ||
| 3534 | (when (get-buffer (format "*%s*" buf-name)) | ||
| 3535 | (setq buf-name (format "SQL-%s" product)) | ||
| 3536 | (when (get-buffer (format "*%s*" buf-name)) | ||
| 3537 | (let ((i 1)) | ||
| 3538 | (while (get-buffer (format "*%s*" | ||
| 3539 | (setq buf-name | ||
| 3540 | (format "SQL-%s%d" product i)))) | ||
| 3541 | (setq i (1+ i)))))) | ||
| 3327 | (set-buffer | 3542 | (set-buffer |
| 3328 | (apply 'make-comint "SQL" program nil params)))) | 3543 | (apply 'make-comint buf-name program nil params)))) |
| 3329 | 3544 | ||
| 3330 | ;;;###autoload | 3545 | ;;;###autoload |
| 3331 | (defun sql-oracle () | 3546 | (defun sql-oracle (&optional buffer) |
| 3332 | "Run sqlplus by Oracle as an inferior process. | 3547 | "Run sqlplus by Oracle as an inferior process. |
| 3333 | 3548 | ||
| 3334 | If buffer `*SQL*' exists but no process is running, make a new process. | 3549 | If buffer `*SQL*' exists but no process is running, make a new process. |
| @@ -3343,6 +3558,11 @@ the list `sql-oracle-options'. | |||
| 3343 | The buffer is put in SQL interactive mode, giving commands for sending | 3558 | The buffer is put in SQL interactive mode, giving commands for sending |
| 3344 | input. See `sql-interactive-mode'. | 3559 | input. See `sql-interactive-mode'. |
| 3345 | 3560 | ||
| 3561 | To set the buffer name directly, use \\[universal-argument] | ||
| 3562 | before \\[sql-oracle]. Once session has started, | ||
| 3563 | \\[sql-rename-buffer] can be called separately to rename the | ||
| 3564 | buffer. | ||
| 3565 | |||
| 3346 | To specify a coding system for converting non-ASCII characters | 3566 | To specify a coding system for converting non-ASCII characters |
| 3347 | in the input and output to the process, use \\[universal-coding-system-argument] | 3567 | in the input and output to the process, use \\[universal-coding-system-argument] |
| 3348 | before \\[sql-oracle]. You can also specify this with \\[set-buffer-process-coding-system] | 3568 | before \\[sql-oracle]. You can also specify this with \\[set-buffer-process-coding-system] |
| @@ -3351,8 +3571,8 @@ The default comes from `process-coding-system-alist' and | |||
| 3351 | `default-process-coding-system'. | 3571 | `default-process-coding-system'. |
| 3352 | 3572 | ||
| 3353 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | 3573 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
| 3354 | (interactive) | 3574 | (interactive "P") |
| 3355 | (sql-product-interactive 'oracle)) | 3575 | (sql-product-interactive 'oracle buffer)) |
| 3356 | 3576 | ||
| 3357 | (defun sql-comint-oracle (product options) | 3577 | (defun sql-comint-oracle (product options) |
| 3358 | "Create comint buffer and connect to Oracle." | 3578 | "Create comint buffer and connect to Oracle." |
| @@ -3375,7 +3595,7 @@ The default comes from `process-coding-system-alist' and | |||
| 3375 | 3595 | ||
| 3376 | 3596 | ||
| 3377 | ;;;###autoload | 3597 | ;;;###autoload |
| 3378 | (defun sql-sybase () | 3598 | (defun sql-sybase (&optional buffer) |
| 3379 | "Run isql by Sybase as an inferior process. | 3599 | "Run isql by Sybase as an inferior process. |
| 3380 | 3600 | ||
| 3381 | If buffer `*SQL*' exists but no process is running, make a new process. | 3601 | If buffer `*SQL*' exists but no process is running, make a new process. |
| @@ -3390,6 +3610,11 @@ can be stored in the list `sql-sybase-options'. | |||
| 3390 | The buffer is put in SQL interactive mode, giving commands for sending | 3610 | The buffer is put in SQL interactive mode, giving commands for sending |
| 3391 | input. See `sql-interactive-mode'. | 3611 | input. See `sql-interactive-mode'. |
| 3392 | 3612 | ||
| 3613 | To set the buffer name directly, use \\[universal-argument] | ||
| 3614 | before \\[sql-sybase]. Once session has started, | ||
| 3615 | \\[sql-rename-buffer] can be called separately to rename the | ||
| 3616 | buffer. | ||
| 3617 | |||
| 3393 | To specify a coding system for converting non-ASCII characters | 3618 | To specify a coding system for converting non-ASCII characters |
| 3394 | in the input and output to the process, use \\[universal-coding-system-argument] | 3619 | in the input and output to the process, use \\[universal-coding-system-argument] |
| 3395 | before \\[sql-sybase]. You can also specify this with \\[set-buffer-process-coding-system] | 3620 | before \\[sql-sybase]. You can also specify this with \\[set-buffer-process-coding-system] |
| @@ -3398,8 +3623,8 @@ The default comes from `process-coding-system-alist' and | |||
| 3398 | `default-process-coding-system'. | 3623 | `default-process-coding-system'. |
| 3399 | 3624 | ||
| 3400 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | 3625 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
| 3401 | (interactive) | 3626 | (interactive "P") |
| 3402 | (sql-product-interactive 'sybase)) | 3627 | (sql-product-interactive 'sybase buffer)) |
| 3403 | 3628 | ||
| 3404 | (defun sql-comint-sybase (product options) | 3629 | (defun sql-comint-sybase (product options) |
| 3405 | "Create comint buffer and connect to Sybase." | 3630 | "Create comint buffer and connect to Sybase." |
| @@ -3419,7 +3644,7 @@ The default comes from `process-coding-system-alist' and | |||
| 3419 | 3644 | ||
| 3420 | 3645 | ||
| 3421 | ;;;###autoload | 3646 | ;;;###autoload |
| 3422 | (defun sql-informix () | 3647 | (defun sql-informix (&optional buffer) |
| 3423 | "Run dbaccess by Informix as an inferior process. | 3648 | "Run dbaccess by Informix as an inferior process. |
| 3424 | 3649 | ||
| 3425 | If buffer `*SQL*' exists but no process is running, make a new process. | 3650 | If buffer `*SQL*' exists but no process is running, make a new process. |
| @@ -3432,6 +3657,11 @@ the variable `sql-database' as default, if set. | |||
| 3432 | The buffer is put in SQL interactive mode, giving commands for sending | 3657 | The buffer is put in SQL interactive mode, giving commands for sending |
| 3433 | input. See `sql-interactive-mode'. | 3658 | input. See `sql-interactive-mode'. |
| 3434 | 3659 | ||
| 3660 | To set the buffer name directly, use \\[universal-argument] | ||
| 3661 | before \\[sql-informix]. Once session has started, | ||
| 3662 | \\[sql-rename-buffer] can be called separately to rename the | ||
| 3663 | buffer. | ||
| 3664 | |||
| 3435 | To specify a coding system for converting non-ASCII characters | 3665 | To specify a coding system for converting non-ASCII characters |
| 3436 | in the input and output to the process, use \\[universal-coding-system-argument] | 3666 | in the input and output to the process, use \\[universal-coding-system-argument] |
| 3437 | before \\[sql-informix]. You can also specify this with \\[set-buffer-process-coding-system] | 3667 | before \\[sql-informix]. You can also specify this with \\[set-buffer-process-coding-system] |
| @@ -3440,8 +3670,8 @@ The default comes from `process-coding-system-alist' and | |||
| 3440 | `default-process-coding-system'. | 3670 | `default-process-coding-system'. |
| 3441 | 3671 | ||
| 3442 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | 3672 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
| 3443 | (interactive) | 3673 | (interactive "P") |
| 3444 | (sql-product-interactive 'informix)) | 3674 | (sql-product-interactive 'informix buffer)) |
| 3445 | 3675 | ||
| 3446 | (defun sql-comint-informix (product options) | 3676 | (defun sql-comint-informix (product options) |
| 3447 | "Create comint buffer and connect to Informix." | 3677 | "Create comint buffer and connect to Informix." |
| @@ -3456,7 +3686,7 @@ The default comes from `process-coding-system-alist' and | |||
| 3456 | 3686 | ||
| 3457 | 3687 | ||
| 3458 | ;;;###autoload | 3688 | ;;;###autoload |
| 3459 | (defun sql-sqlite () | 3689 | (defun sql-sqlite (&optional buffer) |
| 3460 | "Run sqlite as an inferior process. | 3690 | "Run sqlite as an inferior process. |
| 3461 | 3691 | ||
| 3462 | SQLite is free software. | 3692 | SQLite is free software. |
| @@ -3473,6 +3703,11 @@ can be stored in the list `sql-sqlite-options'. | |||
| 3473 | The buffer is put in SQL interactive mode, giving commands for sending | 3703 | The buffer is put in SQL interactive mode, giving commands for sending |
| 3474 | input. See `sql-interactive-mode'. | 3704 | input. See `sql-interactive-mode'. |
| 3475 | 3705 | ||
| 3706 | To set the buffer name directly, use \\[universal-argument] | ||
| 3707 | before \\[sql-sqlite]. Once session has started, | ||
| 3708 | \\[sql-rename-buffer] can be called separately to rename the | ||
| 3709 | buffer. | ||
| 3710 | |||
| 3476 | To specify a coding system for converting non-ASCII characters | 3711 | To specify a coding system for converting non-ASCII characters |
| 3477 | in the input and output to the process, use \\[universal-coding-system-argument] | 3712 | in the input and output to the process, use \\[universal-coding-system-argument] |
| 3478 | before \\[sql-sqlite]. You can also specify this with \\[set-buffer-process-coding-system] | 3713 | before \\[sql-sqlite]. You can also specify this with \\[set-buffer-process-coding-system] |
| @@ -3481,8 +3716,8 @@ The default comes from `process-coding-system-alist' and | |||
| 3481 | `default-process-coding-system'. | 3716 | `default-process-coding-system'. |
| 3482 | 3717 | ||
| 3483 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | 3718 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
| 3484 | (interactive) | 3719 | (interactive "P") |
| 3485 | (sql-product-interactive 'sqlite)) | 3720 | (sql-product-interactive 'sqlite buffer)) |
| 3486 | 3721 | ||
| 3487 | (defun sql-comint-sqlite (product options) | 3722 | (defun sql-comint-sqlite (product options) |
| 3488 | "Create comint buffer and connect to SQLite." | 3723 | "Create comint buffer and connect to SQLite." |
| @@ -3498,7 +3733,7 @@ The default comes from `process-coding-system-alist' and | |||
| 3498 | 3733 | ||
| 3499 | 3734 | ||
| 3500 | ;;;###autoload | 3735 | ;;;###autoload |
| 3501 | (defun sql-mysql () | 3736 | (defun sql-mysql (&optional buffer) |
| 3502 | "Run mysql by TcX as an inferior process. | 3737 | "Run mysql by TcX as an inferior process. |
| 3503 | 3738 | ||
| 3504 | Mysql versions 3.23 and up are free software. | 3739 | Mysql versions 3.23 and up are free software. |
| @@ -3515,6 +3750,11 @@ can be stored in the list `sql-mysql-options'. | |||
| 3515 | The buffer is put in SQL interactive mode, giving commands for sending | 3750 | The buffer is put in SQL interactive mode, giving commands for sending |
| 3516 | input. See `sql-interactive-mode'. | 3751 | input. See `sql-interactive-mode'. |
| 3517 | 3752 | ||
| 3753 | To set the buffer name directly, use \\[universal-argument] | ||
| 3754 | before \\[sql-mysql]. Once session has started, | ||
| 3755 | \\[sql-rename-buffer] can be called separately to rename the | ||
| 3756 | buffer. | ||
| 3757 | |||
| 3518 | To specify a coding system for converting non-ASCII characters | 3758 | To specify a coding system for converting non-ASCII characters |
| 3519 | in the input and output to the process, use \\[universal-coding-system-argument] | 3759 | in the input and output to the process, use \\[universal-coding-system-argument] |
| 3520 | before \\[sql-mysql]. You can also specify this with \\[set-buffer-process-coding-system] | 3760 | before \\[sql-mysql]. You can also specify this with \\[set-buffer-process-coding-system] |
| @@ -3523,8 +3763,8 @@ The default comes from `process-coding-system-alist' and | |||
| 3523 | `default-process-coding-system'. | 3763 | `default-process-coding-system'. |
| 3524 | 3764 | ||
| 3525 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | 3765 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
| 3526 | (interactive) | 3766 | (interactive "P") |
| 3527 | (sql-product-interactive 'mysql)) | 3767 | (sql-product-interactive 'mysql buffer)) |
| 3528 | 3768 | ||
| 3529 | (defun sql-comint-mysql (product options) | 3769 | (defun sql-comint-mysql (product options) |
| 3530 | "Create comint buffer and connect to MySQL." | 3770 | "Create comint buffer and connect to MySQL." |
| @@ -3535,7 +3775,7 @@ The default comes from `process-coding-system-alist' and | |||
| 3535 | (setq params (append (list sql-database) params))) | 3775 | (setq params (append (list sql-database) params))) |
| 3536 | (if (not (string= "" sql-server)) | 3776 | (if (not (string= "" sql-server)) |
| 3537 | (setq params (append (list (concat "--host=" sql-server)) params))) | 3777 | (setq params (append (list (concat "--host=" sql-server)) params))) |
| 3538 | (if (and sql-port (numberp sql-port)) | 3778 | (if (not (= 0 sql-port)) |
| 3539 | (setq params (append (list (concat "--port=" (number-to-string sql-port))) params))) | 3779 | (setq params (append (list (concat "--port=" (number-to-string sql-port))) params))) |
| 3540 | (if (not (string= "" sql-password)) | 3780 | (if (not (string= "" sql-password)) |
| 3541 | (setq params (append (list (concat "--password=" sql-password)) params))) | 3781 | (setq params (append (list (concat "--password=" sql-password)) params))) |
| @@ -3547,7 +3787,7 @@ The default comes from `process-coding-system-alist' and | |||
| 3547 | 3787 | ||
| 3548 | 3788 | ||
| 3549 | ;;;###autoload | 3789 | ;;;###autoload |
| 3550 | (defun sql-solid () | 3790 | (defun sql-solid (&optional buffer) |
| 3551 | "Run solsql by Solid as an inferior process. | 3791 | "Run solsql by Solid as an inferior process. |
| 3552 | 3792 | ||
| 3553 | If buffer `*SQL*' exists but no process is running, make a new process. | 3793 | If buffer `*SQL*' exists but no process is running, make a new process. |
| @@ -3561,6 +3801,11 @@ defaults, if set. | |||
| 3561 | The buffer is put in SQL interactive mode, giving commands for sending | 3801 | The buffer is put in SQL interactive mode, giving commands for sending |
| 3562 | input. See `sql-interactive-mode'. | 3802 | input. See `sql-interactive-mode'. |
| 3563 | 3803 | ||
| 3804 | To set the buffer name directly, use \\[universal-argument] | ||
| 3805 | before \\[sql-solid]. Once session has started, | ||
| 3806 | \\[sql-rename-buffer] can be called separately to rename the | ||
| 3807 | buffer. | ||
| 3808 | |||
| 3564 | To specify a coding system for converting non-ASCII characters | 3809 | To specify a coding system for converting non-ASCII characters |
| 3565 | in the input and output to the process, use \\[universal-coding-system-argument] | 3810 | in the input and output to the process, use \\[universal-coding-system-argument] |
| 3566 | before \\[sql-solid]. You can also specify this with \\[set-buffer-process-coding-system] | 3811 | before \\[sql-solid]. You can also specify this with \\[set-buffer-process-coding-system] |
| @@ -3569,8 +3814,8 @@ The default comes from `process-coding-system-alist' and | |||
| 3569 | `default-process-coding-system'. | 3814 | `default-process-coding-system'. |
| 3570 | 3815 | ||
| 3571 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | 3816 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
| 3572 | (interactive) | 3817 | (interactive "P") |
| 3573 | (sql-product-interactive 'solid)) | 3818 | (sql-product-interactive 'solid buffer)) |
| 3574 | 3819 | ||
| 3575 | (defun sql-comint-solid (product options) | 3820 | (defun sql-comint-solid (product options) |
| 3576 | "Create comint buffer and connect to Solid." | 3821 | "Create comint buffer and connect to Solid." |
| @@ -3588,7 +3833,7 @@ The default comes from `process-coding-system-alist' and | |||
| 3588 | 3833 | ||
| 3589 | 3834 | ||
| 3590 | ;;;###autoload | 3835 | ;;;###autoload |
| 3591 | (defun sql-ingres () | 3836 | (defun sql-ingres (&optional buffer) |
| 3592 | "Run sql by Ingres as an inferior process. | 3837 | "Run sql by Ingres as an inferior process. |
| 3593 | 3838 | ||
| 3594 | If buffer `*SQL*' exists but no process is running, make a new process. | 3839 | If buffer `*SQL*' exists but no process is running, make a new process. |
| @@ -3601,6 +3846,11 @@ the variable `sql-database' as default, if set. | |||
| 3601 | The buffer is put in SQL interactive mode, giving commands for sending | 3846 | The buffer is put in SQL interactive mode, giving commands for sending |
| 3602 | input. See `sql-interactive-mode'. | 3847 | input. See `sql-interactive-mode'. |
| 3603 | 3848 | ||
| 3849 | To set the buffer name directly, use \\[universal-argument] | ||
| 3850 | before \\[sql-ingres]. Once session has started, | ||
| 3851 | \\[sql-rename-buffer] can be called separately to rename the | ||
| 3852 | buffer. | ||
| 3853 | |||
| 3604 | To specify a coding system for converting non-ASCII characters | 3854 | To specify a coding system for converting non-ASCII characters |
| 3605 | in the input and output to the process, use \\[universal-coding-system-argument] | 3855 | in the input and output to the process, use \\[universal-coding-system-argument] |
| 3606 | before \\[sql-ingres]. You can also specify this with \\[set-buffer-process-coding-system] | 3856 | before \\[sql-ingres]. You can also specify this with \\[set-buffer-process-coding-system] |
| @@ -3609,8 +3859,8 @@ The default comes from `process-coding-system-alist' and | |||
| 3609 | `default-process-coding-system'. | 3859 | `default-process-coding-system'. |
| 3610 | 3860 | ||
| 3611 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | 3861 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
| 3612 | (interactive) | 3862 | (interactive "P") |
| 3613 | (sql-product-interactive 'ingres)) | 3863 | (sql-product-interactive 'ingres buffer)) |
| 3614 | 3864 | ||
| 3615 | (defun sql-comint-ingres (product options) | 3865 | (defun sql-comint-ingres (product options) |
| 3616 | "Create comint buffer and connect to Ingres." | 3866 | "Create comint buffer and connect to Ingres." |
| @@ -3624,7 +3874,7 @@ The default comes from `process-coding-system-alist' and | |||
| 3624 | 3874 | ||
| 3625 | 3875 | ||
| 3626 | ;;;###autoload | 3876 | ;;;###autoload |
| 3627 | (defun sql-ms () | 3877 | (defun sql-ms (&optional buffer) |
| 3628 | "Run osql by Microsoft as an inferior process. | 3878 | "Run osql by Microsoft as an inferior process. |
| 3629 | 3879 | ||
| 3630 | If buffer `*SQL*' exists but no process is running, make a new process. | 3880 | If buffer `*SQL*' exists but no process is running, make a new process. |
| @@ -3639,6 +3889,11 @@ in the list `sql-ms-options'. | |||
| 3639 | The buffer is put in SQL interactive mode, giving commands for sending | 3889 | The buffer is put in SQL interactive mode, giving commands for sending |
| 3640 | input. See `sql-interactive-mode'. | 3890 | input. See `sql-interactive-mode'. |
| 3641 | 3891 | ||
| 3892 | To set the buffer name directly, use \\[universal-argument] | ||
| 3893 | before \\[sql-ms]. Once session has started, | ||
| 3894 | \\[sql-rename-buffer] can be called separately to rename the | ||
| 3895 | buffer. | ||
| 3896 | |||
| 3642 | To specify a coding system for converting non-ASCII characters | 3897 | To specify a coding system for converting non-ASCII characters |
| 3643 | in the input and output to the process, use \\[universal-coding-system-argument] | 3898 | in the input and output to the process, use \\[universal-coding-system-argument] |
| 3644 | before \\[sql-ms]. You can also specify this with \\[set-buffer-process-coding-system] | 3899 | before \\[sql-ms]. You can also specify this with \\[set-buffer-process-coding-system] |
| @@ -3647,8 +3902,8 @@ The default comes from `process-coding-system-alist' and | |||
| 3647 | `default-process-coding-system'. | 3902 | `default-process-coding-system'. |
| 3648 | 3903 | ||
| 3649 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | 3904 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
| 3650 | (interactive) | 3905 | (interactive "P") |
| 3651 | (sql-product-interactive 'ms)) | 3906 | (sql-product-interactive 'ms buffer)) |
| 3652 | 3907 | ||
| 3653 | (defun sql-comint-ms (product options) | 3908 | (defun sql-comint-ms (product options) |
| 3654 | "Create comint buffer and connect to Microsoft SQL Server." | 3909 | "Create comint buffer and connect to Microsoft SQL Server." |
| @@ -3675,7 +3930,7 @@ The default comes from `process-coding-system-alist' and | |||
| 3675 | 3930 | ||
| 3676 | 3931 | ||
| 3677 | ;;;###autoload | 3932 | ;;;###autoload |
| 3678 | (defun sql-postgres () | 3933 | (defun sql-postgres (&optional buffer) |
| 3679 | "Run psql by Postgres as an inferior process. | 3934 | "Run psql by Postgres as an inferior process. |
| 3680 | 3935 | ||
| 3681 | If buffer `*SQL*' exists but no process is running, make a new process. | 3936 | If buffer `*SQL*' exists but no process is running, make a new process. |
| @@ -3690,6 +3945,11 @@ Additional command line parameters can be stored in the list | |||
| 3690 | The buffer is put in SQL interactive mode, giving commands for sending | 3945 | The buffer is put in SQL interactive mode, giving commands for sending |
| 3691 | input. See `sql-interactive-mode'. | 3946 | input. See `sql-interactive-mode'. |
| 3692 | 3947 | ||
| 3948 | To set the buffer name directly, use \\[universal-argument] | ||
| 3949 | before \\[sql-postgres]. Once session has started, | ||
| 3950 | \\[sql-rename-buffer] can be called separately to rename the | ||
| 3951 | buffer. | ||
| 3952 | |||
| 3693 | To specify a coding system for converting non-ASCII characters | 3953 | To specify a coding system for converting non-ASCII characters |
| 3694 | in the input and output to the process, use \\[universal-coding-system-argument] | 3954 | in the input and output to the process, use \\[universal-coding-system-argument] |
| 3695 | before \\[sql-postgres]. You can also specify this with \\[set-buffer-process-coding-system] | 3955 | before \\[sql-postgres]. You can also specify this with \\[set-buffer-process-coding-system] |
| @@ -3703,8 +3963,8 @@ Try to set `comint-output-filter-functions' like this: | |||
| 3703 | '(comint-strip-ctrl-m))) | 3963 | '(comint-strip-ctrl-m))) |
| 3704 | 3964 | ||
| 3705 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | 3965 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
| 3706 | (interactive) | 3966 | (interactive "P") |
| 3707 | (sql-product-interactive 'postgres)) | 3967 | (sql-product-interactive 'postgres buffer)) |
| 3708 | 3968 | ||
| 3709 | (defun sql-comint-postgres (product options) | 3969 | (defun sql-comint-postgres (product options) |
| 3710 | "Create comint buffer and connect to Postgres." | 3970 | "Create comint buffer and connect to Postgres." |
| @@ -3725,7 +3985,7 @@ Try to set `comint-output-filter-functions' like this: | |||
| 3725 | 3985 | ||
| 3726 | 3986 | ||
| 3727 | ;;;###autoload | 3987 | ;;;###autoload |
| 3728 | (defun sql-interbase () | 3988 | (defun sql-interbase (&optional buffer) |
| 3729 | "Run isql by Interbase as an inferior process. | 3989 | "Run isql by Interbase as an inferior process. |
| 3730 | 3990 | ||
| 3731 | If buffer `*SQL*' exists but no process is running, make a new process. | 3991 | If buffer `*SQL*' exists but no process is running, make a new process. |
| @@ -3739,6 +3999,11 @@ defaults, if set. | |||
| 3739 | The buffer is put in SQL interactive mode, giving commands for sending | 3999 | The buffer is put in SQL interactive mode, giving commands for sending |
| 3740 | input. See `sql-interactive-mode'. | 4000 | input. See `sql-interactive-mode'. |
| 3741 | 4001 | ||
| 4002 | To set the buffer name directly, use \\[universal-argument] | ||
| 4003 | before \\[sql-interbase]. Once session has started, | ||
| 4004 | \\[sql-rename-buffer] can be called separately to rename the | ||
| 4005 | buffer. | ||
| 4006 | |||
| 3742 | To specify a coding system for converting non-ASCII characters | 4007 | To specify a coding system for converting non-ASCII characters |
| 3743 | in the input and output to the process, use \\[universal-coding-system-argument] | 4008 | in the input and output to the process, use \\[universal-coding-system-argument] |
| 3744 | before \\[sql-interbase]. You can also specify this with \\[set-buffer-process-coding-system] | 4009 | before \\[sql-interbase]. You can also specify this with \\[set-buffer-process-coding-system] |
| @@ -3747,8 +4012,8 @@ The default comes from `process-coding-system-alist' and | |||
| 3747 | `default-process-coding-system'. | 4012 | `default-process-coding-system'. |
| 3748 | 4013 | ||
| 3749 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | 4014 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
| 3750 | (interactive) | 4015 | (interactive "P") |
| 3751 | (sql-product-interactive 'interbase)) | 4016 | (sql-product-interactive 'interbase buffer)) |
| 3752 | 4017 | ||
| 3753 | (defun sql-comint-interbase (product options) | 4018 | (defun sql-comint-interbase (product options) |
| 3754 | "Create comint buffer and connect to Interbase." | 4019 | "Create comint buffer and connect to Interbase." |
| @@ -3766,7 +4031,7 @@ The default comes from `process-coding-system-alist' and | |||
| 3766 | 4031 | ||
| 3767 | 4032 | ||
| 3768 | ;;;###autoload | 4033 | ;;;###autoload |
| 3769 | (defun sql-db2 () | 4034 | (defun sql-db2 (&optional buffer) |
| 3770 | "Run db2 by IBM as an inferior process. | 4035 | "Run db2 by IBM as an inferior process. |
| 3771 | 4036 | ||
| 3772 | If buffer `*SQL*' exists but no process is running, make a new process. | 4037 | If buffer `*SQL*' exists but no process is running, make a new process. |
| @@ -3784,6 +4049,11 @@ db2, newlines will be escaped if necessary. If you don't want that, set | |||
| 3784 | `comint-input-sender' back to `comint-simple-send' by writing an after | 4049 | `comint-input-sender' back to `comint-simple-send' by writing an after |
| 3785 | advice. See the elisp manual for more information. | 4050 | advice. See the elisp manual for more information. |
| 3786 | 4051 | ||
| 4052 | To set the buffer name directly, use \\[universal-argument] | ||
| 4053 | before \\[sql-db2]. Once session has started, | ||
| 4054 | \\[sql-rename-buffer] can be called separately to rename the | ||
| 4055 | buffer. | ||
| 4056 | |||
| 3787 | To specify a coding system for converting non-ASCII characters | 4057 | To specify a coding system for converting non-ASCII characters |
| 3788 | in the input and output to the process, use \\[universal-coding-system-argument] | 4058 | in the input and output to the process, use \\[universal-coding-system-argument] |
| 3789 | before \\[sql-db2]. You can also specify this with \\[set-buffer-process-coding-system] | 4059 | before \\[sql-db2]. You can also specify this with \\[set-buffer-process-coding-system] |
| @@ -3792,8 +4062,8 @@ The default comes from `process-coding-system-alist' and | |||
| 3792 | `default-process-coding-system'. | 4062 | `default-process-coding-system'. |
| 3793 | 4063 | ||
| 3794 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | 4064 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
| 3795 | (interactive) | 4065 | (interactive "P") |
| 3796 | (sql-product-interactive 'db2)) | 4066 | (sql-product-interactive 'db2 buffer)) |
| 3797 | 4067 | ||
| 3798 | (defun sql-comint-db2 (product options) | 4068 | (defun sql-comint-db2 (product options) |
| 3799 | "Create comint buffer and connect to DB2." | 4069 | "Create comint buffer and connect to DB2." |
| @@ -3801,11 +4071,9 @@ The default comes from `process-coding-system-alist' and | |||
| 3801 | ;; make-comint. | 4071 | ;; make-comint. |
| 3802 | (sql-comint product options) | 4072 | (sql-comint product options) |
| 3803 | ) | 4073 | ) |
| 3804 | ;; ;; Properly escape newlines when DB2 is interactive. | ||
| 3805 | ;; (setq comint-input-sender 'sql-escape-newlines-and-send)) | ||
| 3806 | 4074 | ||
| 3807 | ;;;###autoload | 4075 | ;;;###autoload |
| 3808 | (defun sql-linter () | 4076 | (defun sql-linter (&optional buffer) |
| 3809 | "Run inl by RELEX as an inferior process. | 4077 | "Run inl by RELEX as an inferior process. |
| 3810 | 4078 | ||
| 3811 | If buffer `*SQL*' exists but no process is running, make a new process. | 4079 | If buffer `*SQL*' exists but no process is running, make a new process. |
| @@ -3827,9 +4095,14 @@ an empty password. | |||
| 3827 | The buffer is put in SQL interactive mode, giving commands for sending | 4095 | The buffer is put in SQL interactive mode, giving commands for sending |
| 3828 | input. See `sql-interactive-mode'. | 4096 | input. See `sql-interactive-mode'. |
| 3829 | 4097 | ||
| 4098 | To set the buffer name directly, use \\[universal-argument] | ||
| 4099 | before \\[sql-linter]. Once session has started, | ||
| 4100 | \\[sql-rename-buffer] can be called separately to rename the | ||
| 4101 | buffer. | ||
| 4102 | |||
| 3830 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" | 4103 | \(Type \\[describe-mode] in the SQL buffer for a list of commands.)" |
| 3831 | (interactive) | 4104 | (interactive "P") |
| 3832 | (sql-product-interactive 'linter)) | 4105 | (sql-product-interactive 'linter buffer)) |
| 3833 | 4106 | ||
| 3834 | (defun sql-comint-linter (product options) | 4107 | (defun sql-comint-linter (product options) |
| 3835 | "Create comint buffer and connect to Linter." | 4108 | "Create comint buffer and connect to Linter." |