mirror of
https://github.com/postgres/postgres.git
synced 2026-03-13 06:06:25 -04:00
The idea behind this patch is to make it possible to run individual test scripts without running the entire core test suite. Making all the scripts completely independent would involve a massive rewrite, and would probably be worse for coverage of things like concurrent DDL. So this patch just does what seems practical with limited changes. The net effect is that any test script can be run after running limited earlier dependencies: * all scripts depend on test_setup * many scripts depend on create_index * other dependencies are few in number, and are documented in the parallel_schedule file. To accomplish this, I chose a small number of commonly-used tables and moved their creation and filling into test_setup. Later scripts are expected not to modify these tables' data contents, for fear of affecting other scripts' results. Also, our former habit of declaring all C functions in one place is now gone in favor of declaring them where they're used, if that's just one script, or in test_setup if necessary. There's more that could be done to remove some of the remaining inter-script dependencies, but significantly more-invasive changes would be needed, and at least for now it doesn't seem worth it. Discussion: https://postgr.es/m/1114748.1640383217@sss.pgh.pa.us
82 lines
3.3 KiB
PL/PgSQL
82 lines
3.3 KiB
PL/PgSQL
--
|
|
-- Tests for external toast datums
|
|
--
|
|
|
|
-- directory paths and dlsuffix are passed to us in environment variables
|
|
\getenv libdir PG_LIBDIR
|
|
\getenv dlsuffix PG_DLSUFFIX
|
|
|
|
\set regresslib :libdir '/regress' :dlsuffix
|
|
|
|
CREATE FUNCTION make_tuple_indirect (record)
|
|
RETURNS record
|
|
AS :'regresslib'
|
|
LANGUAGE C STRICT;
|
|
|
|
-- Other compression algorithms may cause the compressed data to be stored
|
|
-- inline. pglz guarantees that the data is externalized, so stick to it.
|
|
SET default_toast_compression = 'pglz';
|
|
|
|
CREATE TABLE indtoasttest(descr text, cnt int DEFAULT 0, f1 text, f2 text);
|
|
|
|
INSERT INTO indtoasttest(descr, f1, f2) VALUES('two-compressed', repeat('1234567890',1000), repeat('1234567890',1000));
|
|
INSERT INTO indtoasttest(descr, f1, f2) VALUES('two-toasted', repeat('1234567890',30000), repeat('1234567890',50000));
|
|
INSERT INTO indtoasttest(descr, f1, f2) VALUES('one-compressed,one-null', NULL, repeat('1234567890',1000));
|
|
INSERT INTO indtoasttest(descr, f1, f2) VALUES('one-toasted,one-null', NULL, repeat('1234567890',50000));
|
|
|
|
-- check whether indirect tuples works on the most basic level
|
|
SELECT descr, substring(make_tuple_indirect(indtoasttest)::text, 1, 200) FROM indtoasttest;
|
|
|
|
-- modification without changing varlenas
|
|
UPDATE indtoasttest SET cnt = cnt +1 RETURNING substring(indtoasttest::text, 1, 200);
|
|
|
|
-- modification without modifying assigned value
|
|
UPDATE indtoasttest SET cnt = cnt +1, f1 = f1 RETURNING substring(indtoasttest::text, 1, 200);
|
|
|
|
-- modification modifying, but effectively not changing
|
|
UPDATE indtoasttest SET cnt = cnt +1, f1 = f1||'' RETURNING substring(indtoasttest::text, 1, 200);
|
|
|
|
UPDATE indtoasttest SET cnt = cnt +1, f1 = '-'||f1||'-' RETURNING substring(indtoasttest::text, 1, 200);
|
|
|
|
SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest;
|
|
-- check we didn't screw with main/toast tuple visibility
|
|
VACUUM FREEZE indtoasttest;
|
|
SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest;
|
|
|
|
-- now create a trigger that forces all Datums to be indirect ones
|
|
CREATE FUNCTION update_using_indirect()
|
|
RETURNS trigger
|
|
LANGUAGE plpgsql AS $$
|
|
BEGIN
|
|
NEW := make_tuple_indirect(NEW);
|
|
RETURN NEW;
|
|
END$$;
|
|
|
|
CREATE TRIGGER indtoasttest_update_indirect
|
|
BEFORE INSERT OR UPDATE
|
|
ON indtoasttest
|
|
FOR EACH ROW
|
|
EXECUTE PROCEDURE update_using_indirect();
|
|
|
|
-- modification without changing varlenas
|
|
UPDATE indtoasttest SET cnt = cnt +1 RETURNING substring(indtoasttest::text, 1, 200);
|
|
|
|
-- modification without modifying assigned value
|
|
UPDATE indtoasttest SET cnt = cnt +1, f1 = f1 RETURNING substring(indtoasttest::text, 1, 200);
|
|
|
|
-- modification modifying, but effectively not changing
|
|
UPDATE indtoasttest SET cnt = cnt +1, f1 = f1||'' RETURNING substring(indtoasttest::text, 1, 200);
|
|
|
|
UPDATE indtoasttest SET cnt = cnt +1, f1 = '-'||f1||'-' RETURNING substring(indtoasttest::text, 1, 200);
|
|
|
|
INSERT INTO indtoasttest(descr, f1, f2) VALUES('one-toasted,one-null, via indirect', repeat('1234567890',30000), NULL);
|
|
|
|
SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest;
|
|
-- check we didn't screw with main/toast tuple visibility
|
|
VACUUM FREEZE indtoasttest;
|
|
SELECT substring(indtoasttest::text, 1, 200) FROM indtoasttest;
|
|
|
|
DROP TABLE indtoasttest;
|
|
DROP FUNCTION update_using_indirect();
|
|
|
|
RESET default_toast_compression;
|