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

Function pqGetInt64

src/interfaces/libpq/fe-misc.c:255–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253}
254
255int64
256pqGetInt64(int64 *result, PGconn *conn)
257{
258 int64 tmp;
259 uint32 h32;
260 uint32 l32;
261
262 if (conn->inCursor + 8 > conn->inEnd)
263 return EOF;
264
265 memcpy(&h32, conn->inBuffer + conn->inCursor, 4);
266 conn->inCursor += 4;
267 memcpy(&l32, conn->inBuffer + conn->inCursor, 4);
268 conn->inCursor += 4;
269 h32 = ntohl(h32);
270 l32 = ntohl(l32);
271
272#ifdef INT64_IS_BUSTED
273 /* error out if incoming value is wider than 32 bits */
274 tmp = l32;
275 if ((tmp < 0) ? (h32 != -1) : (h32 != 0))
276 {
277 pqInternalNotice(&conn->noticeHooks,
278 "binary value is out of range for type bigint");
279 return EOF;
280 }
281#else
282 tmp = h32;
283 tmp <<= 32;
284 tmp |= l32;
285#endif
286
287 *result = tmp;
288 return 0;
289}
290
291/*
292 * pqPutInt

Callers 1

pqParseInput3Function · 0.85

Calls 1

pqInternalNoticeFunction · 0.85

Tested by

no test coverage detected