"David G. Johnston" <david.g.johnston@gmail.com> writes:
> Someone more experienced than I will need to actually do the debugging work
> though; hoping this reply will be seen by one of them.
Meh. Somebody was cavalier about detoasting the subscript:
jbvp = getKeyJsonValueFromContainer(container,
VARDATA(path[i]),
VARSIZE(path[i]) - VARHDRSZ,
NULL);
Neither VARDATA nor VARSIZE are valid to apply to an arbitrary datum.
Apparently, nobody has ever tested this with a subscript value fetched
straight from disk :-(. The given example accidentally works with
a NOT MATERIALIZED CTE because the whole thing gets stepwise folded
to constants. Likewise, the expression with || accidentally works
because concatenation always yields a non-toasted result.
regards, tom lane