Skip to content

Commit

Permalink
Merge branch 'main' into postgres-native-scan
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF authored Jan 8, 2025
2 parents 48acfba + dadb234 commit 7b0685b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/pgduckdb_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ ConvertPostgresToDuckValue(Oid attr_type, Datum value, duckdb::Vector &result, i
size_t bytea_length = VARSIZE_ANY_EXHDR(value);
const duckdb::string_t s(bytea_data, bytea_length);
auto data = duckdb::FlatVector::GetData<duckdb::string_t>(result);
data[offset] = duckdb::StringVector::AddString(result, s);
data[offset] = duckdb::StringVector::AddStringOrBlob(result, s);
break;
}
case duckdb::LogicalTypeId::LIST: {
Expand Down
13 changes: 11 additions & 2 deletions test/regression/expected/temporary_tables.out
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,22 @@ SELECT * FROM t;
(1 row)

-- CTAS from DuckDB table to postgres table
CREATE TEMP TABLE t_heap2(c) USING heap AS SELECT * FROM t_heap;
CREATE TEMP TABLE t_heap2(c) USING heap AS SELECT * FROM t;
SELECT * FROM t_heap2;
c
---
1
(1 row)

-- CTAS from postgres table to postgres table (not actually handled by
-- pg_duckdb, but should still work)
CREATE TEMP TABLE t_heap3(c) USING heap AS SELECT * FROM t_heap;
SELECT * FROM t_heap3;
c
---
1
(1 row)

SELECT duckdb.raw_query($$ SELECT database_name, schema_name, sql FROM duckdb_tables() $$);
NOTICE: result: database_name schema_name sql
VARCHAR VARCHAR VARCHAR
Expand Down Expand Up @@ -472,4 +481,4 @@ SELECT * FROM ta;
3 | 3
(6 rows)

DROP TABLE webpages, t, t_heap, t_heap2, ta, tb, tc, td;
DROP TABLE webpages, t, t_heap, t_heap2, t_heap3, ta, tb, tc, td;
9 changes: 7 additions & 2 deletions test/regression/sql/temporary_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,14 @@ CREATE TEMP TABLE t(b) USING duckdb AS SELECT * FROM t_heap;
SELECT * FROM t;

-- CTAS from DuckDB table to postgres table
CREATE TEMP TABLE t_heap2(c) USING heap AS SELECT * FROM t_heap;
CREATE TEMP TABLE t_heap2(c) USING heap AS SELECT * FROM t;
SELECT * FROM t_heap2;

-- CTAS from postgres table to postgres table (not actually handled by
-- pg_duckdb, but should still work)
CREATE TEMP TABLE t_heap3(c) USING heap AS SELECT * FROM t_heap;
SELECT * FROM t_heap3;

SELECT duckdb.raw_query($$ SELECT database_name, schema_name, sql FROM duckdb_tables() $$);

-- multi-VALUES
Expand Down Expand Up @@ -250,4 +255,4 @@ 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;

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

0 comments on commit 7b0685b

Please sign in to comment.