Re: [BUGS] Beta 10 parser error for CREATE STATISTICS IF NOT EXISTS

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Bruno Wolff III <bruno(at)wolff(dot)to>, pgsql-bugs(at)postgresql(dot)org
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [BUGS] Beta 10 parser error for CREATE STATISTICS IF NOT EXISTS
Date: 2017-06-21 01:55:28
Message-ID: 38b7d52e-387a-0e47-7525-b8b654ca4bfb@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On 2017/06/21 10:15, Amit Langote wrote:
> On 2017/06/21 9:42, Bruno Wolff III wrote:
>> I'm not seeing an obvious error in my attempt to use CREATE STATISTICS IF
>> NOT EXISTS. Given this is new, maybe there is a bug in the parser.
>>
>> Sample output:
>> psql (10beta1)
>> Type "help" for help.
>>
>> o365logs=# select version();
>>
>> version
>> --------------------------------------------------------------------------------
>>
>> ----------------------------
>> PostgreSQL 10beta1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5
>> 20150623
>> (Red Hat 4.8.5-11), 64-bit
>> (1 row)
>>
>> o365logs=# CREATE STATISTICS IF NOT EXISTS logs_corrtest (dependencies) ON
>> record_type, operation FROM logs;
>> ERROR: syntax error at or near "NOT"
>> LINE 1: CREATE STATISTICS IF NOT EXISTS logs_corrtest (dependencies)...
>
> Looks like a documentation bug if the authors of the feature actually
> meant to implement the following syntax:
>
> CREATE [ IF NOT EXISTS ] STATISTICS
>
> create if not exists statistics words_stats on a, b from words;
> CREATE STATISTICS
>
> create if not exists statistics words_stats on a, b from words;
> NOTICE: statistics object "words_stats" already exists, skipping
> CREATE STATISTICS
>
> If that's really what's intended, it seems a bit inconsistent with most
> other commands and with DROP STATISTICS [ IF NOT EXISTS ] itself.

Here is a patch, just in case, that changes the grammar to accept the
following syntax instead of the current one:

CREATE STATISTICS [ IF NOT EXIST ] ...

Also added a test. Documentation already displays the above syntax, so no
update needed there.

Thanks,
Amit

Attachment Content-Type Size
0001-Fix-the-syntax-of-IF-NOT-EXISTS-variant-of-CREATE-ST.patch text/plain 3.2 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2017-06-21 02:01:06 Re: Beta 10 parser error for CREATE STATISTICS IF NOT EXISTS
Previous Message Amit Langote 2017-06-21 01:15:28 Re: Beta 10 parser error for CREATE STATISTICS IF NOT EXISTS

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-06-21 02:01:06 Re: Beta 10 parser error for CREATE STATISTICS IF NOT EXISTS
Previous Message Michael Paquier 2017-06-21 01:48:53 Re: Proposal for CSN based snapshots