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.38 1998/07/24 03:31:24 scrappy 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},
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},
116 {"instead", INSTEAD},
117 {"interval", INTERVAL},
123 {"lancompiler", LANCOMPILER},
124 {"language", LANGUAGE},
125 {"leading", LEADING},
131 {"location", LOCATION},
134 {"maxvalue", MAXVALUE},
135 {"minute", MINUTE_P},
136 {"minvalue", MINVALUE},
140 {"national", NATIONAL},
141 {"natural", NATURAL},
145 {"nocreatedb", NOCREATEDB},
146 {"nocreateuser", NOCREATEUSER},
149 {"nothing", NOTHING},
151 {"notnull", NOTNULL},
153 {"numeric", NUMERIC},
156 {"operator", OPERATOR},
161 {"partial", PARTIAL},
162 {"password", PASSWORD},
163 {"position", POSITION},
164 {"precision", PRECISION},
165 {"primary", PRIMARY},
166 {"privileges", PRIVILEGES},
167 {"procedural", PROCEDURAL},
168 {"procedure", PROCEDURE},
171 {"references", REFERENCES},
174 {"returns", RETURNS},
177 {"rollback", ROLLBACK},
180 {"second", SECOND_P},
182 {"sequence", SEQUENCE},
187 {"statement", STATEMENT},
190 {"substring", SUBSTRING},
193 {"timezone_hour", TIMEZONE_HOUR},
194 {"timezone_minute", TIMEZONE_MINUTE},
196 {"trailing", TRAILING},
197 {"transaction", TRANSACTION},
198 {"trigger", TRIGGER},
201 {"trusted", TRUSTED},
212 {"varchar", VARCHAR},
213 {"varying", VARYING},
214 {"verbose", VERBOSE},
215 {"version", VERSION},
225 ScanKeywordLookup(char *text)
227 ScanKeyword *low = &ScanKeywords[0];
228 ScanKeyword *high = endof(ScanKeywords) - 1;
234 middle = low + (high - low) / 2;
235 difference = strcmp(middle->name, text);
238 else if (difference < 0)