Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] Updated TODO item

From: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>
To: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
Cc: Kaare Rasmussen <kar(at)kakidata(dot)dk>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [HACKERS] Updated TODO item
Date: 2002-01-08 04:42:13
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-patches
On Tue, 8 Jan 2002, Christopher Kings-Lynne wrote:

> > Does this have the multiple "WITH xxx" clauses which were discussed
> > earlier? That is a nonstarter for syntax. There are other places in the
> > grammar having "with clauses" and multiple arguments or subclauses, and
> > having the shift/reduce issues resolved...
> I might be thicker than a whale sandwich (10 points if you can pick the
> quote :) ), but can someone please tell me what a shift/reduce issue is,
> exactly...

A Yacc parser does two things in order to parse input:

1) Reduce: attempt to reduce the stack by simplifying it to a rule
2) Shift: obtain the next token from input so that a reduction may be able
to take.

Shift/reduce conflicts are pretty ugly. Basically, what happens is that
the parser finds itself in a state where it is valid to reduce OR shift at
some point in the grammar. What I believe Thomas was refering to was this

Take a rule:

rule a: CREATE DATABASE <name> WITH LOCATION = <name>
rule b: CREATE DATABASE <name> WITH LOCATION = <name> WITH OWNER = <name>

now if the input is:


Then the parser can reach the point under-marked by the circumflex and
find it valid to reduce the stack (CREATE DATABASE test WITH LOCATION =
'/var/test') to rule a OR shift and put the WITH (after the circumflex) on
the stack given that this should match rule b.

Naturally, if this conflict is ignored for the grammar above, you could
end up with wild results in your parsed node tree. Realistically, Bison
and other yacc compilers will generate parsers unaffected for this
situation because they always opt to shift when there is a shift/reduce
conflict -- a pretty safe bet. But if it should have been valid to reduce
the input to a once it reached the circumflex, you'd be in trouble.


In response to


pgsql-hackers by date

Next:From: Jan WieckDate: 2002-01-08 04:50:36
Subject: Re: RC1 time?
Previous:From: Gavin SherryDate: 2002-01-08 04:26:07
Subject: Re: [HACKERS] Updated TODO item

pgsql-patches by date

Next:From: Bruce MomjianDate: 2002-01-08 05:40:48
Subject: URL's fixed
Previous:From: Gavin SherryDate: 2002-01-08 04:26:07
Subject: Re: [HACKERS] Updated TODO item

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group