Handling RestrictInfo in expression_tree_walker

From: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Handling RestrictInfo in expression_tree_walker
Date: 2019-08-07 07:24:17
Message-ID: 20645147-d73b-989f-cee0-8a26b6251d10@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

I wonder if there is some particular reason for not handling
T_RestrictInfo node tag in expression_tree_walker?
There are many data structure in Postgres which contains lists of
RestrictInfo or expression with RestrictInfo as parameter (for example
orclause in RestrictInfo).
To handle such cases now it is needed to write code performing list
iteration and calling expression_tree_walker for each list element and
handling RrestrictInfo in callback function:

static bool
change_varno_walker(Node *node, ChangeVarnoContext *context)
{
    if (node == NULL)
        return false;

    if (IsA(node, Var) && ((Var *) node)->varno == context->oldRelid)
    {
        ((Var *) node)->varno = context->newRelid;
        ((Var *) node)->varnoold = context->newRelid;
        return false;
    }
    if (IsA(node, RestrictInfo))
    {
        change_rinfo((RestrictInfo*)node, context->oldRelid,
context->newRelid);
        return false;
    }
    return expression_tree_walker(node, change_varno_walker, context);
}

Are there any complaints against handling RestrictInfo in
expression_tree_walker?

--
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2019-08-07 07:27:41 Re: partition routing layering in nodeModifyTable.c
Previous Message Surafel Temesgen 2019-08-07 07:20:09 Re: FETCH FIRST clause PERCENT option