Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b2daedf

Browse files
author
Nikita Glukhov
committed
Jsonpath engine and operators
1 parent 9b5fab1 commit b2daedf

35 files changed

+11663
-48
lines changed

src/backend/Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ parser/gram.h: parser/gram.y
136136
storage/lmgr/lwlocknames.h: storage/lmgr/generate-lwlocknames.pl storage/lmgr/lwlocknames.txt
137137
$(MAKE) -C storage/lmgr lwlocknames.h lwlocknames.c
138138

139+
utils/adt/jsonpath_gram.h: utils/adt/jsonpath_gram.y
140+
$(MAKE) -C utils/adt jsonpath_gram.h
141+
139142
# run this unconditionally to avoid needing to know its dependencies here:
140143
submake-catalog-headers:
141144
$(MAKE) -C catalog distprep generated-header-symlinks
@@ -159,7 +162,7 @@ submake-utils-headers:
159162

160163
.PHONY: generated-headers
161164

162-
generated-headers: $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/storage/lwlocknames.h submake-catalog-headers submake-utils-headers
165+
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
163166

164167
$(top_builddir)/src/include/parser/gram.h: parser/gram.h
165168
prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
@@ -171,6 +174,10 @@ $(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
171174
cd '$(dir $@)' && rm -f $(notdir $@) && \
172175
$(LN_S) "$$prereqdir/$(notdir $<)" .
173176

177+
$(top_builddir)/src/include/utils/jsonpath_gram.h: utils/adt/jsonpath_gram.h
178+
prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
179+
cd '$(dir $@)' && rm -f $(notdir $@) && \
180+
$(LN_S) "$$prereqdir/$(notdir $<)" .
174181

175182
utils/probes.o: utils/probes.d $(SUBDIROBJS)
176183
$(DTRACE) $(DTRACEFLAGS) -C -G -s $(call expand_subsys,$^) -o $@
@@ -186,6 +193,7 @@ distprep:
186193
$(MAKE) -C replication repl_gram.c repl_scanner.c syncrep_gram.c syncrep_scanner.c
187194
$(MAKE) -C storage/lmgr lwlocknames.h lwlocknames.c
188195
$(MAKE) -C utils distprep
196+
$(MAKE) -C utils/adt jsonpath_gram.c jsonpath_gram.h jsonpath_scan.c
189197
$(MAKE) -C utils/misc guc-file.c
190198
$(MAKE) -C utils/sort qsort_tuple.c
191199

@@ -308,6 +316,7 @@ maintainer-clean: distclean
308316
storage/lmgr/lwlocknames.c \
309317
storage/lmgr/lwlocknames.h \
310318
utils/misc/guc-file.c \
319+
utils/adt/jsonpath_gram.h \
311320
utils/sort/qsort_tuple.c
312321

313322

src/backend/lib/stringinfo.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,24 @@ enlargeStringInfo(StringInfo str, int needed)
312312

313313
str->maxlen = newlen;
314314
}
315+
316+
/*
317+
* alignStringInfoInt - aling StringInfo to int by adding
318+
* zero padding bytes
319+
*/
320+
void
321+
alignStringInfoInt(StringInfo buf)
322+
{
323+
switch(INTALIGN(buf->len) - buf->len)
324+
{
325+
case 3:
326+
appendStringInfoCharMacro(buf, 0);
327+
case 2:
328+
appendStringInfoCharMacro(buf, 0);
329+
case 1:
330+
appendStringInfoCharMacro(buf, 0);
331+
default:
332+
break;
333+
}
334+
}
335+

src/backend/utils/adt/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/jsonpath_gram.h
2+
/jsonpath_gram.c
3+
/jsonpath_scan.c

src/backend/utils/adt/Makefile

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ OBJS = acl.o amutils.o arrayfuncs.o array_expanded.o array_selfuncs.o \
1717
float.o format_type.o formatting.o genfile.o \
1818
geo_ops.o geo_selfuncs.o geo_spgist.o inet_cidr_ntop.o inet_net_pton.o \
1919
int.o int8.o json.o jsonb.o jsonb_gin.o jsonb_op.o jsonb_util.o \
20-
jsonfuncs.o like.o lockfuncs.o mac.o mac8.o misc.o name.o \
20+
jsonfuncs.o jsonpath_gram.o jsonpath_scan.o jsonpath.o jsonpath_exec.o jsonpath_json.o \
21+
like.o lockfuncs.o mac.o mac8.o misc.o name.o \
2122
network.o network_gist.o network_selfuncs.o network_spgist.o \
2223
numeric.o numutils.o oid.o oracle_compat.o \
2324
orderedsetaggs.o partitionfuncs.o pg_locale.o pg_lsn.o \
@@ -32,6 +33,23 @@ OBJS = acl.o amutils.o arrayfuncs.o array_expanded.o array_selfuncs.o \
3233
txid.o uuid.o varbit.o varchar.o varlena.o version.o \
3334
windowfuncs.o xid.o xml.o
3435

36+
jsonpath_gram.c: BISONFLAGS += -d
37+
38+
jsonpath_scan.c: FLEXFLAGS = -CF -p -p
39+
40+
jsonpath_gram.h: jsonpath_gram.c ;
41+
42+
# Force these dependencies to be known even without dependency info built:
43+
jsonpath_gram.o jsonpath_scan.o jsonpath_parser.o: jsonpath_gram.h
44+
45+
jsonpath_json.o: jsonpath_exec.c
46+
47+
# jsonpath_gram.c, jsonpath_gram.h, and jsonpath_scan.c are in the distribution
48+
# tarball, so they are not cleaned here.
49+
clean distclean maintainer-clean:
50+
rm -f lex.backup
51+
52+
3553
like.o: like.c like_match.c
3654

3755
varlena.o: varlena.c levenshtein.c

0 commit comments

Comments
 (0)