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

Function PQsendPrepare

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

* PQsendPrepare * Submit a Parse message, but don't wait for it to finish * * Returns: 1 if successfully submitted * 0 if error (conn->errorMessage is set) */

Source from the content-addressed store, hash-verified

1515 * 0 if error (conn->errorMessage is set)
1516 */
1517int
1518PQsendPrepare(PGconn *conn,
1519 const char *stmtName, const char *query,
1520 int nParams, const Oid *paramTypes)
1521{
1522 PGcmdQueueEntry *entry = NULL;
1523
1524 if (!PQsendQueryStart(conn, true))
1525 return 0;
1526
1527 /* check the arguments */
1528 if (!stmtName)
1529 {
1530 appendPQExpBufferStr(&conn->errorMessage,
1531 libpq_gettext("statement name is a null pointer\n"));
1532 return 0;
1533 }
1534 if (!query)
1535 {
1536 appendPQExpBufferStr(&conn->errorMessage,
1537 libpq_gettext("command string is a null pointer\n"));
1538 return 0;
1539 }
1540 if (nParams < 0 || nParams > PQ_QUERY_PARAM_MAX_LIMIT)
1541 {
1542 appendPQExpBuffer(&conn->errorMessage,
1543 libpq_gettext("number of parameters must be between 0 and %d\n"),
1544 PQ_QUERY_PARAM_MAX_LIMIT);
1545 return 0;
1546 }
1547
1548 entry = pqAllocCmdQueueEntry(conn);
1549 if (entry == NULL)
1550 return 0; /* error msg already set */
1551
1552 /* construct the Parse message */
1553 if (pqPutMsgStart('P', conn) < 0 ||
1554 pqPuts(stmtName, conn) < 0 ||
1555 pqPuts(query, conn) < 0)
1556 goto sendFailed;
1557
1558 if (nParams > 0 && paramTypes)
1559 {
1560 int i;
1561
1562 if (pqPutInt(nParams, 2, conn) < 0)
1563 goto sendFailed;
1564 for (i = 0; i < nParams; i++)
1565 {
1566 if (pqPutInt(paramTypes[i], 4, conn) < 0)
1567 goto sendFailed;
1568 }
1569 }
1570 else
1571 {
1572 if (pqPutInt(0, 2, conn) < 0)
1573 goto sendFailed;
1574 }

Callers 6

prepare_foreign_modifyFunction · 0.85
test_pipelined_insertFunction · 0.85
test_preparedFunction · 0.85
test_transactionFunction · 0.85
PQprepareFunction · 0.85
sendCommandFunction · 0.85

Calls 12

PQsendQueryStartFunction · 0.85
appendPQExpBufferStrFunction · 0.85
libpq_gettextFunction · 0.85
appendPQExpBufferFunction · 0.85
pqAllocCmdQueueEntryFunction · 0.85
pqPutMsgStartFunction · 0.85
pqPutsFunction · 0.85
pqPutIntFunction · 0.85
pqPutMsgEndFunction · 0.85
pqPipelineFlushFunction · 0.85
pqAppendCmdQueueEntryFunction · 0.85
pqRecycleCmdQueueEntryFunction · 0.85

Tested by 3

test_pipelined_insertFunction · 0.68
test_preparedFunction · 0.68
test_transactionFunction · 0.68