From 43b92a8ac0405f552a4f8ac4cebd4d52e3de868e Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Fri, 27 Feb 2026 20:10:51 +0100 Subject: [PATCH] Standardize pg_regress usage Standard PGXS `make installcheck` usage depends on a existing postgres server. Tests will run in a contrib_regression database created by pg_regress. The pg_regress option --use-existing makes pg_regress require an existing contrib_regression database, but the Makefile does not create it. Removing that option makes using the testsuite easier. Similarly, the init.sql file was not loaded by the Makefile, but it is required to run the tests. Move it into tests/sql/ and name it 00_init.sql so it gets run first. With these changes, the testsuite runs without any further tweaking during the Debian package builds for apt.postgresql.org. Signed-off-by: Christoph Berg --- Makefile | 2 +- test/expected/00_init.out | 25 +++++++++++++++++++++++++ test/{init.sql => sql/00_init.sql} | 0 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test/expected/00_init.out rename test/{init.sql => sql/00_init.sql} (100%) diff --git a/Makefile b/Makefile index a4d79a6..362c585 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ EXTRA_CLEAN = sql/$(EXTENSION)--$(EXTVERSION).sql $(EXTENSION).control TESTS = $(wildcard test/sql/*.sql) REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS)) -REGRESS_OPTS = --use-existing --inputdir=test +REGRESS_OPTS = --inputdir=test MODULE_big = $(EXTENSION) SRC = $(wildcard $(SRC_DIR)/*.c) diff --git a/test/expected/00_init.out b/test/expected/00_init.out new file mode 100644 index 0000000..5d12a2f --- /dev/null +++ b/test/expected/00_init.out @@ -0,0 +1,25 @@ +CREATE TABLE projects +( id integer +, name text +, project_name text +, client_id integer +, subclient_id int +); +-- ensure these dropped column cases are tested +ALTER TABLE projects DROP COLUMN project_name; +ALTER TABLE projects DROP COLUMN subclient_id; +INSERT INTO projects VALUES (1, 'Windows 7', 1); +INSERT INTO projects VALUES (2, 'has,comma', 1); +INSERT INTO projects VALUES (NULL, NULL, NULL); +INSERT INTO projects VALUES (4, 'OSX', 2); +INSERT INTO projects VALUES (NULL, 'has"quote', NULL); +INSERT INTO projects VALUES (5, 'has,comma and "quote"', 7); +INSERT INTO projects VALUES (6, E'has \n LF', 7); +INSERT INTO projects VALUES (7, E'has \r CR', 8); +INSERT INTO projects VALUES (8, E'has \r\n CRLF"', 8); +create extension if not exists pg_csv; +CREATE TABLE nasty ( + "unusual"",names" INTEGER GENERATED ALWAYS AS IDENTITY, + text TEXT +); +INSERT INTO nasty (text) VALUES ('test'); diff --git a/test/init.sql b/test/sql/00_init.sql similarity index 100% rename from test/init.sql rename to test/sql/00_init.sql