adding stuff to parser, question

From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: adding stuff to parser, question
Date: 2009-01-31 16:46:26
Message-ID: D4AFC2ED-4F96-43A3-A50D-71E843F65E4C@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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. :)

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-01-31 16:55:48 Re: [PATCH] Space reservation v02
Previous Message Robert Haas 2009-01-31 16:42:17 Re: How to get SE-PostgreSQL acceptable