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.44 1998/09/01 04:30:23 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},
36 {"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 {"instead", INSTEAD},
119 {"interval", INTERVAL},
125 {"lancompiler", LANCOMPILER},
126 {"language", LANGUAGE},
127 {"leading", LEADING},
133 {"location", LOCATION},
136 {"maxvalue", MAXVALUE},
137 {"minute", MINUTE_P},
138 {"minvalue", MINVALUE},
142 {"national", NATIONAL},
143 {"natural", NATURAL},
147 {"nocreatedb", NOCREATEDB},
148 {"nocreateuser", NOCREATEUSER},
151 {"nothing", NOTHING},
153 {"notnull", NOTNULL},
155 {"numeric", NUMERIC},
159 {"operator", OPERATOR},
164 {"partial", PARTIAL},
165 {"password", PASSWORD},
166 {"position", POSITION},
167 {"precision", PRECISION},
168 {"primary", PRIMARY},
169 {"privileges", PRIVILEGES},
170 {"procedural", PROCEDURAL},
171 {"procedure", PROCEDURE},
174 {"references", REFERENCES},
177 {"returns", RETURNS},
180 {"rollback", ROLLBACK},
183 {"second", SECOND_P},
185 {"sequence", SEQUENCE},
191 {"statement", STATEMENT},
194 {"substring", SUBSTRING},
197 {"timezone_hour", TIMEZONE_HOUR},
198 {"timezone_minute", TIMEZONE_MINUTE},
200 {"trailing", TRAILING},
201 {"transaction", TRANSACTION},
202 {"trigger", TRIGGER},
205 {"trusted", TRUSTED},
209 {"unlisten", UNLISTEN},
217 {"varchar", VARCHAR},
218 {"varying", VARYING},
219 {"verbose", VERBOSE},
220 {"version", VERSION},
230 ScanKeywordLookup(char *text)
232 ScanKeyword *low = &ScanKeywords[0];
233 ScanKeyword *high = endof(ScanKeywords) - 1;
239 middle = low + (high - low) / 2;
240 difference = strcmp(middle->name, text);
243 else if (difference < 0)