Fix NULL handling in datum_to_jsonb().

Tom Lane <tgl@sss.pgh.pa.us>

Commit: a93b3782e3358cbb1ad8d65386a2e1478b805649
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2015-10-15T17:46:09Z
Releases: 9.5.0
Fix NULL handling in datum_to_jsonb().

The function failed to adhere to its specification that the "tcategory"
argument should not be examined when the input value is NULL.  This
resulted in a crash in some cases.  Per bug #13680 from Boyko Yordanov.

In passing, re-pgindent some recent changes in jsonb.c, and fix a rather
ungrammatical comment.

Diagnosis and patch by Michael Paquier, cosmetic changes by me

Files

PathChange+/−
src/backend/utils/adt/jsonb.c modified +15 −12
src/test/regress/expected/jsonb.out modified +9 −0
src/test/regress/sql/jsonb.sql modified +4 −0