X-Git-Url: https://git.8kb.co.uk/?p=postgresql%2Fpg_jsonb_opx;a=blobdiff_plain;f=jsonb_opx.c;fp=jsonb_opx.c;h=377d60974a343f6866df0dc3c41f08de714f1ab1;hp=518c5cdbeb3f013097c399f18bf3e4763595f501;hb=bf6318c60bd05043800c698a6b14f6aaa17a4824;hpb=4182f8ab210feedbd7d146aa2c6c6fa77ba4962f diff --git a/jsonb_opx.c b/jsonb_opx.c index 518c5cd..377d609 100755 --- a/jsonb_opx.c +++ b/jsonb_opx.c @@ -93,12 +93,12 @@ jsonb_delete_key(PG_FUNCTION_ARGS) case WJB_BEGIN_ARRAY: array_level++; if (skip_key == 0) - return_jsonb_value = pushJsonbValue(&state, WJB_BEGIN_ARRAY, &jsonb_iterator_value); + return_jsonb_value = pushJsonbValue(&state, WJB_BEGIN_ARRAY, NULL); break; case WJB_BEGIN_OBJECT: nest_level++; if (skip_key == 0) - return_jsonb_value = pushJsonbValue(&state, WJB_BEGIN_OBJECT, &jsonb_iterator_value); + return_jsonb_value = pushJsonbValue(&state, WJB_BEGIN_OBJECT, NULL); break; case WJB_ELEM: /* only match array elements if they are text */ @@ -244,12 +244,12 @@ jsonb_delete_keys(PG_FUNCTION_ARGS) case WJB_BEGIN_ARRAY: array_level++; if (skip_key == 0) - return_jsonb_value = pushJsonbValue(&state, WJB_BEGIN_ARRAY, &jsonb_iterator_value); + return_jsonb_value = pushJsonbValue(&state, WJB_BEGIN_ARRAY, NULL); break; case WJB_BEGIN_OBJECT: nest_level++; if (skip_key == 0) - return_jsonb_value = pushJsonbValue(&state, WJB_BEGIN_OBJECT, &jsonb_iterator_value); + return_jsonb_value = pushJsonbValue(&state, WJB_BEGIN_OBJECT, NULL); break; case WJB_ELEM: /* only match array elements if they are text or null */ @@ -395,7 +395,7 @@ jsonb_delete_jsonb(PG_FUNCTION_ARGS) case WJB_BEGIN_OBJECT: case WJB_END_ARRAY: case WJB_END_OBJECT: - return_jsonb_value = pushJsonbValue(&state, jsonb_iterator_token, &jsonb_iterator_value); + return_jsonb_value = pushJsonbValue(&state, jsonb_iterator_token, NULL); break; case WJB_ELEM: /* @@ -407,7 +407,7 @@ jsonb_delete_jsonb(PG_FUNCTION_ARGS) { if (jsonb_iterator_value.type == jbvBinary) { - return_jsonb_value = pushJsonbBinary(state, jsonb_iterator_value.val.binary.data); + return_jsonb_value = pushJsonbBinary(&state, jsonb_iterator_value.val.binary.data); } else { @@ -474,7 +474,7 @@ jsonb_delete_jsonb(PG_FUNCTION_ARGS) /* if our value is nested binary data, iterate separately pushing each val */ if (jsonb_iterator_value.type == jbvBinary) { - return_jsonb_value = pushJsonbBinary(state, jsonb_iterator_value.val.binary.data); + return_jsonb_value = pushJsonbBinary(&state, jsonb_iterator_value.val.binary.data); } else { @@ -607,7 +607,7 @@ jsonb_concat_jsonb(PG_FUNCTION_ARGS) } first = false; - return_jsonb_value = pushJsonbValue(&state, jsonb_iterator_token, &jsonb_iterator_value); + return_jsonb_value = pushJsonbValueBlind(&state, jsonb_iterator_token, &jsonb_iterator_value); } first = true; @@ -630,7 +630,7 @@ jsonb_concat_jsonb(PG_FUNCTION_ARGS) } first = false; - return_jsonb_value = pushJsonbValue(&state, jsonb_iterator_token, &jsonb_iterator_value); + return_jsonb_value = pushJsonbValueBlind(&state, jsonb_iterator_token, &jsonb_iterator_value); } return_jsonb_value = pushJsonbValue(&state, jsonb_root_close, NULL); @@ -689,12 +689,13 @@ jsonb_replace_jsonb(PG_FUNCTION_ARGS) { if ((jsonb_iterator_token == WJB_ELEM ) && (jsonb_iterator_value.type == jbvBinary)) { - return_jsonb_value = pushJsonbBinary(state, jsonb_iterator_value.val.binary.data); + return_jsonb_value = pushJsonbBinary(&state, jsonb_iterator_value.val.binary.data); } else { - return_jsonb_value = pushJsonbValue(&state, jsonb_iterator_token, &jsonb_iterator_value); + return_jsonb_value = pushJsonbValueBlind(&state, jsonb_iterator_token, &jsonb_iterator_value); } + Assert(jsonb_iterator_token != WJB_VALUE); if ( jsonb_iterator_token == WJB_KEY ) @@ -704,7 +705,7 @@ jsonb_replace_jsonb(PG_FUNCTION_ARGS) jsonb_lookup_key.val.string.len = jsonb_iterator_value.val.string.len; jsonb_iterator_token = JsonbIteratorNext(&jsonb_iterator, &jsonb_iterator_value, true); - Assert(sonb_iterator_token == WJB_VALUE); + Assert(jsonb_iterator_token == WJB_VALUE); jsonb_lookup_value = findJsonbValueFromContainer(&input_jsonb_b->root, jsonb_lookup_flags, &jsonb_lookup_key); @@ -718,7 +719,7 @@ jsonb_replace_jsonb(PG_FUNCTION_ARGS) /* if our value is nested binary data, iterate separately pushing each val */ if (jsonb_lookup_value->type == jbvBinary) { - return_jsonb_value = pushJsonbBinary(state, jsonb_lookup_value->val.binary.data); + return_jsonb_value = pushJsonbBinary(&state, jsonb_lookup_value->val.binary.data); } else {