Re: BUG #16272: Index expression can refer to wrong attributes if index is created via CREATE TABLE LIKE

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, tom(at)intevation(dot)de, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: Re: BUG #16272: Index expression can refer to wrong attributes if index is created via CREATE TABLE LIKE
Date: 2020-09-13 07:00:01
Message-ID: 05051f9d-b32b-cb35-6735-0e9f2ab86b5f@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello hackers,

22.08.2020 04:41, Michael Paquier wrote:
> For the archive's sake, this has been committed as of 5028981,
> backpatched down to 9.5.
> --
> Michael
I've encountered an issue (on REL_13_STABLE) that is attributed by `git
bisect` to 894f5dea (5028981 on master).
When executing the following query:
CREATE TABLE test(i int CHECK (i > 0));
CREATE TABLE pg_user(LIKE test INCLUDING CONSTRAINTS);

I get an assertion:
Core was generated by `postgres: law regression [local] CREATE
TABLE                                 '.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig(at)entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig(at)entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007f8872deb859 in __GI_abort () at abort.c:79
#2  0x0000561be6ee042b in ExceptionalCondition (
    conditionName=conditionName(at)entry=0x561be6f3f120 "lockmode != NoLock
|| IsBootstrapProcessingMode() || CheckRelationLockedByMe(r,
AccessShareLock, true)", errorType=errorType(at)entry=0x561be6f3d01d
"FailedAssertion",
    fileName=fileName(at)entry=0x561be6fe843f "relation.c",
lineNumber=lineNumber(at)entry=68) at assert.c:67
#3  0x0000561be6a1e349 in relation_open (relationId=12098,
lockmode=<optimized out>) at relation.c:68
#4  0x0000561be6b6b174 in expandTableLikeClause (heapRel=0x561be8f56e98,
    table_like_clause=table_like_clause(at)entry=0x561be8f77440) at
parse_utilcmd.c:1179
#5  0x0000561be6dafa90 in ProcessUtilitySlow
(pstate=pstate(at)entry=0x561be8f771c0, pstmt=pstmt(at)entry=0x561be8f57120,
    queryString=queryString(at)entry=0x561be8f56460 "CREATE TABLE
pg_user(LIKE test INCLUDING CONSTRAINTS);",
    context=context(at)entry=PROCESS_UTILITY_TOPLEVEL,
params=params(at)entry=0x0, queryEnv=queryEnv(at)entry=0x0,
    qc=0x7ffe509d76b0, dest=<optimized out>) at utility.c:1212
#6  0x0000561be6daec91 in standard_ProcessUtility (pstmt=0x561be8f57120,
    queryString=0x561be8f56460 "CREATE TABLE pg_user(LIKE test INCLUDING
CONSTRAINTS);",
    context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0,
dest=0x561be8f57400, qc=0x7ffe509d76b0)
    at utility.c:1069
#7  0x0000561be6dac066 in PortalRunUtility (portal=0x561be8fb77e0,
pstmt=0x561be8f57120, isTopLevel=<optimized out>,
    setHoldSnapshot=<optimized out>, dest=0x561be8f57400,
qc=0x7ffe509d76b0) at pquery.c:1157
#8  0x0000561be6dacb34 in PortalRunMulti
(portal=portal(at)entry=0x561be8fb77e0, isTopLevel=isTopLevel(at)entry=true,
    setHoldSnapshot=setHoldSnapshot(at)entry=false,
dest=dest(at)entry=0x561be8f57400, altdest=altdest(at)entry=0x561be8f57400,
    qc=qc(at)entry=0x7ffe509d76b0) at pquery.c:1303
#9  0x0000561be6dadabe in PortalRun (portal=portal(at)entry=0x561be8fb77e0,
count=count(at)entry=9223372036854775807,
    isTopLevel=isTopLevel(at)entry=true, run_once=run_once(at)entry=true,
dest=dest(at)entry=0x561be8f57400,
    altdest=altdest(at)entry=0x561be8f57400, qc=0x7ffe509d76b0) at pquery.c:779
#10 0x0000561be6da905a in exec_simple_query (
    query_string=0x561be8f56460 "CREATE TABLE pg_user(LIKE test
INCLUDING CONSTRAINTS);") at postgres.c:1239
#11 0x0000561be6daaedc in PostgresMain (argc=<optimized out>,
argv=argv(at)entry=0x561be8f81868, dbname=<optimized out>,
    username=<optimized out>) at postgres.c:4315
#12 0x0000561be6d182cf in BackendRun (port=0x561be8f77ea0) at
postmaster.c:4536
#13 BackendStartup (port=0x561be8f77ea0) at postmaster.c:4220
#14 ServerLoop () at postmaster.c:1739
#15 0x0000561be6d1921f in PostmasterMain (argc=<optimized out>,
argv=0x561be8f508c0) at postmaster.c:1412
#16 0x0000561be6a0e1f2 in main (argc=3, argv=0x561be8f508c0) at main.c:210

Best regards,
Alexander

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2020-09-13 14:42:52 Re: BUG #16615: Cannot determine type of Date for "is null" expression
Previous Message PG Bug reporting form 2020-09-13 00:28:45 BUG #16615: Cannot determine type of Date for "is null" expression