From bd9b4f16894b98cffade9a77d87b910a939d10c5 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 14 Sep 2012 18:24:53 -0400 Subject: [PATCH] Improve largeobject regression test to show size of object read from file. The idea here is to provide a more easily diagnosable failure diff when the problem is that tenk.data has been DOS-ified, as I believe to be happening currently on buildfarm member hamerkop. Per suggestion from Magnus Hagander. Also, sync output/largeobject_1.source with current regression test. Failure to do that in commit 3a0e4d36ebd7f477822d5bae41ba121a40d22ccc turns out to be the real reason that hamerkop has been complaining. --- src/test/regress/input/largeobject.source | 3 +++ src/test/regress/output/largeobject.source | 7 +++++ src/test/regress/output/largeobject_1.source | 27 ++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/src/test/regress/input/largeobject.source b/src/test/regress/input/largeobject.source index 17d64a2fc3..40f40f8c76 100644 --- a/src/test/regress/input/largeobject.source +++ b/src/test/regress/input/largeobject.source @@ -136,6 +136,9 @@ INSERT INTO lotest_stash_values (loid) SELECT lo_import('@abs_srcdir@/data/tenk. BEGIN; UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)); +-- verify length of large object +SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values; + -- with the default BLKSZ, LOBLKSZ = 2048, so this positions us for a block -- edge case SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values; diff --git a/src/test/regress/output/largeobject.source b/src/test/regress/output/largeobject.source index 14ae4c6cdc..55aaf8f2af 100644 --- a/src/test/regress/output/largeobject.source +++ b/src/test/regress/output/largeobject.source @@ -222,6 +222,13 @@ TRUNCATE lotest_stash_values; INSERT INTO lotest_stash_values (loid) SELECT lo_import('@abs_srcdir@/data/tenk.data'); BEGIN; UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)); +-- verify length of large object +SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values; + lo_lseek +---------- + 670800 +(1 row) + -- with the default BLKSZ, LOBLKSZ = 2048, so this positions us for a block -- edge case SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values; diff --git a/src/test/regress/output/largeobject_1.source b/src/test/regress/output/largeobject_1.source index d2088d72b7..24fb09cef4 100644 --- a/src/test/regress/output/largeobject_1.source +++ b/src/test/regress/output/largeobject_1.source @@ -9,6 +9,25 @@ CREATE TABLE lotest_stash_values (loid oid, fd integer); -- The mode arg to lo_creat is unused, some vestigal holdover from ancient times -- returns the large object id INSERT INTO lotest_stash_values (loid) SELECT lo_creat(42); +-- Test ALTER LARGE OBJECT +CREATE ROLE regresslo; +DO $$ + BEGIN + EXECUTE 'ALTER LARGE OBJECT ' || (select loid from lotest_stash_values) + || ' OWNER TO regresslo'; + END +$$; +SELECT + rol.rolname +FROM + lotest_stash_values s + JOIN pg_largeobject_metadata lo ON s.loid = lo.oid + JOIN pg_authid rol ON lo.lomowner = rol.oid; + rolname +----------- + regresslo +(1 row) + -- NOTE: large objects require transactions BEGIN; -- lo_open(lobjId oid, mode integer) returns integer @@ -203,6 +222,13 @@ TRUNCATE lotest_stash_values; INSERT INTO lotest_stash_values (loid) SELECT lo_import('@abs_srcdir@/data/tenk.data'); BEGIN; UPDATE lotest_stash_values SET fd=lo_open(loid, CAST(x'20000' | x'40000' AS integer)); +-- verify length of large object +SELECT lo_lseek(fd, 0, 2) FROM lotest_stash_values; + lo_lseek +---------- + 680801 +(1 row) + -- with the default BLKSZ, LOBLKSZ = 2048, so this positions us for a block -- edge case SELECT lo_lseek(fd, 2030, 0) FROM lotest_stash_values; @@ -284,3 +310,4 @@ SELECT lo_unlink(loid) FROM lotest_stash_values; \lo_unlink :newloid TRUNCATE lotest_stash_values; +DROP ROLE regresslo; -- 2.40.0