This patch removes some old code from libpq that implements a URI-like syntax for database connection parameters. It has been inside an #ifdef NOT_USED block since 2001 or so and is marked as "broken", so I don't think it is likely to be rehabilitated any time soon.

Barring any objections, I'll apply this to HEAD tomorrow.

-Neil
Index: src/interfaces/libpq/fe-connect.c
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.309
diff -c -r1.309 fe-connect.c
*** src/interfaces/libpq/fe-connect.c	10 Jun 2005 04:01:36 -0000	1.309
--- src/interfaces/libpq/fe-connect.c	11 Jun 2005 12:37:59 -0000
***************
*** 458,476 ****
  		conn->pghost = NULL;
  	}
  
- #ifdef NOT_USED
- 
- 	/*
- 	 * parse dbName to get all additional info in it, if any
- 	 */
- 	if (update_db_info(conn) != 0)
- 	{
- 		conn->status = CONNECTION_BAD;
- 		/* errorMessage is already set */
- 		return false;
- 	}
- #endif
- 
  	/*
  	 * validate sslmode option
  	 */
--- 458,463 ----
***************
*** 643,805 ****
  }
  
  
- #ifdef NOT_USED					/* because it's broken */
- /*
-  * update_db_info -
-  * get all additional info out of dbName
-  */
- static int
- update_db_info(PGconn *conn)
- {
- 	char	   *tmp,
- 			   *tmp2,
- 			   *old = conn->dbName;
- 
- 	if (strchr(conn->dbName, '@') != NULL)
- 	{
- 		/* old style: [EMAIL PROTECTED]:port] */
- 		tmp = strrchr(conn->dbName, ':');
- 		if (tmp != NULL)		/* port number given */
- 		{
- 			if (conn->pgport)
- 				free(conn->pgport);
- 			conn->pgport = strdup(tmp + 1);
- 			*tmp = '\0';
- 		}
- 
- 		tmp = strrchr(conn->dbName, '@');
- 		if (tmp != NULL)		/* host name given */
- 		{
- 			if (conn->pghost)
- 				free(conn->pghost);
- 			conn->pghost = strdup(tmp + 1);
- 			*tmp = '\0';
- 		}
- 
- 		conn->dbName = strdup(old);
- 		free(old);
- 	}
- 	else
- 	{
- 		int			offset;
- 
- 		/*
- 		 * only allow protocols tcp and unix
- 		 */
- 		if (strncmp(conn->dbName, "tcp:", 4) == 0)
- 			offset = 4;
- 		else if (strncmp(conn->dbName, "unix:", 5) == 0)
- 			offset = 5;
- 		else
- 			return 0;
- 
- 		if (strncmp(conn->dbName + offset, "postgresql://", strlen("postgresql://")) == 0)
- 		{
- 
- 			/*-------
- 			 * new style:
- 			 *	<tcp|unix>:postgresql://server[:port|:/unixsocket/path:]
- 			 *	[/db name][?options]
- 			 *-------
- 			 */
- 			offset += strlen("postgresql://");
- 
- 			tmp = strrchr(conn->dbName + offset, '?');
- 			if (tmp != NULL)	/* options given */
- 			{
- 				if (conn->pgoptions)
- 					free(conn->pgoptions);
- 				conn->pgoptions = strdup(tmp + 1);
- 				*tmp = '\0';
- 			}
- 
- 			tmp = last_dir_separator(conn->dbName + offset);
- 			if (tmp != NULL)	/* database name given */
- 			{
- 				if (conn->dbName)
- 					free(conn->dbName);
- 				conn->dbName = strdup(tmp + 1);
- 				*tmp = '\0';
- 			}
- 			else
- 			{
- 				/*
- 				 * Why do we default only this value from the environment
- 				 * again?
- 				 */
- 				if ((tmp = getenv("PGDATABASE")) != NULL)
- 				{
- 					if (conn->dbName)
- 						free(conn->dbName);
- 					conn->dbName = strdup(tmp);
- 				}
- 				else if (conn->pguser)
- 				{
- 					if (conn->dbName)
- 						free(conn->dbName);
- 					conn->dbName = strdup(conn->pguser);
- 				}
- 			}
- 
- 			tmp = strrchr(old + offset, ':');
- 			if (tmp != NULL)	/* port number or Unix socket path given */
- 			{
- 				*tmp = '\0';
- 				if ((tmp2 = strchr(tmp + 1, ':')) != NULL)
- 				{
- 					if (strncmp(old, "unix:", 5) != 0)
- 					{
- 						printfPQExpBuffer(&conn->errorMessage,
- 										  libpq_gettext("connectDBStart() -- "
- 										  "socket name can only be specified with "
- 										  "non-TCP\n"));
- 						return 1;
- 					}
- 					*tmp2 = '\0';
- 					if (conn->pgunixsocket)
- 						free(conn->pgunixsocket);
- 					conn->pgunixsocket = strdup(tmp + 1);
- 				}
- 				else
- 				{
- 					if (conn->pgport)
- 						free(conn->pgport);
- 					conn->pgport = strdup(tmp + 1);
- 					if (conn->pgunixsocket)
- 						free(conn->pgunixsocket);
- 					conn->pgunixsocket = NULL;
- 				}
- 			}
- 
- 			if (strncmp(old, "unix:", 5) == 0)
- 			{
- 				if (conn->pghost)
- 					free(conn->pghost);
- 				conn->pghost = NULL;
- 				if (strcmp(old + offset, "localhost") != 0)
- 				{
- 					printfPQExpBuffer(&conn->errorMessage,
- 									  libpq_gettext("connectDBStart() -- "
- 									  "non-TCP access only possible on "
- 									  "localhost\n"));
- 					return 1;
- 				}
- 			}
- 			else
- 			{
- 				if (conn->pghost)
- 					free(conn->pghost);
- 				conn->pghost = strdup(old + offset);
- 			}
- 			free(old);
- 		}
- 	}
- 
- 	return 0;
- }
- #endif   /* NOT_USED */
- 
- 
  /* ----------
   * connectNoDelay -
   * Sets the TCP_NODELAY socket option.
--- 630,635 ----
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match

Reply via email to