From 3f8d139e8126a0fae2ad4686f4eca92989d1e6be Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Sat, 17 Nov 2012 18:13:50 +0200 Subject: [PATCH] Move RANGE to acceptable types, add tests --- Makefile | 4 ++++ src/type.c | 2 +- test/expected/plproxy_range.out | 35 +++++++++++++++++++++++++++++++++ test/sql/plproxy_range.sql | 34 ++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 test/expected/plproxy_range.out create mode 100644 test/sql/plproxy_range.sql diff --git a/Makefile b/Makefile index d8aa2e3..7078b4e 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,7 @@ EXTSQL = sql/$(EXTENSION)--$(EXTVERSION).sql \ 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") +PG92 = $(shell test "$(PGVER)" "<" "9.2" && echo "false" || echo "true") # SQL/MED available, add foreign data wrapper and regression tests ifeq ($(SQLMED), true) @@ -71,6 +72,9 @@ DATA_built = sql/plproxy.sql EXTRA_CLEAN += $(EXTSQL) endif +ifeq ($(PG92), true) +REGRESS += plproxy_range +endif # # load PGXS makefile diff --git a/src/type.c b/src/type.c index 9c0b080..7a16ce3 100644 --- a/src/type.c +++ b/src/type.c @@ -302,7 +302,6 @@ plproxy_find_type_info(ProxyFunction *func, Oid oid, bool for_send) switch (s_type->typtype) { default: - case TYPTYPE_RANGE: plproxy_error(func, "unsupported type code: %s (%u)", namebuf, oid); break; case TYPTYPE_PSEUDO: @@ -314,6 +313,7 @@ plproxy_find_type_info(ProxyFunction *func, Oid oid, bool for_send) case TYPTYPE_COMPOSITE: case TYPTYPE_DOMAIN: case TYPTYPE_ENUM: + case TYPTYPE_RANGE: break; } diff --git a/test/expected/plproxy_range.out b/test/expected/plproxy_range.out new file mode 100644 index 0000000..cc46c84 --- /dev/null +++ b/test/expected/plproxy_range.out @@ -0,0 +1,35 @@ +\c test_part0 +CREATE TYPE f8range AS RANGE ( + subtype = float8, + subtype_diff = float8mi +); +create or replace function test_range(in id int, inout frange f8range, + out irange int4range) +returns record as $$ +begin + irange := '[20,30)'; + return; +end; +$$ language plpgsql; +select * from test_range(0, '(1.5,2.4]'); + frange | irange +-----------+--------- + (1.5,2.4] | [20,30) +(1 row) + +\c regression +CREATE TYPE f8range AS RANGE ( + subtype = float8, + subtype_diff = float8mi +); +create or replace function test_range(in _id integer, inout frange f8range, out irange int4range) +returns setof record as $$ + cluster 'testcluster'; + run on _id; +$$ language plproxy; +select * from test_range(0, '(1.5,2.4]'); + frange | irange +-----------+--------- + (1.5,2.4] | [20,30) +(1 row) + diff --git a/test/sql/plproxy_range.sql b/test/sql/plproxy_range.sql new file mode 100644 index 0000000..41977e9 --- /dev/null +++ b/test/sql/plproxy_range.sql @@ -0,0 +1,34 @@ + +\c test_part0 + +CREATE TYPE f8range AS RANGE ( + subtype = float8, + subtype_diff = float8mi +); + +create or replace function test_range(in id int, inout frange f8range, + out irange int4range) +returns record as $$ +begin + irange := '[20,30)'; + return; +end; +$$ language plpgsql; + +select * from test_range(0, '(1.5,2.4]'); + +\c regression + +CREATE TYPE f8range AS RANGE ( + subtype = float8, + subtype_diff = float8mi +); + +create or replace function test_range(in _id integer, inout frange f8range, out irange int4range) +returns setof record as $$ + cluster 'testcluster'; + run on _id; +$$ language plproxy; + +select * from test_range(0, '(1.5,2.4]'); + -- 2.39.5