From a9e8bfd4d7a98c425193b895ff22cdcd0920e0d7 Mon Sep 17 00:00:00 2001 From: Dimitri Fontaine Date: Wed, 30 Aug 2017 15:22:42 +0200 Subject: [PATCH] Support for colon characters in PostgreSQL socket path. Google Cloud SQL instances are now using the following format for the name of their socket ::. We do that by allowing to escape a colon in the socket directory name by doubling it, as in the username field. It also allows to accept any character in the socket directory name, which is a good cleanup. Fix #621. --- pgloader.1 | 14 ++++++++++++++ pgloader.1.md | 5 +++++ src/parsers/command-db-uri.lisp | 3 ++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pgloader.1 b/pgloader.1 index 9b17dcc..bd3cece 100644 --- a/pgloader.1 +++ b/pgloader.1 @@ -830,6 +830,20 @@ postgresql://unix:/tmp:54321/dbname . .IP The \fInetloc\fR defaults to the value of the \fBPGHOST\fR environment variable, and if it is unset, to either the default \fBunix\fR socket path when running on a Unix system, and \fBlocalhost\fR otherwise\. +. +.IP +Socket path containing colons are supported by doubling the colons within the path, as in the following example: +. +.IP "" 4 +. +.nf + +postgresql://unix:/tmp/project::region::instance:5432/dbname +. +.fi +. +.IP "" 0 + . .IP "\(bu" 4 \fIdbname\fR diff --git a/pgloader.1.md b/pgloader.1.md index e1bc0bf..ee326d9 100644 --- a/pgloader.1.md +++ b/pgloader.1.md @@ -704,6 +704,11 @@ Where: variable, and if it is unset, to either the default `unix` socket path when running on a Unix system, and `localhost` otherwise. + Socket path containing colons are supported by doubling the colons + within the path, as in the following example: + + postgresql://unix:/tmp/project::region::instance:5432/dbname + - *dbname* Should be a proper identifier (letter followed by a mix of letters, diff --git a/src/parsers/command-db-uri.lisp b/src/parsers/command-db-uri.lisp index 1bcc494..6351172 100644 --- a/src/parsers/command-db-uri.lisp +++ b/src/parsers/command-db-uri.lisp @@ -60,7 +60,8 @@ (or (member char #.(quote (coerce "/.-_" 'list))) (alphanumericp char))) -(defrule socket-directory (and "unix:" (* (socket-directory-character-p character))) +(defrule socket-directory (and "unix:" + (* (or (not ":") doubled-colon))) (:destructure (unix socket-directory) (declare (ignore unix)) (list :unix (when socket-directory (text socket-directory)))))