33
33
#include <arpa/inet.h>
34
34
#endif
35
35
36
- #include "common/pg_lzcompress.h"
37
- #include "utils/elog.h"
38
36
39
37
/*
40
38
* This macro lists the backend message types that could be "long" (more
41
39
* than a couple of kilobytes).
42
40
*/
43
41
#define VALID_LONG_MESSAGE_TYPE (id ) \
44
- ((id) == 'T' || (id) == 'D' || (id) == 'd' || (id) == 'z' || (id) == ' V' || \
42
+ ((id) == 'T' || (id) == 'D' || (id) == 'd' || (id) == 'V' || \
45
43
(id) == 'E' || (id) == 'N' || (id) == 'A')
46
44
47
45
@@ -391,7 +389,6 @@ pqParseInput3(PGconn *conn)
391
389
conn -> copy_already_done = 0 ;
392
390
break ;
393
391
case 'd' : /* Copy Data */
394
- case 'z' : /* Copy Compressed Data */
395
392
396
393
/*
397
394
* If we see Copy Data, just silently drop it. This would
@@ -1536,7 +1533,7 @@ getReadyForQuery(PGconn *conn)
1536
1533
* message available, -1 if end of copy, -2 if error.
1537
1534
*/
1538
1535
static int
1539
- getCopyDataMessage (PGconn * conn , char * kind )
1536
+ getCopyDataMessage (PGconn * conn )
1540
1537
{
1541
1538
char id ;
1542
1539
int msgLength ;
@@ -1587,7 +1584,6 @@ getCopyDataMessage(PGconn *conn, char* kind)
1587
1584
* completeness.) Otherwise, if it's anything except Copy Data,
1588
1585
* report end-of-copy.
1589
1586
*/
1590
- * kind = id ;
1591
1587
switch (id )
1592
1588
{
1593
1589
case 'A' : /* NOTIFY */
@@ -1603,7 +1599,6 @@ getCopyDataMessage(PGconn *conn, char* kind)
1603
1599
return 0 ;
1604
1600
break ;
1605
1601
case 'd' : /* Copy Data, pass it back to caller */
1606
- case 'z' : /* Copy Compressed Data, pass it back to caller */
1607
1602
return msgLength ;
1608
1603
case 'c' :
1609
1604
@@ -1646,7 +1641,6 @@ int
1646
1641
pqGetCopyData3 (PGconn * conn , char * * buffer , int async )
1647
1642
{
1648
1643
int msgLength ;
1649
- char id ;
1650
1644
1651
1645
for (;;)
1652
1646
{
@@ -1655,7 +1649,7 @@ pqGetCopyData3(PGconn *conn, char **buffer, int async)
1655
1649
* callers, we keep returning 0 until the next message is fully
1656
1650
* available, even if it is not Copy Data.
1657
1651
*/
1658
- msgLength = getCopyDataMessage (conn , & id );
1652
+ msgLength = getCopyDataMessage (conn );
1659
1653
if (msgLength < 0 )
1660
1654
return msgLength ; /* end-of-copy or error */
1661
1655
if (msgLength == 0 )
@@ -1677,55 +1671,20 @@ pqGetCopyData3(PGconn *conn, char **buffer, int async)
1677
1671
msgLength -= 4 ;
1678
1672
if (msgLength > 0 )
1679
1673
{
1680
- if (id == 'z' ) { /* compressed data */
1681
- int zip_len = msgLength -= 4 ;
1682
- int raw_len ;
1683
- int len ;
1684
-
1685
- Assert (zip_len > 0 );
1686
-
1687
- if (pqGetInt (& raw_len , 4 , conn ))
1688
- return -2 ;
1689
-
1690
- * buffer = (char * ) malloc (raw_len + 1 );
1691
- if (* buffer == NULL )
1692
- {
1693
- printfPQExpBuffer (& conn -> errorMessage ,
1694
- libpq_gettext ("out of memory\n" ));
1695
- return -2 ;
1696
- }
1697
- len = pglz_decompress (& conn -> inBuffer [conn -> inCursor ], zip_len , * buffer , raw_len );
1698
- if (len != raw_len )
1699
- {
1700
- printfPQExpBuffer (& conn -> errorMessage ,
1701
- libpq_gettext ("decompress error\n" ));
1702
- return -2 ;
1703
- }
1704
- (* buffer )[raw_len ] = '\0' ; /* Add terminating null */
1705
-
1706
-
1707
- /* Mark message consumed */
1708
- conn -> inStart = conn -> inCursor + msgLength ;
1709
-
1710
- return raw_len ;
1711
- }
1712
- else
1674
+ * buffer = (char * ) malloc (msgLength + 1 );
1675
+ if (* buffer == NULL )
1713
1676
{
1714
- * buffer = (char * ) malloc (msgLength + 1 );
1715
- if (* buffer == NULL )
1716
- {
1717
- printfPQExpBuffer (& conn -> errorMessage ,
1718
- libpq_gettext ("out of memory\n" ));
1719
- return -2 ;
1720
- }
1721
- memcpy (* buffer , & conn -> inBuffer [conn -> inCursor ], msgLength );
1722
- (* buffer )[msgLength ] = '\0' ; /* Add terminating null */
1677
+ printfPQExpBuffer (& conn -> errorMessage ,
1678
+ libpq_gettext ("out of memory\n" ));
1679
+ return -2 ;
1680
+ }
1681
+ memcpy (* buffer , & conn -> inBuffer [conn -> inCursor ], msgLength );
1682
+ (* buffer )[msgLength ] = '\0' ; /* Add terminating null */
1723
1683
1724
- /* Mark message consumed */
1725
- conn -> inStart = conn -> inCursor + msgLength ;
1684
+ /* Mark message consumed */
1685
+ conn -> inStart = conn -> inCursor + msgLength ;
1726
1686
1727
- return msgLength ;
1728
- }
1687
+ return msgLength ;
1729
1688
}
1730
1689
1731
1690
/* Empty, so drop it and loop around for another */
@@ -1795,7 +1754,6 @@ pqGetlineAsync3(PGconn *conn, char *buffer, int bufsize)
1795
1754
{
1796
1755
int msgLength ;
1797
1756
int avail ;
1798
- char id ;
1799
1757
1800
1758
if (conn -> asyncStatus != PGASYNC_COPY_OUT
1801
1759
&& conn -> asyncStatus != PGASYNC_COPY_BOTH )
@@ -1807,7 +1765,7 @@ pqGetlineAsync3(PGconn *conn, char *buffer, int bufsize)
1807
1765
* even if it is not Copy Data. This should keep PQendcopy from blocking.
1808
1766
* (Note: unlike pqGetCopyData3, we do not change asyncStatus here.)
1809
1767
*/
1810
- msgLength = getCopyDataMessage (conn , & id );
1768
+ msgLength = getCopyDataMessage (conn );
1811
1769
if (msgLength < 0 )
1812
1770
return -1 ; /* end-of-copy or error */
1813
1771
if (msgLength == 0 )
0 commit comments