Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rjuju
Copy link
Contributor

@rjuju rjuju commented Aug 23, 2025

Postgres standard way to check for list emptiness is to compare a pointer to NIL rather than NULL.

Postgres standard way to check for list emptiness is to compare a pointer to
NIL rather than NULL.
@ankane ankane merged commit dd3a1e9 into pgvector:master Aug 23, 2025
@ankane
Copy link
Member

ankane commented Aug 23, 2025

Thanks @rjuju!

@rjuju rjuju deleted the fix_nil branch August 23, 2025 13:55
@rjuju
Copy link
Contributor Author

rjuju commented Aug 24, 2025

thanks for merging!

@ankane
Copy link
Member

ankane commented Aug 24, 2025

No problem. fwiw, this comment mentions using NIL, but Postgres itself uses NULL.

@rjuju
Copy link
Contributor Author

rjuju commented Aug 24, 2025

Yes it's not surprising, using NULL is quite strong muscle memory thing in C and the additional cast done by NIL doesn't really add much. It's definitely not a game changer to use NIL here, but if one day this list is changed to another structure (I think this kind of change happened quite frequently on the partitioning related structures some years ago) you should then get a clear compiler error rather than random errors and segfaults that will make waste a bit of time at the time it breaks. I guess that's the main reason to prefer NIL.

klmckeig pushed a commit to klmckeig/pgvector that referenced this pull request Dec 8, 2025
Postgres standard way to check for list emptiness is to compare a pointer to
NIL rather than NULL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants