pgrx
pgrx copied to clipboard
Test case with a `#[should_panic]` for corrupted arrays (requires array mutation)
Currently, there is no test case to make sure the debug assertions I'm introducing in Pull Request #1514 actually catch the type of bugs they're intended to catch (see issue #1195).
I'd like to write #[should_fail]
tests to make sure that an array which is broken or read incorrectly in certain ways actually does cause a debug build to panic when it should, rather than just going ahead and performing UB.
However, this issue will probably be on the back-burner for a while, since it requires pgrx to support mutating arrays.
Per conversations with @workingjubilee, any test we could write right now that would require mutating a Postgres Array to break it for this purpose would then be such a mess of hacks - unsafe code directly messing with byte-level representation - that its unreadability and unreliability would mean it's not helpful for debugging.
So, writing these test cases will need to wait until after arrays are mutable. However, I don't want to forget it, so I'm setting up this issue now.