Skip to content

Commit 774bcff

Browse files
committed
libpq: Change some static functions to extern
This is in preparation of a follow up commit that starts using these functions from fe-cancel.c. Author: Jelte Fennema-Nio <jelte.fennema@microsoft.com> Discussion: https://postgr.es/m/AM5PR83MB0178D3B31CA1B6EC4A8ECC42F7529@AM5PR83MB0178.EURPRD83.prod.outlook.com
1 parent 53747f7 commit 774bcff

File tree

2 files changed

+46
-46
lines changed

2 files changed

+46
-46
lines changed

src/interfaces/libpq/fe-connect.c

Lines changed: 41 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -387,15 +387,10 @@ static const char uri_designator[] = "postgresql://";
387387
static const char short_uri_designator[] = "postgres://";
388388

389389
static bool connectOptions1(PGconn *conn, const char *conninfo);
390-
static bool connectOptions2(PGconn *conn);
391-
static int connectDBStart(PGconn *conn);
392-
static int connectDBComplete(PGconn *conn);
393390
static PGPing internal_ping(PGconn *conn);
394-
static PGconn *makeEmptyPGconn(void);
395391
static void pqFreeCommandQueue(PGcmdQueueEntry *queue);
396392
static bool fillPGconn(PGconn *conn, PQconninfoOption *connOptions);
397393
static void freePGconn(PGconn *conn);
398-
static void closePGconn(PGconn *conn);
399394
static void release_conn_addrinfo(PGconn *conn);
400395
static int store_conn_addrinfo(PGconn *conn, struct addrinfo *addrlist);
401396
static void sendTerminateConn(PGconn *conn);
@@ -644,8 +639,8 @@ pqDropServerData(PGconn *conn)
644639
* PQconnectStart or PQconnectStartParams (which differ in the same way as
645640
* PQconnectdb and PQconnectdbParams) and PQconnectPoll.
646641
*
647-
* Internally, the static functions connectDBStart, connectDBComplete
648-
* are part of the connection procedure.
642+
* The non-exported functions pqConnectDBStart, pqConnectDBComplete are
643+
* part of the connection procedure implementation.
649644
*/
650645

651646
/*
@@ -678,7 +673,7 @@ PQconnectdbParams(const char *const *keywords,
678673
PGconn *conn = PQconnectStartParams(keywords, values, expand_dbname);
679674

680675
if (conn && conn->status != CONNECTION_BAD)
681-
(void) connectDBComplete(conn);
676+
(void) pqConnectDBComplete(conn);
682677

683678
return conn;
684679
}
@@ -731,7 +726,7 @@ PQconnectdb(const char *conninfo)
731726
PGconn *conn = PQconnectStart(conninfo);
732727

733728
if (conn && conn->status != CONNECTION_BAD)
734-
(void) connectDBComplete(conn);
729+
(void) pqConnectDBComplete(conn);
735730

736731
return conn;
737732
}
@@ -785,7 +780,7 @@ PQconnectStartParams(const char *const *keywords,
785780
* to initialize conn->errorMessage to empty. All subsequent steps during
786781
* connection initialization will only append to that buffer.
787782
*/
788-
conn = makeEmptyPGconn();
783+
conn = pqMakeEmptyPGconn();
789784
if (conn == NULL)
790785
return NULL;
791786

@@ -819,15 +814,15 @@ PQconnectStartParams(const char *const *keywords,
819814
/*
820815
* Compute derived options
821816
*/
822-
if (!connectOptions2(conn))
817+
if (!pqConnectOptions2(conn))
823818
return conn;
824819

825820
/*
826821
* Connect to the database
827822
*/
828-
if (!connectDBStart(conn))
823+
if (!pqConnectDBStart(conn))
829824
{
830-
/* Just in case we failed to set it in connectDBStart */
825+
/* Just in case we failed to set it in pqConnectDBStart */
831826
conn->status = CONNECTION_BAD;
832827
}
833828

@@ -863,7 +858,7 @@ PQconnectStart(const char *conninfo)
863858
* to initialize conn->errorMessage to empty. All subsequent steps during
864859
* connection initialization will only append to that buffer.
865860
*/
866-
conn = makeEmptyPGconn();
861+
conn = pqMakeEmptyPGconn();
867862
if (conn == NULL)
868863
return NULL;
869864

@@ -876,15 +871,15 @@ PQconnectStart(const char *conninfo)
876871
/*
877872
* Compute derived options
878873
*/
879-
if (!connectOptions2(conn))
874+
if (!pqConnectOptions2(conn))
880875
return conn;
881876

882877
/*
883878
* Connect to the database
884879
*/
885-
if (!connectDBStart(conn))
880+
if (!pqConnectDBStart(conn))
886881
{
887-
/* Just in case we failed to set it in connectDBStart */
882+
/* Just in case we failed to set it in pqConnectDBStart */
888883
conn->status = CONNECTION_BAD;
889884
}
890885

@@ -895,7 +890,7 @@ PQconnectStart(const char *conninfo)
895890
* Move option values into conn structure
896891
*
897892
* Don't put anything cute here --- intelligence should be in
898-
* connectOptions2 ...
893+
* pqConnectOptions2 ...
899894
*
900895
* Returns true on success. On failure, returns false and sets error message.
901896
*/
@@ -933,7 +928,7 @@ fillPGconn(PGconn *conn, PQconninfoOption *connOptions)
933928
*
934929
* Internal subroutine to set up connection parameters given an already-
935930
* created PGconn and a conninfo string. Derived settings should be
936-
* processed by calling connectOptions2 next. (We split them because
931+
* processed by calling pqConnectOptions2 next. (We split them because
937932
* PQsetdbLogin overrides defaults in between.)
938933
*
939934
* Returns true if OK, false if trouble (in which case errorMessage is set
@@ -1055,15 +1050,15 @@ libpq_prng_init(PGconn *conn)
10551050
}
10561051

10571052
/*
1058-
* connectOptions2
1053+
* pqConnectOptions2
10591054
*
10601055
* Compute derived connection options after absorbing all user-supplied info.
10611056
*
10621057
* Returns true if OK, false if trouble (in which case errorMessage is set
10631058
* and so is conn->status).
10641059
*/
1065-
static bool
1066-
connectOptions2(PGconn *conn)
1060+
bool
1061+
pqConnectOptions2(PGconn *conn)
10671062
{
10681063
int i;
10691064

@@ -1822,7 +1817,7 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions,
18221817
* to initialize conn->errorMessage to empty. All subsequent steps during
18231818
* connection initialization will only append to that buffer.
18241819
*/
1825-
conn = makeEmptyPGconn();
1820+
conn = pqMakeEmptyPGconn();
18261821
if (conn == NULL)
18271822
return NULL;
18281823

@@ -1901,14 +1896,14 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions,
19011896
/*
19021897
* Compute derived options
19031898
*/
1904-
if (!connectOptions2(conn))
1899+
if (!pqConnectOptions2(conn))
19051900
return conn;
19061901

19071902
/*
19081903
* Connect to the database
19091904
*/
1910-
if (connectDBStart(conn))
1911-
(void) connectDBComplete(conn);
1905+
if (pqConnectDBStart(conn))
1906+
(void) pqConnectDBComplete(conn);
19121907

19131908
return conn;
19141909

@@ -2277,14 +2272,14 @@ setTCPUserTimeout(PGconn *conn)
22772272
}
22782273

22792274
/* ----------
2280-
* connectDBStart -
2275+
* pqConnectDBStart -
22812276
* Begin the process of making a connection to the backend.
22822277
*
22832278
* Returns 1 if successful, 0 if not.
22842279
* ----------
22852280
*/
2286-
static int
2287-
connectDBStart(PGconn *conn)
2281+
int
2282+
pqConnectDBStart(PGconn *conn)
22882283
{
22892284
if (!conn)
22902285
return 0;
@@ -2347,14 +2342,14 @@ connectDBStart(PGconn *conn)
23472342

23482343

23492344
/*
2350-
* connectDBComplete
2345+
* pqConnectDBComplete
23512346
*
23522347
* Block and complete a connection.
23532348
*
23542349
* Returns 1 on success, 0 on failure.
23552350
*/
2356-
static int
2357-
connectDBComplete(PGconn *conn)
2351+
int
2352+
pqConnectDBComplete(PGconn *conn)
23582353
{
23592354
PostgresPollingStatusType flag = PGRES_POLLING_WRITING;
23602355
time_t finish_time = ((time_t) -1);
@@ -2704,7 +2699,7 @@ PQconnectPoll(PGconn *conn)
27042699
* combining it with the insertion.
27052700
*
27062701
* We don't need to initialize conn->prng_state here, because that
2707-
* already happened in connectOptions2.
2702+
* already happened in pqConnectOptions2.
27082703
*/
27092704
for (int i = 1; i < conn->naddr; i++)
27102705
{
@@ -4181,7 +4176,7 @@ internal_ping(PGconn *conn)
41814176

41824177
/* Attempt to complete the connection */
41834178
if (conn->status != CONNECTION_BAD)
4184-
(void) connectDBComplete(conn);
4179+
(void) pqConnectDBComplete(conn);
41854180

41864181
/* Definitely OK if we succeeded */
41874182
if (conn->status != CONNECTION_BAD)
@@ -4233,11 +4228,11 @@ internal_ping(PGconn *conn)
42334228

42344229

42354230
/*
4236-
* makeEmptyPGconn
4231+
* pqMakeEmptyPGconn
42374232
* - create a PGconn data structure with (as yet) no interesting data
42384233
*/
4239-
static PGconn *
4240-
makeEmptyPGconn(void)
4234+
PGconn *
4235+
pqMakeEmptyPGconn(void)
42414236
{
42424237
PGconn *conn;
42434238

@@ -4330,7 +4325,7 @@ makeEmptyPGconn(void)
43304325
* freePGconn
43314326
* - free an idle (closed) PGconn data structure
43324327
*
4333-
* NOTE: this should not overlap any functionality with closePGconn().
4328+
* NOTE: this should not overlap any functionality with pqClosePGconn().
43344329
* Clearing/resetting of transient state belongs there; what we do here is
43354330
* release data that is to be held for the life of the PGconn structure.
43364331
* If a value ought to be cleared/freed during PQreset(), do it there not here.
@@ -4517,15 +4512,15 @@ sendTerminateConn(PGconn *conn)
45174512
}
45184513

45194514
/*
4520-
* closePGconn
4515+
* pqClosePGconn
45214516
* - properly close a connection to the backend
45224517
*
45234518
* This should reset or release all transient state, but NOT the connection
45244519
* parameters. On exit, the PGconn should be in condition to start a fresh
45254520
* connection with the same parameters (see PQreset()).
45264521
*/
4527-
static void
4528-
closePGconn(PGconn *conn)
4522+
void
4523+
pqClosePGconn(PGconn *conn)
45294524
{
45304525
/*
45314526
* If possible, send Terminate message to close the connection politely.
@@ -4568,7 +4563,7 @@ PQfinish(PGconn *conn)
45684563
{
45694564
if (conn)
45704565
{
4571-
closePGconn(conn);
4566+
pqClosePGconn(conn);
45724567
freePGconn(conn);
45734568
}
45744569
}
@@ -4582,9 +4577,9 @@ PQreset(PGconn *conn)
45824577
{
45834578
if (conn)
45844579
{
4585-
closePGconn(conn);
4580+
pqClosePGconn(conn);
45864581

4587-
if (connectDBStart(conn) && connectDBComplete(conn))
4582+
if (pqConnectDBStart(conn) && pqConnectDBComplete(conn))
45884583
{
45894584
/*
45904585
* Notify event procs of successful reset.
@@ -4615,9 +4610,9 @@ PQresetStart(PGconn *conn)
46154610
{
46164611
if (conn)
46174612
{
4618-
closePGconn(conn);
4613+
pqClosePGconn(conn);
46194614

4620-
return connectDBStart(conn);
4615+
return pqConnectDBStart(conn);
46214616
}
46224617

46234618
return 0;

src/interfaces/libpq/libpq-int.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,15 @@ extern char *const pgresStatus[];
675675
/* === in fe-connect.c === */
676676

677677
extern void pqDropConnection(PGconn *conn, bool flushInput);
678+
extern bool pqConnectOptions2(PGconn *conn);
678679
#if defined(WIN32) && defined(SIO_KEEPALIVE_VALS)
679680
extern int pqSetKeepalivesWin32(pgsocket sock, int idle, int interval);
680681
#endif
682+
extern int pqConnectDBStart(PGconn *conn);
683+
extern int pqConnectDBComplete(PGconn *conn);
684+
extern PGconn *pqMakeEmptyPGconn(void);
681685
extern void pqReleaseConnHosts(PGconn *conn);
686+
extern void pqClosePGconn(PGconn *conn);
682687
extern int pqPacketSend(PGconn *conn, char pack_type,
683688
const void *buf, size_t buf_len);
684689
extern bool pqGetHomeDirectory(char *buf, int bufsize);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy