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

Commit2a3a396

Browse files
committed
Clarify the ra != rb case in compareJsonbContainers().
It's impossible to reach this case with either ra or rb beingWJB_DONE, because our earlier checks that the structure andlength of the inputs match should guarantee that we reach theirends simultaneously. However, the comment completely fails toexplain this, and the Asserts don't cover it either. The commentis pretty obscure anyway, so rewrite it, and extend the Assertsto reject WJB_DONE.This is only cosmetic, so no need for back-patch.Author: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/0c623e8a204187b87b4736792398eaf1@postgrespro.ru
1 parentaad1617 commit2a3a396

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,19 +277,16 @@ compareJsonbContainers(JsonbContainer *a, JsonbContainer *b)
277277
else
278278
{
279279
/*
280-
* If the two values were of the same container type, then there'd
281-
* have been a chance to observe the variation in the number of
282-
* elements/pairs (when processing WJB_BEGIN_OBJECT, say). They're
283-
* either two heterogeneously-typed containers, or a container and
284-
* some scalar type.
285-
*
286-
* We don't have to consider the WJB_END_ARRAY and WJB_END_OBJECT
287-
* cases here, because we would have seen the corresponding
288-
* WJB_BEGIN_ARRAY and WJB_BEGIN_OBJECT tokens first, and
289-
* concluded that they don't match.
280+
* It's not possible for one iterator to report end of array or
281+
* object while the other one reports something else, because we
282+
* would have detected a length mismatch when we processed the
283+
* container-start tokens above. Likewise we can't see WJB_DONE
284+
* from one but not the other. So we have two different-type
285+
* containers, or a container and some scalar type, or two
286+
* different scalar types. Sort on the basis of the type code.
290287
*/
291-
Assert(ra!=WJB_END_ARRAY&&ra!=WJB_END_OBJECT);
292-
Assert(rb!=WJB_END_ARRAY&&rb!=WJB_END_OBJECT);
288+
Assert(ra!=WJB_DONE&&ra!=WJB_END_ARRAY&&ra!=WJB_END_OBJECT);
289+
Assert(rb!=WJB_DONE&&rb!=WJB_END_ARRAY&&rb!=WJB_END_OBJECT);
293290

294291
Assert(va.type!=vb.type);
295292
Assert(va.type!=jbvBinary);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp