Re: Patch to add support of "IF NOT EXISTS" to others "CREATE" statements

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Fabrízio de Royes Mello <fabrizio(at)timbira(dot)com(dot)br>
Cc: Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch to add support of "IF NOT EXISTS" to others "CREATE" statements
Date: 2013-07-14 09:23:02
Message-ID: 20130714092302.GA29095@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jul 14, 2013 at 03:36:09AM -0300, Fabrízio de Royes Mello wrote:
> > Next, changes in src/backend, starting with parser changes: the patch
> > adds "IF_P NOT EXISTS" variants for various productions. For example:

<snip>

> > I think opt_if_not_exists should be used for the others as well.
> >
>
> I could not use the "opt_if_not_exists" because bison emits an error:
>
> /usr/bin/bison -d -o gram.c gram.y
> gram.y: conflicts: 10 shift/reduce
> gram.y: expected 0 shift/reduce conflicts
> make[3]: *** [gram.c] Error 1
>
> I really don't know how to solve this problem. I'm just do ajustments like
> that:

This probably isn't solvable, which is why the coding is double in many
existing places. The issue is that by using opt_if_not_exists you make
that bison has to decide much earlier which rule it is parsing. Bison
only has one token lookahead and if that's not enough you get errors.

BTW, bison dumps a large file describing all its states that you should
be able to work out from that where the exact problem lies.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts.
-- Arthur Schopenhauer

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Atri Sharma 2013-07-14 15:10:19 Re: Removing Inner Joins
Previous Message Fabrízio de Royes Mello 2013-07-14 06:36:09 Re: Patch to add support of "IF NOT EXISTS" to others "CREATE" statements