Commit 550b9d26 authored by Alexander Korotkov's avatar Alexander Korotkov

Get rid of jsonpath_gram.h and jsonpath_scanner.h

Jsonpath grammar and scanner are both quite small.  It doesn't worth complexity
to compile them separately.  This commit makes grammar and scanner be compiled
at once.  Therefore, jsonpath_gram.h and jsonpath_gram.h are no longer needed.
This commit also does some reorganization of code in jsonpath_gram.y.

Discussion: https://postgr.es/m/d47b2023-3ecb-5f04-d253-d557547cf74f%402ndQuadrant.com
parent 641fde25
......@@ -136,9 +136,6 @@ parser/gram.h: parser/gram.y
storage/lmgr/lwlocknames.h: storage/lmgr/generate-lwlocknames.pl storage/lmgr/lwlocknames.txt
$(MAKE) -C storage/lmgr lwlocknames.h lwlocknames.c
utils/adt/jsonpath_gram.h: utils/adt/jsonpath_gram.y
$(MAKE) -C utils/adt jsonpath_gram.h
# run this unconditionally to avoid needing to know its dependencies here:
submake-catalog-headers:
$(MAKE) -C catalog distprep generated-header-symlinks
......@@ -162,7 +159,7 @@ submake-utils-headers:
.PHONY: generated-headers
generated-headers: $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/storage/lwlocknames.h $(top_builddir)/src/include/utils/jsonpath_gram.h submake-catalog-headers submake-utils-headers
generated-headers: $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/storage/lwlocknames.h submake-catalog-headers submake-utils-headers
$(top_builddir)/src/include/parser/gram.h: parser/gram.h
prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
......@@ -174,11 +171,6 @@ $(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
cd '$(dir $@)' && rm -f $(notdir $@) && \
$(LN_S) "$$prereqdir/$(notdir $<)" .
$(top_builddir)/src/include/utils/jsonpath_gram.h: utils/adt/jsonpath_gram.h
prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
cd '$(dir $@)' && rm -f $(notdir $@) && \
$(LN_S) "$$prereqdir/$(notdir $<)" .
utils/probes.o: utils/probes.d $(SUBDIROBJS)
$(DTRACE) $(DTRACEFLAGS) -C -G -s $(call expand_subsys,$^) -o $@
......@@ -193,7 +185,7 @@ distprep:
$(MAKE) -C replication repl_gram.c repl_scanner.c syncrep_gram.c syncrep_scanner.c
$(MAKE) -C storage/lmgr lwlocknames.h lwlocknames.c
$(MAKE) -C utils distprep
$(MAKE) -C utils/adt jsonpath_gram.c jsonpath_gram.h jsonpath_scan.c
$(MAKE) -C utils/adt jsonpath_gram.c jsonpath_scan.c
$(MAKE) -C utils/misc guc-file.c
$(MAKE) -C utils/sort qsort_tuple.c
......@@ -316,7 +308,6 @@ maintainer-clean: distclean
storage/lmgr/lwlocknames.c \
storage/lmgr/lwlocknames.h \
utils/adt/jsonpath_gram.c \
utils/adt/jsonpath_gram.h \
utils/adt/jsonpath_scan.c \
utils/misc/guc-file.c \
utils/sort/qsort_tuple.c
......
/jsonpath_gram.h
/jsonpath_gram.c
/jsonpath_scan.c
......@@ -17,7 +17,7 @@ OBJS = acl.o amutils.o arrayfuncs.o array_expanded.o array_selfuncs.o \
float.o format_type.o formatting.o genfile.o \
geo_ops.o geo_selfuncs.o geo_spgist.o inet_cidr_ntop.o inet_net_pton.o \
int.o int8.o json.o jsonb.o jsonb_gin.o jsonb_op.o jsonb_util.o \
jsonfuncs.o jsonpath_gram.o jsonpath_scan.o jsonpath.o jsonpath_exec.o \
jsonfuncs.o jsonpath_gram.o jsonpath.o jsonpath_exec.o \
like.o like_support.o lockfuncs.o mac.o mac8.o misc.o name.o \
network.o network_gist.o network_selfuncs.o network_spgist.o \
numeric.o numutils.o oid.o oracle_compat.o \
......@@ -33,26 +33,13 @@ OBJS = acl.o amutils.o arrayfuncs.o array_expanded.o array_selfuncs.o \
txid.o uuid.o varbit.o varchar.o varlena.o version.o \
windowfuncs.o xid.o xml.o
# There is no correct way to write a rule that generates two files.
# See comment in src/backend/parser/Makefile for the explanation of
# the trick used here.
jsonpath_gram.h: jsonpath_gram.c
touch $@
jsonpath_gram.c: BISONFLAGS += -d
jsonpath_scan.c: FLEXFLAGS = -CF -p -p
# Force these dependencies to be known even without dependency info built:
jsonpath_gram.o jsonpath_scan.o jsonpath_parser.o: jsonpath_gram.h
# jsonpath_gram.c, jsonpath_gram.h, and jsonpath_scan.c are in the
# distribution tarball, so they are not cleaned here.
clean distclean maintainer-clean:
rm -f lex.backup
jsonpath_gram.o: jsonpath_scan.c
# jsonpath_gram.c and jsonpath_scan.c are in the distribution tarball,
# so they are not cleaned here.
like.o: like.c like_match.c
......
This diff is collapsed.
%{
/*-------------------------------------------------------------------------
*
* jsonpath_scan.l
......@@ -11,12 +12,10 @@
*-------------------------------------------------------------------------
*/
%{
#include "postgres.h"
#include "mb/pg_wchar.h"
#include "nodes/pg_list.h"
#include "utils/jsonpath_scanner.h"
static JsonPathString scanstring;
......@@ -46,7 +45,6 @@ fprintf_to_ereport(const char *fmt, const char *msg)
ereport(ERROR, (errmsg_internal("%s", msg)));
}
#define yyerror jsonpath_yyerror
%}
%option 8bit
......
......@@ -54,7 +54,7 @@ install: all installdirs
cp $(srcdir)/$$dir/*.h '$(DESTDIR)$(includedir_server)'/$$dir/ || exit; \
done
ifeq ($(vpath_build),yes)
for file in catalog/schemapg.h catalog/pg_*_d.h parser/gram.h storage/lwlocknames.h utils/probes.h utils/jsonpath_gram.h; do \
for file in catalog/schemapg.h catalog/pg_*_d.h parser/gram.h storage/lwlocknames.h utils/probes.h; do \
cp $$file '$(DESTDIR)$(includedir_server)'/$$file || exit; \
done
endif
......@@ -78,7 +78,7 @@ uninstall:
clean:
rm -f utils/fmgroids.h utils/fmgrprotos.h utils/errcodes.h utils/header-stamp
rm -f parser/gram.h storage/lwlocknames.h utils/probes.h utils/jsonpath_gram.h
rm -f parser/gram.h storage/lwlocknames.h utils/probes.h
rm -f catalog/schemapg.h catalog/pg_*_d.h catalog/header-stamp
distclean maintainer-clean: clean
......
......@@ -3,4 +3,3 @@
/probes.h
/errcodes.h
/header-stamp
/jsonpath_gram.h
/*-------------------------------------------------------------------------
*
* jsonpath_scanner.h
* Definitions for jsonpath scanner & parser
*
* Portions Copyright (c) 2019, PostgreSQL Global Development Group
*
* src/include/utils/jsonpath_scanner.h
*
*-------------------------------------------------------------------------
*/
#ifndef JSONPATH_SCANNER_H
#define JSONPATH_SCANNER_H
/* struct JsonPathString is shared between scan and gram */
typedef struct JsonPathString
{
char *val;
int len;
int total;
} JsonPathString;
#include "utils/jsonpath.h"
#include "utils/jsonpath_gram.h"
/* flex 2.5.4 doesn't bother with a decl for this */
extern int jsonpath_yylex(YYSTYPE *yylval_param);
extern int jsonpath_yyparse(JsonPathParseResult **result);
extern void jsonpath_yyerror(JsonPathParseResult **result, const char *message);
#endif
......@@ -327,24 +327,6 @@ sub GenerateFiles
);
}
if (IsNewer(
'src/backend/utils/adt/jsonpath_gram.h',
'src/backend/utils/adt/jsonpath_gram.y'))
{
print "Generating jsonpath_gram.h...\n";
chdir('src/backend/utils/adt');
system('perl ../../../tools/msvc/pgbison.pl jsonpath_gram.y');
chdir('../../../..');
}
if (IsNewer(
'src/include/utils/jsonpath_gram.h',
'src/backend/utils/adt/jsonpath_gram.h'))
{
copyFile('src/backend/utils/adt/jsonpath_gram.h',
'src/include/utils/jsonpath_gram.h');
}
if ($self->{options}->{python}
&& IsNewer(
'src/pl/plpython/spiexceptions.h',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment