model-writtenrun 8494 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Neil Chen reported that JSON and JSONB constructors reject casts returning SQL NULL with "function returned NULL", while explicitly casting first works; COPY TO with JSON format also encounters the error and can leave an unfinished array with FORCE_ARRAY #1.
- Neil's initial patch replaced OidFunctionCall1() with a shared FunctionCallInvoke() helper that checks the result's null flag while preserving EXECUTE checks and execution hooks, allowing constructors to emit JSON null; he reported all 243 regression tests passing and asked whether top-level to_json() and to_jsonb() should instead preserve SQL NULL #1.
- Neil revised the patch to preserve SQL NULL from top-level to_json() and to_jsonb() calls while retaining JSON null inside constructors, explaining that this matches explicit casts and lets callers distinguish the results using IS NULL or COALESCE; he added regression coverage and again reported all 243 tests passing #2.
- The thread ends with Neil requesting feedback on SQL NULL versus JSON null for direct conversions; no reviewer response or linked commit is present, so that behavior remains open for discussion #2.