postgres_scanner icon indicating copy to clipboard operation
postgres_scanner copied to clipboard

Can't copy between 2 Postgres databases using COPY FROM DATABASE

Open anikoo-aka opened this issue 1 year ago • 2 comments

What happens?

I have attached 2 Postgres databases (PG14 and PG15) and able to run queries on both databases. PG15 database is empty and does not have any tables. When I run the following statement, I get an error:

COPY FROM DATABASE pg14 TO  pg15;
Invalid Error: Failed to execute query "CREATE INDEX orders_pkey ON public.orders()": ERROR:  syntax error at or near ")"
LINE 1: CREATE INDEX orders_pkey ON public.orders()
                                                  ^

D show orders;
┌──────────────┬───────────────┬─────────┬─────────┬─────────┬─────────┐
│ column_name  │  column_type  │  null   │   key   │ default │  extra  │
│   varchar    │    varchar    │ varchar │ varchar │ varchar │ varchar │
├──────────────┼───────────────┼─────────┼─────────┼─────────┼─────────┤
│ order_id     │ INTEGER       │ NO      │ PRI     │         │         │
│ customer_id  │ INTEGER       │ YES     │         │         │         │
│ order_date   │ DATE          │ YES     │         │         │         │
│ product_id   │ INTEGER       │ YES     │         │         │         │
│ notes        │ VARCHAR       │ YES     │         │         │         │
│ total_amount │ DECIMAL(10,2) │ YES     │         │         │         │
└──────────────┴───────────────┴─────────┴─────────┴─────────┴─────────┘

I tried to copy the schema only using the query below and got the same error:

COPY FROM DATABASE pg14 TO  pg15 (SCHEMA);

To Reproduce

Create the same table with the same table structure and try copying between 2 postgres hosts.

OS:

macOS

PostgreSQL Version:

14 and 15

DuckDB Version:

1.1.0

DuckDB Client:

CLI

Full Name:

Arash Nikoo

Affiliation:

Akamai

Have you tried this on the latest main branch?

  • [X] 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?

  • [X] I agree

anikoo-aka avatar Sep 20 '24 19:09 anikoo-aka