Changeset: e19de3fb749e for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/e19de3fb749e Added Files: monetdb5/modules/atoms/pg_jsonpath/CMakeLists.txt monetdb5/modules/atoms/pg_jsonpath/postgres_defines.h Modified Files: cmake/monetdb-findpackages.cmake monetdb5/modules/atoms/CMakeLists.txt monetdb5/modules/atoms/pg_jsonpath/jsonpath.c monetdb5/modules/atoms/pg_jsonpath/jsonpath.h monetdb5/modules/atoms/pg_jsonpath/jsonpath_gram.y Branch: json-extend Log Message:
make subdir object library diffs (truncated from 399 to 300 lines): diff --git a/cmake/monetdb-findpackages.cmake b/cmake/monetdb-findpackages.cmake --- a/cmake/monetdb-findpackages.cmake +++ b/cmake/monetdb-findpackages.cmake @@ -11,6 +11,7 @@ #]] # Detect required packages +find_package(FLEX) find_package(BISON 3.0 REQUIRED) find_package(Iconv) find_package(Threads) diff --git a/monetdb5/modules/atoms/CMakeLists.txt b/monetdb5/modules/atoms/CMakeLists.txt --- a/monetdb5/modules/atoms/CMakeLists.txt +++ b/monetdb5/modules/atoms/CMakeLists.txt @@ -12,6 +12,8 @@ add_library(atoms OBJECT) +add_subdirectory(pg_jsonpath) + target_sources(atoms PRIVATE streams.c streams.h @@ -43,7 +45,8 @@ target_link_libraries(atoms monetdb_config_header mutf8 bat - mal) + mal + pg_jsonpath) target_compile_definitions(atoms PRIVATE diff --git a/monetdb5/modules/atoms/pg_jsonpath/CMakeLists.txt b/monetdb5/modules/atoms/pg_jsonpath/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/monetdb5/modules/atoms/pg_jsonpath/CMakeLists.txt @@ -0,0 +1,49 @@ +#[[ +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# Copyright 2024 MonetDB Foundation; +# Copyright August 2008 - 2023 MonetDB B.V.; +# Copyright 1997 - July 2008 CWI. +#]] + +add_library(pg_jsonpath OBJECT) + +FLEX_TARGET(jsonpath_scanner + jsonpath_scan.l + ${CMAKE_CURRENT_BINARY_DIR}/jsonpath_scan.tab.c + DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/jsonpath_scan.tab.h) + +BISON_TARGET(jsonpath_parser + jsonpath_gram.y + ${CMAKE_CURRENT_BINARY_DIR}/jsonpath_parser.tab.c + COMPILE_FLAGS "-d -p json -Wno-conflicts-sr -Wno-conflicts-rr" + DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/jsonpath_parser.tab.h) + + target_sources(pg_jsonpath + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/jsonpath.c + ${CMAKE_CURRENT_SOURCE_DIR}/jsonpath_internal.h + postgres_defines.h + ${FLEX_jsonpath_scanner_OUTPUT_HEADER} + ${FLEX_jsonpath_scanner_OUTPUT_SOURCE} + ${BISON_jsonpath_parser_OUTPUT_HEADER} + ${BISON_jsonpath_parser_OUTPUT_SOURCE} + ) + + target_link_libraries(pg_jsonpath + PRIVATE + monetdb_config_header + bat + sqlinclude + sqlcommon) + + target_include_directories(pg_jsonpath + PRIVATE + $<TARGET_PROPERTY:sqlcommon,INTERFACE_INCLUDE_DIRECTORIES> + PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> + $<INSTALL_INTERFACE:${INCLUDEDIR}/monetdb>) diff --git a/monetdb5/modules/atoms/pg_jsonpath/jsonpath.c b/monetdb5/modules/atoms/pg_jsonpath/jsonpath.c --- a/monetdb5/modules/atoms/pg_jsonpath/jsonpath.c +++ b/monetdb5/modules/atoms/pg_jsonpath/jsonpath.c @@ -61,18 +61,7 @@ *------------------------------------------------------------------------- */ -#include "postgres.h" - -#include "catalog/pg_type.h" -#include "lib/stringinfo.h" -#include "libpq/pqformat.h" -#include "miscadmin.h" -#include "nodes/miscnodes.h" -#include "nodes/nodeFuncs.h" -#include "utils/fmgrprotos.h" -#include "utils/formatting.h" -#include "utils/json.h" -#include "utils/jsonpath.h" +#include "jsonpath.h" static Datum jsonPathFromCstring(char *in, int len, struct Node *escontext); @@ -94,6 +83,7 @@ static int operationPriority(JsonPathIte /* * jsonpath type input function */ +/* Datum jsonpath_in(PG_FUNCTION_ARGS) { @@ -102,6 +92,7 @@ jsonpath_in(PG_FUNCTION_ARGS) return jsonPathFromCstring(in, len, fcinfo->context); } +*/ /* * jsonpath type recv function @@ -111,6 +102,7 @@ jsonpath_in(PG_FUNCTION_ARGS) * can change the binary format sent in future if necessary. For now, * only version 1 is supported. */ +/* Datum jsonpath_recv(PG_FUNCTION_ARGS) { @@ -126,10 +118,12 @@ jsonpath_recv(PG_FUNCTION_ARGS) return jsonPathFromCstring(str, nbytes, NULL); } +*/ /* * jsonpath type output function */ +/* Datum jsonpath_out(PG_FUNCTION_ARGS) { @@ -137,12 +131,14 @@ jsonpath_out(PG_FUNCTION_ARGS) PG_RETURN_CSTRING(jsonPathToCstring(NULL, in, VARSIZE(in))); } +*/ /* * jsonpath type send function * * Just send jsonpath as a version number, then a string of text */ +/* Datum jsonpath_send(PG_FUNCTION_ARGS) { @@ -161,6 +157,7 @@ jsonpath_send(PG_FUNCTION_ARGS) PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } +*/ /* * Converts C-string to a jsonpath value. @@ -169,6 +166,7 @@ jsonpath_send(PG_FUNCTION_ARGS) * flattenJsonPathParseItem() does second pass turning AST into binary * representation of jsonpath. */ +/* static Datum jsonPathFromCstring(char *in, int len, struct Node *escontext) { @@ -180,13 +178,14 @@ jsonPathFromCstring(char *in, int len, s return (Datum) 0; if (!jsonpath) + return TODO_ERROR; ereturn(escontext, (Datum) 0, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid input syntax for type %s: \"%s\"", "jsonpath", in))); initStringInfo(&buf); - enlargeStringInfo(&buf, 4 * len /* estimation */ ); + enlargeStringInfo(&buf, 4 * len ); appendStringInfoSpaces(&buf, JSONPATH_HDRSZ); @@ -202,6 +201,7 @@ jsonPathFromCstring(char *in, int len, s PG_RETURN_JSONPATH_P(res); } +*/ /* * Converts jsonpath value to a C-string. @@ -209,6 +209,7 @@ jsonPathFromCstring(char *in, int len, s * If 'out' argument is non-null, the resulting C-string is stored inside the * StringBuffer. The resulting string is always returned. */ +/* static char * jsonPathToCstring(StringInfo out, JsonPath *in, int estimated_len) { @@ -230,6 +231,7 @@ jsonPathToCstring(StringInfo out, JsonPa return out->data; } +*/ /* * Recursive function converting given jsonpath parse item and all its @@ -1214,6 +1216,7 @@ jspGetBool(JsonPathItem *v) return (bool) *v->content.value.data; } +/* Numeric jspGetNumeric(JsonPathItem *v) { @@ -1221,6 +1224,7 @@ jspGetNumeric(JsonPathItem *v) return (Numeric) v->content.value.data; } +*/ char * jspGetString(JsonPathItem *v, int32 *len) diff --git a/monetdb5/modules/atoms/pg_jsonpath/jsonpath.h b/monetdb5/modules/atoms/pg_jsonpath/jsonpath.h --- a/monetdb5/modules/atoms/pg_jsonpath/jsonpath.h +++ b/monetdb5/modules/atoms/pg_jsonpath/jsonpath.h @@ -14,11 +14,7 @@ #ifndef JSONPATH_H #define JSONPATH_H -#include "executor/tablefunc.h" -#include "fmgr.h" -#include "nodes/pg_list.h" -#include "nodes/primnodes.h" -#include "utils/jsonb.h" +#include "postgres_defines.h" typedef struct { @@ -31,6 +27,7 @@ typedef struct #define JSONPATH_LAX (0x80000000) #define JSONPATH_HDRSZ (offsetof(JsonPath, data)) +/* static inline JsonPath * DatumGetJsonPathP(Datum d) { @@ -46,6 +43,7 @@ DatumGetJsonPathPCopy(Datum d) #define PG_GETARG_JSONPATH_P(x) DatumGetJsonPathP(PG_GETARG_DATUM(x)) #define PG_GETARG_JSONPATH_P_COPY(x) DatumGetJsonPathPCopy(PG_GETARG_DATUM(x)) #define PG_RETURN_JSONPATH_P(p) PG_RETURN_POINTER(p) +*/ #define jspIsScalar(type) ((type) >= jpiNull && (type) <= jpiBool) @@ -199,7 +197,7 @@ extern bool jspGetNext(JsonPathItem *v, extern void jspGetArg(JsonPathItem *v, JsonPathItem *a); extern void jspGetLeftArg(JsonPathItem *v, JsonPathItem *a); extern void jspGetRightArg(JsonPathItem *v, JsonPathItem *a); -extern Numeric jspGetNumeric(JsonPathItem *v); +// extern Numeric jspGetNumeric(JsonPathItem *v); extern bool jspGetBool(JsonPathItem *v); extern char *jspGetString(JsonPathItem *v, int32 *len); extern bool jspGetArraySubscript(JsonPathItem *v, JsonPathItem *from, @@ -259,7 +257,7 @@ struct JsonPathParseItem } like_regex; /* scalars */ - Numeric numeric; + // Numeric numeric; bool boolean; struct { @@ -296,6 +294,7 @@ typedef struct JsonPathVariable /* SQL/JSON query functions */ +/* extern bool JsonPathExists(Datum jb, JsonPath *jp, bool *error, List *vars); extern Datum JsonPathQuery(Datum jb, JsonPath *jp, JsonWrapper wrapper, bool *empty, bool *error, List *vars, @@ -303,8 +302,8 @@ extern Datum JsonPathQuery(Datum jb, Jso extern JsonbValue *JsonPathValue(Datum jb, JsonPath *jp, bool *empty, bool *error, List *vars, const char *column_name); - +*/ /* For JSON_TABLE() */ -extern PGDLLIMPORT const TableFuncRoutine JsonbTableRoutine; _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org