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
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)
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)
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
$(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/
+\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',
-- 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';
+\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;
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';
$$ 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 $$