summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorTom Lane2016-03-24 00:22:08 +0000
committerTom Lane2016-03-24 00:22:08 +0000
commit2c6af4f44228d76d3351fe26f68b00b55cdd239a (patch)
tree6a5ce32658ba9ad51ea05d6f46ef0aaf44b1f244 /src/bin
parent3df9c374e279db37b00cd9c86219471d0cdaa97c (diff)
Move keywords.c/kwlookup.c into src/common/.
Now that we have src/common/ for code shared between frontend and backend, we can get rid of (most of) the klugy ways that the keyword table and keyword lookup code were formerly shared between different uses. This is a first step towards a more general plan of getting rid of special-purpose kluges for sharing code in src/bin/. I chose to merge kwlookup.c back into keywords.c, as it once was, and always has been so far as keywords.h is concerned. We could have kept them separate, but there is noplace that uses ScanKeywordLookup without also wanting access to the backend's keyword list, so there seems little point. ecpg is still a bit weird, but at least now the trickiness is documented. I think that the MSVC build script should require no adjustments beyond what's done here ... but we'll soon find out.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_dump/.gitignore2
-rw-r--r--src/bin/pg_dump/Makefile19
-rw-r--r--src/bin/pg_dump/dumputils.c10
-rw-r--r--src/bin/pg_dump/keywords.c30
-rw-r--r--src/bin/psql/.gitignore2
-rw-r--r--src/bin/psql/Makefile9
-rw-r--r--src/bin/scripts/.gitignore2
-rw-r--r--src/bin/scripts/Makefile23
8 files changed, 23 insertions, 74 deletions
diff --git a/src/bin/pg_dump/.gitignore b/src/bin/pg_dump/.gitignore
index c2c8677bd80..ae4cf3ce428 100644
--- a/src/bin/pg_dump/.gitignore
+++ b/src/bin/pg_dump/.gitignore
@@ -1,5 +1,3 @@
-/kwlookup.c
-
/pg_dump
/pg_dumpall
/pg_restore
diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile
index 4162c8e5645..ddf940210ab 100644
--- a/src/bin/pg_dump/Makefile
+++ b/src/bin/pg_dump/Makefile
@@ -22,21 +22,16 @@ OBJS= pg_backup_archiver.o pg_backup_db.o pg_backup_custom.o \
pg_backup_null.o pg_backup_tar.o pg_backup_directory.o \
pg_backup_utils.o parallel.o compress_io.o dumputils.o $(WIN32RES)
-KEYWRDOBJS = keywords.o kwlookup.o
-
-kwlookup.c: % : $(top_srcdir)/src/backend/parser/%
- rm -f $@ && $(LN_S) $< .
-
all: pg_dump pg_restore pg_dumpall
-pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) $(KEYWRDOBJS) | submake-libpq submake-libpgport
- $(CC) $(CFLAGS) pg_dump.o common.o pg_dump_sort.o $(KEYWRDOBJS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+pg_dump: pg_dump.o common.o pg_dump_sort.o $(OBJS) | submake-libpq submake-libpgport
+ $(CC) $(CFLAGS) pg_dump.o common.o pg_dump_sort.o $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-pg_restore: pg_restore.o $(OBJS) $(KEYWRDOBJS) | submake-libpq submake-libpgport
- $(CC) $(CFLAGS) pg_restore.o $(KEYWRDOBJS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+pg_restore: pg_restore.o $(OBJS) | submake-libpq submake-libpgport
+ $(CC) $(CFLAGS) pg_restore.o $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-pg_dumpall: pg_dumpall.o dumputils.o $(KEYWRDOBJS) | submake-libpq submake-libpgport
- $(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(KEYWRDOBJS) $(WIN32RES) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
+pg_dumpall: pg_dumpall.o dumputils.o | submake-libpq submake-libpgport
+ $(CC) $(CFLAGS) pg_dumpall.o dumputils.o $(WIN32RES) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs
$(INSTALL_PROGRAM) pg_dump$(X) '$(DESTDIR)$(bindir)'/pg_dump$(X)
@@ -50,4 +45,4 @@ uninstall:
rm -f $(addprefix '$(DESTDIR)$(bindir)'/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X))
clean distclean maintainer-clean:
- rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o kwlookup.c $(KEYWRDOBJS)
+ rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o
diff --git a/src/bin/pg_dump/dumputils.c b/src/bin/pg_dump/dumputils.c
index 24ba5c8755c..a685d28d600 100644
--- a/src/bin/pg_dump/dumputils.c
+++ b/src/bin/pg_dump/dumputils.c
@@ -18,13 +18,9 @@
#include "dumputils.h"
-#include "parser/keywords.h"
+#include "common/keywords.h"
-/* Globals from keywords.c */
-extern const ScanKeyword FEScanKeywords[];
-extern const int NumFEScanKeywords;
-
#define supports_grant_options(version) ((version) >= 70400)
static bool parseAclItem(const char *item, const char *type,
@@ -116,8 +112,8 @@ fmtId(const char *rawid)
* that's fine, since we already know we have all-lower-case.
*/
const ScanKeyword *keyword = ScanKeywordLookup(rawid,
- FEScanKeywords,
- NumFEScanKeywords);
+ ScanKeywords,
+ NumScanKeywords);
if (keyword != NULL && keyword->category != UNRESERVED_KEYWORD)
need_quotes = true;
diff --git a/src/bin/pg_dump/keywords.c b/src/bin/pg_dump/keywords.c
deleted file mode 100644
index 6f3a2d7edaa..00000000000
--- a/src/bin/pg_dump/keywords.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * keywords.c
- * lexical token lookup for key words in PostgreSQL
- *
- *
- * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- * src/bin/pg_dump/keywords.c
- *
- *-------------------------------------------------------------------------
- */
-#include "postgres_fe.h"
-
-#include "parser/keywords.h"
-
-/*
- * We don't need the token number, so leave it out to avoid requiring other
- * backend headers.
- */
-#define PG_KEYWORD(a,b,c) {a,0,c},
-
-const ScanKeyword FEScanKeywords[] = {
-#include "parser/kwlist.h"
-};
-
-const int NumFEScanKeywords = lengthof(FEScanKeywords);
diff --git a/src/bin/psql/.gitignore b/src/bin/psql/.gitignore
index dc88807f52e..ce881f45ad2 100644
--- a/src/bin/psql/.gitignore
+++ b/src/bin/psql/.gitignore
@@ -3,7 +3,5 @@
/sql_help.h
/sql_help.c
/dumputils.c
-/keywords.c
-/kwlookup.c
/psql
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index 5f4038e2cb6..75a9b395b4a 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -22,7 +22,7 @@ override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) -I$(top_srcdir)/src/bin/p
OBJS= command.o common.o help.o input.o stringutils.o mainloop.o copy.o \
startup.o prompt.o variables.o large_obj.o print.o describe.o \
- tab-complete.o mbprint.o dumputils.o keywords.o kwlookup.o \
+ tab-complete.o mbprint.o dumputils.o \
sql_help.o psqlscan.o psqlscanslash.o \
$(WIN32RES)
@@ -34,10 +34,7 @@ psql: $(OBJS) | submake-libpq submake-libpgport
help.o: sql_help.h
-dumputils.c keywords.c: % : $(top_srcdir)/src/bin/pg_dump/%
- rm -f $@ && $(LN_S) $< .
-
-kwlookup.c: % : $(top_srcdir)/src/backend/parser/%
+dumputils.c: % : $(top_srcdir)/src/bin/pg_dump/%
rm -f $@ && $(LN_S) $< .
sql_help.c: sql_help.h ;
@@ -70,7 +67,7 @@ uninstall:
rm -f '$(DESTDIR)$(bindir)/psql$(X)' '$(DESTDIR)$(datadir)/psqlrc.sample'
clean distclean:
- rm -f psql$(X) $(OBJS) dumputils.c keywords.c kwlookup.c lex.backup
+ rm -f psql$(X) $(OBJS) dumputils.c lex.backup
# files removed here are supposed to be in the distribution tarball,
# so do not clean them in the clean/distclean rules
diff --git a/src/bin/scripts/.gitignore b/src/bin/scripts/.gitignore
index 1056b2870c0..e12d27a2f1b 100644
--- a/src/bin/scripts/.gitignore
+++ b/src/bin/scripts/.gitignore
@@ -10,8 +10,6 @@
/pg_isready
/dumputils.c
-/keywords.c
-/kwlookup.c
/mbprint.c
/print.c
diff --git a/src/bin/scripts/Makefile b/src/bin/scripts/Makefile
index c4e04c9aa8a..ad34d42d682 100644
--- a/src/bin/scripts/Makefile
+++ b/src/bin/scripts/Makefile
@@ -25,26 +25,23 @@ all: $(PROGRAMS)
%: %.o $(WIN32RES)
$(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-createdb: createdb.o common.o dumputils.o kwlookup.o keywords.o | submake-libpq submake-libpgport
+createdb: createdb.o common.o dumputils.o | submake-libpq submake-libpgport
createlang: createlang.o common.o print.o mbprint.o | submake-libpq submake-libpgport
-createuser: createuser.o common.o dumputils.o kwlookup.o keywords.o | submake-libpq submake-libpgport
-dropdb: dropdb.o common.o dumputils.o kwlookup.o keywords.o | submake-libpq submake-libpgport
+createuser: createuser.o common.o dumputils.o | submake-libpq submake-libpgport
+dropdb: dropdb.o common.o dumputils.o | submake-libpq submake-libpgport
droplang: droplang.o common.o print.o mbprint.o | submake-libpq submake-libpgport
-dropuser: dropuser.o common.o dumputils.o kwlookup.o keywords.o | submake-libpq submake-libpgport
-clusterdb: clusterdb.o common.o dumputils.o kwlookup.o keywords.o | submake-libpq submake-libpgport
-vacuumdb: vacuumdb.o common.o dumputils.o kwlookup.o keywords.o | submake-libpq submake-libpgport
-reindexdb: reindexdb.o common.o dumputils.o kwlookup.o keywords.o | submake-libpq submake-libpgport
+dropuser: dropuser.o common.o dumputils.o | submake-libpq submake-libpgport
+clusterdb: clusterdb.o common.o dumputils.o | submake-libpq submake-libpgport
+vacuumdb: vacuumdb.o common.o dumputils.o | submake-libpq submake-libpgport
+reindexdb: reindexdb.o common.o dumputils.o | submake-libpq submake-libpgport
pg_isready: pg_isready.o common.o | submake-libpq submake-libpgport
-dumputils.c keywords.c: % : $(top_srcdir)/src/bin/pg_dump/%
+dumputils.c: % : $(top_srcdir)/src/bin/pg_dump/%
rm -f $@ && $(LN_S) $< .
print.c mbprint.c : % : $(top_srcdir)/src/bin/psql/%
rm -f $@ && $(LN_S) $< .
-kwlookup.c: % : $(top_srcdir)/src/backend/parser/%
- rm -f $@ && $(LN_S) $< .
-
install: all installdirs
$(INSTALL_PROGRAM) createdb$(X) '$(DESTDIR)$(bindir)'/createdb$(X)
$(INSTALL_PROGRAM) dropdb$(X) '$(DESTDIR)$(bindir)'/dropdb$(X)
@@ -65,8 +62,8 @@ uninstall:
clean distclean maintainer-clean:
rm -f $(addsuffix $(X), $(PROGRAMS)) $(addsuffix .o, $(PROGRAMS))
- rm -f common.o dumputils.o kwlookup.o keywords.o print.o mbprint.o $(WIN32RES)
- rm -f dumputils.c print.c mbprint.c kwlookup.c keywords.c
+ rm -f common.o dumputils.o print.o mbprint.o $(WIN32RES)
+ rm -f dumputils.c print.c mbprint.c
rm -rf tmp_check
check: