MCPcopy Create free account
hub / github.com/apache/cloudberry / getCopyStart

Function getCopyStart

src/interfaces/libpq/fe-protocol3.c:1666–1717  ·  view source on GitHub ↗

* getCopyStart - process CopyInResponse, CopyOutResponse or * CopyBothResponse message * * parseInput already read the message type and length. */

Source from the content-addressed store, hash-verified

1664 * parseInput already read the message type and length.
1665 */
1666static int
1667getCopyStart(PGconn *conn, ExecStatusType copytype)
1668{
1669 PGresult *result;
1670 int nfields;
1671 int i;
1672
1673 result = PQmakeEmptyPGresult(conn, copytype);
1674 if (!result)
1675 goto failure;
1676
1677 if (pqGetc(&conn->copy_is_binary, conn))
1678 goto failure;
1679 result->binary = conn->copy_is_binary;
1680 /* the next two bytes are the number of fields */
1681 if (pqGetInt(&(result->numAttributes), 2, conn))
1682 goto failure;
1683 nfields = result->numAttributes;
1684
1685 /* allocate space for the attribute descriptors */
1686 if (nfields > 0)
1687 {
1688 result->attDescs = (PGresAttDesc *)
1689 pqResultAlloc(result, nfields * sizeof(PGresAttDesc), true);
1690 if (!result->attDescs)
1691 goto failure;
1692 MemSet(result->attDescs, 0, nfields * sizeof(PGresAttDesc));
1693 }
1694
1695 for (i = 0; i < nfields; i++)
1696 {
1697 int format;
1698
1699 if (pqGetInt(&format, 2, conn))
1700 goto failure;
1701
1702 /*
1703 * Since pqGetInt treats 2-byte integers as unsigned, we need to
1704 * coerce these results to signed form.
1705 */
1706 format = (int) ((int16) format);
1707 result->attDescs[i].format = format;
1708 }
1709
1710 /* Success! */
1711 conn->result = result;
1712 return 0;
1713
1714failure:
1715 PQclear(result);
1716 return EOF;
1717}
1718
1719/*
1720 * getReadyForQuery - process ReadyForQuery message

Callers 1

pqParseInput3Function · 0.85

Calls 5

PQmakeEmptyPGresultFunction · 0.85
pqGetcFunction · 0.85
pqGetIntFunction · 0.85
pqResultAllocFunction · 0.85
PQclearFunction · 0.85

Tested by

no test coverage detected