Re: Add support for DEFAULT specification in COPY FROM

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>, Israel Barth Rubio <barthisrael(at)gmail(dot)com>, Zhihong Yu <zyu(at)yugabyte(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add support for DEFAULT specification in COPY FROM
Date: 2023-03-15 17:00:00
Message-ID: 71318aea-e47b-3ca1-3b5c-aa8047169902@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,
13.03.2023 17:15, Andrew Dunstan wrote:
>
> On 2022-12-02 Fr 09:11, Israel Barth Rubio wrote:
>> Hello all,
>>
>> I'm submitting a new version of the patch. Instead of changing signature
>> of several functions in order to use the defaults parameter, it is now storing
>> that in the cstate structure, which is already passed to all functions that
>> were previously modified.
>>
>
> Thanks, committed.

Please look at the query:
create table t (f1 int);
copy t from stdin with (format csv, default '\D');
1,\D

that invokes an assertion failure after 9f8377f7a:
Core was generated by `postgres: law regression [local]
COPY                                         '.
Program terminated with signal SIGABRT, Aborted.

warning: Section `.reg-xstate/3253881' in core file too small.
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140665061189440)
at ./nptl/pthread_kill.c:44
44      ./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140665061189440)
at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140665061189440) at
./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=140665061189440, signo=signo(at)entry=6) at
./nptl/pthread_kill.c:89
#3  0x00007fef2250e476 in __GI_raise (sig=sig(at)entry=6) at
../sysdeps/posix/raise.c:26
#4  0x00007fef224f47f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00005600fd395750 in ExceptionalCondition (
    conditionName=conditionName(at)entry=0x5600fd3fa751 "n >= 0 && n < list->length",
    fileName=fileName(at)entry=0x5600fd416db8
"../../../src/include/nodes/pg_list.h", lineNumber=lineNumber(at)entry=280)
    at assert.c:66
#6  0x00005600fd02626d in list_nth_cell (n=<optimized out>, list=<optimized out>)
    at ../../../src/include/nodes/pg_list.h:280
#7  list_nth_int (n=<optimized out>, list=<optimized out>) at
../../../src/include/nodes/pg_list.h:313
#8  CopyReadAttributesCSV (cstate=<optimized out>) at copyfromparse.c:1905
#9  0x00005600fd0265a5 in NextCopyFromRawFields (cstate=0x5600febdd238,
fields=0x7fff12ef7130, nfields=0x7fff12ef712c)
    at copyfromparse.c:833
#10 0x00005600fd0267f9 in NextCopyFrom (cstate=cstate(at)entry=0x5600febdd238,
econtext=econtext(at)entry=0x5600fec9c5c8,
    values=0x5600febdd5c8, nulls=0x5600febdd5d0) at copyfromparse.c:885
#11 0x00005600fd0234db in CopyFrom (cstate=cstate(at)entry=0x5600febdd238) at
copyfrom.c:989
#12 0x00005600fd0222e5 in DoCopy (pstate=0x5600febdc568, stmt=0x5600febb2d58,
stmt_location=0, stmt_len=49,
    processed=0x7fff12ef7340) at copy.c:308
#13 0x00005600fd25c5e9 in standard_ProcessUtility (pstmt=0x5600febb2e78,
    queryString=0x5600febb2178 "copy t from stdin with (format csv, default
'\\D');", readOnlyTree=<optimized out>,
    context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0,
dest=0x5600febb3138, qc=0x7fff12ef7600)
    at utility.c:742
#14 0x00005600fd25a9f1 in PortalRunUtility (portal=portal(at)entry=0x5600fec4ea48,
pstmt=pstmt(at)entry=0x5600febb2e78,
    isTopLevel=isTopLevel(at)entry=true,
setHoldSnapshot=setHoldSnapshot(at)entry=false, dest=dest(at)entry=0x5600febb3138,
    qc=qc(at)entry=0x7fff12ef7600) at pquery.c:1158
#15 0x00005600fd25ab2d in PortalRunMulti (portal=portal(at)entry=0x5600fec4ea48,
isTopLevel=isTopLevel(at)entry=true,
    setHoldSnapshot=setHoldSnapshot(at)entry=false, dest=dest(at)entry=0x5600febb3138,
    altdest=altdest(at)entry=0x5600febb3138, qc=qc(at)entry=0x7fff12ef7600) at
pquery.c:1315
#16 0x00005600fd25b1c1 in PortalRun (portal=portal(at)entry=0x5600fec4ea48,
count=count(at)entry=9223372036854775807,
    isTopLevel=isTopLevel(at)entry=true, run_once=run_once(at)entry=true,
dest=dest(at)entry=0x5600febb3138,
    altdest=altdest(at)entry=0x5600febb3138, qc=0x7fff12ef7600) at pquery.c:791
#17 0x00005600fd256f34 in exec_simple_query (
    query_string=0x5600febb2178 "copy t from stdin with (format csv, default
'\\D');") at postgres.c:1240
#18 0x00005600fd258ae7 in PostgresMain (dbname=<optimized out>,
username=<optimized out>) at postgres.c:4572
#19 0x00005600fd1c2d3f in BackendRun (port=0x5600febe05c0, port=0x5600febe05c0)
at postmaster.c:4461
#20 BackendStartup (port=0x5600febe05c0) at postmaster.c:4189
#21 ServerLoop () at postmaster.c:1779
#22 0x00005600fd1c3d63 in PostmasterMain (argc=argc(at)entry=3,
argv=argv(at)entry=0x5600febad640) at postmaster.c:1463
#23 0x00005600fced4fc6 in main (argc=3, argv=0x5600febad640) at main.c:200

Best regards,
Alexander

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kumar, Sachin 2023-03-15 17:42:32 Initial Schema Sync for Logical Replication
Previous Message Ankit Kumar Pandey 2023-03-15 16:48:22 Re: optimize several list functions with SIMD intrinsics