mirror of
https://github.com/postgres/postgres.git
synced 2025-12-12 02:37:31 +03:00
Give a hint, when [] is incorrectly used for a composite type in array.
That used to be accepted, so let's try to give a hint to users on why their PL/python functions no longer work. Reviewed by Pavel Stehule. Discussion: <CAH38_tmbqwaUyKs9yagyRra=SMaT45FPBxk1pmTYcM0TyXGG7Q@mail.gmail.com>
This commit is contained in:
@@ -213,3 +213,12 @@ CREATE FUNCTION composite_type_as_list() RETURNS type_record[] AS $$
|
||||
return [[('first', 1), ('second', 1)], [('first', 2), ('second', 2)], [('first', 3), ('second', 3)]];
|
||||
$$ LANGUAGE plpythonu;
|
||||
SELECT * FROM composite_type_as_list();
|
||||
|
||||
-- Starting with PostgreSQL 10, a composite type in an array cannot be
|
||||
-- represented as a Python list, because it's ambiguous with multi-dimensional
|
||||
-- arrays. So this throws an error now. The error should contain a useful hint
|
||||
-- on the issue.
|
||||
CREATE FUNCTION composite_type_as_list_broken() RETURNS type_record[] AS $$
|
||||
return [['first', 1]];
|
||||
$$ LANGUAGE plpythonu;
|
||||
SELECT * FROM composite_type_as_list_broken();
|
||||
|
||||
Reference in New Issue
Block a user