1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-12 02:37:31 +03:00

Handle domains over arrays like plain arrays in PL/python.

Domains over arrays are now converted to/from python lists when passed as
arguments or return values. Like regular arrays.

This has some potential to break applications that rely on the old behavior
that they are passed as strings, but in practice there probably aren't many
such applications out there.

Rodolfo Campero
This commit is contained in:
Heikki Linnakangas
2013-11-26 14:22:38 +02:00
parent 7cc0ba9f17
commit 37364c6311
4 changed files with 89 additions and 4 deletions

View File

@@ -294,6 +294,26 @@ $$ LANGUAGE plpythonu;
SELECT * FROM test_type_conversion_array_error();
--
-- Domains over arrays
--
CREATE DOMAIN ordered_pair_domain AS integer[] CHECK (array_length(VALUE,1)=2 AND VALUE[1] < VALUE[2]);
CREATE FUNCTION test_type_conversion_array_domain(x ordered_pair_domain) RETURNS ordered_pair_domain AS $$
plpy.info(x, type(x))
return x
$$ LANGUAGE plpythonu;
SELECT * FROM test_type_conversion_array_domain(ARRAY[0, 100]::ordered_pair_domain);
SELECT * FROM test_type_conversion_array_domain(NULL::ordered_pair_domain);
CREATE FUNCTION test_type_conversion_array_domain_check_violation() RETURNS ordered_pair_domain AS $$
return [2,1]
$$ LANGUAGE plpythonu;
SELECT * FROM test_type_conversion_array_domain_check_violation();
---
--- Composite types
---