| 253 | } |
| 254 | |
| 255 | int64 |
| 256 | pqGetInt64(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 |
no test coverage detected