Skip to content

Commit

Permalink
Restrict domain use for temporary tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-XM-Zeng committed Jan 3, 2025
1 parent b2009ed commit 29f976d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/pgduckdb_ruleutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,15 @@ pgduckdb_get_tabledef(Oid relation_oid) {
continue;
}

if (get_typtype(column->atttypid) == TYPTYPE_DOMAIN) {
elog(ERROR, "Domain is not supported in DuckDB");
} else if (type_is_array(column->atttypid)) {
Oid elem_type = get_base_element_type(column->atttypid);
if (get_typtype(elem_type) == TYPTYPE_DOMAIN) {
elog(ERROR, "Domain is not supported in DuckDB");
}
}

const char *column_name = NameStr(column->attname);

const char *column_type_name = format_type_with_typemod(column->atttypid, column->atttypmod);
Expand Down
9 changes: 9 additions & 0 deletions test/regression/expected/temporary_tables.out
Original file line number Diff line number Diff line change
Expand Up @@ -472,4 +472,13 @@ SELECT * FROM ta;
3 | 3
(6 rows)

CREATE DOMAIN domainint4 int4;
CREATE TEMP TABLE domaintest(testint4 domainint4) USING duckdb;
ERROR: Domain is not supported in DuckDB
CREATE DOMAIN domain_int_array as INT[];
CREATE TEMP TABLE domaintest(testint4_array domain_int_array) USING duckdb;
ERROR: Domain is not supported in DuckDB
CREATE TEMP TABLE domaintest(testint4_array domainint4[]) USING duckdb;
ERROR: Domain is not supported in DuckDB
DROP DOMAIN domainint4;
DROP TABLE webpages, t, t_heap, t_heap2, ta, tb, tc, td;
7 changes: 7 additions & 0 deletions test/regression/sql/temporary_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,11 @@ INSERT INTO ta (a) SELECT * FROM generate_series(1, 3); -- OK
INSERT INTO ta (b) SELECT * FROM generate_series(1, 3); -- OK
SELECT * FROM ta;

CREATE DOMAIN domainint4 int4;
CREATE TEMP TABLE domaintest(testint4 domainint4) USING duckdb;
CREATE DOMAIN domain_int_array as INT[];
CREATE TEMP TABLE domaintest(testint4_array domain_int_array) USING duckdb;
CREATE TEMP TABLE domaintest(testint4_array domainint4[]) USING duckdb;

DROP DOMAIN domainint4;
DROP TABLE webpages, t, t_heap, t_heap2, ta, tb, tc, td;

0 comments on commit 29f976d

Please sign in to comment.