public inbox for [email protected]  
help / color / mirror / Atom feed
From: jian he <[email protected]>
To: PostgreSQL-development <[email protected]>
Cc: Paul A Jungwirth <[email protected]>
Subject: FOR PORTION OF gram.y target_location seems wrong
Date: Fri, 24 Apr 2026 09:10:47 +0800
Message-ID: <CACJufxEKdga8bEE4mkMDVYJ78V_7Orj7M8FcsYk_VnsY4Bv4aA@mail.gmail.com> (raw)

Hi.

| FOR PORTION OF ColId FROM a_expr TO a_expr
    {
        ForPortionOfClause *n = makeNode(ForPortionOfClause);
        n->range_name = $4;
        n->location = @4;
        n->target_start = $6;
        n->target_end = $8;
        n->target_location = @5;
        $$ = (Node *) n;
    }

n->target_location = @5;

Should be

n->target_location = @6;

It's not reachable because of queries like:

UPDATE for_portion_of_test
  FOR PORTION OF valid_at FROM NULL TO NULL
  SET name = 'NULL to NULL';

won't reach
ereport(ERROR,
        (errmsg("FOR PORTION OF target was null")),
        executor_errposition(estate, forPortionOf->targetLocation));

typedef struct ForPortionOfClause
{
    NodeTag        type;
    char       *range_name;        /* column name of the range/multirange */
    ParseLoc    location;        /* token location, or -1 if unknown */
    ParseLoc    target_location;    /* token location, or -1 if unknown */
    Node       *target;            /* Expr from FOR PORTION OF col
(...) syntax */
    Node       *target_start;    /* Expr from FROM ... TO ... syntax */
    Node       *target_end;        /* Expr from FROM ... TO ... syntax */
} ForPortionOfClause;

Generally, we place ParseLoc at the end of the node, putting it
elsewhere should be fine.
But here, we have two comments, ``/* token location, or -1 if unknown */``.
The "token" is ambiguous, perhaps it's worth the trouble to enhance it?



--
jian
https://www.enterprisedb.com/





view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: FOR PORTION OF gram.y target_location seems wrong
  In-Reply-To: <CACJufxEKdga8bEE4mkMDVYJ78V_7Orj7M8FcsYk_VnsY4Bv4aA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox