From 89b97dac410d340edeb8c076a04cd0de758bd4ae Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Fri, 9 Mar 2012 00:02:44 +0200 Subject: [PATCH] Makefile and tests cleanup - Use CREATE EXTENSION in 9.1+ tests - set verbosity to 'terse' to have less noise - Less messy Makefile rules --- Makefile | 59 ++++++++++++++++++-------------- test/expected/plproxy_sqlmed.out | 17 ++++++--- test/expected/plproxy_test.out | 16 +++------ test/sql/plproxy_sqlmed.sql | 4 +-- test/sql/plproxy_test.sql | 1 + 5 files changed, 52 insertions(+), 45 deletions(-) diff --git a/Makefile b/Makefile index 5694846..727af51 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ EXTENSION = plproxy -EXTVERSION = $(shell grep default_version $(EXTENSION).control | \ - sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/") + +# sync with NEWS, META.json, plproxy.control, debian/changelog +EXTVERSION = 2.3.0 # set to 1 to disallow functions containing SELECT NO_SELECT = 0 @@ -10,30 +11,36 @@ PG_CONFIG = pg_config PQINC = $(shell $(PG_CONFIG) --includedir) PQLIB = $(shell $(PG_CONFIG) --libdir) -# PostgreSQL version -PGVER = $(shell $(PG_CONFIG) --version | sed 's/PostgreSQL //') -SQLMED = $(shell test $(PGVER) "<" "8.4" && echo "false" || echo "true") -PG91 = $(shell test $(PGVER) "<" "9.1" && echo "false" || echo "true") - # module setup -MODULE_big = plproxy +MODULE_big = $(EXTENSION) SRCS = src/cluster.c src/execute.c src/function.c src/main.c \ src/query.c src/result.c src/type.c src/poll_compat.c OBJS = src/scanner.o src/parser.tab.o $(SRCS:.c=.o) -DATA_built = sql/plproxy.sql -EXTRA_CLEAN = src/scanner.[ch] src/parser.tab.[ch] sql/plproxy.sql +EXTRA_CLEAN = src/scanner.[ch] src/parser.tab.[ch] libplproxy.* PG_CPPFLAGS = -I$(PQINC) -DNO_SELECT=$(NO_SELECT) SHLIB_LINK = -L$(PQLIB) -lpq -DISTNAME = plproxy-$(EXTVERSION) +DISTNAME = $(EXTENSION)-$(EXTVERSION) # regression testing setup REGRESS = plproxy_init plproxy_test plproxy_select plproxy_many \ plproxy_errors plproxy_clustermap plproxy_dynamic_record \ plproxy_encoding plproxy_split plproxy_target +REGRESS_OPTS = --dbname=regression --inputdir=test +# pg9.1 ignores --dbname +override CONTRIB_TESTDB := regression -# SQL files +# sql source PLPROXY_SQL = sql/plproxy_lang.sql +# Generated SQL files +EXTSQL = sql/$(EXTENSION)--$(EXTVERSION).sql +# Fixed SQL +EXTMISC = sql/plproxy--unpackaged--2.3.0.sql + +# PostgreSQL version +PGVER = $(shell $(PG_CONFIG) --version | sed 's/PostgreSQL //') +SQLMED = $(shell test $(PGVER) "<" "8.4" && echo "false" || echo "true") +PG91 = $(shell test $(PGVER) "<" "9.1" && echo "false" || echo "true") # SQL/MED available, add foreign data wrapper and regression tests ifeq ($(SQLMED), true) @@ -41,24 +48,20 @@ REGRESS += plproxy_sqlmed PLPROXY_SQL += sql/plproxy_fdw.sql endif -# Extensions available, rename files as appropriate. +# Extensions available ifeq ($(PG91),true) -all: sql/$(EXTENSION)--$(EXTVERSION).sql - -sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql - cp $< $@ - -DATA = $(wildcard sql/*--*.sql) sql/$(EXTENSION)--$(EXTVERSION).sql -EXTRA_CLEAN += sql/$(EXTENSION)--$(EXTVERSION).sql +DATA_built = $(EXTSQL) +DATA = $(EXTMISC) +EXTRA_CLEAN += sql/plproxy.sql +else +DATA_built = sql/plproxy.sql +EXTRA_CLEAN += $(EXTSQL) endif -REGRESS_OPTS = --dbname=regression --inputdir=test - -# pg9.1 ignores --dbname -override CONTRIB_TESTDB := regression - +# # load PGXS makefile +# PGXS = $(shell $(PG_CONFIG) --pgxs) include $(PGXS) @@ -83,6 +86,10 @@ src/scanner.c: src/scanner.l sql/plproxy.sql: $(PLPROXY_SQL) cat $^ > $@ +$(EXTSQL): $(PLPROXY_SQL) + echo "create extension plproxy;" > sql/plproxy.sql + cat $^ > $@ + # dependencies $(OBJS): src/plproxy.h src/rowstamp.h src/execute.o: src/poll_compat.h @@ -105,7 +112,7 @@ doc-clean: $(MAKE) -C doc clean test: install - $(MAKE) installcheck || { less regression.diffs; exit 1; } + $(MAKE) installcheck || { filterdiff --format=unified regression.diffs | less; exit 1; } ack: cp results/*.out expected/ diff --git a/test/expected/plproxy_sqlmed.out b/test/expected/plproxy_sqlmed.out index 97f0082..f1a8ce2 100644 --- a/test/expected/plproxy_sqlmed.out +++ b/test/expected/plproxy_sqlmed.out @@ -1,6 +1,5 @@ +\set VERBOSITY terse set client_min_messages = 'warning'; -drop foreign data wrapper if exists plproxy cascade; -create foreign data wrapper plproxy; create server sqlmedcluster foreign data wrapper plproxy options ( partition_0 'dbname=test_part3 host=localhost', partition_1 'dbname=test_part2 host=localhost', @@ -40,14 +39,24 @@ reset session authorization; -- cluster definition validation -- partition numbers must be consecutive alter server sqlmedcluster options (drop partition_2); +ERROR: Pl/Proxy: partitions must be numbered consecutively select * from sqlmed_test1(); -ERROR: PL/Proxy function public.sqlmed_test1(0): partitions numbers must be consecutive + sqlmed_test1 +----------------------------------------------- + plproxy: user=test_user_bob dbname=test_part3 +(1 row) + -- invalid partition count alter server sqlmedcluster options (drop partition_3, add partition_2 'dbname=test_part1 host=localhost'); +ERROR: option "partition_2" provided more than once select * from sqlmed_test1(); -ERROR: PL/Proxy function public.sqlmed_test1(0): invalid partition count + sqlmed_test1 +----------------------------------------------- + plproxy: user=test_user_bob dbname=test_part3 +(1 row) + -- switching betweem SQL/MED and compat mode create or replace function sqlmed_compat_test() returns setof text as $$ cluster 'testcluster'; diff --git a/test/expected/plproxy_test.out b/test/expected/plproxy_test.out index 5eb74ec..aa347f7 100644 --- a/test/expected/plproxy_test.out +++ b/test/expected/plproxy_test.out @@ -1,3 +1,4 @@ +\set VERBOSITY terse -- test normal function create function testfunc(username text, id integer, data text) returns text as $$ cluster 'testcluster'; run on hashtext(username); $$ language plproxy; @@ -396,11 +397,7 @@ as $$ run on 0; $$ language plproxy; select * from test_error1(); -ERROR: public.test_error1(0): [test_part] REMOTE ERROR: column "line2err" does not exist -LINE 1: select line2err - ^ -QUERY: select line2err -CONTEXT: Remote context: PL/pgSQL function "test_error1" line 3 at SQL statement +ERROR: public.test_error1(0): [test_part] REMOTE ERROR: column "line2err" does not exist at character 8 create function test_error2() returns int4 as $$ cluster 'testcluster'; @@ -409,18 +406,13 @@ as $$ $$ language plproxy; select * from test_error2(); NOTICE: PL/Proxy: dropping stale conn -ERROR: public.test_error2(0): [test_part] REMOTE ERROR: column "err" does not exist -LINE 1: select * from test_error2(); - ^ +ERROR: public.test_error2(0): [test_part] REMOTE ERROR: column "err" does not exist at character 8 create function test_error3() returns int4 as $$ connect 'dbname=test_part'; $$ language plproxy; select * from test_error3(); -ERROR: public.test_error3(0): [test_part] REMOTE ERROR: function public.test_error3() does not exist -LINE 1: select * from test_error3(); - ^ -HINT: Remote hint: No function matches the given name and argument types. You might need to add explicit type casts. +ERROR: public.test_error3(0): [test_part] REMOTE ERROR: function public.test_error3() does not exist at character 21 -- test invalid db create function test_bad_db() returns int4 as $$ diff --git a/test/sql/plproxy_sqlmed.sql b/test/sql/plproxy_sqlmed.sql index 3898ace..c553edf 100644 --- a/test/sql/plproxy_sqlmed.sql +++ b/test/sql/plproxy_sqlmed.sql @@ -1,9 +1,7 @@ +\set VERBOSITY terse set client_min_messages = 'warning'; -drop foreign data wrapper if exists plproxy cascade; -create foreign data wrapper plproxy; - create server sqlmedcluster foreign data wrapper plproxy options ( partition_0 'dbname=test_part3 host=localhost', partition_1 'dbname=test_part2 host=localhost', diff --git a/test/sql/plproxy_test.sql b/test/sql/plproxy_test.sql index 7eac7bc..800eb57 100644 --- a/test/sql/plproxy_test.sql +++ b/test/sql/plproxy_test.sql @@ -1,3 +1,4 @@ +\set VERBOSITY terse -- test normal function create function testfunc(username text, id integer, data text) -- 2.39.5