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

Function getParamDescriptions

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

* parseInput subroutine to read a 't' (ParameterDescription) message. * We'll build a new PGresult structure containing the parameter data. * Returns: 0 if processed message successfully, EOF to suspend parsing * (the latter case is not actually used currently). */

Source from the content-addressed store, hash-verified

823 * (the latter case is not actually used currently).
824 */
825static int
826getParamDescriptions(PGconn *conn, int msgLength)
827{
828 PGresult *result;
829 const char *errmsg = NULL; /* means "out of memory", see below */
830 int nparams;
831 int i;
832
833 result = PQmakeEmptyPGresult(conn, PGRES_COMMAND_OK);
834 if (!result)
835 goto advance_and_error;
836
837 /* parseInput already read the 't' label and message length. */
838 /* the next two bytes are the number of parameters */
839 if (pqGetInt(&(result->numParameters), 2, conn))
840 goto not_enough_data;
841 nparams = result->numParameters;
842
843 /* allocate space for the parameter descriptors */
844 if (nparams > 0)
845 {
846 result->paramDescs = (PGresParamDesc *)
847 pqResultAlloc(result, nparams * sizeof(PGresParamDesc), true);
848 if (!result->paramDescs)
849 goto advance_and_error;
850 MemSet(result->paramDescs, 0, nparams * sizeof(PGresParamDesc));
851 }
852
853 /* get parameter info */
854 for (i = 0; i < nparams; i++)
855 {
856 int typid;
857
858 if (pqGetInt(&typid, 4, conn))
859 goto not_enough_data;
860 result->paramDescs[i].typid = typid;
861 }
862
863 /* Success! */
864 conn->result = result;
865
866 return 0;
867
868not_enough_data:
869 errmsg = libpq_gettext("insufficient data in \"t\" message");
870
871advance_and_error:
872 /* Discard unsaved result, if any */
873 if (result && result != conn->result)
874 PQclear(result);
875
876 /*
877 * Replace partially constructed result with an error result. First
878 * discard the old result to try to win back some memory.
879 */
880 pqClearAsyncResult(conn);
881
882 /*

Callers 1

pqParseInput3Function · 0.85

Calls 8

PQmakeEmptyPGresultFunction · 0.85
pqGetIntFunction · 0.85
pqResultAllocFunction · 0.85
libpq_gettextFunction · 0.85
PQclearFunction · 0.85
pqClearAsyncResultFunction · 0.85
appendPQExpBufferFunction · 0.85
pqSaveErrorResultFunction · 0.85

Tested by

no test coverage detected