Re: Add support for DEFAULT specification in COPY FROM - Mailing list pgsql-hackers

From Alexander Lakhin
Subject Re: Add support for DEFAULT specification in COPY FROM
Date
Msg-id 71318aea-e47b-3ca1-3b5c-aa8047169902@gmail.com
Whole thread Raw
In response to Re: Add support for DEFAULT specification in COPY FROM  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: Add support for DEFAULT specification in COPY FROM  (Andrew Dunstan <andrew@dunslane.net>)
Re: Add support for DEFAULT specification in COPY FROM  (Andrew Dunstan <andrew@dunslane.net>)
List 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@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007fef2250e476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007fef224f47f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00005600fd395750 in ExceptionalCondition (
    conditionName=conditionName@entry=0x5600fd3fa751 "n >= 0 && n < list->length",
    fileName=fileName@entry=0x5600fd416db8 "../../../src/include/nodes/pg_list.h", lineNumber=lineNumber@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@entry=0x5600febdd238, econtext=econtext@entry=0x5600fec9c5c8,
    values=0x5600febdd5c8, nulls=0x5600febdd5d0) at copyfromparse.c:885
#11 0x00005600fd0234db in CopyFrom (cstate=cstate@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@entry=0x5600fec4ea48, pstmt=pstmt@entry=0x5600febb2e78,
    isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=false, dest=dest@entry=0x5600febb3138,
    qc=qc@entry=0x7fff12ef7600) at pquery.c:1158
#15 0x00005600fd25ab2d in PortalRunMulti (portal=portal@entry=0x5600fec4ea48, isTopLevel=isTopLevel@entry=true,
    setHoldSnapshot=setHoldSnapshot@entry=false, dest=dest@entry=0x5600febb3138,
    altdest=altdest@entry=0x5600febb3138, qc=qc@entry=0x7fff12ef7600) at pquery.c:1315
#16 0x00005600fd25b1c1 in PortalRun (portal=portal@entry=0x5600fec4ea48, count=count@entry=9223372036854775807,
    isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x5600febb3138,
    altdest=altdest@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@entry=3, argv=argv@entry=0x5600febad640) at postmaster.c:1463
#23 0x00005600fced4fc6 in main (argc=3, argv=0x5600febad640) at main.c:200

Best regards,
Alexander

pgsql-hackers by date:

Previous
From: Ankit Kumar Pandey
Date:
Subject: Re: optimize several list functions with SIMD intrinsics
Next
From: "Kumar, Sachin"
Date:
Subject: Initial Schema Sync for Logical Replication