mirror of
https://github.com/postgres/postgres.git
synced 2026-07-06 16:25:55 -04:00
Resolve unknown-type literals in GRAPH_TABLE COLUMNS
The unknown-type literals in the COLUMNS clause of a GRAPH_TABLE are now resolved to the appropriate types. Without that, this could cause various failures. Author: Satya Narlapuram <satyanarlapuram@gmail.com> Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> Reviewed-by: Junwang Zhao <zhjwpku@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/CAHg%2BQDcyKNWyzDoKMxiZNjv7C-wAxs8y0ZoNkOV137Y%2Bnk3UXg%40mail.gmail.com
This commit is contained in:
parent
8021cdceb0
commit
cc9aa7f3a9
3 changed files with 15 additions and 0 deletions
|
|
@ -1005,6 +1005,10 @@ transformRangeGraphTable(ParseState *pstate, RangeGraphTable *rgt)
|
|||
columns = lappend(columns, te);
|
||||
}
|
||||
|
||||
/* resolve any still-unresolved output columns as being type text */
|
||||
if (pstate->p_resolve_unknowns)
|
||||
resolveTargetListUnknowns(pstate, columns);
|
||||
|
||||
/*
|
||||
* Assign collations to column expressions now since
|
||||
* assign_query_collations() does not process rangetable entries.
|
||||
|
|
|
|||
|
|
@ -160,6 +160,15 @@ SELECT * FROM GRAPH_TABLE (myshop MATCH (c IS customers) COLUMNS (c.name));
|
|||
customer3
|
||||
(3 rows)
|
||||
|
||||
-- unknown type resolution
|
||||
SELECT *, pg_typeof(unknown_col) AS unknown_col_type, pg_typeof(null_col) AS null_col_type FROM GRAPH_TABLE (myshop MATCH (c IS customers) COLUMNS (c.name, 'unknown-literal' AS unknown_col, NULL AS null_col));
|
||||
name | unknown_col | null_col | unknown_col_type | null_col_type
|
||||
-----------+-----------------+----------+------------------+---------------
|
||||
customer1 | unknown-literal | | text | text
|
||||
customer2 | unknown-literal | | text | text
|
||||
customer3 | unknown-literal | | text | text
|
||||
(3 rows)
|
||||
|
||||
SELECT * FROM GRAPH_TABLE (myshop MATCH (c IS customers WHERE c.address = 'US')-[IS customer_orders]->(o IS orders) COLUMNS (c.name));
|
||||
name
|
||||
-----------
|
||||
|
|
|
|||
|
|
@ -134,6 +134,8 @@ INSERT INTO wishlist_items (wishlist_items_id, wishlist_id, product_no) VALUES
|
|||
|
||||
-- single element path pattern
|
||||
SELECT * FROM GRAPH_TABLE (myshop MATCH (c IS customers) COLUMNS (c.name));
|
||||
-- unknown type resolution
|
||||
SELECT *, pg_typeof(unknown_col) AS unknown_col_type, pg_typeof(null_col) AS null_col_type FROM GRAPH_TABLE (myshop MATCH (c IS customers) COLUMNS (c.name, 'unknown-literal' AS unknown_col, NULL AS null_col));
|
||||
SELECT * FROM GRAPH_TABLE (myshop MATCH (c IS customers WHERE c.address = 'US')-[IS customer_orders]->(o IS orders) COLUMNS (c.name));
|
||||
-- graph element specification without label or variable
|
||||
SELECT * FROM GRAPH_TABLE (myshop MATCH (c IS customers WHERE c.address = 'US')-[]->(o IS orders) COLUMNS (c.name AS customer_name));
|
||||
|
|
|
|||
Loading…
Reference in a new issue