Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Silent switching from binary to text copy

Open
#358 6 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, postgresql
Domain
database

Research direction

Start by tracing the pg_use_binary_copy setting and the COPY format selection used when inserting into PostgreSQL. Reproduce the NUMERIC and FLOAT cases from the issue with pg_debug_show_queries enabled, then verify that the NUMERIC case follows the intended binary-copy behavior without regressing the existing FLOAT case.

Written by the indexing model from the issue text.

Description

What happens?

Despite having set pg_use_binary_copy=true, if the target table has a column with NUMERIC type then text format is used (instead of binary) when copying data from DuckDB to PostgreSQL.

To Reproduce
  1. Configure duckdb-postgres as follows:

    • SET pg_debug_show_queries=true;
    • SET pg_use_binary_copy=true;
  2. Create a DuckDB table: CREATE OR REPLACE TABLE mytable (id INTEGER, value NUMERIC);.

  3. Insert a row into the table created at step 2: INSERT INTO mytable VALUES (1, 1.234);.

  4. Open a connection to PostgreSQL: ATTACH 'dbname=<dbname> user=<user> password=<password> host=<host>' AS pg (TYPE postgres);.

  5. Create a PostgresSQL table:

    CALL postgres_execute('pg', '
        DROP TABLE IF EXISTS mytable;
        CREATE TABLE mytable (
            id INTEGER,
            value NUMERIC
        );'
    );
    
  6. Copy data from DuckDB to PostgreSQL: INSERT INTO pg.mytable (id, value) SELECT id, value FROM mytable;. The following line would show up in debug messages: COPY "public"."mytable" FROM STDIN (FORMAT TEXT, NULL ').

  7. Repeat step 5 by replacing NUMERIC with FLOAT.

  8. Repeat step 6. Now, data would be copied using the binary format (debug message: COPY "public"."mytable" ("id", "value") FROM STDIN (FORMAT BINARY)).

OS:

Debian 12

PostgreSQL Version:

17.5

DuckDB Version:

v1.4.0-dev2508

DuckDB Client:

Python

Full Name:

Alessandro Cerioni

Affiliation:

État de Genève

Have you tried this on the latest main 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
Dominant language
C++
Stars
375
Forks
113
Avg merge
6h 42m
Merged PRs (30d)
30

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from duckdb/duckdb-postgres

All issues in duckdb/duckdb-postgres

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.