Move RANGE to acceptable types, add tests
authorMarko Kreen <markokr@gmail.com>
Sat, 17 Nov 2012 16:13:50 +0000 (18:13 +0200)
committerMarko Kreen <markokr@gmail.com>
Sat, 17 Nov 2012 21:31:34 +0000 (23:31 +0200)
Makefile
src/type.c
test/expected/plproxy_range.out [new file with mode: 0644]
test/sql/plproxy_range.sql [new file with mode: 0644]

index d8aa2e3e5155f2ed8c99d944bb95392ee22ce1d5..7078b4e0855dfb8fad03348c3191bcb537431b6e 100644 (file)
--- 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
index 9c0b0808e009c6fa9cfa6d20d352c673e01a1172..7a16ce34eac9e8de7541fb4d3d7d2aac634fcb61 100644 (file)
@@ -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 (file)
index 0000000..cc46c84
--- /dev/null
@@ -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 (file)
index 0000000..41977e9
--- /dev/null
@@ -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]');
+