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

Promote row expressions to full-fledged citizens of the expression syntax,

rather than allowing them only in a few special cases as before.  In
particular you can now pass a ROW() construct to a function that accepts
a rowtype parameter.  Internal generation of RowExprs fixes a number of
corner cases that used to not work very well, such as referencing the
whole-row result of a JOIN or subquery.  This represents a further step in
the work I started a month or so back to make rowtype values into
first-class citizens.
This commit is contained in:
Tom Lane
2004-05-10 22:44:49 +00:00
parent 9a939886ac
commit 2f63232d30
34 changed files with 1281 additions and 551 deletions

View File

@@ -218,6 +218,17 @@ SELECT hobbies_by_name('basketball');
SELECT name, overpaid(emp.*) FROM emp;
--
-- Try a few cases with SQL-spec row constructor expressions
--
SELECT * FROM equipment(ROW('skywalking', 'mer'));
SELECT name(equipment(ROW('skywalking', 'mer')));
SELECT *, name(equipment(h.*)) FROM hobbies_r h;
SELECT *, (equipment(CAST((h.*) AS hobbies_r))).name FROM hobbies_r h;
--
-- check that old-style C functions work properly with TOASTed values
--

View File

@@ -45,9 +45,9 @@ SELECT '' AS four, * FROM DEFAULTEXPR_TBL;
-- syntax errors
-- test for extraneous comma
CREATE TABLE error_tbl (i int DEFAULT (100, ));
ERROR: syntax error at or near "," at character 43
ERROR: syntax error at or near ")" at character 45
LINE 1: CREATE TABLE error_tbl (i int DEFAULT (100, ));
^
^
-- this will fail because gram.y uses b_expr not a_expr for defaults,
-- to avoid a shift/reduce conflict that arises from NOT NULL being
-- part of the column definition syntax:

View File

@@ -686,6 +686,45 @@ SELECT name, overpaid(emp.*) FROM emp;
linda | f
(6 rows)
--
-- Try a few cases with SQL-spec row constructor expressions
--
SELECT * FROM equipment(ROW('skywalking', 'mer'));
name | hobby
------+------------
guts | skywalking
(1 row)
SELECT name(equipment(ROW('skywalking', 'mer')));
name
------
guts
(1 row)
SELECT *, name(equipment(h.*)) FROM hobbies_r h;
name | person | name
-------------+--------+---------------
posthacking | mike | advil
posthacking | mike | peet's coffee
posthacking | jeff | advil
posthacking | jeff | peet's coffee
basketball | joe | hightops
basketball | sally | hightops
skywalking | | guts
(7 rows)
SELECT *, (equipment(CAST((h.*) AS hobbies_r))).name FROM hobbies_r h;
name | person | name
-------------+--------+---------------
posthacking | mike | advil
posthacking | mike | peet's coffee
posthacking | jeff | advil
posthacking | jeff | peet's coffee
basketball | joe | hightops
basketball | sally | hightops
skywalking | | guts
(7 rows)
--
-- check that old-style C functions work properly with TOASTed values
--