Re: Adding OLD/NEW support to RETURNING

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Jeff Davis <pgsql(at)j-davis(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tomas Vondra <tomas(at)vondra(dot)me>
Subject: Re: Adding OLD/NEW support to RETURNING
Date: 2024-10-14 16:05:58
Message-ID: CAEZATCU5fDmry9U6GWo8WUG5+qw=D8-PcYACm3No0r1Uxu5O7w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 14 Oct 2024 at 16:34, jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> typedef struct ReturningOption
> {
> NodeTag type;
> ReturningOptionKind option; /* specified option */
> char *value; /* option's value */
> ParseLoc location; /* token location, or -1 if unknown */
> } ReturningOption;
>
> @@ -4304,6 +4332,16 @@ raw_expression_tree_walker_impl(Node *no
> return true;
> }
> break;
> + case T_ReturningClause:
> + {
> + ReturningClause *returning = (ReturningClause *) node;
> +
> + if (WALK(returning->options))
> + return true;
> + if (WALK(returning->exprs))
> + return true;
> + }
> + break;
>
> + if (WALK(returning->options))
> + return true;
> T_ReturningOption is primitive, so we only need to
> "if (WALK(returning->exprs))"?

No, it still needs to walk the options so that it will call the
callback for each option. The fact that T_ReturningOption is primitive
doesn't change that, it just means that there is no more structure
*below* a ReturningOption that needs to be traversed. The
ReturningOption itself still needs to be traversed. For example,
imagine you wanted to use raw_expression_tree_walker() to print out
the whole structure of a raw parse tree. You'd want your printing
callback to be called for every node, including the ReturningOption
nodes.

Regards,
Dean

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2024-10-14 16:06:05 Re: not null constraints, again
Previous Message jian he 2024-10-14 15:34:21 Re: Adding OLD/NEW support to RETURNING