Re: Date-time extraneous fields with reserved keywords - Mailing list pgsql-hackers

From Joseph Koshakow
Subject Re: Date-time extraneous fields with reserved keywords
Date
Msg-id CAAvxfHcGv=iKs63vRN3VaesBApefLuP0j8W146enio2o=kMB4Q@mail.gmail.com
Whole thread Raw
In response to Re: Date-time extraneous fields with reserved keywords  (Keisuke Kuroda <kuroda.keisuke@nttcom.co.jp>)
Responses Re: Date-time extraneous fields with reserved keywords  (Joseph Koshakow <koshy44@gmail.com>)
List pgsql-hackers


On Sat, Mar 4, 2023 at 11:23 AM Keisuke Kuroda <kuroda.keisuke@nttcom.co.jp> wrote:
>
>    Good catch.
>    Of the reserved words that are special values of type Date/Time,
>    'now', 'today', 'tomorrow', 'yesterday', and 'allballs',
>    I get an error even before applying the patch.

Thanks for pointing this out. After taking a look
at the code, 'now', 'today', 'tomorrow',
'yesterday', and 'allballs' all set the
appropriate tmask field which is what causes them
to error.

  case DTK_NOW:
        tmask = (DTK_DATE_M | DTK_TIME_M | DTK_M(TZ));

  case DTK_YESTERDAY:
        tmask = DTK_DATE_M;

  case DTK_TODAY:
        tmask = DTK_DATE_M;

  case DTK_TOMORROW:
        tmask = DTK_DATE_M;

  case DTK_ZULU:
        tmask = (DTK_TIME_M | DTK_M(TZ));


while 'epoch', 'infinity', and '-infinity' do not
set tmask (note the default below handles all of
these fields)

  default:
      *dtype = val;

So I think a better fix here would be to also set
tmask for those three reserved keywords.


>    One thing I noticed is that the following SQL
>    returns normal results even after applying the patch.
>
>    postgres=# select timestamp 'epoch 01:01:01';
>          timestamp
>    ---------------------
>     1970-01-01 00:00:00
>    (1 row)
>
>    When 'epoch','infinity','-infinity' and time are specified together,
>    the time specified in the SQL is not included in result.
>    I think it might be better to assume that this pattern is also an error.
>    What do you think?

I agree this pattern should also be an error. I
think that the tmask approach will cause an error
for this pattern as well.

Thanks,
Joe Koshakow

pgsql-hackers by date:

Previous
From: Kartyshov Ivan
Date:
Subject: Re: [HACKERS] make async slave to wait for lsn to be replayed
Next
From: Jeff Davis
Date:
Subject: Re: Request for comment on setting binary format output per session