@@ -1061,44 +1061,6 @@ PrintQueryResult(PGresult *result, bool last, bool is_watch, const printQueryOpt
1061
1061
return success ;
1062
1062
}
1063
1063
1064
- /*
1065
- * Data structure and functions to record notices while they are
1066
- * emitted, so that they can be shown later.
1067
- *
1068
- * We need to know which result is last, which requires to extract
1069
- * one result in advance, hence two buffers are needed.
1070
- */
1071
- struct t_notice_messages
1072
- {
1073
- PQExpBufferData messages [2 ];
1074
- int current ;
1075
- };
1076
-
1077
- /*
1078
- * Store notices in appropriate buffer, for later display.
1079
- */
1080
- static void
1081
- AppendNoticeMessage (void * arg , const char * msg )
1082
- {
1083
- struct t_notice_messages * notices = arg ;
1084
-
1085
- appendPQExpBufferStr (& notices -> messages [notices -> current ], msg );
1086
- }
1087
-
1088
- /*
1089
- * Show notices stored in buffer, which is then reset.
1090
- */
1091
- static void
1092
- ShowNoticeMessage (struct t_notice_messages * notices )
1093
- {
1094
- PQExpBufferData * current = & notices -> messages [notices -> current ];
1095
-
1096
- if (* current -> data != '\0' )
1097
- pg_log_info ("%s" , current -> data );
1098
- resetPQExpBuffer (current );
1099
- }
1100
-
1101
-
1102
1064
/*
1103
1065
* SendQuery: send the query string to the backend
1104
1066
* (and print out result)
@@ -1483,7 +1445,6 @@ ExecQueryAndProcessResults(const char *query, double *elapsed_msec, bool *svpt_g
1483
1445
instr_time before ,
1484
1446
after ;
1485
1447
PGresult * result ;
1486
- struct t_notice_messages notices ;
1487
1448
1488
1449
if (timing )
1489
1450
INSTR_TIME_SET_CURRENT (before );
@@ -1513,12 +1474,6 @@ ExecQueryAndProcessResults(const char *query, double *elapsed_msec, bool *svpt_g
1513
1474
return 0 ;
1514
1475
}
1515
1476
1516
- /* intercept notices */
1517
- notices .current = 0 ;
1518
- initPQExpBuffer (& notices .messages [0 ]);
1519
- initPQExpBuffer (& notices .messages [1 ]);
1520
- PQsetNoticeProcessor (pset .db , AppendNoticeMessage , & notices );
1521
-
1522
1477
/* first result */
1523
1478
result = PQgetResult (pset .db );
1524
1479
@@ -1536,7 +1491,6 @@ ExecQueryAndProcessResults(const char *query, double *elapsed_msec, bool *svpt_g
1536
1491
*/
1537
1492
const char * error = PQresultErrorMessage (result );
1538
1493
1539
- ShowNoticeMessage (& notices );
1540
1494
if (strlen (error ))
1541
1495
pg_log_info ("%s" , error );
1542
1496
@@ -1601,31 +1555,22 @@ ExecQueryAndProcessResults(const char *query, double *elapsed_msec, bool *svpt_g
1601
1555
if (result_status == PGRES_COPY_IN ||
1602
1556
result_status == PGRES_COPY_OUT )
1603
1557
{
1604
- ShowNoticeMessage (& notices );
1605
-
1606
1558
if (is_watch )
1607
1559
{
1608
1560
ClearOrSaveAllResults ();
1609
1561
pg_log_error ("\\watch cannot be used with COPY" );
1610
1562
return -1 ;
1611
1563
}
1612
1564
1613
- /* use normal notice processor during COPY */
1614
- PQsetNoticeProcessor (pset .db , NoticeProcessor , NULL );
1615
-
1616
1565
success &= HandleCopyResult (& result );
1617
-
1618
- PQsetNoticeProcessor (pset .db , AppendNoticeMessage , & notices );
1619
1566
}
1620
1567
1621
1568
/*
1622
1569
* Check PQgetResult() again. In the typical case of a single-command
1623
1570
* string, it will return NULL. Otherwise, we'll have other results
1624
1571
* to process. We need to do that to check whether this is the last.
1625
1572
*/
1626
- notices .current ^= 1 ;
1627
1573
next_result = PQgetResult (pset .db );
1628
- notices .current ^= 1 ;
1629
1574
last = (next_result == NULL );
1630
1575
1631
1576
/*
@@ -1647,9 +1592,6 @@ ExecQueryAndProcessResults(const char *query, double *elapsed_msec, bool *svpt_g
1647
1592
* elapsed_msec = INSTR_TIME_GET_MILLISEC (after );
1648
1593
}
1649
1594
1650
- /* notices already shown above for copy */
1651
- ShowNoticeMessage (& notices );
1652
-
1653
1595
/* this may or may not print something depending on settings */
1654
1596
if (result != NULL )
1655
1597
success &= PrintQueryResult (result , last , false, opt , printQueryFout );
@@ -1659,7 +1601,6 @@ ExecQueryAndProcessResults(const char *query, double *elapsed_msec, bool *svpt_g
1659
1601
SetResultVariables (result , true);
1660
1602
1661
1603
ClearOrSaveResult (result );
1662
- notices .current ^= 1 ;
1663
1604
result = next_result ;
1664
1605
1665
1606
if (cancel_pressed )
@@ -1669,11 +1610,6 @@ ExecQueryAndProcessResults(const char *query, double *elapsed_msec, bool *svpt_g
1669
1610
}
1670
1611
}
1671
1612
1672
- /* reset notice hook */
1673
- PQsetNoticeProcessor (pset .db , NoticeProcessor , NULL );
1674
- termPQExpBuffer (& notices .messages [0 ]);
1675
- termPQExpBuffer (& notices .messages [1 ]);
1676
-
1677
1613
/* may need this to recover from conn loss during COPY */
1678
1614
if (!CheckConnection ())
1679
1615
return -1 ;
0 commit comments