Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite45c5be

Browse files
committed
Fix thinko in JsObjectSize() macro.
The macro gave the wrong answers for a JsObject with is_json == 0:it would return 1 if jsonb_cont == NULL, or if that wasn't NULL,it would return 1 for any non-zero size.We could fix that, but the only use of this macro at present is in theJsObjectIsEmpty() macro, so it seems simpler and clearer to get rid ofJsObjectSize() and put corrected logic into JsObjectIsEmpty().Thinko in commitcf35346, so no need for back-patch.Nikita GlukhovDiscussion:https://postgr.es/m/fbd1d566-bba0-a3de-d6d0-d3b1d7c24ff2@postgrespro.ru
1 parentf3db7f1 commite45c5be

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎src/backend/utils/adt/jsonfuncs.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,14 @@ typedef struct JsObject
308308
((jsv)->is_json ? (jsv)->val.json.type == JSON_TOKEN_STRING \
309309
: ((jsv)->val.jsonb && (jsv)->val.jsonb->type == jbvString))
310310

311-
#defineJsObjectSize(jso) \
311+
#defineJsObjectIsEmpty(jso) \
312312
((jso)->is_json \
313-
? hash_get_num_entries((jso)->val.json_hash) \
314-
: !(jso)->val.jsonb_cont || JsonContainerSize((jso)->val.jsonb_cont))
313+
? hash_get_num_entries((jso)->val.json_hash) == 0 \
314+
: ((jso)->val.jsonb_cont == NULL || \
315+
JsonContainerSize((jso)->val.jsonb_cont) == 0))
315316

316-
#defineJsObjectIsEmpty(jso) (JsObjectSize(jso) == 0)
317-
318-
#defineJsObjectFree(jso) do { \
317+
#defineJsObjectFree(jso) \
318+
do { \
319319
if ((jso)->is_json) \
320320
hash_destroy((jso)->val.json_hash); \
321321
} while (0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp