* PQconnectStart * * Begins the establishment of a connection to a postgres backend through the * postmaster using connection information in a string. * * See comment for PQconnectdb for the definition of the string format. * * Returns a PGconn*. If NULL is returned, a malloc error has occurred, and * you should not attempt to proceed with this connection. If the status * field of the
| 907 | * See PQconnectPoll for more info. |
| 908 | */ |
| 909 | PGconn * |
| 910 | PQconnectStart(const char *conninfo) |
| 911 | { |
| 912 | PGconn *conn; |
| 913 | |
| 914 | /* |
| 915 | * Allocate memory for the conn structure. Note that we also expect this |
| 916 | * to initialize conn->errorMessage to empty. All subsequent steps during |
| 917 | * connection initialization will only append to that buffer. |
| 918 | */ |
| 919 | conn = makeEmptyPGconn(); |
| 920 | if (conn == NULL) |
| 921 | return NULL; |
| 922 | |
| 923 | /* |
| 924 | * Parse the conninfo string |
| 925 | */ |
| 926 | if (!connectOptions1(conn, conninfo)) |
| 927 | return conn; |
| 928 | |
| 929 | /* |
| 930 | * Compute derived options |
| 931 | */ |
| 932 | if (!connectOptions2(conn)) |
| 933 | return conn; |
| 934 | |
| 935 | /* |
| 936 | * Connect to the database |
| 937 | */ |
| 938 | if (!connectDBStart(conn)) |
| 939 | { |
| 940 | /* Just in case we failed to set it in connectDBStart */ |
| 941 | conn->status = CONNECTION_BAD; |
| 942 | } |
| 943 | |
| 944 | return conn; |
| 945 | } |
| 946 | |
| 947 | /* |
| 948 | * Move option values into conn structure |
no test coverage detected