mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Rename JsonIsPredicate.value_type, fix JSON backend/nodes/ infrastructure.
I started out with the intention to rename value_type to item_type to avoid a collision with a typedef name that appears on some platforms. Along the way, I noticed that the adjacent field "format" was not being correctly handled by the backend/nodes/ infrastructure functions: copyfuncs.c erroneously treated it as a scalar, while equalfuncs, outfuncs, and readfuncs omitted handling it at all. This looks like it might be cosmetic at the moment because the field is always NULL after parse analysis; but that's likely a bug in itself, and the code's certainly not very future-proof. Let's fix it while we can still do so without forcing an initdb on beta testers. Further study found a few other inconsistencies in the backend/nodes/ infrastructure for the recently-added JSON node types, so fix those too. catversion bumped because of potential change in stored rules. Discussion: https://postgr.es/m/526703.1652385613@sss.pgh.pa.us
This commit is contained in:
@ -3952,24 +3952,24 @@ ExecEvalJsonIsPredicate(ExprState *state, ExprEvalStep *op)
|
||||
{
|
||||
text *json = DatumGetTextP(js);
|
||||
|
||||
if (pred->value_type == JS_TYPE_ANY)
|
||||
if (pred->item_type == JS_TYPE_ANY)
|
||||
res = true;
|
||||
else
|
||||
{
|
||||
switch (json_get_first_token(json, false))
|
||||
{
|
||||
case JSON_TOKEN_OBJECT_START:
|
||||
res = pred->value_type == JS_TYPE_OBJECT;
|
||||
res = pred->item_type == JS_TYPE_OBJECT;
|
||||
break;
|
||||
case JSON_TOKEN_ARRAY_START:
|
||||
res = pred->value_type == JS_TYPE_ARRAY;
|
||||
res = pred->item_type == JS_TYPE_ARRAY;
|
||||
break;
|
||||
case JSON_TOKEN_STRING:
|
||||
case JSON_TOKEN_NUMBER:
|
||||
case JSON_TOKEN_TRUE:
|
||||
case JSON_TOKEN_FALSE:
|
||||
case JSON_TOKEN_NULL:
|
||||
res = pred->value_type == JS_TYPE_SCALAR;
|
||||
res = pred->item_type == JS_TYPE_SCALAR;
|
||||
break;
|
||||
default:
|
||||
res = false;
|
||||
@ -3986,13 +3986,13 @@ ExecEvalJsonIsPredicate(ExprState *state, ExprEvalStep *op)
|
||||
}
|
||||
else if (exprtype == JSONBOID)
|
||||
{
|
||||
if (pred->value_type == JS_TYPE_ANY)
|
||||
if (pred->item_type == JS_TYPE_ANY)
|
||||
res = true;
|
||||
else
|
||||
{
|
||||
Jsonb *jb = DatumGetJsonbP(js);
|
||||
|
||||
switch (pred->value_type)
|
||||
switch (pred->item_type)
|
||||
{
|
||||
case JS_TYPE_OBJECT:
|
||||
res = JB_ROOT_IS_OBJECT(jb);
|
||||
|
Reference in New Issue
Block a user