From 8265548064314efff7613c17061dbaf7c1e1cf2d Mon Sep 17 00:00:00 2001 From: Gabriel Samson Date: Wed, 8 Mar 2023 00:32:29 -0800 Subject: [PATCH 1/3] Initial fix at enum arrays --- postgres_scanner.cpp | 11 ++++++----- test/all_pg_types.sql | 8 ++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/postgres_scanner.cpp b/postgres_scanner.cpp index 77f690a1d..cc9a39160 100644 --- a/postgres_scanner.cpp +++ b/postgres_scanner.cpp @@ -293,6 +293,7 @@ ORDER BY attnum; info.type_info.typtype = res->GetString(row, 5); info.typelem = res->GetInt64(row, 6); + info.elem_info.nspname = res->GetString(row, 2); info.elem_info.typname = res->GetString(row, 7); info.elem_info.typlen = res->GetInt64(row, 8); info.elem_info.typtype = res->GetString(row, 9); @@ -835,11 +836,11 @@ static void ProcessValue(const LogicalType &type, const PostgresTypeInfo *type_i continue; } - if (elem_info->typlen > 0 && ele_len != elem_info->typlen) { - throw InvalidInputException( - "Expected to read a Postgres list value of length %d, but only have size %d", elem_info->typlen, - ele_len); - } + // if (elem_info->typlen > 0 && ele_len != elem_info->typlen) { + // throw InvalidInputException( + // "Expected to read a Postgres list value of length %d, but only have size %d", elem_info->typlen, + // ele_len); + // } ProcessValue(ListType::GetChildType(type), elem_info, atttypmod, 0, nullptr, value_ptr, ele_len, child_vec, child_offset + child_idx); value_ptr += ele_len; diff --git a/test/all_pg_types.sql b/test/all_pg_types.sql index 3284a5a3b..3c70cb2be 100644 --- a/test/all_pg_types.sql +++ b/test/all_pg_types.sql @@ -27,6 +27,8 @@ CREATE TABLE pg_datetypes ( timestamptz_col timestamptz ); +CREATE TYPE enum_type AS ENUM ('foo', 'bar', 'baz'); + CREATE TABLE pg_numarraytypes ( bool_col _bool, smallint_col _int2, @@ -54,6 +56,9 @@ CREATE TABLE pg_datearraytypes ( timestamp_col _timestamp, timestamptz_col _timestamptz); +CREATE TABLE pg_enumarraypgtypes ( + enum_col _enum_type); + INSERT INTO pg_numtypes (bool_col, smallint_col, integer_col, bigint_col, float_col, double_col, decimal_col, udecimal_col) VALUES (false, 0, 0, 0, 0, 0, 0, 0), (false, -42, -42, -42, -42.01, -42.01, -42.01, -42.01), @@ -80,3 +85,6 @@ VALUES ('{a, Z, NULL}', '{a, Z, NULL}', '{aaaa, ZZZZ, NULL}', '{aaaa, ZZZZ, NULL insert into pg_datearraytypes (date_col, time_col,timetz_col, timestamp_col, timestamptz_col) VALUES ('{2019-11-26, 2021-03-01, NULL}','{14:42:43, 12:45:01, NULL}','{14:42:43, 12:45:01, NULL}','{2019-11-26T12:45:01, 2021-03-01T12:45:01, NULL}','{2019-11-26T12:45:01, 2021-03-01T12:45:01, NULL}'), (NULL, NULL, NULL, NULL, NULL); + +insert into pg_enumarraypgtypes (enum_col) +VALUES ('{}'), ('{foo}'), ('{foo, bar}'), ('{foo, bar, baz}'), ('{foo, bar, baz, NULL}'), (NULL); From 56f996e9f02f66a32943aad9431e8ec6923cb31d Mon Sep 17 00:00:00 2001 From: Gabriel Samson Date: Wed, 8 Mar 2023 00:33:01 -0800 Subject: [PATCH 2/3] Naming nit --- test/all_pg_types.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/all_pg_types.sql b/test/all_pg_types.sql index 3c70cb2be..e455df253 100644 --- a/test/all_pg_types.sql +++ b/test/all_pg_types.sql @@ -56,7 +56,7 @@ CREATE TABLE pg_datearraytypes ( timestamp_col _timestamp, timestamptz_col _timestamptz); -CREATE TABLE pg_enumarraypgtypes ( +CREATE TABLE pg_enumarraytypes ( enum_col _enum_type); INSERT INTO pg_numtypes (bool_col, smallint_col, integer_col, bigint_col, float_col, double_col, decimal_col, udecimal_col) VALUES @@ -86,5 +86,5 @@ VALUES ('{a, Z, NULL}', '{a, Z, NULL}', '{aaaa, ZZZZ, NULL}', '{aaaa, ZZZZ, NULL insert into pg_datearraytypes (date_col, time_col,timetz_col, timestamp_col, timestamptz_col) VALUES ('{2019-11-26, 2021-03-01, NULL}','{14:42:43, 12:45:01, NULL}','{14:42:43, 12:45:01, NULL}','{2019-11-26T12:45:01, 2021-03-01T12:45:01, NULL}','{2019-11-26T12:45:01, 2021-03-01T12:45:01, NULL}'), (NULL, NULL, NULL, NULL, NULL); -insert into pg_enumarraypgtypes (enum_col) +insert into pg_enumarraytypes (enum_col) VALUES ('{}'), ('{foo}'), ('{foo, bar}'), ('{foo, bar, baz}'), ('{foo, bar, baz, NULL}'), (NULL); From b20b662346b91029abb31480e9c12e1ff48486da Mon Sep 17 00:00:00 2001 From: Gabriel Samson Date: Wed, 8 Mar 2023 00:39:39 -0800 Subject: [PATCH 3/3] Remove fixed len err --- postgres_scanner.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/postgres_scanner.cpp b/postgres_scanner.cpp index cc9a39160..b526b2d9e 100644 --- a/postgres_scanner.cpp +++ b/postgres_scanner.cpp @@ -836,11 +836,6 @@ static void ProcessValue(const LogicalType &type, const PostgresTypeInfo *type_i continue; } - // if (elem_info->typlen > 0 && ele_len != elem_info->typlen) { - // throw InvalidInputException( - // "Expected to read a Postgres list value of length %d, but only have size %d", elem_info->typlen, - // ele_len); - // } ProcessValue(ListType::GetChildType(type), elem_info, atttypmod, 0, nullptr, value_ptr, ele_len, child_vec, child_offset + child_idx); value_ptr += ele_len;