cookConstraint dead code - Mailing list pgsql-hackers

From jian he
Subject cookConstraint dead code
Date
Msg-id CACJufxFxBKGLzgN+avkG+c8vdnLNhoqMCxQ-5OnVDqWC5P7j4g@mail.gmail.com
Whole thread Raw
List pgsql-hackers
hi.

in cookConstraint
    /*
     * Make sure no outside relations are referred to (this is probably dead
     * code now that add_missing_from is history).
     */
    if (list_length(pstate->p_rtable) != 1)
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
                 errmsg("only table \"%s\" can be referenced in check
constraint",
                        relname)));

looks like it indeed is dead code.
because  we cannot use subquery in check constraint.
if you want to reference another table, then you need
explicit mention it, like:

CREATE TABLE t3 (a int CHECK ( (a> v3.a)));

v3. is a ColumnRef node.
transformColumnRef, refnameNamespaceItem will error out if there is no
table name
specified in FROM clause.



pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: Please update the pgconf.dev Unconference notes
Next
From: DIPESH DHAMELIYA
Date:
Subject: Re: [PATCH] Allow parallelism for plpgsql return expression after commit 556f7b7