Re: Bug in to_timestamp().

From: Artur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru>
To: Robert Haas <robertmhaas(at)gmail(dot)com>, amul sul <sul_amul(at)yahoo(dot)co(dot)in>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru>, Bruce Momjian <bruce(at)momjian(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bug in to_timestamp().
Date: 2016-08-25 08:25:23
Message-ID: 22dbe4e0-b550-ca86-8634-adcda0faa159@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> #1.
> Whitespace @ line # 317.

Sorry, fixed.

> #2. Warning at compilation;
>
> formatting.c: In function ‘do_to_timestamp’:
> formatting.c:3049:37: warning: ‘prev_type’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> if (prev_type == NODE_TYPE_SPACE || prev_type == NODE_TYPE_SEPARATOR)
> ^
> formatting.c:2988:5: note: ‘prev_type’ was declared here
> prev_type;
> ^
>
> You can avoid this by assigning zero (or introduce NODE_TYPE_INVAL ) to prev_type at following line:
>
> 256 + prev_type;

You are right. I assigned to prev_type NODE_TYPE_SPACE to be able to
execute such query:

SELECT to_timestamp('---2000----JUN', 'YYYY MON');

Will be it a proper behaviour?

--
Artur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

Attachment Content-Type Size
0001-to-timestamp-format-checking-v4.patch text/x-patch 18.3 KB
0002-to-timestamp-validation-v2.patch text/x-patch 6.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message amul sul 2016-08-25 09:10:29 Re: Bug in to_timestamp().
Previous Message Petr Jelinek 2016-08-25 08:22:59 Re: Logical Replication WIP