Skip to content

postgres_attach fails with SQL syntax error when postgres contains table with column of type "array of enum" #82

@jhrcek

Description

@jhrcek

What happens?

When you have table in postgres, containing a column whose type is "array of enum",
running postgres_attach fails with error like this:

Error: IO Error: Unable to query Postgres: ERROR:  syntax error at or near "."
LINE 1: SELECT unnest(enum_range(NULL::.myenum))
                                       ^

To Reproduce

  1. Start latest version (15.2) of postgresql locally in docker (but it's also reproducible with older postgres, like 12.11)
docker run \
-p 5432:5432 \
-e POSTGRES_USER=test \
-e POSTGRES_PASSWORD=test \
-e POSTGRES_DB=test \
-e PGDATA=/var/lib/postgresql/data/pgdata \
--tmpfs /var/lib/postgresql/data/pgdata \
postgres:15.2-alpine \
-c log_statement=all
  1. Connect to test db using psql
psql "host=localhost user=test password=test"

and init simple DB schema using following statements (note the column whose type is array of some enum)

CREATE TYPE myenum as ENUM ('whatever');
CREATE TABLE test (array_of_myenum myenum[]);
  1. Start duckdb from CLI and try postgres_attach
~/Tmp> duckdb 
v0.7.0 f7827396d7
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
D LOAD postgres;
D CALL postgres_attach('host=localhost user=test password=test');
Error: IO Error: Unable to query Postgres: ERROR:  syntax error at or near "."
LINE 1: SELECT unnest(enum_range(NULL::.myenum))
                                       ^
 ERROR:  syntax error at or near "."
LINE 1: SELECT unnest(enum_range(NULL::.myenum))
                                       ^

OS:

Linux - Fedora 36

PostgreSQL Version:

reproduced in 12.11 and 15.2

DuckDB Version:

v0.7.0 f7827396d7

DuckDB Client:

duckdb cli

Full Name:

Jan Hrček

Affiliation:

Holmusk

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions