diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-06-18 21:40:58 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-06-18 21:40:58 +0000 |
commit | 4c310eca2eabce72e7346af4a539ed066cbabe3e (patch) | |
tree | 7f78874c9e9a6abe93a450f34991ba55fec8a43c /src/include/parser | |
parent | 532834081d9e9d482ff50becab86e014b5f1db30 (diff) | |
download | postgresql-4c310eca2eabce72e7346af4a539ed066cbabe3e.tar.gz |
Arrange for quote_identifier() and pg_dump to not quote keywords that are
unreserved according to the grammar. The list of unreserved words has gotten
extensive enough that the unnecessary quoting is becoming a bit of an eyesore.
To do this, add knowledge of the keyword category to keywords.c's table.
(Someday we might be able to generate keywords.c's table and the keyword lists
in gram.y from a common source.) For the moment, lie about WITH's status in
the table so it will still get quoted --- this is because of the expectation
that WITH will become reserved when the SQL recursive-queries patch gets done.
I didn't force initdb because this affects nothing on-disk; but note that a
few regression tests have changed expected output.
Diffstat (limited to 'src/include/parser')
-rw-r--r-- | src/include/parser/keywords.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/include/parser/keywords.h b/src/include/parser/keywords.h index d16b5374a9..4cb37e5288 100644 --- a/src/include/parser/keywords.h +++ b/src/include/parser/keywords.h @@ -1,23 +1,31 @@ /*------------------------------------------------------------------------- * * keywords.h - * lexical token lookup for reserved words in postgres SQL + * lexical token lookup for key words in PostgreSQL * * * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/parser/keywords.h,v 1.22 2007/01/05 22:19:56 momjian Exp $ + * $PostgreSQL: pgsql/src/include/parser/keywords.h,v 1.23 2007/06/18 21:40:58 tgl Exp $ * *------------------------------------------------------------------------- */ #ifndef KEYWORDS_H #define KEYWORDS_H +/* Keyword categories --- should match lists in gram.y */ +#define UNRESERVED_KEYWORD 0 +#define COL_NAME_KEYWORD 1 +#define TYPE_FUNC_NAME_KEYWORD 2 +#define RESERVED_KEYWORD 3 + + typedef struct ScanKeyword { - const char *name; - int value; + const char *name; /* in lower case */ + int16 value; /* grammar's token code */ + int16 category; /* see codes above */ } ScanKeyword; extern const ScanKeyword *ScanKeywordLookup(const char *text); |