Skip to content

Commit

Permalink
Merge pull request duckdb#86 from gpsamson/gps/enum-arr
Browse files Browse the repository at this point in the history
Fix enum array support
  • Loading branch information
Mytherin authored Mar 9, 2023
2 parents 6745dd5 + b20b662 commit c3bfcec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 1 addition & 5 deletions postgres_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -835,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;
Expand Down
8 changes: 8 additions & 0 deletions test/all_pg_types.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -54,6 +56,9 @@ CREATE TABLE pg_datearraytypes (
timestamp_col _timestamp,
timestamptz_col _timestamptz);

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
(false, 0, 0, 0, 0, 0, 0, 0),
(false, -42, -42, -42, -42.01, -42.01, -42.01, -42.01),
Expand All @@ -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_enumarraytypes (enum_col)
VALUES ('{}'), ('{foo}'), ('{foo, bar}'), ('{foo, bar, baz}'), ('{foo, bar, baz, NULL}'), (NULL);

0 comments on commit c3bfcec

Please sign in to comment.