Changeset: 6a38d99f6151 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/6a38d99f6151
Modified Files:
monetdb5/modules/atoms/json.c
monetdb5/modules/atoms/pg_jsonpath/jsonpath.h
monetdb5/modules/atoms/pg_jsonpath/jsonpath_exec.c
monetdb5/modules/atoms/pg_jsonpath/jsonpath_gram.y
monetdb5/modules/atoms/pg_jsonpath/postgres_defines.h
monetdb5/modules/atoms/pg_jsonpath/postgres_defines_internal.h
Branch: json-extend
Log Message:
get rid of the postgres Datum type
diffs (212 lines):
diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -1693,7 +1693,7 @@ JSONfilter(json *ret, const json *js, co
bool error;
List* vars = NULL;
const char *column_name = NULL;
- yyjson_val *res = JsonPathQuery((Datum) root, path, JSW_UNCONDITIONAL,
&empty, &error, vars, column_name, alc, errmsg);
+ yyjson_val *res = JsonPathQuery(root, path, JSW_UNCONDITIONAL, &empty,
&error, vars, column_name, alc, errmsg);
if (!res && errmsg[0]) {
sa_destroy(sa);
return createException(MAL, SQLSTATE(HY013), "JsonPathQuery
iternal error: %s", errmsg);
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
@@ -191,17 +191,17 @@ typedef struct JsonPathVariable
int namelen; /* strlen(name) as
cache for GetJsonPathVar() */
Oid typid;
int32 typmod;
- Datum value;
+ void* value;
bool isnull;
} JsonPathVariable;
/* SQL/JSON query functions */
-extern bool JsonPathExists(Datum jb, JsonPath *jp, bool *error, List *vars,
yyjson_alc* alc, char* errmsg);
-extern JsonbValue *JsonPathQuery(Datum jb, JsonPath *jp, JsonWrapper wrapper,
+extern bool JsonPathExists(JsonbValue* jb, JsonPath *jp, bool *error, List
*vars, yyjson_alc* alc, char* errmsg);
+extern JsonbValue *JsonPathQuery(JsonbValue* jb, JsonPath *jp, JsonWrapper
wrapper,
bool *empty, bool *error,
List *vars,
const char *column_name,
yyjson_alc* alc, char* errmsg);
-extern JsonbValue *JsonPathValue(Datum jb, JsonPath *jp, bool *empty,
+extern JsonbValue *JsonPathValue(JsonbValue* jb, JsonPath *jp, bool *empty,
bool *error,
List *vars,
const char
*column_name, yyjson_alc* alc, char* errmsg);
diff --git a/monetdb5/modules/atoms/pg_jsonpath/jsonpath_exec.c
b/monetdb5/modules/atoms/pg_jsonpath/jsonpath_exec.c
--- a/monetdb5/modules/atoms/pg_jsonpath/jsonpath_exec.c
+++ b/monetdb5/modules/atoms/pg_jsonpath/jsonpath_exec.c
@@ -148,16 +148,7 @@ typedef struct JsonValueListIterator
/* Structures for JSON_TABLE execution */
-/*
- * Struct holding the result of jsonpath evaluation, to be used as source row
- * for JsonTableGetValue() which in turn computes the values of individual
- * JSON_TABLE columns.
- */
-typedef struct JsonTablePlanRowSource
-{
- Datum value;
- bool isnull;
-} JsonTablePlanRowSource;
+
/* strict/lax flags is decomposed into four [un]wrap/error flags */
#define jspStrictAbsenceOfErrors(cxt) (!(cxt)->laxMode)
@@ -234,7 +225,7 @@ static JsonbValue *GetJsonPathVar(void *
JsonbValue
**baseObject, int *baseObjectId);
static int CountJsonPathVars(void *cxt);
static yyjson_mut_val*
-JsonItemFromDatum(Datum val, Oid typid, int32 typmod, yyjson_mut_doc*
mutable_doc);
+JsonItemFromDatum(void* val, Oid typid, int32 typmod, yyjson_mut_doc*
mutable_doc);
static int JsonbArraySize(JsonbValue *jb);
static JsonPathBool executeComparison(JsonPathItem *cmp, JsonbValue *lv,
JsonbValue *rv, void *p);
@@ -2030,7 +2021,7 @@ CountJsonPathVars(void *cxt)
* datum value of the specified type.
*/
static yyjson_mut_val*
-JsonItemFromDatum(Datum val, Oid typid, int32 typmod, yyjson_mut_doc*
mutable_doc)
+JsonItemFromDatum(void* val, Oid typid, int32 typmod, yyjson_mut_doc*
mutable_doc)
{
(void) val; (void) typid; (void) typmod; (void) mutable_doc;
assert(0);
@@ -2209,7 +2200,7 @@ getArrayIndex(JsonPathExecContext *cxt,
JsonbValue *jbv;
JsonValueList found = {0};
JsonPathExecResult res = executeItem(cxt, jsp, jb, &found);
- Datum numeric_index;
+ lng numeric_index;
bool have_error = false;
if (jperIsError(res))
@@ -2221,7 +2212,7 @@ getArrayIndex(JsonPathExecContext *cxt,
(errcode(ERRCODE_INVALID_SQL_JSON_SUBSCRIPT),
errmsg("jsonpath
array subscript is not a single numeric value"))));
- numeric_index = (Datum) yyjson_get_int(jbv);
+ numeric_index = yyjson_get_int(jbv);
*index = (int) numeric_index;
if (have_error)
@@ -2385,7 +2376,7 @@ wrapItemsInArray(yyjson_alc* alc, const
* *error to true.
*/
bool
-JsonPathExists(Datum jb, JsonPath *jp, bool *error, List *vars, yyjson_alc*
alc, char* errmsg)
+JsonPathExists(JsonbValue* jb, JsonPath *jp, bool *error, List *vars,
yyjson_alc* alc, char* errmsg)
{
JsonPathExecResult res;
@@ -2397,7 +2388,7 @@ JsonPathExists(Datum jb, JsonPath *jp, b
res = executeJsonPath(jp, vars,
GetJsonPathVar,
CountJsonPathVars,
- DatumGetJsonbP(jb), !error,
NULL, true, cxt);
+ jb, !error, NULL, true, cxt);
if (!jperIsError(res) || errmsg[0])
return false; // throw exception
@@ -2416,7 +2407,7 @@ JsonPathExists(Datum jb, JsonPath *jp, b
* *error to true. *empty is set to true if no match is found.
*/
JsonbValue *
-JsonPathQuery(Datum jb, JsonPath *jp, JsonWrapper wrapper, bool *empty,
+JsonPathQuery(JsonbValue* jb, JsonPath *jp, JsonWrapper wrapper, bool *empty,
bool *error, List *vars,
const char *column_name, yyjson_alc* alc, char*
errmsg)
{
@@ -2434,7 +2425,7 @@ JsonPathQuery(Datum jb, JsonPath *jp, Js
res = executeJsonPath(jp, vars,
GetJsonPathVar,
CountJsonPathVars,
- DatumGetJsonbP(jb), !error,
&found, true, cxt);
+ jb, !error, &found, true,
cxt);
Assert(error || !jperIsError(res));
if (error && jperIsError(res))
{
@@ -2515,7 +2506,7 @@ JsonPathQuery(Datum jb, JsonPath *jp, Js
* *error to true. *empty is set to true if no match is found.
*/
JsonbValue *
-JsonPathValue(Datum jb, JsonPath *jp, bool *empty, bool *error, List *vars,
+JsonPathValue(JsonbValue * jb, JsonPath *jp, bool *empty, bool *error, List
*vars,
const char *column_name, yyjson_alc* alc, char*
errmsg)
{
JsonbValue *res;
@@ -2530,7 +2521,7 @@ JsonPathValue(Datum jb, JsonPath *jp, bo
JsonPathExecContext* cxt = &_cxt;
jper = executeJsonPath(jp, vars, GetJsonPathVar, CountJsonPathVars,
- DatumGetJsonbP(jb),
+ jb,
!error, &found, true, &_cxt);
Assert(error || !jperIsError(jper));
diff --git a/monetdb5/modules/atoms/pg_jsonpath/jsonpath_gram.y
b/monetdb5/modules/atoms/pg_jsonpath/jsonpath_gram.y
--- a/monetdb5/modules/atoms/pg_jsonpath/jsonpath_gram.y
+++ b/monetdb5/modules/atoms/pg_jsonpath/jsonpath_gram.y
@@ -492,9 +492,7 @@ makeItemUnary(JsonPathItemType type, Jso
if (type == jpiMinus && a->type == jpiNumeric && !a->next)
{
v = makeItemType(jpiNumeric);
- v->value.numeric =
- DatumGetNumeric(DirectFunctionCall1(numeric_uminus,
-
NumericGetDatum(a->value.numeric)));
+ v->value.numeric = numeric_uminus(a->value.numeric);
return v;
}
diff --git a/monetdb5/modules/atoms/pg_jsonpath/postgres_defines.h
b/monetdb5/modules/atoms/pg_jsonpath/postgres_defines.h
--- a/monetdb5/modules/atoms/pg_jsonpath/postgres_defines.h
+++ b/monetdb5/modules/atoms/pg_jsonpath/postgres_defines.h
@@ -14,8 +14,6 @@
typedef uint32_t uint32;
typedef int int32;
typedef sht int16;
-typedef uint16_t uint16;
-typedef lng int64;
// jsonb.h
@@ -39,9 +37,6 @@ enum jbvType
jbvDatetime = 0x20,
};
-// postgres.h
-typedef uintptr_t Datum; // TODO: remove this type
-
// postgres_ext.h
typedef unsigned int Oid; // TODO: remove this type
@@ -65,8 +60,6 @@ typedef enum JsonWrapper
JSW_UNCONDITIONAL,
} JsonWrapper;
-#define DatumGetJsonbP(jb) ((JsonbValue*) jb)
-
typedef yyjson_val Jsonb;
typedef struct list List;
diff --git a/monetdb5/modules/atoms/pg_jsonpath/postgres_defines_internal.h
b/monetdb5/modules/atoms/pg_jsonpath/postgres_defines_internal.h
--- a/monetdb5/modules/atoms/pg_jsonpath/postgres_defines_internal.h
+++ b/monetdb5/modules/atoms/pg_jsonpath/postgres_defines_internal.h
@@ -49,15 +49,6 @@ pg_strtoint32(const char *s)
#define check_stack_depth(result) if (THRhighwater()) {snprintf(cxt->_errmsg,
1024, "stack overflow"); return (res = result);}
#define CHECK_FOR_INTERRUPTS() /* TODO */
-#define DatumGetNumeric(X) (X)
-#define numeric_in atoi
-#define DirectFunctionCall3(func, A, B, C) func(A)
-#define CStringGetDatum(X) (X)
-#define ObjectIdGetDatum(X) (X)
-#define Int32GetDatum(X) (X)
-#define DirectFunctionCall1(func, A) (func A)
-#define NumericGetDatum(X) (X)
-
#define for_each_from(cell, list, N) \
cell = list->h; \
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]