Re: Date-time extraneous fields with reserved keywords

From: Joseph Koshakow <koshy44(at)gmail(dot)com>
To: Keisuke Kuroda <kuroda(dot)keisuke(at)nttcom(dot)co(dot)jp>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Date-time extraneous fields with reserved keywords
Date: 2023-03-04 16:33:02
Message-ID: CAAvxfHcGv=iKs63vRN3VaesBApefLuP0j8W146enio2o=kMB4Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Mar 4, 2023 at 11:23 AM Keisuke Kuroda <kuroda(dot)keisuke(at)nttcom(dot)co(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2023-03-04 16:35:11 Re: Request for comment on setting binary format output per session
Previous Message Kartyshov Ivan 2023-03-04 15:36:49 Re: [HACKERS] make async slave to wait for lsn to be replayed