Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit294505e

Browse files
author
Neil Conway
committed
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", soI don't think it is likely to be rehabilitated any time soon.
1 parent72a5db1 commit294505e

File tree

1 file changed

+1
-170
lines changed

1 file changed

+1
-170
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 1 addition & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.310 2005/06/12 00:00:21 neilc Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.311 2005/06/12 00:07:07 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -460,18 +460,6 @@ connectOptions2(PGconn *conn)
460460
conn->pghost=NULL;
461461
}
462462

463-
#ifdefNOT_USED
464-
/*
465-
* parse dbName to get all additional info in it, if any
466-
*/
467-
if (update_db_info(conn)!=0)
468-
{
469-
conn->status=CONNECTION_BAD;
470-
/* errorMessage is already set */
471-
return false;
472-
}
473-
#endif
474-
475463
/*
476464
* validate sslmode option
477465
*/
@@ -644,163 +632,6 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions,
644632
}
645633

646634

647-
#ifdefNOT_USED/* because it's broken */
648-
/*
649-
* update_db_info -
650-
* get all additional info out of dbName
651-
*/
652-
staticint
653-
update_db_info(PGconn*conn)
654-
{
655-
char*tmp,
656-
*tmp2,
657-
*old=conn->dbName;
658-
659-
if (strchr(conn->dbName,'@')!=NULL)
660-
{
661-
/* old style: dbname[@server][:port] */
662-
tmp=strrchr(conn->dbName,':');
663-
if (tmp!=NULL)/* port number given */
664-
{
665-
if (conn->pgport)
666-
free(conn->pgport);
667-
conn->pgport=strdup(tmp+1);
668-
*tmp='\0';
669-
}
670-
671-
tmp=strrchr(conn->dbName,'@');
672-
if (tmp!=NULL)/* host name given */
673-
{
674-
if (conn->pghost)
675-
free(conn->pghost);
676-
conn->pghost=strdup(tmp+1);
677-
*tmp='\0';
678-
}
679-
680-
conn->dbName=strdup(old);
681-
free(old);
682-
}
683-
else
684-
{
685-
intoffset;
686-
687-
/*
688-
* only allow protocols tcp and unix
689-
*/
690-
if (strncmp(conn->dbName,"tcp:",4)==0)
691-
offset=4;
692-
elseif (strncmp(conn->dbName,"unix:",5)==0)
693-
offset=5;
694-
else
695-
return0;
696-
697-
if (strncmp(conn->dbName+offset,"postgresql://",strlen("postgresql://"))==0)
698-
{
699-
700-
/*-------
701-
* new style:
702-
*<tcp|unix>:postgresql://server[:port|:/unixsocket/path:]
703-
*[/db name][?options]
704-
*-------
705-
*/
706-
offset+=strlen("postgresql://");
707-
708-
tmp=strrchr(conn->dbName+offset,'?');
709-
if (tmp!=NULL)/* options given */
710-
{
711-
if (conn->pgoptions)
712-
free(conn->pgoptions);
713-
conn->pgoptions=strdup(tmp+1);
714-
*tmp='\0';
715-
}
716-
717-
tmp=last_dir_separator(conn->dbName+offset);
718-
if (tmp!=NULL)/* database name given */
719-
{
720-
if (conn->dbName)
721-
free(conn->dbName);
722-
conn->dbName=strdup(tmp+1);
723-
*tmp='\0';
724-
}
725-
else
726-
{
727-
/*
728-
* Why do we default only this value from the environment
729-
* again?
730-
*/
731-
if ((tmp=getenv("PGDATABASE"))!=NULL)
732-
{
733-
if (conn->dbName)
734-
free(conn->dbName);
735-
conn->dbName=strdup(tmp);
736-
}
737-
elseif (conn->pguser)
738-
{
739-
if (conn->dbName)
740-
free(conn->dbName);
741-
conn->dbName=strdup(conn->pguser);
742-
}
743-
}
744-
745-
tmp=strrchr(old+offset,':');
746-
if (tmp!=NULL)/* port number or Unix socket path given */
747-
{
748-
*tmp='\0';
749-
if ((tmp2=strchr(tmp+1,':'))!=NULL)
750-
{
751-
if (strncmp(old,"unix:",5)!=0)
752-
{
753-
printfPQExpBuffer(&conn->errorMessage,
754-
libpq_gettext("connectDBStart() -- "
755-
"socket name can only be specified with "
756-
"non-TCP\n"));
757-
return1;
758-
}
759-
*tmp2='\0';
760-
if (conn->pgunixsocket)
761-
free(conn->pgunixsocket);
762-
conn->pgunixsocket=strdup(tmp+1);
763-
}
764-
else
765-
{
766-
if (conn->pgport)
767-
free(conn->pgport);
768-
conn->pgport=strdup(tmp+1);
769-
if (conn->pgunixsocket)
770-
free(conn->pgunixsocket);
771-
conn->pgunixsocket=NULL;
772-
}
773-
}
774-
775-
if (strncmp(old,"unix:",5)==0)
776-
{
777-
if (conn->pghost)
778-
free(conn->pghost);
779-
conn->pghost=NULL;
780-
if (strcmp(old+offset,"localhost")!=0)
781-
{
782-
printfPQExpBuffer(&conn->errorMessage,
783-
libpq_gettext("connectDBStart() -- "
784-
"non-TCP access only possible on "
785-
"localhost\n"));
786-
return1;
787-
}
788-
}
789-
else
790-
{
791-
if (conn->pghost)
792-
free(conn->pghost);
793-
conn->pghost=strdup(old+offset);
794-
}
795-
free(old);
796-
}
797-
}
798-
799-
return0;
800-
}
801-
#endif/* NOT_USED */
802-
803-
804635
/* ----------
805636
* connectNoDelay -
806637
* Sets the TCP_NODELAY socket option.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp