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