Skip to content

Server closed the connection on executing prepared statement #1018

@saygoodbyye

Description

@saygoodbyye

What happens?

Server crashes on executing prepared statement

➜  pg_duckdb git:(main) ✗ psql                                                                     
psql (17.8)
Type "help" for help.

test=# create extension pg_duckdb ;
CREATE EXTENSION
test=# prepare test_sql as select r['upper'], r['LOWER'] from read_parquet('/home/test/work/pg_duckdb/test/regression/data/uppercase.parquet') r;
PREPARE
test=# execute test_sql ;
server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
The connection to the server was lost. Attempting reset: Failed.
!?>

To Reproduce

configure:

CFLAGS='-Og' ./configure --enable-tap-tests --enable-debug --enable-cassert --with-openssl --with-icu --with-lz4 --with-libxml --quiet --prefix=$PGPREFIX

postgresql.conf:

shared_preload_libraries='pg_duckdb'

test.sql:

create extension pg_duckdb;
prepare test_sql as select r['upper'], r['LOWER'] from read_parquet('/home/test/work/pg_duckdb/test/regression/data/uppercase.parquet') r;
execute test_sql;

backtrace:

#0  __pthread_kill_implementation (threadid=<optimized out>, signo=6, no_tid=0) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (threadid=<optimized out>, signo=6) at ./nptl/pthread_kill.c:89
#2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:100
#3  0x00007f64bda45e2e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007f64bda28888 in __GI_abort () at ./stdlib/abort.c:77
#5  0x00005f5c12bd01ad in ExceptionalCondition (conditionName=conditionName@entry=0x5f5c12cd1ddf "false", fileName=fileName@entry=0x5f5c12cd39ab "execTuples.c", lineNumber=lineNumber@entry=1090) at assert.c:66
#6  0x00005f5c12898e06 in slot_deform_heap_tuple (slot=0x5f5c235d0ff8, tuple=<optimized out>, offp=0x5f5c235d1060, natts=2) at execTuples.c:1090
#7  tts_minimal_getsomeattrs (slot=0x5f5c235d0ff8, natts=<optimized out>) at execTuples.c:549
#8  0x00005f5c1289ab22 in slot_getsomeattrs_int (slot=0x5f5c235d0ff8, attnum=2) at execTuples.c:1999
#9  0x00005f5c1267655a in slot_getsomeattrs (slot=0x5f5c235d0ff8, attnum=<optimized out>) at ../../../../src/include/executor/tuptable.h:358
#10 slot_getallattrs (slot=slot@entry=0x5f5c235d0ff8) at ../../../../src/include/executor/tuptable.h:370
#11 0x00005f5c12676762 in printtup (slot=0x5f5c235d0ff8, self=0x5f5c233679a8) at printtup.c:318
#12 0x00005f5c12a806b5 in RunFromStore (portal=portal@entry=0x5f5c23422030, direction=direction@entry=ForwardScanDirection, count=count@entry=0, dest=0x5f5c233679a8) at pquery.c:1097
#13 0x00005f5c12a8079b in PortalRunSelect (portal=portal@entry=0x5f5c23422030, forward=forward@entry=true, count=0, count@entry=9223372036854775807, dest=dest@entry=0x5f5c233679a8) at pquery.c:918
#14 0x00005f5c12a8206d in PortalRun (portal=portal@entry=0x5f5c23422030, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x5f5c233679a8, altdest=altdest@entry=0x5f5c233679a8, 
    qc=0x7ffe07048800) at pquery.c:766
#15 0x00005f5c12a7e0f8 in exec_simple_query (query_string=query_string@entry=0x5f5c23366b50 "execute test_sql;") at postgres.c:1278
#16 0x00005f5c12a80171 in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:4767
#17 0x00005f5c12a793f6 in BackendMain (startup_data=<optimized out>, startup_data_len=<optimized out>) at backend_startup.c:105
#18 0x00005f5c129d01ff in postmaster_child_launch (child_type=child_type@entry=B_BACKEND, startup_data=startup_data@entry=0x7ffe07048a24 "", startup_data_len=startup_data_len@entry=4, client_sock=client_sock@entry=0x7ffe07048a60) at launch_backend.c:277
#19 0x00005f5c129d4994 in BackendStartup (client_sock=client_sock@entry=0x7ffe07048a60) at postmaster.c:3596
#20 0x00005f5c129d4c0a in ServerLoop () at postmaster.c:1678
#21 0x00005f5c129d6393 in PostmasterMain (argc=argc@entry=3, argv=argv@entry=0x5f5c2330e850) at postmaster.c:1376
#22 0x00005f5c128eda12 in main (argc=3, argv=0x5f5c2330e850) at main.c:199

OS:

Ubuntu 25.10

pg_duckdb Version (if built from source use commit hash):

dafe12d

Postgres Version (if built from source use commit hash):

dfd85098030475dbc38abe623f852d3aa1e1a40b

Hardware:

No response

Full Name:

Egor Chindyaskin

Affiliation:

Postgres Professional

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a source build

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Linux distribution) to reproduce the issue?

  • Yes, I have

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