emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* custom port for postgresql
@ 2016-09-07 18:53 Jakob Lombacher
  2016-09-14  5:04 ` Adam Porter
  0 siblings, 1 reply; 2+ messages in thread
From: Jakob Lombacher @ 2016-09-07 18:53 UTC (permalink / raw)
  To: Emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 226 bytes --]

Hi,

I wondered why I couldn't connect to my database, and I figured out that a
custom port is not supported as header argument for postgresql.

I don't know how the merging in this project works, so here is the patch.

Jakob

[-- Attachment #1.2: Type: text/html, Size: 327 bytes --]

[-- Attachment #2: 0001-port-added-to-psql.patch --]
[-- Type: text/x-patch, Size: 1348 bytes --]

From 9043307466cabdf7d6c6fa2534c39ad00d42b522 Mon Sep 17 00:00:00 2001
From: Jakob Lombacher <Jakob@Lombacher.net>
Date: Wed, 31 Aug 2016 22:11:57 +0200
Subject: [PATCH] port added to psql

---
 lisp/ob-sql.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
index 7801c5f..25187a3 100644
--- a/lisp/ob-sql.el
+++ b/lisp/ob-sql.el
@@ -90,12 +90,13 @@
 	       (when password (concat "-p" password))
 	       (when database (concat "-D" database))))))
 
-(defun org-babel-sql-dbstring-postgresql (host user database)
+(defun org-babel-sql-dbstring-postgresql (host port user database)
   "Make PostgreSQL command line args for database connection.
 Pass nil to omit that arg."
   (combine-and-quote-strings
    (delq nil
 	 (list (when host (concat "-h" host))
+	       (when port     (format "-p%d" port))
 	       (when user (concat "-U" user))
 	       (when database (concat "-d" database))))))
 
@@ -171,7 +172,7 @@ This function is called by `org-babel-execute-src-block'."
 footer=off -F \"\t\"  %s -f %s -o %s %s"
 				  (if colnames-p "" "-t")
 				  (org-babel-sql-dbstring-postgresql
-				   dbhost dbuser database)
+				   dbhost dbport dbuser database)
 				  (org-babel-process-file-name in-file)
 				  (org-babel-process-file-name out-file)
 				  (or cmdline "")))
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: custom port for postgresql
  2016-09-07 18:53 custom port for postgresql Jakob Lombacher
@ 2016-09-14  5:04 ` Adam Porter
  0 siblings, 0 replies; 2+ messages in thread
From: Adam Porter @ 2016-09-14  5:04 UTC (permalink / raw)
  To: emacs-orgmode

Jakob Lombacher <Jakob@lombacher.net> writes:

> -(defun org-babel-sql-dbstring-postgresql (host user database)
> +(defun org-babel-sql-dbstring-postgresql (host port user database)

Hi Jakob,

Two suggestions:

1.  Generally people put something like "[PATCH]" in the subject so that
the maintainers will know it contains a patch.  :)

2.  I'd suggest putting the new `port` argument at the end of the
argument list, after an `&optional`.  Even though it makes more sense to
put it after the host, putting it at the end and making it optional
means that people won't have to change existing code that calls this
function.

Thanks for submitting the patch.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-14  5:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-07 18:53 custom port for postgresql Jakob Lombacher
2016-09-14  5:04 ` Adam Porter

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).