1 /*-------------------------------------------------------------------------
4 * lexical token lookup for reserved words in postgres SQL
6 * Copyright (c) 1994, Regents of the University of California
10 * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.46 1998/09/30 05:47:57 thomas Exp $
12 *-------------------------------------------------------------------------
18 #include "nodes/parsenodes.h"
19 #include "nodes/pg_list.h"
21 #include "parser/keywords.h"
22 #include "utils/elog.h"
25 * List of (keyword-name, keyword-token-value) pairs.
27 * !!WARNING!!: This list must be sorted, because binary
28 * search is used to locate entries.
30 static ScanKeyword ScanKeywords[] = {
32 {"abort", ABORT_TRANS},
33 {"absolute", ABSOLUTE},
37 {"aggregate", AGGREGATE},
45 {"backward", BACKWARD},
47 {"begin", BEGIN_TRANS},
56 {"character", CHARACTER},
63 {"constraint", CONSTRAINT},
66 {"createdb", CREATEDB},
67 {"createuser", CREATEUSER},
69 {"current", CURRENT}, /* 6.4 to 6.5 is migration time! CURRENT
70 * will be removed in 6.5! Use OLD keyword
72 {"current_date", CURRENT_DATE},
73 {"current_time", CURRENT_TIME},
74 {"current_timestamp", CURRENT_TIMESTAMP},
75 {"current_user", CURRENT_USER},
78 {"database", DATABASE},
84 {"delimiters", DELIMITERS},
86 {"distinct", DISTINCT},
91 {"encoding", ENCODING},
102 {"foreign", FOREIGN},
103 {"forward", FORWARD},
106 {"function", FUNCTION},
109 {"handler", HANDLER},
113 {"increment", INCREMENT},
115 {"inherits", INHERITS},
118 {"insensitive", INSENSITIVE},
119 {"instead", INSTEAD},
120 {"interval", INTERVAL},
126 {"lancompiler", LANCOMPILER},
127 {"language", LANGUAGE},
128 {"leading", LEADING},
134 {"location", LOCATION},
137 {"maxvalue", MAXVALUE},
138 {"minute", MINUTE_P},
139 {"minvalue", MINVALUE},
143 {"national", NATIONAL},
144 {"natural", NATURAL},
149 {"nocreatedb", NOCREATEDB},
150 {"nocreateuser", NOCREATEUSER},
153 {"nothing", NOTHING},
155 {"notnull", NOTNULL},
157 {"numeric", NUMERIC},
163 {"operator", OPERATOR},
168 {"partial", PARTIAL},
169 {"password", PASSWORD},
170 {"position", POSITION},
171 {"precision", PRECISION},
172 {"primary", PRIMARY},
174 {"privileges", PRIVILEGES},
175 {"procedural", PROCEDURAL},
176 {"procedure", PROCEDURE},
180 {"references", REFERENCES},
181 {"relative", RELATIVE},
184 {"returns", RETURNS},
187 {"rollback", ROLLBACK},
191 {"second", SECOND_P},
193 {"sequence", SEQUENCE},
199 {"statement", STATEMENT},
202 {"substring", SUBSTRING},
205 {"timestamp", TIMESTAMP},
206 {"timezone_hour", TIMEZONE_HOUR},
207 {"timezone_minute", TIMEZONE_MINUTE},
209 {"trailing", TRAILING},
210 {"transaction", TRANSACTION},
211 {"trigger", TRIGGER},
214 {"trusted", TRUSTED},
218 {"unlisten", UNLISTEN},
226 {"varchar", VARCHAR},
227 {"varying", VARYING},
228 {"verbose", VERBOSE},
229 {"version", VERSION},
239 ScanKeywordLookup(char *text)
241 ScanKeyword *low = &ScanKeywords[0];
242 ScanKeyword *high = endof(ScanKeywords) - 1;
248 middle = low + (high - low) / 2;
249 difference = strcmp(middle->name, text);
252 else if (difference < 0)