summaryrefslogtreecommitdiff
path: root/src/backend/parser/kwlookup.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-07-14 20:24:10 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-07-14 20:24:10 +0000
commit1aa58d3a8389fcf8899745049f128f6b8fec7bc9 (patch)
tree2e36e9cf65a517ce558fbfe694821da5bb28c131 /src/backend/parser/kwlookup.c
parent0d4899e448df2b02434d6d423156408cde012707 (diff)
downloadpostgresql-1aa58d3a8389fcf8899745049f128f6b8fec7bc9.tar.gz
Tweak the core scanner so that it can be used by plpgsql too.
Changes: Pass in the keyword lookup array instead of having it be hardwired. (This incidentally allows elimination of some duplicate coding in ecpg.) Re-order the token declarations in gram.y so that non-keyword tokens have numbers that won't change when keywords are added or removed. Add ".." and ":=" to the set of tokens recognized by scan.l. (Since these combinations are nowhere legal in core SQL, this does not change anything except the precise wording of the error you get when you write this.)
Diffstat (limited to 'src/backend/parser/kwlookup.c')
-rw-r--r--src/backend/parser/kwlookup.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/backend/parser/kwlookup.c b/src/backend/parser/kwlookup.c
index 7321a57c15..58c8cdd78f 100644
--- a/src/backend/parser/kwlookup.c
+++ b/src/backend/parser/kwlookup.c
@@ -6,15 +6,12 @@
* NB - this file is also used by ECPG and several frontend programs in
* src/bin/ including pg_dump and psql
*
- * Note that this file expects that the ScanKeywords array is defined
- * and that LastScanKeyword points to its element one past the last.
- *
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/kwlookup.c,v 2.2 2009/03/08 16:53:30 alvherre Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/kwlookup.c,v 2.3 2009/07/14 20:24:10 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -39,7 +36,9 @@
* receive a different case-normalization mapping.
*/
const ScanKeyword *
-ScanKeywordLookup(const char *text)
+ScanKeywordLookup(const char *text,
+ const ScanKeyword *keywords,
+ int num_keywords)
{
int len,
i;
@@ -69,8 +68,8 @@ ScanKeywordLookup(const char *text)
/*
* Now do a binary search using plain strcmp() comparison.
*/
- low = &ScanKeywords[0];
- high = LastScanKeyword - 1;
+ low = keywords;
+ high = keywords + (num_keywords - 1);
while (low <= high)
{
const ScanKeyword *middle;