Thread: create/alter user extension syntax

create/alter user extension syntax

From
Peter Eisentraut
Date:
I tried the following:

{CREATE|ALTER} USER username
[ WITH ID/UID/<whatever> number ]
[ WITH PASSWORD password ]
[ etc. as usual ]

which gives shift/reduce conflicts, even if I make PASSWORD and
ID/whatever a pure keyword (WITH is already one). So that won't work.

I am currently basing my "experiments" on CREATE USER name [ SYSID nr ] [
WITH PASSWORD ... ] ... which allows SYSID to be a ColId. Any better (and
working) syntax suggestions are welcome.

(Also, the idea would be to reuse "SYSID" for a CREATE GROUP (any day now
;) statement, so no UID.)

-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden




Re: [HACKERS] create/alter user extension syntax

From
Thomas Lockhart
Date:
> I tried the following:
> {CREATE|ALTER} USER username
> [ WITH ID/UID/<whatever> number ]
> [ WITH PASSWORD password ]
> [ etc. as usual ]
> which gives shift/reduce conflicts, even if I make PASSWORD and
> ID/whatever a pure keyword (WITH is already one). So that won't work.

Sure it will (well, probably ;)

It depends how you set up the syntax. If you just try to have
something like (pseudocode, I'm rushing to leave for the weekend)

createuser: CREATE USER ColId Qual {};

Qual: WITH ID number {}   | WITH PASSWORD password {};

then the single-token lookahead of yacc will get in trouble. But if
you break it up some more then yacc can start maintaining multiple
token pointers to keep going, and the shift/reduce conflicts will go
away. Something like

cu: CREATE USER ColId QualClause {};

QualClause: QualClause WITH QualExpr {};         | QualClause {}         | /*EMPTY*/ {};

might do the trick, though I might be omitting one level. Check gram.y
for similar syntax examples such as the column qualifiers for CREATE
TABLE (though those are a bit more involved than this probably needs).

Good luck, and I'll be happy to help in a few days if you want.
                    - Thomas

-- 
Thomas Lockhart                lockhart@alumni.caltech.edu
South Pasadena, California