emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: [PATCH] custom port for postgresql
@ 2016-09-16  7:48 Jakob Lombacher
  2016-09-17  8:39 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Jakob Lombacher @ 2016-09-16  7:48 UTC (permalink / raw)
  To: Adam Porter; +Cc: emacs-orgmode


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

Hi Adam,

thanks for the "patch" hint ;-)

I changed the dbport as optional argument and added the dbpassword option
as well.

Jakob

2016-09-14 7:04 GMT+02:00 Adam Porter <adam@alphapapa.net>:

> 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.
>
>
>

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

[-- Attachment #2: 0001-add-dbport-and-dbpassword-options-to-psql.patch --]
[-- Type: text/x-patch, Size: 1676 bytes --]

From e92e5982c3a8db125e161d676835b47ed3806071 Mon Sep 17 00:00:00 2001
From: Jakob Lombacher <Jakob@Lombacher.net>
Date: Fri, 16 Sep 2016 09:12:56 +0200
Subject: [PATCH] add dbport and dbpassword options to psql

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

diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
index 7801c5f..ed7feb8 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 user database &optional port)
   "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))))))
 
@@ -167,11 +168,12 @@ This function is called by `org-babel-execute-src-block'."
 				    (org-babel-process-file-name in-file)
 				    (org-babel-process-file-name out-file)))
 		    (`postgresql (format
-				  "psql --set=\"ON_ERROR_STOP=1\" %s -A -P \
+				  "%spsql --set=\"ON_ERROR_STOP=1\" %s -A -P \
 footer=off -F \"\t\"  %s -f %s -o %s %s"
+				  (if dbpassword (format "PGPASSWORD=%s " dbpassword) "")
 				  (if colnames-p "" "-t")
 				  (org-babel-sql-dbstring-postgresql
-				   dbhost dbuser database)
+				   dbhost dbuser database dbport)
 				  (org-babel-process-file-name in-file)
 				  (org-babel-process-file-name out-file)
 				  (or cmdline "")))
-- 
2.8.1


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

* Re: [PATCH] custom port for postgresql
  2016-09-16  7:48 [PATCH] custom port for postgresql Jakob Lombacher
@ 2016-09-17  8:39 ` Nicolas Goaziou
  2016-09-22 14:03   ` Jakob Lombacher
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2016-09-17  8:39 UTC (permalink / raw)
  To: Jakob Lombacher; +Cc: Adam Porter, emacs-orgmode

Hello,

Jakob Lombacher <Jakob@lombacher.net> writes:

> I changed the dbport as optional argument and added the dbpassword option
> as well.

I applied your patch with the modifications below:

- I added a proper commit message

- I added TINYCHANGE cookie

- I reordered dbport argument as in your initial patch. Although the
  recommendation of making it optional makes sense, it breaks
  consistency with other "dbstring" functions, and this is an internal
  function anyway.

Could you provide an entry for ORG-NEWS file?

Thank you for the patch.

Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] custom port for postgresql
  2016-09-17  8:39 ` Nicolas Goaziou
@ 2016-09-22 14:03   ` Jakob Lombacher
  2016-09-22 19:50     ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Jakob Lombacher @ 2016-09-22 14:03 UTC (permalink / raw)
  To: Jakob Lombacher, Adam Porter, emacs-orgmode


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

Hi Nicolas,

sure, here you go.

All the best

Jakob

2016-09-17 10:39 GMT+02:00 Nicolas Goaziou <mail@nicolasgoaziou.fr>:

> Hello,
>
> Jakob Lombacher <Jakob@lombacher.net> writes:
>
> > I changed the dbport as optional argument and added the dbpassword option
> > as well.
>
> I applied your patch with the modifications below:
>
> - I added a proper commit message
>
> - I added TINYCHANGE cookie
>
> - I reordered dbport argument as in your initial patch. Although the
>   recommendation of making it optional makes sense, it breaks
>   consistency with other "dbstring" functions, and this is an internal
>   function anyway.
>
> Could you provide an entry for ORG-NEWS file?
>
> Thank you for the patch.
>
> Regards,
>
> --
> Nicolas Goaziou
>

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

[-- Attachment #2: 0001-ORG-NEWS-support-of-header-argument-for-postgresql.patch --]
[-- Type: text/x-patch, Size: 1007 bytes --]

From dd964b7af9ea082a5d8d71630565899dabf7a116 Mon Sep 17 00:00:00 2001
From: Jakob Lombacher <Jakob@Lombacher.net>
Date: Thu, 22 Sep 2016 15:59:35 +0200
Subject: [PATCH] ORG-NEWS support of header argument for postgresql

---
 etc/ORG-NEWS | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index eda018f..de99f7b 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -317,6 +317,11 @@ Alice <-- Bob: another authentication Response
 Please note that *pdf* *does not work out of the box* and needss
 additional setup in addition to plantuml. See
 [[http://plantuml.com/pdf.html]] for details and setup information.
+**** Improved support of header arguments for postgresql 
+     The postgresql engine in a sql code block supports now *:dbport*
+     and *:dbpassword* as header arguments.
+     
+     
 *** Rewrite of radio lists
 Radio lists, i.e, Org plain lists in foreign buffers, have been
 rewritten to be on par with Radio tables.  You can use a large set of
-- 
2.8.1


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

* Re: [PATCH] custom port for postgresql
  2016-09-22 14:03   ` Jakob Lombacher
@ 2016-09-22 19:50     ` Nicolas Goaziou
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2016-09-22 19:50 UTC (permalink / raw)
  To: Jakob Lombacher; +Cc: Adam Porter, emacs-orgmode

Hello,

Jakob Lombacher <Jakob@lombacher.net> writes:

> Hi Nicolas,
>
> sure, here you go.

Applied. Thank you.

Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2016-09-22 19:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-16  7:48 [PATCH] custom port for postgresql Jakob Lombacher
2016-09-17  8:39 ` Nicolas Goaziou
2016-09-22 14:03   ` Jakob Lombacher
2016-09-22 19:50     ` Nicolas Goaziou

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).