Skip to content

Commit 70ad7ed

Browse files
committed
Adjust largeobject regression test to leave a couple of LOs behind.
Since we commonly test pg_dump/pg_restore by seeing whether they can dump and restore the regression test database, it behooves us to include some large objects in that test scenario. I tried to include a comment on one of these large objects to improve the test scenario further ... but it turns out that pg_upgrade fails to preserve comments on large objects, and its regression test notices the discrepancy. So uncommenting that COMMENT is a TODO for later.
1 parent 9d4444a commit 70ad7ed

File tree

3 files changed

+66
-4
lines changed

3 files changed

+66
-4
lines changed

src/test/regress/input/largeobject.source

+24-2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ SELECT lo_close(fd) FROM lotest_stash_values;
7979

8080
END;
8181

82+
-- Copy to another large object.
83+
-- Note: we intentionally don't remove the object created here;
84+
-- it's left behind to help test pg_dump.
85+
86+
SELECT lo_from_bytea(0, lo_get(loid)) AS newloid FROM lotest_stash_values
87+
\gset
88+
89+
-- Ideally we'd put a comment on this object for pg_dump testing purposes.
90+
-- But since pg_upgrade fails to preserve large object comments, doing so
91+
-- would break pg_upgrade's regression test.
92+
-- COMMENT ON LARGE OBJECT :newloid IS 'I Wandered Lonely as a Cloud';
93+
8294
-- Read out a portion
8395
BEGIN;
8496
UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer));
@@ -207,8 +219,10 @@ SELECT pageno, data FROM pg_largeobject WHERE loid = (SELECT loid from lotest_st
207219
EXCEPT
208220
SELECT pageno, data FROM pg_largeobject WHERE loid = :newloid;
209221

210-
211222
SELECT lo_unlink(loid) FROM lotest_stash_values;
223+
224+
TRUNCATE lotest_stash_values;
225+
212226
\lo_unlink :newloid
213227

214228
\lo_import 'results/lotest.txt'
@@ -232,5 +246,13 @@ SELECT lo_get(:newloid_1, 4294967294, 100);
232246
\lo_unlink :newloid_1
233247
\lo_unlink :newloid_2
234248

235-
TRUNCATE lotest_stash_values;
249+
-- This object is left in the database for pg_dump test purposes
250+
SELECT lo_from_bytea(0, E'\\xdeadbeef') AS newloid
251+
\gset
252+
253+
SET bytea_output TO hex;
254+
SELECT lo_get(:newloid);
255+
256+
DROP TABLE lotest_stash_values;
257+
236258
DROP ROLE regresslo;

src/test/regress/output/largeobject.source

+21-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ SELECT lo_close(fd) FROM lotest_stash_values;
8585
(1 row)
8686

8787
END;
88+
-- Copy to another large object.
89+
-- Note: we intentionally don't remove the object created here;
90+
-- it's left behind to help test pg_dump.
91+
SELECT lo_from_bytea(0, lo_get(loid)) AS newloid FROM lotest_stash_values
92+
\gset
93+
-- Ideally we'd put a comment on this object for pg_dump testing purposes.
94+
-- But since pg_upgrade fails to preserve large object comments, doing so
95+
-- would break pg_upgrade's regression test.
96+
-- COMMENT ON LARGE OBJECT :newloid IS 'I Wandered Lonely as a Cloud';
8897
-- Read out a portion
8998
BEGIN;
9099
UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer));
@@ -398,6 +407,7 @@ SELECT lo_unlink(loid) FROM lotest_stash_values;
398407
1
399408
(1 row)
400409

410+
TRUNCATE lotest_stash_values;
401411
\lo_unlink :newloid
402412
\lo_import 'results/lotest.txt'
403413
\set newloid_1 :LASTOID
@@ -449,5 +459,15 @@ SELECT lo_get(:newloid_1, 4294967294, 100);
449459

450460
\lo_unlink :newloid_1
451461
\lo_unlink :newloid_2
452-
TRUNCATE lotest_stash_values;
462+
-- This object is left in the database for pg_dump test purposes
463+
SELECT lo_from_bytea(0, E'\\xdeadbeef') AS newloid
464+
\gset
465+
SET bytea_output TO hex;
466+
SELECT lo_get(:newloid);
467+
lo_get
468+
------------
469+
\xdeadbeef
470+
(1 row)
471+
472+
DROP TABLE lotest_stash_values;
453473
DROP ROLE regresslo;

src/test/regress/output/largeobject_1.source

+21-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ SELECT lo_close(fd) FROM lotest_stash_values;
8585
(1 row)
8686

8787
END;
88+
-- Copy to another large object.
89+
-- Note: we intentionally don't remove the object created here;
90+
-- it's left behind to help test pg_dump.
91+
SELECT lo_from_bytea(0, lo_get(loid)) AS newloid FROM lotest_stash_values
92+
\gset
93+
-- Ideally we'd put a comment on this object for pg_dump testing purposes.
94+
-- But since pg_upgrade fails to preserve large object comments, doing so
95+
-- would break pg_upgrade's regression test.
96+
-- COMMENT ON LARGE OBJECT :newloid IS 'I Wandered Lonely as a Cloud';
8897
-- Read out a portion
8998
BEGIN;
9099
UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer));
@@ -398,6 +407,7 @@ SELECT lo_unlink(loid) FROM lotest_stash_values;
398407
1
399408
(1 row)
400409

410+
TRUNCATE lotest_stash_values;
401411
\lo_unlink :newloid
402412
\lo_import 'results/lotest.txt'
403413
\set newloid_1 :LASTOID
@@ -449,5 +459,15 @@ SELECT lo_get(:newloid_1, 4294967294, 100);
449459

450460
\lo_unlink :newloid_1
451461
\lo_unlink :newloid_2
452-
TRUNCATE lotest_stash_values;
462+
-- This object is left in the database for pg_dump test purposes
463+
SELECT lo_from_bytea(0, E'\\xdeadbeef') AS newloid
464+
\gset
465+
SET bytea_output TO hex;
466+
SELECT lo_get(:newloid);
467+
lo_get
468+
------------
469+
\xdeadbeef
470+
(1 row)
471+
472+
DROP TABLE lotest_stash_values;
453473
DROP ROLE regresslo;

0 commit comments

Comments
 (0)