1 /*-------------------------------------------------------------------------
4 * lexical token lookup for reserved words in postgres SQL
6 * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
7 * Portions Copyright (c) 1994, Regents of the University of California
12 * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.77 2000/06/12 19:40:41 momjian Exp $
14 * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.77 2000/06/12 19:40:41 momjian Exp $
17 *-------------------------------------------------------------------------
23 #include "nodes/parsenodes.h"
24 #include "nodes/pg_list.h"
25 #include "parser/keywords.h"
26 #include "parser/parse.h"
29 * List of (keyword-name, keyword-token-value) pairs.
31 * !!WARNING!!: This list must be sorted, because binary
32 * search is used to locate entries.
34 static ScanKeyword ScanKeywords[] = {
36 {"abort", ABORT_TRANS},
37 {"absolute", ABSOLUTE},
42 {"aggregate", AGGREGATE},
50 {"backward", BACKWARD},
52 {"begin", BEGIN_TRANS},
63 {"character", CHARACTER},
67 {"coalesce", COALESCE},
72 {"committed", COMMITTED},
73 {"constraint", CONSTRAINT},
74 {"constraints", CONSTRAINTS},
77 {"createdb", CREATEDB},
78 {"createuser", CREATEUSER},
80 /* for portability with old rules bjm 2000-06-12 */
82 {"current_date", CURRENT_DATE},
83 {"current_time", CURRENT_TIME},
84 {"current_timestamp", CURRENT_TIMESTAMP},
85 {"current_user", CURRENT_USER},
88 {"database", DATABASE},
94 {"deferrable", DEFERRABLE},
95 {"deferred", DEFERRED},
97 {"delimiters", DELIMITERS},
99 {"distinct", DISTINCT},
105 {"encoding", ENCODING},
108 {"exclusive", EXCLUSIVE},
109 {"execute", EXECUTE},
111 {"explain", EXPLAIN},
113 {"extract", EXTRACT},
119 {"foreign", FOREIGN},
120 {"forward", FORWARD},
123 {"function", FUNCTION},
127 {"handler", HANDLER},
130 {"immediate", IMMEDIATE},
132 {"increment", INCREMENT},
134 {"inherits", INHERITS},
135 {"initially", INITIALLY},
137 {"insensitive", INSENSITIVE},
139 {"instead", INSTEAD},
140 {"intersect", INTERSECT},
141 {"interval", INTERVAL},
145 {"isolation", ISOLATION},
148 {"lancompiler", LANCOMPILER},
149 {"language", LANGUAGE},
150 {"leading", LEADING},
158 {"location", LOCATION},
161 {"maxvalue", MAXVALUE},
162 {"minute", MINUTE_P},
163 {"minvalue", MINVALUE},
168 {"national", NATIONAL},
169 {"natural", NATURAL},
174 {"nocreatedb", NOCREATEDB},
175 {"nocreateuser", NOCREATEUSER},
178 {"nothing", NOTHING},
180 {"notnull", NOTNULL},
183 {"numeric", NUMERIC},
191 {"operator", OPERATOR},
196 {"overlaps", OVERLAPS},
197 {"partial", PARTIAL},
198 {"password", PASSWORD},
199 {"pendant", PENDANT},
200 {"position", POSITION},
201 {"precision", PRECISION},
202 {"primary", PRIMARY},
204 {"privileges", PRIVILEGES},
205 {"procedural", PROCEDURAL},
206 {"procedure", PROCEDURE},
209 {"references", REFERENCES},
210 {"reindex", REINDEX},
211 {"relative", RELATIVE},
214 {"restrict", RESTRICT},
215 {"returns", RETURNS},
218 {"rollback", ROLLBACK},
222 {"second", SECOND_P},
224 {"sequence", SEQUENCE},
226 {"serializable", SERIALIZABLE},
227 {"session_user", SESSION_USER},
234 {"statement", STATEMENT},
237 {"substring", SUBSTRING},
241 {"temporary", TEMPORARY},
244 {"timestamp", TIMESTAMP},
245 {"timezone_hour", TIMEZONE_HOUR},
246 {"timezone_minute", TIMEZONE_MINUTE},
248 {"trailing", TRAILING},
249 {"transaction", TRANSACTION},
250 {"trigger", TRIGGER},
253 {"truncate", TRUNCATE},
254 {"trusted", TRUSTED},
259 {"unlisten", UNLISTEN},
267 {"varchar", VARCHAR},
268 {"varying", VARYING},
269 {"verbose", VERBOSE},
270 {"version", VERSION},
281 ScanKeywordLookup(char *text)
283 ScanKeyword *low = &ScanKeywords[0];
284 ScanKeyword *high = endof(ScanKeywords) - 1;
290 middle = low + (high - low) / 2;
291 difference = strcmp(middle->name, text);
294 else if (difference < 0)