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

Function pqParseInput3

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

* parseInput: if appropriate, parse input data from backend * until input is exhausted or a stopping state is reached. * Note that this function will NOT attempt to read more data from the backend. */

Source from the content-addressed store, hash-verified

76 * Note that this function will NOT attempt to read more data from the backend.
77 */
78void
79pqParseInput3(PGconn *conn)
80{
81 char id;
82 int msgLength;
83 int avail;
84#ifndef FRONTEND
85 int i;
86 int64 numRejected = 0;
87 int64 numCompleted = 0;
88#endif
89
90
91 /*
92 * Loop to parse successive complete messages available in the buffer.
93 */
94 for (;;)
95 {
96 /*
97 * Try to read a message. First get the type code and length. Return
98 * if not enough data.
99 */
100 conn->inCursor = conn->inStart;
101 if (pqGetc(&id, conn))
102 return;
103 if (pqGetInt(&msgLength, 4, conn))
104 return;
105
106 /*
107 * Try to validate message type/length here. A length less than 4 is
108 * definitely broken. Large lengths should only be believed for a few
109 * message types.
110 */
111 if (msgLength < 4)
112 {
113 handleSyncLoss(conn, id, msgLength);
114 return;
115 }
116 if (msgLength > 30000 && !VALID_LONG_MESSAGE_TYPE(id))
117 {
118 handleSyncLoss(conn, id, msgLength);
119 return;
120 }
121
122 /*
123 * Can't process if message body isn't all here yet.
124 */
125 msgLength -= 4;
126 avail = conn->inEnd - conn->inCursor;
127 if (avail < msgLength)
128 {
129 /*
130 * Before returning, enlarge the input buffer if needed to hold
131 * the whole message. This is better than leaving it to
132 * pqReadData because we can avoid multiple cycles of realloc()
133 * when the message is large; also, we can implement a reasonable
134 * recovery strategy if we are unable to make the buffer big
135 * enough.

Callers 1

parseInputFunction · 0.85

Calls 15

pqGetcFunction · 0.85
pqGetIntFunction · 0.85
handleSyncLossFunction · 0.85
pqCheckInBufferSpaceFunction · 0.85
getNotifyFunction · 0.85
pqGetErrorNotice3Function · 0.85
pqGetInt64Function · 0.85
pqGetsFunction · 0.85
PQmakeEmptyPGresultFunction · 0.85
appendPQExpBufferStrFunction · 0.85
libpq_gettextFunction · 0.85
pqSaveErrorResultFunction · 0.85

Tested by

no test coverage detected