Fix core dump in jsonb #> operator, and add regression test cases.
jsonb's #> operator segfaulted (dereferencing a null pointer) if the RHS was a zero-length array, as reported in bug #11207 from Justin Van Winkle. json's #> operator returns NULL in such cases, so for the moment let's make jsonb act likewise. Also add a bunch of regression test queries memorializing the -> and #> operators' behavior for this and other corner cases. There is a good argument for changing some of these behaviors, as they are not very consistent with each other, and throwing an error isn't necessarily a desirable behavior for operators that are likely to be used in indexes. However, everybody can agree that a core dump is the Wrong Thing, and we need test cases even if we decide to change their expected output later.
Showing
- src/backend/utils/adt/jsonfuncs.c 15 additions, 1 deletionsrc/backend/utils/adt/jsonfuncs.c
- src/test/regress/expected/json.out 166 additions, 19 deletionssrc/test/regress/expected/json.out
- src/test/regress/expected/json_1.out 166 additions, 19 deletionssrc/test/regress/expected/json_1.out
- src/test/regress/expected/jsonb.out 142 additions, 28 deletionssrc/test/regress/expected/jsonb.out
- src/test/regress/expected/jsonb_1.out 142 additions, 28 deletionssrc/test/regress/expected/jsonb_1.out
- src/test/regress/sql/json.sql 40 additions, 9 deletionssrc/test/regress/sql/json.sql
- src/test/regress/sql/jsonb.sql 40 additions, 15 deletionssrc/test/regress/sql/jsonb.sql
Loading
Please register or sign in to comment