Rename frontend keyword arrays to avoid conflict with backend.

ecpg and pg_dump each contain keyword arrays with structure similar
to the backend's keyword array.  Up to now, we actually named those
arrays the same as the backend's and relied on parser/keywords.h
to declare them.  This seems a tad too cute, though, and it breaks
now that we need to PGDLLIMPORT-decorate the backend symbols.
Rename to avoid the problem.  Per buildfarm.

(It strikes me that maybe we should get rid of the separate keywords.c
files altogether, and just define these arrays in the modules that use
them, but that's a rather more invasive change.)
This commit is contained in:
Tom Lane 2012-03-31 13:15:53 -04:00
parent a52e6fe7bc
commit c252a17d82
4 changed files with 17 additions and 9 deletions

View File

@ -22,6 +22,10 @@
#include "parser/keywords.h"
/* Globals from keywords.c */
extern const ScanKeyword FEScanKeywords[];
extern const int NumFEScanKeywords;
/* Globals exported by this file */
int quote_all_identifiers = 0;
const char *progname = NULL;
@ -150,8 +154,8 @@ fmtId(const char *rawid)
* that's fine, since we already know we have all-lower-case.
*/
const ScanKeyword *keyword = ScanKeywordLookup(rawid,
ScanKeywords,
NumScanKeywords);
FEScanKeywords,
NumFEScanKeywords);
if (keyword != NULL && keyword->category != UNRESERVED_KEYWORD)
need_quotes = true;

View File

@ -23,8 +23,8 @@
*/
#define PG_KEYWORD(a,b,c) {a,0,c},
const ScanKeyword ScanKeywords[] = {
const ScanKeyword FEScanKeywords[] = {
#include "parser/kwlist.h"
};
const int NumScanKeywords = lengthof(ScanKeywords);
const int NumFEScanKeywords = lengthof(FEScanKeywords);

View File

@ -16,13 +16,17 @@
#include "extern.h"
#include "preproc.h"
/* Globals from keywords.c */
extern const ScanKeyword SQLScanKeywords[];
extern const int NumSQLScanKeywords;
/*
* List of (keyword-name, keyword-token-value) pairs.
*
* !!WARNING!!: This list must be sorted, because binary
* search is used to locate entries.
*/
static const ScanKeyword ScanECPGKeywords[] = {
static const ScanKeyword ECPGScanKeywords[] = {
/* name, value, category */
/*
@ -87,12 +91,12 @@ ScanECPGKeywordLookup(const char *text)
const ScanKeyword *res;
/* First check SQL symbols defined by the backend. */
res = ScanKeywordLookup(text, ScanKeywords, NumScanKeywords);
res = ScanKeywordLookup(text, SQLScanKeywords, NumSQLScanKeywords);
if (res)
return res;
/* Try ECPG-specific keywords. */
res = ScanKeywordLookup(text, ScanECPGKeywords, lengthof(ScanECPGKeywords));
res = ScanKeywordLookup(text, ECPGScanKeywords, lengthof(ECPGScanKeywords));
if (res)
return res;

View File

@ -22,8 +22,8 @@
#define PG_KEYWORD(a,b,c) {a,b,c},
const ScanKeyword ScanKeywords[] = {
const ScanKeyword SQLScanKeywords[] = {
#include "parser/kwlist.h"
};
const int NumScanKeywords = lengthof(ScanKeywords);
const int NumSQLScanKeywords = lengthof(SQLScanKeywords);