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