Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/storage/postgres_type_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
JOIN pg_class ON pg_class.oid = t.typrelid
JOIN pg_attribute ON attrelid=t.typrelid
JOIN pg_type sub_type ON (pg_attribute.atttypid=sub_type.oid)
WHERE pg_class.relkind = 'c'
WHERE pg_class.relkind IN ('c', 'r', 'v', 'm', 'f', 'p')
AND t.typtype='c'
AND pg_attribute.attnum > 0
AND NOT pg_attribute.attisdropped
${CONDITION}
ORDER BY n.oid, t.oid, attrelid, attnum;
)";
Expand Down
73 changes: 73 additions & 0 deletions test/sql/storage/attach_types_table_row.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# name: test/sql/storage/attach_types_table_row.test
# description: Test scanning columns whose type is a relation's implicit row composite
# group: [storage]

require postgres_scanner

require-env POSTGRES_TEST_DATABASE_AVAILABLE

statement ok
PRAGMA enable_verification

statement ok
ATTACH 'dbname=postgresscanner' AS s (TYPE POSTGRES)

statement ok
USE s;

statement ok
DROP SCHEMA IF EXISTS row_types CASCADE;

statement ok
CREATE SCHEMA row_types;

statement ok
CREATE TABLE row_types.widget(id INT, label VARCHAR);

statement ok
INSERT INTO row_types.widget VALUES (1, 'hello');

# view whose column is a table-aliased row variable
statement ok
CALL postgres_execute('s', 'CREATE VIEW row_types.widget_row AS SELECT w FROM row_types.widget AS w');

statement ok
CALL pg_clear_cache();

query II
SELECT w.id, w.label FROM row_types.widget_row
----
1 hello

# table column declared with another relation's row type
statement ok
CALL postgres_execute('s', 'CREATE TABLE row_types.wrapper(id INT, payload row_types.widget)');

statement ok
CALL postgres_execute('s', 'INSERT INTO row_types.wrapper VALUES (1, ROW(2, ''nested''))');

statement ok
CALL pg_clear_cache();

query III
SELECT id, payload.id, payload.label FROM row_types.wrapper
----
1 2 nested

# text protocol
statement ok
SET pg_use_text_protocol=true;

statement ok
CALL pg_clear_cache();

query II
SELECT w.id, w.label FROM row_types.widget_row
----
1 hello

statement ok
SET pg_use_text_protocol=false;

statement ok
DROP SCHEMA IF EXISTS row_types CASCADE;
Loading