lobj64fix.patch

text/x-patch

Filename: lobj64fix.patch
Type: text/x-patch
Part: 0
Message: Re: 64-bit API for large object

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/include/storage/large_object.h 0 0
src/interfaces/libpq/fe-lobj.c 0 0
diff --git a/src/include/storage/large_object.h b/src/include/storage/large_object.h
new file mode 100644
index 52f01c6..715f0c3
*** a/src/include/storage/large_object.h
--- b/src/include/storage/large_object.h
*************** typedef struct LargeObjectDesc
*** 65,71 ****
  /*
   * Maximum byte length for each large object
  */
! #define MAX_LARGE_OBJECT_SIZE	INT64CONST(INT_MAX * LOBLKSIZE)
  
  /*
   * Function definitions...
--- 65,71 ----
  /*
   * Maximum byte length for each large object
  */
! #define MAX_LARGE_OBJECT_SIZE	((int64)INT_MAX * LOBLKSIZE)
  
  /*
   * Function definitions...
diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c
new file mode 100644
index fb17ac8..022cfec
*** a/src/interfaces/libpq/fe-lobj.c
--- b/src/interfaces/libpq/fe-lobj.c
*************** static pg_int64
*** 1046,1058 ****
  lo_hton64(pg_int64 host64)
  {
  	pg_int64 	result;
! 	uint32_t	h32, l32;
  
  	/* High order half first, since we're doing MSB-first */
! 	h32 = (uint32_t) (host64 >> 32);
  
  	/* Now the low order half */
! 	l32 = (uint32_t) (host64 & 0xffffffff);
  
  	result = htonl(l32);
  	result <<= 32;
--- 1046,1058 ----
  lo_hton64(pg_int64 host64)
  {
  	pg_int64 	result;
! 	uint32	h32, l32;
  
  	/* High order half first, since we're doing MSB-first */
! 	h32 = (uint32) (host64 >> 32);
  
  	/* Now the low order half */
! 	l32 = (uint32) (host64 & 0xffffffff);
  
  	result = htonl(l32);
  	result <<= 32;
*************** static pg_int64
*** 1069,1078 ****
  lo_ntoh64(pg_int64 net64)
  {
  	pg_int64 	result;
! 	uint32_t	h32, l32;
  
! 	l32 = (uint32_t) (net64 >> 32);
! 	h32 = (uint32_t) (net64 & 0xffffffff);
  
  	result = ntohl(h32);
  	result <<= 32;
--- 1069,1078 ----
  lo_ntoh64(pg_int64 net64)
  {
  	pg_int64 	result;
! 	uint32	h32, l32;
  
! 	l32 = (uint32) (net64 >> 32);
! 	h32 = (uint32) (net64 & 0xffffffff);
  
  	result = ntohl(h32);
  	result <<= 32;