Przeglądaj źródła

Change DSN parser a bit, so that it's possible to specify path to the unix
domain socket for communication with DB server. Consider everything after '@'
but before the last '/' to be host name (currently everything after '@' but
before first '/' is considered hostname), so that in the case of the socket
in the /foo/bar directory, one can specify DSN as follows:

postgres://username:password@/foo/bar/name_of_table

No response from: [email protected]

Maxim Sobolev 21 lat temu
rodzic
commit
e39877fe6b
1 zmienionych plików z 3 dodań i 1 usunięć
  1. 3 1
      modules/db_postgres/db_utils.c

+ 3 - 1
modules/db_postgres/db_utils.c

@@ -77,7 +77,9 @@ int parse_sql_url(char* _url, char** _user, char** _pass,
 
 
 	at = strchr(slash, '@');
 	at = strchr(slash, '@');
 
 
-	db_slash = strchr(slash, '/');
+	db_slash = strrchr(slash, '/');
+	if (db_slash <= at)
+		db_slash = NULL;
 	if (db_slash) {
 	if (db_slash) {
 		*db_slash++ = '\0';
 		*db_slash++ = '\0';
 		*_db = trim(db_slash);
 		*_db = trim(db_slash);