adding stuff to parser, question - Mailing list pgsql-hackers

From Grzegorz Jaskiewicz
Subject adding stuff to parser, question
Date
Msg-id D4AFC2ED-4F96-43A3-A50D-71E843F65E4C@pointblue.com.pl
Whole thread Raw
Responses Re: adding stuff to parser, question  (Grzegorz Jaskiewicz <gj@pointblue.com.pl>)
Re: adding stuff to parser, question  (Gregory Stark <stark@enterprisedb.com>)
Re: adding stuff to parser, question  (David Fetter <david@fetter.org>)
List pgsql-hackers
Hey folks,

I am trying to add "GRANT SELECT ON ALL TABLES" to postgres, as it has  
been quite few times now - where I had to write a procedure for that.
I kind of looked around, and more or less know how to approach it. But  
I am stuck on parser :), yes - parser.

Can someone walk me through adding new rules to parser ?
so far I have this:

Index: parser/gram.y
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.656
diff -u -r2.656 gram.y
--- parser/gram.y    22 Jan 2009 20:16:05 -0000    2.656
+++ parser/gram.y    31 Jan 2009 16:44:57 -0000
@@ -494,7 +494,7 @@     STATISTICS STDIN STDOUT STORAGE STRICT_P STRIP_P SUBSTRING  
SUPERUSER_P     SYMMETRIC SYSID SYSTEM_P

-    TABLE TABLESPACE TEMP TEMPLATE TEMPORARY TEXT_P THEN TIME TIMESTAMP
+    TABLE TABLES TABLESPACE TEMP TEMPLATE TEMPORARY TEXT_P THEN TIME  
TIMESTAMP     TO TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P     TRUNCATE TRUSTED TYPE_P

@@ -4301,6 +4301,13 @@                     n->objs = $2;                     $$ = n;                 }
+            | ALL TABLES
+                {
+                    PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
+                    n->objtype = ACL_OBJECT_RELATION;
+                    n->objs = NULL;
+                    $$ = n;
+                }             | SEQUENCE qualified_name_list                 {                     PrivTarget *n =
(PrivTarget*) palloc(sizeof(PrivTarget));
 
Index: parser/keywords.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/parser/keywords.c,v
retrieving revision 1.209
diff -u -r1.209 keywords.c
--- parser/keywords.c    1 Jan 2009 17:23:45 -0000    1.209
+++ parser/keywords.c    31 Jan 2009 16:44:57 -0000
@@ -373,6 +373,7 @@     {"sysid", SYSID, UNRESERVED_KEYWORD},     {"system", SYSTEM_P, UNRESERVED_KEYWORD},
{"table",TABLE, RESERVED_KEYWORD},
 
+    {"table", TABLES, RESERVED_KEYWORD},     {"tablespace", TABLESPACE, UNRESERVED_KEYWORD},     {"temp", TEMP,
UNRESERVED_KEYWORD},    {"template", TEMPLATE, UNRESERVED_KEYWORD},
 




But that seems to be not nearly enough, for psql to recognize "GRANT  
SELECT ON ALL TABLES TO foo".
Please help me out, with stuff I am missing here. I never had any  
expierence with bison, or any other lexical parsers for that matter.

Thanks. :)



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: How to get SE-PostgreSQL acceptable
Next
From: Robert Haas
Date:
Subject: Re: [PATCH] Space reservation v02