我能够通过应用程序“ pgAdmin III”连接到Linux上的PostgreSQL服务器。这是图片
但是当我尝试使用命令M-x sql-postgres
将Emacs连接到该数据库时,输出显示为string-prefix-p: Wrong type argument: stringp, nil
。
我认为可能是由于两个原因。
我在服务器上输入了错误的登录信息。为了清楚起见,这是我根据上图中服务器连接输入的信息,“用户”:postgres,“数据库”:postgres,“服务器”:PostgreSQL 10,“端口”:5433。
另一个原因可能是我的.emacs
文件中未包含服务器路径。服务器安装在目录/home/myname/Postgresql/
中,这是我在.emacs
中添加的内容,但(add-to-list 'load-path "/home/myname/Postgresql/")
仍然不起作用。
有人可以帮我吗?当我尝试连接到mysql服务器时,也会发生同样的事情。 mysql和postsql(包括服务器)在Linux上的Emacs外部均可正常运行。但是我只是不知道如何将我的Emacs连接到那些服务器。
使用M-x toggle-debug-on-error
将“服务器”更新为“本地主机”后,错误更新
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
compare-strings(" " nil nil nil 0 1 nil)
string-prefix-p(" " nil)
sql-buffer-hidden-p(nil)
(or (sql-buffer-hidden-p buf) (not sql-display-sqli-buffer-function))
(if (or (sql-buffer-hidden-p buf) (not sql-display-sqli-buffer-function)) nil (make-progress-reporter message min-value max-value current-value min-change min-time))
sql-make-progress-reporter(nil "Login")
(setq rpt (sql-make-progress-reporter nil "Login"))
(let ((start-buffer (current-buffer)) new-sqli-buffer rpt) (apply (function sql-get-login) (sql-get-product-feature product :sqli-login)) (setq rpt (sql-make-progress-reporter nil "Login")) (let ((sql-user (default-value (quote sql-user))) (sql-password (default-value (quote sql-password))) (sql-server (default-value (quote sql-server))) (sql-database (default-value (quote sql-database))) (sql-port (default-value (quote sql-port))) (default-directory (or sql-default-directory default-directory))) (funcall (sql-get-product-feature product :sqli-comint-func) product (sql-get-product-feature product :sqli-options) (cond ((not new-name) (sql-generate-unique-sqli-buffer-name product nil)) ((consp new-name) (sql-generate-unique-sqli-buffer-name product (read-string "Buffer name (\"*SQL: XXX*\"; enter `XXX'): " (sql-make-alternate-buffer-name product)))) ((or (string-prefix-p " " new-name) (string-match-p "\\`[*].*[*]\\'" new-name)) new-name) ((stringp new-name) (sql-generate-unique-sqli-buffer-name product new-name)) (t (sql-generate-unique-sqli-buffer-name product nil))))) (let ((sql-interactive-product product)) (sql-interactive-mode)) (setq new-sqli-buffer (current-buffer)) (set (make-local-variable (quote sql-buffer)) (buffer-name new-sqli-buffer)) (save-current-buffer (set-buffer start-buffer) (if (derived-mode-p (quote sql-mode)) (progn (setq sql-buffer (buffer-name new-sqli-buffer)) (run-hooks (quote sql-set-sqli-hook))))) (let ((proc (get-buffer-process new-sqli-buffer)) (secs sql-login-delay) (step 0.3)) (while (and (memq (process-status proc) (quote (open run))) (or (accept-process-output proc step) (<= 0.0 (setq secs (- secs step)))) (progn (goto-char (point-max)) (not (re-search-backward sql-prompt-regexp 0 t)))) (sql-progress-reporter-update rpt))) (goto-char (point-max)) (if (re-search-backward sql-prompt-regexp nil t) (progn (run-hooks (quote sql-login-hook)))) (sql-progress-reporter-done rpt) (goto-char (point-max)) (let ((sql-display-sqli-buffer-function t)) (sql-display-buffer new-sqli-buffer)) (get-buffer new-sqli-buffer))
(if (and buf (or (not new-name) (and (stringp new-name) (string-match-p (regexp-quote new-name) buf)))) (sql-display-buffer buf) (let ((start-buffer (current-buffer)) new-sqli-buffer rpt) (apply (function sql-get-login) (sql-get-product-feature product :sqli-login)) (setq rpt (sql-make-progress-reporter nil "Login")) (let ((sql-user (default-value (quote sql-user))) (sql-password (default-value (quote sql-password))) (sql-server (default-value (quote sql-server))) (sql-database (default-value (quote sql-database))) (sql-port (default-value (quote sql-port))) (default-directory (or sql-default-directory default-directory))) (funcall (sql-get-product-feature product :sqli-comint-func) product (sql-get-product-feature product :sqli-options) (cond ((not new-name) (sql-generate-unique-sqli-buffer-name product nil)) ((consp new-name) (sql-generate-unique-sqli-buffer-name product (read-string "Buffer name (\"*SQL: XXX*\"; enter `XXX'): " ...))) ((or (string-prefix-p " " new-name) (string-match-p "\\`[*].*[*]\\'" new-name)) new-name) ((stringp new-name) (sql-generate-unique-sqli-buffer-name product new-name)) (t (sql-generate-unique-sqli-buffer-name product nil))))) (let ((sql-interactive-product product)) (sql-interactive-mode)) (setq new-sqli-buffer (current-buffer)) (set (make-local-variable (quote sql-buffer)) (buffer-name new-sqli-buffer)) (save-current-buffer (set-buffer start-buffer) (if (derived-mode-p (quote sql-mode)) (progn (setq sql-buffer (buffer-name new-sqli-buffer)) (run-hooks (quote sql-set-sqli-hook))))) (let ((proc (get-buffer-process new-sqli-buffer)) (secs sql-login-delay) (step 0.3)) (while (and (memq (process-status proc) (quote (open run))) (or (accept-process-output proc step) (<= 0.0 (setq secs ...))) (progn (goto-char (point-max)) (not (re-search-backward sql-prompt-regexp 0 t)))) (sql-progress-reporter-update rpt))) (goto-char (point-max)) (if (re-search-backward sql-prompt-regexp nil t) (progn (run-hooks (quote sql-login-hook)))) (sql-progress-reporter-done rpt) (goto-char (point-max)) (let ((sql-display-sqli-buffer-function t)) (sql-display-buffer new-sqli-buffer)) (get-buffer new-sqli-buffer)))
(let ((buf (sql-find-sqli-buffer product sql-connection))) (if (and buf (or (not new-name) (and (stringp new-name) (string-match-p (regexp-quote new-name) buf)))) (sql-display-buffer buf) (let ((start-buffer (current-buffer)) new-sqli-buffer rpt) (apply (function sql-get-login) (sql-get-product-feature product :sqli-login)) (setq rpt (sql-make-progress-reporter nil "Login")) (let ((sql-user (default-value (quote sql-user))) (sql-password (default-value (quote sql-password))) (sql-server (default-value (quote sql-server))) (sql-database (default-value (quote sql-database))) (sql-port (default-value (quote sql-port))) (default-directory (or sql-default-directory default-directory))) (funcall (sql-get-product-feature product :sqli-comint-func) product (sql-get-product-feature product :sqli-options) (cond ((not new-name) (sql-generate-unique-sqli-buffer-name product nil)) ((consp new-name) (sql-generate-unique-sqli-buffer-name product ...)) ((or ... ...) new-name) ((stringp new-name) (sql-generate-unique-sqli-buffer-name product new-name)) (t (sql-generate-unique-sqli-buffer-name product nil))))) (let ((sql-interactive-product product)) (sql-interactive-mode)) (setq new-sqli-buffer (current-buffer)) (set (make-local-variable (quote sql-buffer)) (buffer-name new-sqli-buffer)) (save-current-buffer (set-buffer start-buffer) (if (derived-mode-p (quote sql-mode)) (progn (setq sql-buffer (buffer-name new-sqli-buffer)) (run-hooks (quote sql-set-sqli-hook))))) (let ((proc (get-buffer-process new-sqli-buffer)) (secs sql-login-delay) (step 0.3)) (while (and (memq (process-status proc) (quote ...)) (or (accept-process-output proc step) (<= 0.0 ...)) (progn (goto-char ...) (not ...))) (sql-progress-reporter-update rpt))) (goto-char (point-max)) (if (re-search-backward sql-prompt-regexp nil t) (progn (run-hooks (quote sql-login-hook)))) (sql-progress-reporter-done rpt) (goto-char (point-max)) (let ((sql-display-sqli-buffer-function t)) (sql-display-buffer new-sqli-buffer)) (get-buffer new-sqli-buffer))))
(progn (let ((buf (sql-find-sqli-buffer product sql-connection))) (if (and buf (or (not new-name) (and (stringp new-name) (string-match-p (regexp-quote new-name) buf)))) (sql-display-buffer buf) (let ((start-buffer (current-buffer)) new-sqli-buffer rpt) (apply (function sql-get-login) (sql-get-product-feature product :sqli-login)) (setq rpt (sql-make-progress-reporter nil "Login")) (let ((sql-user (default-value ...)) (sql-password (default-value ...)) (sql-server (default-value ...)) (sql-database (default-value ...)) (sql-port (default-value ...)) (default-directory (or sql-default-directory default-directory))) (funcall (sql-get-product-feature product :sqli-comint-func) product (sql-get-product-feature product :sqli-options) (cond (... ...) (... ...) (... new-name) (... ...) (t ...)))) (let ((sql-interactive-product product)) (sql-interactive-mode)) (setq new-sqli-buffer (current-buffer)) (set (make-local-variable (quote sql-buffer)) (buffer-name new-sqli-buffer)) (save-current-buffer (set-buffer start-buffer) (if (derived-mode-p (quote sql-mode)) (progn (setq sql-buffer ...) (run-hooks ...)))) (let ((proc (get-buffer-process new-sqli-buffer)) (secs sql-login-delay) (step 0.3)) (while (and (memq ... ...) (or ... ...) (progn ... ...)) (sql-progress-reporter-update rpt))) (goto-char (point-max)) (if (re-search-backward sql-prompt-regexp nil t) (progn (run-hooks (quote sql-login-hook)))) (sql-progress-reporter-done rpt) (goto-char (point-max)) (let ((sql-display-sqli-buffer-function t)) (sql-display-buffer new-sqli-buffer)) (get-buffer new-sqli-buffer)))))
(if (sql-get-product-feature product :sqli-comint-func) (progn (let ((buf (sql-find-sqli-buffer product sql-connection))) (if (and buf (or (not new-name) (and (stringp new-name) (string-match-p ... buf)))) (sql-display-buffer buf) (let ((start-buffer (current-buffer)) new-sqli-buffer rpt) (apply (function sql-get-login) (sql-get-product-feature product :sqli-login)) (setq rpt (sql-make-progress-reporter nil "Login")) (let ((sql-user ...) (sql-password ...) (sql-server ...) (sql-database ...) (sql-port ...) (default-directory ...)) (funcall (sql-get-product-feature product :sqli-comint-func) product (sql-get-product-feature product :sqli-options) (cond ... ... ... ... ...))) (let ((sql-interactive-product product)) (sql-interactive-mode)) (setq new-sqli-buffer (current-buffer)) (set (make-local-variable (quote sql-buffer)) (buffer-name new-sqli-buffer)) (save-current-buffer (set-buffer start-buffer) (if (derived-mode-p ...) (progn ... ...))) (let ((proc ...) (secs sql-login-delay) (step 0.3)) (while (and ... ... ...) (sql-progress-reporter-update rpt))) (goto-char (point-max)) (if (re-search-backward sql-prompt-regexp nil t) (progn (run-hooks ...))) (sql-progress-reporter-done rpt) (goto-char (point-max)) (let ((sql-display-sqli-buffer-function t)) (sql-display-buffer new-sqli-buffer)) (get-buffer new-sqli-buffer))))))
(if product (if (sql-get-product-feature product :sqli-comint-func) (progn (let ((buf (sql-find-sqli-buffer product sql-connection))) (if (and buf (or (not new-name) (and ... ...))) (sql-display-buffer buf) (let ((start-buffer ...) new-sqli-buffer rpt) (apply (function sql-get-login) (sql-get-product-feature product :sqli-login)) (setq rpt (sql-make-progress-reporter nil "Login")) (let (... ... ... ... ... ...) (funcall ... product ... ...)) (let (...) (sql-interactive-mode)) (setq new-sqli-buffer (current-buffer)) (set (make-local-variable ...) (buffer-name new-sqli-buffer)) (save-current-buffer (set-buffer start-buffer) (if ... ...)) (let (... ... ...) (while ... ...)) (goto-char (point-max)) (if (re-search-backward sql-prompt-regexp nil t) (progn ...)) (sql-progress-reporter-done rpt) (goto-char (point-max)) (let (...) (sql-display-buffer new-sqli-buffer)) (get-buffer new-sqli-buffer)))))) (user-error "No default SQL product defined: set `sql-product'"))
sql-product-interactive(postgres nil)
sql-postgres(nil)
call-interactively(sql-postgres record nil)
command-execute(sql-postgres record)
execute-extended-command(nil "sql-postgres")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)