From 70ad7ed4e88d9de3273f2f875cfaa044a35dfa97 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 12 Jun 2014 17:51:47 -0400 Subject: [PATCH] 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. --- src/test/regress/input/largeobject.source | 26 ++++++++++++++++++-- src/test/regress/output/largeobject.source | 22 ++++++++++++++++- src/test/regress/output/largeobject_1.source | 22 ++++++++++++++++- 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/src/test/regress/input/largeobject.source b/src/test/regress/input/largeobject.source index bd577d58b2..a19959a1b8 100644 --- a/src/test/regress/input/largeobject.source +++ b/src/test/regress/input/largeobject.source @@ -79,6 +79,18 @@ SELECT lo_close(fd) FROM lotest_stash_values; END; +-- Copy to another large object. +-- Note: we intentionally don't remove the object created here; +-- it's left behind to help test pg_dump. + +SELECT lo_from_bytea(0, lo_get(loid)) AS newloid FROM lotest_stash_values +\gset + +-- Ideally we'd put a comment on this object for pg_dump testing purposes. +-- But since pg_upgrade fails to preserve large object comments, doing so +-- would break pg_upgrade's regression test. +-- COMMENT ON LARGE OBJECT :newloid IS 'I Wandered Lonely as a Cloud'; + -- Read out a portion BEGIN; 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 EXCEPT SELECT pageno, data FROM pg_largeobject WHERE loid = :newloid; - SELECT lo_unlink(loid) FROM lotest_stash_values; + +TRUNCATE lotest_stash_values; + \lo_unlink :newloid \lo_import 'results/lotest.txt' @@ -232,5 +246,13 @@ SELECT lo_get(:newloid_1, 4294967294, 100); \lo_unlink :newloid_1 \lo_unlink :newloid_2 -TRUNCATE lotest_stash_values; +-- This object is left in the database for pg_dump test purposes +SELECT lo_from_bytea(0, E'\\xdeadbeef') AS newloid +\gset + +SET bytea_output TO hex; +SELECT lo_get(:newloid); + +DROP TABLE lotest_stash_values; + DROP ROLE regresslo; diff --git a/src/test/regress/output/largeobject.source b/src/test/regress/output/largeobject.source index 63a51241d0..8b34ac491b 100644 --- a/src/test/regress/output/largeobject.source +++ b/src/test/regress/output/largeobject.source @@ -85,6 +85,15 @@ SELECT lo_close(fd) FROM lotest_stash_values; (1 row) END; +-- Copy to another large object. +-- Note: we intentionally don't remove the object created here; +-- it's left behind to help test pg_dump. +SELECT lo_from_bytea(0, lo_get(loid)) AS newloid FROM lotest_stash_values +\gset +-- Ideally we'd put a comment on this object for pg_dump testing purposes. +-- But since pg_upgrade fails to preserve large object comments, doing so +-- would break pg_upgrade's regression test. +-- COMMENT ON LARGE OBJECT :newloid IS 'I Wandered Lonely as a Cloud'; -- Read out a portion BEGIN; 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; 1 (1 row) +TRUNCATE lotest_stash_values; \lo_unlink :newloid \lo_import 'results/lotest.txt' \set newloid_1 :LASTOID @@ -449,5 +459,15 @@ SELECT lo_get(:newloid_1, 4294967294, 100); \lo_unlink :newloid_1 \lo_unlink :newloid_2 -TRUNCATE lotest_stash_values; +-- This object is left in the database for pg_dump test purposes +SELECT lo_from_bytea(0, E'\\xdeadbeef') AS newloid +\gset +SET bytea_output TO hex; +SELECT lo_get(:newloid); + lo_get +------------ + \xdeadbeef +(1 row) + +DROP TABLE lotest_stash_values; DROP ROLE regresslo; diff --git a/src/test/regress/output/largeobject_1.source b/src/test/regress/output/largeobject_1.source index dee56e10b3..5167a01418 100644 --- a/src/test/regress/output/largeobject_1.source +++ b/src/test/regress/output/largeobject_1.source @@ -85,6 +85,15 @@ SELECT lo_close(fd) FROM lotest_stash_values; (1 row) END; +-- Copy to another large object. +-- Note: we intentionally don't remove the object created here; +-- it's left behind to help test pg_dump. +SELECT lo_from_bytea(0, lo_get(loid)) AS newloid FROM lotest_stash_values +\gset +-- Ideally we'd put a comment on this object for pg_dump testing purposes. +-- But since pg_upgrade fails to preserve large object comments, doing so +-- would break pg_upgrade's regression test. +-- COMMENT ON LARGE OBJECT :newloid IS 'I Wandered Lonely as a Cloud'; -- Read out a portion BEGIN; 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; 1 (1 row) +TRUNCATE lotest_stash_values; \lo_unlink :newloid \lo_import 'results/lotest.txt' \set newloid_1 :LASTOID @@ -449,5 +459,15 @@ SELECT lo_get(:newloid_1, 4294967294, 100); \lo_unlink :newloid_1 \lo_unlink :newloid_2 -TRUNCATE lotest_stash_values; +-- This object is left in the database for pg_dump test purposes +SELECT lo_from_bytea(0, E'\\xdeadbeef') AS newloid +\gset +SET bytea_output TO hex; +SELECT lo_get(:newloid); + lo_get +------------ + \xdeadbeef +(1 row) + +DROP TABLE lotest_stash_values; DROP ROLE regresslo; -- 2.40.0