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

Function PQsendQueryGuts

src/interfaces/libpq/fe-exec.c:1741–1905  ·  view source on GitHub ↗

* PQsendQueryGuts * Common code for sending a query with extended query protocol * PQsendQueryStart should be done already * * command may be NULL to indicate we use an already-prepared statement */

Source from the content-addressed store, hash-verified

1739 * command may be NULL to indicate we use an already-prepared statement
1740 */
1741static int
1742PQsendQueryGuts(PGconn *conn,
1743 const char *command,
1744 const char *stmtName,
1745 int nParams,
1746 const Oid *paramTypes,
1747 const char *const *paramValues,
1748 const int *paramLengths,
1749 const int *paramFormats,
1750 int resultFormat)
1751{
1752 int i;
1753 PGcmdQueueEntry *entry;
1754
1755 entry = pqAllocCmdQueueEntry(conn);
1756 if (entry == NULL)
1757 return 0; /* error msg already set */
1758
1759 /*
1760 * We will send Parse (if needed), Bind, Describe Portal, Execute, Sync
1761 * (if not in pipeline mode), using specified statement name and the
1762 * unnamed portal.
1763 */
1764
1765 if (command)
1766 {
1767 /* construct the Parse message */
1768 if (pqPutMsgStart('P', conn) < 0 ||
1769 pqPuts(stmtName, conn) < 0 ||
1770 pqPuts(command, conn) < 0)
1771 goto sendFailed;
1772 if (nParams > 0 && paramTypes)
1773 {
1774 if (pqPutInt(nParams, 2, conn) < 0)
1775 goto sendFailed;
1776 for (i = 0; i < nParams; i++)
1777 {
1778 if (pqPutInt(paramTypes[i], 4, conn) < 0)
1779 goto sendFailed;
1780 }
1781 }
1782 else
1783 {
1784 if (pqPutInt(0, 2, conn) < 0)
1785 goto sendFailed;
1786 }
1787 if (pqPutMsgEnd(conn) < 0)
1788 goto sendFailed;
1789 }
1790
1791 /* Construct the Bind message */
1792 if (pqPutMsgStart('B', conn) < 0 ||
1793 pqPuts("", conn) < 0 ||
1794 pqPuts(stmtName, conn) < 0)
1795 goto sendFailed;
1796
1797 /* Send parameter formats */
1798 if (nParams > 0 && paramFormats)

Callers 2

PQsendQueryParamsFunction · 0.85
PQsendQueryPreparedFunction · 0.85

Calls 12

pqAllocCmdQueueEntryFunction · 0.85
pqPutMsgStartFunction · 0.85
pqPutsFunction · 0.85
pqPutIntFunction · 0.85
pqPutMsgEndFunction · 0.85
appendPQExpBufferStrFunction · 0.85
libpq_gettextFunction · 0.85
pqPutncharFunction · 0.85
pqPutcFunction · 0.85
pqPipelineFlushFunction · 0.85
pqAppendCmdQueueEntryFunction · 0.85
pqRecycleCmdQueueEntryFunction · 0.85

Tested by

no test coverage detected