Skip to content

Commit 5e72143

Browse files
jhfclaude
andcommitted
Fix C bugs, add audit comments, and deduplicate FK check code
Bug fixes: - Fix DatumNegativeInfinity passing text* to numeric_in (expects cstring). Use CStringGetDatum + DirectFunctionCall3 instead of cstring_to_text. - Fix write_history not validating SPI_fnumber result before SPI_gettypeid, matching the validation pattern in generated_always_as_row_start_end. Audit comment: - Add detailed comment block above FK/UK plan cache declarations documenting lifecycle, transaction scoping, cleanup callback, and session-scoped plans. Refactor: - Extract shared fk_check_c() helper from fk_insert_check_c/fk_update_check_c, eliminating ~250 lines of near-identical code. The only difference between insert and update is which tuple to validate (tg_trigtuple vs tg_newtuple). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fdd7422 commit 5e72143

2 files changed

Lines changed: 71 additions & 277 deletions

File tree

src/covers_without_gaps.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,10 @@ Datum DatumNegativeInfinity(Oid elem_oid)
414414
return DateADTGetDatum(DATEVAL_NOBEGIN);
415415
case NUMERICOID:
416416
{
417-
text* negativeInfinityText = cstring_to_text("-Infinity");
418-
Datum negativeInfinityDatum = DirectFunctionCall1(numeric_in, PointerGetDatum(negativeInfinityText));
419-
pfree(negativeInfinityText);
417+
Datum negativeInfinityDatum = DirectFunctionCall3(numeric_in,
418+
CStringGetDatum("-Infinity"),
419+
ObjectIdGetDatum(InvalidOid),
420+
Int32GetDatum(-1));
420421
return negativeInfinityDatum;
421422
}
422423
case TIMESTAMPOID:

0 commit comments

Comments
 (0)