fix-lo-contrib.patch

application/octet-stream

Filename: fix-lo-contrib.patch
Type: application/octet-stream
Part: 0
Message: Re: Largeobject Access Controls (r2460)

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+
contrib/lo/lo_test.sql 2 2
contrib/vacuumlo/vacuumlo.c 4 1
Index: contrib/lo/lo_test.sql
===================================================================
--- contrib/lo/lo_test.sql	(head)
+++ contrib/lo/lo_test.sql	(work)
@@ -12,7 +12,7 @@
 --
 
 -- Check what is in pg_largeobject
-SELECT count(DISTINCT loid) FROM pg_largeobject;
+SELECT count(oid) FROM pg_largeobject_metadata;
 
 -- ignore any errors here - simply drop the table if it already exists
 DROP TABLE a;
@@ -74,6 +74,6 @@
 DROP TABLE a;
 
 -- Check what is in pg_largeobject ... if different from original, trouble
-SELECT count(DISTINCT loid) FROM pg_largeobject;
+SELECT count(oid) FROM pg_largeobject_metadata;
 
 -- end of tests
Index: contrib/vacuumlo/vacuumlo.c
===================================================================
--- contrib/vacuumlo/vacuumlo.c	(head)
+++ contrib/vacuumlo/vacuumlo.c	(work)
@@ -142,7 +142,10 @@
 	 */
 	buf[0] = '\0';
 	strcat(buf, "CREATE TEMP TABLE vacuum_l AS ");
-	strcat(buf, "SELECT DISTINCT loid AS lo FROM pg_largeobject ");
+	if (PQserverVersion(conn) >= 80500)
+		strcat(buf, "SELECT oid AS lo FROM pg_largeobject_metadata");
+	else
+		strcat(buf, "SELECT DISTINCT loid AS lo FROM pg_largeobject");
 	res = PQexec(conn, buf);
 	if (PQresultStatus(res) != PGRES_COMMAND_OK)
 	{