@@ -499,7 +499,7 @@ test_pipeline_abort(PGconn *conn)
499
499
PQerrorMessage (conn ));
500
500
501
501
/* Try to send two queries in one command */
502
- if (PQsendQuery (conn , "SELECT 1; SELECT 2" ) != 1 )
502
+ if (PQsendQueryParams (conn , "SELECT 1; SELECT 2" , 0 , NULL , NULL , NULL , NULL , 0 ) != 1 )
503
503
pg_fatal ("failed to send query: %s" , PQerrorMessage (conn ));
504
504
if (PQpipelineSync (conn ) != 1 )
505
505
pg_fatal ("pipeline sync failed: %s" , PQerrorMessage (conn ));
@@ -531,7 +531,8 @@ test_pipeline_abort(PGconn *conn)
531
531
fprintf (stderr , "ok\n" );
532
532
533
533
/* Test single-row mode with an error partways */
534
- if (PQsendQuery (conn , "SELECT 1.0/g FROM generate_series(3, -1, -1) g" ) != 1 )
534
+ if (PQsendQueryParams (conn , "SELECT 1.0/g FROM generate_series(3, -1, -1) g" ,
535
+ 0 , NULL , NULL , NULL , NULL , 0 ) != 1 )
535
536
pg_fatal ("failed to send query: %s" , PQerrorMessage (conn ));
536
537
if (PQpipelineSync (conn ) != 1 )
537
538
pg_fatal ("pipeline sync failed: %s" , PQerrorMessage (conn ));
@@ -991,133 +992,10 @@ test_pipeline_idle(PGconn *conn)
991
992
992
993
PQsetNoticeProcessor (conn , notice_processor , & n_notices );
993
994
994
- /*
995
- * Cause a Close message to be sent to the server, and watch libpq's
996
- * reaction to the resulting CloseComplete. libpq must not get in IDLE
997
- * state until that has been received.
998
- */
999
- if (PQenterPipelineMode (conn ) != 1 )
1000
- pg_fatal ("failed to enter pipeline mode: %s" , PQerrorMessage (conn ));
1001
-
1002
- if (PQsendQuery (conn , "SELECT 1" ) != 1 )
1003
- pg_fatal ("failed to send query: %s" , PQerrorMessage (conn ));
1004
- PQsendFlushRequest (conn );
1005
- res = PQgetResult (conn );
1006
- if (res == NULL )
1007
- pg_fatal ("PQgetResult returned null when there's a pipeline item: %s" ,
1008
- PQerrorMessage (conn ));
1009
- if (PQresultStatus (res ) != PGRES_TUPLES_OK )
1010
- pg_fatal ("Unexpected result code %s from first pipeline item" ,
1011
- PQresStatus (PQresultStatus (res )));
1012
- PQclear (res );
1013
-
1014
- res = PQgetResult (conn );
1015
- if (res != NULL )
1016
- pg_fatal ("expected NULL result" );
1017
-
1018
- if (PQpipelineSync (conn ) != 1 )
1019
- pg_fatal ("pipeline sync failed: %s" , PQerrorMessage (conn ));
1020
- res = PQgetResult (conn );
1021
- if (res == NULL )
1022
- pg_fatal ("PQgetResult returned null when there's a pipeline item: %s" ,
1023
- PQerrorMessage (conn ));
1024
- if (PQresultStatus (res ) != PGRES_PIPELINE_SYNC )
1025
- pg_fatal ("Unexpected result code %s instead of PGRES_PIPELINE_SYNC, error: %s" ,
1026
- PQresStatus (PQresultStatus (res )), PQerrorMessage (conn ));
1027
- PQclear (res );
1028
- res = NULL ;
1029
-
1030
- if (PQexitPipelineMode (conn ) != 1 )
1031
- pg_fatal ("attempt to exit pipeline mode failed when it should've succeeded: %s" ,
1032
- PQerrorMessage (conn ));
1033
-
1034
- /*
1035
- * Must not have got any notices here; note bug as described in
1036
- * https://postgr.es/m/CA+mi_8bvD0_CW3sumgwPvWdNzXY32itoG_16tDYRu_1S2gV2iw@mail.gmail.com
1037
- */
1038
- if (n_notices > 0 )
1039
- pg_fatal ("got %d notice(s)" , n_notices );
1040
- fprintf (stderr , "ok - 1\n" );
1041
-
1042
- /*
1043
- * Verify that we can send a query using simple query protocol after one
1044
- * in pipeline mode.
1045
- */
1046
- if (PQenterPipelineMode (conn ) != 1 )
1047
- pg_fatal ("failed to enter pipeline mode: %s" , PQerrorMessage (conn ));
1048
- if (PQsendQuery (conn , "SELECT 1" ) != 1 )
1049
- pg_fatal ("failed to send query: %s" , PQerrorMessage (conn ));
1050
- PQsendFlushRequest (conn );
1051
- res = PQgetResult (conn );
1052
- if (res == NULL )
1053
- pg_fatal ("PQgetResult returned null when there's a pipeline item: %s" ,
1054
- PQerrorMessage (conn ));
1055
- if (PQresultStatus (res ) != PGRES_TUPLES_OK )
1056
- pg_fatal ("unexpected result code %s from first pipeline item" ,
1057
- PQresStatus (PQresultStatus (res )));
1058
- res = PQgetResult (conn );
1059
- if (res != NULL )
1060
- pg_fatal ("got unexpected non-null result" );
1061
- /* We can exit pipeline mode now */
1062
- if (PQexitPipelineMode (conn ) != 1 )
1063
- pg_fatal ("attempt to exit pipeline mode failed when it should've succeeded: %s" ,
1064
- PQerrorMessage (conn ));
1065
- res = PQexec (conn , "SELECT 2" );
1066
- if (n_notices > 0 )
1067
- pg_fatal ("got %d notice(s)" , n_notices );
1068
- if (res == NULL )
1069
- pg_fatal ("PQexec returned NULL" );
1070
- if (PQresultStatus (res ) != PGRES_TUPLES_OK )
1071
- pg_fatal ("unexpected result code %s from non-pipeline query" ,
1072
- PQresStatus (PQresultStatus (res )));
1073
- res = PQgetResult (conn );
1074
- if (res != NULL )
1075
- pg_fatal ("did not receive terminating NULL" );
1076
- if (n_notices > 0 )
1077
- pg_fatal ("got %d notice(s)" , n_notices );
1078
- fprintf (stderr , "ok - 2\n" );
1079
-
1080
- /*
1081
- * Case 2: exiting pipeline mode is not OK if a second command is sent.
1082
- */
1083
-
1084
- if (PQenterPipelineMode (conn ) != 1 )
1085
- pg_fatal ("failed to enter pipeline mode: %s" , PQerrorMessage (conn ));
1086
- if (PQsendQuery (conn , "SELECT 1" ) != 1 )
1087
- pg_fatal ("failed to send query: %s" , PQerrorMessage (conn ));
1088
- PQsendFlushRequest (conn );
1089
- res = PQgetResult (conn );
1090
- if (res == NULL )
1091
- pg_fatal ("PQgetResult returned null when there's a pipeline item: %s" ,
1092
- PQerrorMessage (conn ));
1093
- if (PQresultStatus (res ) != PGRES_TUPLES_OK )
1094
- pg_fatal ("unexpected result code %s from first pipeline item" ,
1095
- PQresStatus (PQresultStatus (res )));
1096
- if (PQsendQuery (conn , "SELECT 2" ) != 1 )
1097
- pg_fatal ("failed to send query: %s" , PQerrorMessage (conn ));
1098
- PQsendFlushRequest (conn );
1099
- /* read terminating null from first query */
1100
- res = PQgetResult (conn );
1101
- if (res != NULL )
1102
- pg_fatal ("did not receive terminating NULL" );
1103
- res = PQgetResult (conn );
1104
- if (res == NULL )
1105
- pg_fatal ("PQgetResult returned null when there's a pipeline item: %s" ,
1106
- PQerrorMessage (conn ));
1107
- if (PQresultStatus (res ) != PGRES_TUPLES_OK )
1108
- pg_fatal ("unexpected result code %s from first pipeline item" ,
1109
- PQresStatus (PQresultStatus (res )));
1110
- res = PQgetResult (conn );
1111
- if (res != NULL )
1112
- pg_fatal ("did not receive terminating NULL" );
1113
- if (PQexitPipelineMode (conn ) != 1 )
1114
- pg_fatal ("attempt to exit pipeline mode failed when it should've succeeded: %s" ,
1115
- PQerrorMessage (conn ));
1116
-
1117
995
/* Try to exit pipeline mode in pipeline-idle state */
1118
996
if (PQenterPipelineMode (conn ) != 1 )
1119
997
pg_fatal ("failed to enter pipeline mode: %s" , PQerrorMessage (conn ));
1120
- if (PQsendQuery (conn , "SELECT 1" ) != 1 )
998
+ if (PQsendQueryParams (conn , "SELECT 1" , 0 , NULL , NULL , NULL , NULL , 0 ) != 1 )
1121
999
pg_fatal ("failed to send query: %s" , PQerrorMessage (conn ));
1122
1000
PQsendFlushRequest (conn );
1123
1001
res = PQgetResult (conn );
@@ -1131,7 +1009,7 @@ test_pipeline_idle(PGconn *conn)
1131
1009
res = PQgetResult (conn );
1132
1010
if (res != NULL )
1133
1011
pg_fatal ("did not receive terminating NULL" );
1134
- if (PQsendQuery (conn , "SELECT 2" ) != 1 )
1012
+ if (PQsendQueryParams (conn , "SELECT 2" , 0 , NULL , NULL , NULL , NULL , 0 ) != 1 )
1135
1013
pg_fatal ("failed to send query: %s" , PQerrorMessage (conn ));
1136
1014
if (PQexitPipelineMode (conn ) == 1 )
1137
1015
pg_fatal ("exiting pipeline succeeded when it shouldn't" );
@@ -1153,12 +1031,12 @@ test_pipeline_idle(PGconn *conn)
1153
1031
1154
1032
if (n_notices > 0 )
1155
1033
pg_fatal ("got %d notice(s)" , n_notices );
1156
- fprintf (stderr , "ok - 3 \n" );
1034
+ fprintf (stderr , "ok - 1 \n" );
1157
1035
1158
1036
/* Have a WARNING in the middle of a resultset */
1159
1037
if (PQenterPipelineMode (conn ) != 1 )
1160
1038
pg_fatal ("entering pipeline mode failed: %s" , PQerrorMessage (conn ));
1161
- if (PQsendQuery (conn , "SELECT pg_catalog.pg_advisory_unlock(1,1)" ) != 1 )
1039
+ if (PQsendQueryParams (conn , "SELECT pg_catalog.pg_advisory_unlock(1,1)" , 0 , NULL , NULL , NULL , NULL , 0 ) != 1 )
1162
1040
pg_fatal ("failed to send query: %s" , PQerrorMessage (conn ));
1163
1041
PQsendFlushRequest (conn );
1164
1042
res = PQgetResult (conn );
@@ -1168,7 +1046,7 @@ test_pipeline_idle(PGconn *conn)
1168
1046
pg_fatal ("unexpected result code %s" , PQresStatus (PQresultStatus (res )));
1169
1047
if (PQexitPipelineMode (conn ) != 1 )
1170
1048
pg_fatal ("failed to exit pipeline mode: %s" , PQerrorMessage (conn ));
1171
- fprintf (stderr , "ok - 4 \n" );
1049
+ fprintf (stderr , "ok - 2 \n" );
1172
1050
}
1173
1051
1174
1052
static void
0 commit comments