@@ -1433,7 +1433,6 @@ static int
1433
1433
PQsendQueryInternal (PGconn * conn , const char * query , bool newQuery )
1434
1434
{
1435
1435
PGcmdQueueEntry * entry = NULL ;
1436
- PGcmdQueueEntry * entry2 = NULL ;
1437
1436
1438
1437
if (!PQsendQueryStart (conn , newQuery ))
1439
1438
return 0 ;
@@ -1446,103 +1445,48 @@ PQsendQueryInternal(PGconn *conn, const char *query, bool newQuery)
1446
1445
return 0 ;
1447
1446
}
1448
1447
1449
- entry = pqAllocCmdQueueEntry (conn );
1450
- if (entry == NULL )
1451
- return 0 ; /* error msg already set */
1452
1448
if (conn -> pipelineStatus != PQ_PIPELINE_OFF )
1453
1449
{
1454
- entry2 = pqAllocCmdQueueEntry (conn );
1455
- if (entry2 == NULL )
1456
- goto sendFailed ;
1450
+ appendPQExpBuffer (& conn -> errorMessage ,
1451
+ libpq_gettext ("%s not allowed in pipeline mode\n" ),
1452
+ "PQsendQuery" );
1453
+ return 0 ;
1457
1454
}
1458
1455
1456
+ entry = pqAllocCmdQueueEntry (conn );
1457
+ if (entry == NULL )
1458
+ return 0 ; /* error msg already set */
1459
+
1459
1460
/* Send the query message(s) */
1460
- if (conn -> pipelineStatus == PQ_PIPELINE_OFF )
1461
+ /* construct the outgoing Query message */
1462
+ if (pqPutMsgStart ('Q' , conn ) < 0 ||
1463
+ pqPuts (query , conn ) < 0 ||
1464
+ pqPutMsgEnd (conn ) < 0 )
1461
1465
{
1462
- /* construct the outgoing Query message */
1463
- if (pqPutMsgStart ('Q' , conn ) < 0 ||
1464
- pqPuts (query , conn ) < 0 ||
1465
- pqPutMsgEnd (conn ) < 0 )
1466
- {
1467
- /* error message should be set up already */
1468
- pqRecycleCmdQueueEntry (conn , entry );
1469
- return 0 ;
1470
- }
1471
-
1472
- /* remember we are using simple query protocol */
1473
- entry -> queryclass = PGQUERY_SIMPLE ;
1474
- /* and remember the query text too, if possible */
1475
- entry -> query = strdup (query );
1466
+ /* error message should be set up already */
1467
+ pqRecycleCmdQueueEntry (conn , entry );
1468
+ return 0 ;
1476
1469
}
1477
- else
1478
- {
1479
- /*
1480
- * In pipeline mode we cannot use the simple protocol, so we send
1481
- * Parse, Bind, Describe Portal, Execute, Close Portal (with the
1482
- * unnamed portal).
1483
- */
1484
- if (pqPutMsgStart ('P' , conn ) < 0 ||
1485
- pqPuts ("" , conn ) < 0 ||
1486
- pqPuts (query , conn ) < 0 ||
1487
- pqPutInt (0 , 2 , conn ) < 0 ||
1488
- pqPutMsgEnd (conn ) < 0 )
1489
- goto sendFailed ;
1490
- if (pqPutMsgStart ('B' , conn ) < 0 ||
1491
- pqPuts ("" , conn ) < 0 ||
1492
- pqPuts ("" , conn ) < 0 ||
1493
- pqPutInt (0 , 2 , conn ) < 0 ||
1494
- pqPutInt (0 , 2 , conn ) < 0 ||
1495
- pqPutInt (0 , 2 , conn ) < 0 ||
1496
- pqPutMsgEnd (conn ) < 0 )
1497
- goto sendFailed ;
1498
- if (pqPutMsgStart ('D' , conn ) < 0 ||
1499
- pqPutc ('P' , conn ) < 0 ||
1500
- pqPuts ("" , conn ) < 0 ||
1501
- pqPutMsgEnd (conn ) < 0 )
1502
- goto sendFailed ;
1503
- if (pqPutMsgStart ('E' , conn ) < 0 ||
1504
- pqPuts ("" , conn ) < 0 ||
1505
- pqPutInt (0 , 4 , conn ) < 0 ||
1506
- pqPutMsgEnd (conn ) < 0 )
1507
- goto sendFailed ;
1508
- if (pqPutMsgStart ('C' , conn ) < 0 ||
1509
- pqPutc ('P' , conn ) < 0 ||
1510
- pqPuts ("" , conn ) < 0 ||
1511
- pqPutMsgEnd (conn ) < 0 )
1512
- goto sendFailed ;
1513
1470
1514
- entry -> queryclass = PGQUERY_EXTENDED ;
1515
- entry -> query = strdup (query );
1516
- }
1471
+ /* remember we are using simple query protocol */
1472
+ entry -> queryclass = PGQUERY_SIMPLE ;
1473
+ /* and remember the query text too, if possible */
1474
+ entry -> query = strdup (query );
1517
1475
1518
1476
/*
1519
1477
* Give the data a push. In nonblock mode, don't complain if we're unable
1520
1478
* to send it all; PQgetResult() will do any additional flushing needed.
1521
1479
*/
1522
- if (pqPipelineFlush (conn ) < 0 )
1480
+ if (pqFlush (conn ) < 0 )
1523
1481
goto sendFailed ;
1524
1482
1525
1483
/* OK, it's launched! */
1526
1484
pqAppendCmdQueueEntry (conn , entry );
1527
1485
1528
- /*
1529
- * When pipeline mode is in use, we need a second entry in the command
1530
- * queue to represent Close Portal message. This allows us later to wait
1531
- * for the CloseComplete message to be received before getting in IDLE
1532
- * state.
1533
- */
1534
- if (conn -> pipelineStatus != PQ_PIPELINE_OFF )
1535
- {
1536
- entry2 -> queryclass = PGQUERY_CLOSE ;
1537
- entry2 -> query = NULL ;
1538
- pqAppendCmdQueueEntry (conn , entry2 );
1539
- }
1540
-
1541
1486
return 1 ;
1542
1487
1543
1488
sendFailed :
1544
1489
pqRecycleCmdQueueEntry (conn , entry );
1545
- pqRecycleCmdQueueEntry (conn , entry2 );
1546
1490
/* error message should be set up already */
1547
1491
return 0 ;
1548
1492
}
@@ -2246,22 +2190,6 @@ PQgetResult(PGconn *conn)
2246
2190
break ;
2247
2191
}
2248
2192
2249
- /* If the next command we expect is CLOSE, read and consume it */
2250
- if (conn -> asyncStatus == PGASYNC_PIPELINE_IDLE &&
2251
- conn -> cmd_queue_head &&
2252
- conn -> cmd_queue_head -> queryclass == PGQUERY_CLOSE )
2253
- {
2254
- if (res && res -> resultStatus != PGRES_FATAL_ERROR )
2255
- {
2256
- conn -> asyncStatus = PGASYNC_BUSY ;
2257
- parseInput (conn );
2258
- conn -> asyncStatus = PGASYNC_PIPELINE_IDLE ;
2259
- }
2260
- else
2261
- /* we won't ever see the Close */
2262
- pqCommandQueueAdvance (conn );
2263
- }
2264
-
2265
2193
/* Time to fire PGEVT_RESULTCREATE events, if there are any */
2266
2194
if (res && res -> nEvents > 0 )
2267
2195
(void ) PQfireResultCreateEvents (conn , res );
@@ -2977,8 +2905,9 @@ PQfn(PGconn *conn,
2977
2905
2978
2906
if (conn -> pipelineStatus != PQ_PIPELINE_OFF )
2979
2907
{
2980
- appendPQExpBufferStr (& conn -> errorMessage ,
2981
- libpq_gettext ("PQfn not allowed in pipeline mode\n" ));
2908
+ appendPQExpBuffer (& conn -> errorMessage ,
2909
+ libpq_gettext ("%s not allowed in pipeline mode\n" ),
2910
+ "PQfn" );
2982
2911
return NULL ;
2983
2912
}
2984
2913
0 commit comments