aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/jsonfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-03-02 23:31:39 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2016-03-02 23:31:39 -0500
commit597e41e45eec8038b8c2c1153d1d050bfafeacbf (patch)
tree241308e4d3a6c6a9b72a68d8f3fef452228901c6 /src/backend/utils/adt/jsonfuncs.c
parent55965eb7d2f28d9325e80b7dd6f593bb22aa29b9 (diff)
downloadpostgresql-597e41e45eec8038b8c2c1153d1d050bfafeacbf.tar.gz
postgresql-597e41e45eec8038b8c2c1153d1d050bfafeacbf.zip
Fix json_to_record() bug with nested objects.
A thinko concerning nesting depth caused json_to_record() to produce bogus output if a field of its input object contained a sub-object with a field name matching one of the requested output column names. Per bug #13996 from Johann Visagie. I added a regression test case based on his example, plus parallel tests for json_to_recordset, jsonb_to_record, jsonb_to_recordset. The latter three do not exhibit the same bug (which suggests that we may be missing some opportunities to share code...) but testing seems like a good idea in any case. Back-patch to 9.4 where these functions were introduced.
Diffstat (limited to 'src/backend/utils/adt/jsonfuncs.c')
-rw-r--r--src/backend/utils/adt/jsonfuncs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index b49a5dd61e4..18e7b9c8798 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -2350,7 +2350,7 @@ hash_object_field_end(void *state, char *fname, bool isnull)
/*
* Ignore nested fields.
*/
- if (_state->lex->lex_level > 2)
+ if (_state->lex->lex_level > 1)
return;
/*