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

Function PQsendDescribe

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

* PQsendDescribe * Common code to send a Describe command * * Available options for desc_type are * 'S' to describe a prepared statement; or * 'P' to describe a portal. * Returns 1 on success and 0 on failure. */

Source from the content-addressed store, hash-verified

2486 * Returns 1 on success and 0 on failure.
2487 */
2488static int
2489PQsendDescribe(PGconn *conn, char desc_type, const char *desc_target)
2490{
2491 PGcmdQueueEntry *entry = NULL;
2492
2493 /* Treat null desc_target as empty string */
2494 if (!desc_target)
2495 desc_target = "";
2496
2497 if (!PQsendQueryStart(conn, true))
2498 return 0;
2499
2500 entry = pqAllocCmdQueueEntry(conn);
2501 if (entry == NULL)
2502 return 0; /* error msg already set */
2503
2504 /* construct the Describe message */
2505 if (pqPutMsgStart('D', conn) < 0 ||
2506 pqPutc(desc_type, conn) < 0 ||
2507 pqPuts(desc_target, conn) < 0 ||
2508 pqPutMsgEnd(conn) < 0)
2509 goto sendFailed;
2510
2511 /* construct the Sync message */
2512 if (conn->pipelineStatus == PQ_PIPELINE_OFF)
2513 {
2514 if (pqPutMsgStart('S', conn) < 0 ||
2515 pqPutMsgEnd(conn) < 0)
2516 goto sendFailed;
2517 }
2518
2519 /* remember we are doing a Describe */
2520 entry->queryclass = PGQUERY_DESCRIBE;
2521
2522 /*
2523 * Give the data a push (in pipeline mode, only if we're past the size
2524 * threshold). In nonblock mode, don't complain if we're unable to send
2525 * it all; PQgetResult() will do any additional flushing needed.
2526 */
2527 if (pqPipelineFlush(conn) < 0)
2528 goto sendFailed;
2529
2530 /* OK, it's launched! */
2531 pqAppendCmdQueueEntry(conn, entry);
2532
2533 return 1;
2534
2535sendFailed:
2536 pqRecycleCmdQueueEntry(conn, entry);
2537 /* error message should be set up already */
2538 return 0;
2539}
2540
2541/*
2542 * PQnotifies

Callers 4

PQdescribePreparedFunction · 0.85
PQdescribePortalFunction · 0.85
PQsendDescribePreparedFunction · 0.85
PQsendDescribePortalFunction · 0.85

Calls 9

PQsendQueryStartFunction · 0.85
pqAllocCmdQueueEntryFunction · 0.85
pqPutMsgStartFunction · 0.85
pqPutcFunction · 0.85
pqPutsFunction · 0.85
pqPutMsgEndFunction · 0.85
pqPipelineFlushFunction · 0.85
pqAppendCmdQueueEntryFunction · 0.85
pqRecycleCmdQueueEntryFunction · 0.85

Tested by

no test coverage detected