Module: sip-router Branch: janakj/postgres Commit: dc24f971ded42f7315f389251120a6e39e364616 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=dc24f971...
Author: Maxim Sobolev sobomax@sippysoft.com Committer: Maxim Sobolev sobomax@sippysoft.com Date: Wed May 21 04:16:30 2008 +0000
Put back functionality lost during DB API 2.0 conversion. Allo '/' to be part of the "hostname" portion of the "URI". PostgreSQL allows using this to specify location of the unix domain socket for communication with the server. Example of such URL would be:
postgres://someuser@/var/run/sippy
Here the sippy is the database name, while /var/run is the location of the socket. This change should be backward compatible since '/' is not allowed in the database name.
---
modules/db_postgres/pg_uri.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/modules/db_postgres/pg_uri.c b/modules/db_postgres/pg_uri.c index 3f876d1..02fa494 100644 --- a/modules/db_postgres/pg_uri.c +++ b/modules/db_postgres/pg_uri.c @@ -169,6 +169,8 @@ static int parse_postgres_uri(struct pg_uri* res, str* uri) break;
case '/': + if (memchr(uri->s + i + 1, '/', uri->len - i - 1) != NULL) + break; if (dupl_string(&res->host, begin, uri->s + i) < 0) goto err; if (dupl_string(&res->database, uri->s + i + 1, uri->s + uri->len) < 0) goto err; @@ -186,6 +188,8 @@ static int parse_postgres_uri(struct pg_uri* res, str* uri) break;
case '/': + if (memchr(uri->s + i + 1, '/', uri->len - i - 1) != NULL) + break; res->host = prev_token; res->port = str2s(begin, uri->s + i - begin, 0); if (dupl_string(&res->database, uri->s + i + 1, uri->s + uri->len) < 0) @@ -203,6 +207,8 @@ static int parse_postgres_uri(struct pg_uri* res, str* uri) break;
case '/': + if (memchr(uri->s + i + 1, '/', uri->len - i - 1) != NULL) + break; if (dupl_string(&res->host, begin, uri->s + i) < 0) goto err; if (dupl_string(&res->database, uri->s + i + 1, uri->s + uri->len) < 0) goto err;