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.47 1998/10/18 23:29:27 momjian 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 will be removed in 6.5! Use OLD keyword in rules. Jan */
70 {"current_date", CURRENT_DATE},
71 {"current_time", CURRENT_TIME},
72 {"current_timestamp", CURRENT_TIMESTAMP},
73 {"current_user", CURRENT_USER},
76 {"database", DATABASE},
82 {"delimiters", DELIMITERS},
84 {"distinct", DISTINCT},
89 {"encoding", ENCODING},
100 {"foreign", FOREIGN},
101 {"forward", FORWARD},
104 {"function", FUNCTION},
107 {"handler", HANDLER},
111 {"increment", INCREMENT},
113 {"inherits", INHERITS},
115 {"insensitive", INSENSITIVE},
117 {"instead", INSTEAD},
118 {"interval", INTERVAL},
124 {"lancompiler", LANCOMPILER},
125 {"language", LANGUAGE},
126 {"leading", LEADING},
132 {"location", LOCATION},
135 {"maxvalue", MAXVALUE},
136 {"minute", MINUTE_P},
137 {"minvalue", MINVALUE},
141 {"national", NATIONAL},
142 {"natural", NATURAL},
147 {"nocreatedb", NOCREATEDB},
148 {"nocreateuser", NOCREATEUSER},
151 {"nothing", NOTHING},
153 {"notnull", NOTNULL},
155 {"numeric", NUMERIC},
161 {"operator", OPERATOR},
166 {"partial", PARTIAL},
167 {"password", PASSWORD},
168 {"position", POSITION},
169 {"precision", PRECISION},
170 {"primary", PRIMARY},
172 {"privileges", PRIVILEGES},
173 {"procedural", PROCEDURAL},
174 {"procedure", PROCEDURE},
178 {"references", REFERENCES},
179 {"relative", RELATIVE},
182 {"returns", RETURNS},
185 {"rollback", ROLLBACK},
189 {"second", SECOND_P},
191 {"sequence", SEQUENCE},
197 {"statement", STATEMENT},
200 {"substring", SUBSTRING},
203 {"timestamp", TIMESTAMP},
204 {"timezone_hour", TIMEZONE_HOUR},
205 {"timezone_minute", TIMEZONE_MINUTE},
207 {"trailing", TRAILING},
208 {"transaction", TRANSACTION},
209 {"trigger", TRIGGER},
212 {"trusted", TRUSTED},
216 {"unlisten", UNLISTEN},
224 {"varchar", VARCHAR},
225 {"varying", VARYING},
226 {"verbose", VERBOSE},
227 {"version", VERSION},
237 ScanKeywordLookup(char *text)
239 ScanKeyword *low = &ScanKeywords[0];
240 ScanKeyword *high = endof(ScanKeywords) - 1;
246 middle = low + (high - low) / 2;
247 difference = strcmp(middle->name, text);
250 else if (difference < 0)