pg.ddx.io pgvector/pgvector GitHub issues and pull requests
help / color / mirror / Atom feed[pgvector/pgvector] PR #890: Use NIL for empty lists
7+ messages / 2 participants
[nested] [flat]
* [pgvector/pgvector] PR #890: Use NIL for empty lists
@ 2025-08-23 10:07 "rjuju (@rjuju)" <noreply+rjuju@github.com>
0 siblings, 0 replies; 7+ messages in thread
From: rjuju (@rjuju) @ 2025-08-23 10:07 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Postgres standard way to check for list emptiness is to compare a pointer to NIL rather than NULL.
inline patch 1: src/hnsw.c, src/ivfflat.c (+2/-2 lines) download inline-1.patch
diff --git a/src/hnsw.c b/src/hnsw.c
index 5bfc6193e..606466c82 100644
--- a/src/hnsw.c
+++ b/src/hnsw.c
@@ -130,7 +130,7 @@ hnswcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
Relation index;
/* Never use index without order */
- if (path->indexorderbys == NULL)
+ if (path->indexorderbys == NIL)
{
*indexStartupCost = get_float8_infinity();
*indexTotalCost = get_float8_infinity();
diff --git a/src/ivfflat.c b/src/ivfflat.c
index 9e8370ffe..c4cd1bbdf 100644
--- a/src/ivfflat.c
+++ b/src/ivfflat.c
@@ -92,7 +92,7 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
Relation index;
/* Never use index without order */
- if (path->indexorderbys == NULL)
+ if (path->indexorderbys == NIL)
{
*indexStartupCost = get_float8_infinity();
*indexTotalCost = get_float8_infinity();
^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgvector/pgvector] PR #890: Use NIL for empty lists
@ 2025-08-23 10:31 ` "ankane (@ankane)" <noreply+ankane@github.com>
5 siblings, 0 replies; 7+ messages in thread
From: ankane (@ankane) @ 2025-08-23 10:31 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@ankane closed this.
^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgvector/pgvector] PR #890: Use NIL for empty lists
@ 2025-08-23 10:31 ` "ankane (@ankane)" <noreply+ankane@github.com>
5 siblings, 0 replies; 7+ messages in thread
From: ankane (@ankane) @ 2025-08-23 10:31 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@ankane merged this (commit dd3a1e9137d8).
^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgvector/pgvector] PR #890: Use NIL for empty lists
@ 2025-08-23 10:31 ` "ankane (@ankane)" <noreply+ankane@github.com>
5 siblings, 0 replies; 7+ messages in thread
From: ankane (@ankane) @ 2025-08-23 10:31 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Thanks @rjuju!
^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgvector/pgvector] PR #890: Use NIL for empty lists
@ 2025-08-24 00:22 ` "rjuju (@rjuju)" <noreply+rjuju@github.com>
5 siblings, 0 replies; 7+ messages in thread
From: rjuju (@rjuju) @ 2025-08-24 00:22 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
thanks for merging!
^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgvector/pgvector] PR #890: Use NIL for empty lists
@ 2025-08-24 00:43 ` "ankane (@ankane)" <noreply+ankane@github.com>
5 siblings, 0 replies; 7+ messages in thread
From: ankane (@ankane) @ 2025-08-24 00:43 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
No problem. fwiw, [this comment](https://github.com/postgres/postgres/blob/REL_17_5/src/include/nodes/pathnodes.h#L1686-L1691) mentions using `NIL`, but [Postgres itself](https://github.com/postgres/postgres/blob/REL_17_5/src/backend/optimizer/plan/createplan.c#L3120) uses `NULL`.
^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgvector/pgvector] PR #890: Use NIL for empty lists
@ 2025-08-24 01:03 ` "rjuju (@rjuju)" <noreply+rjuju@github.com>
5 siblings, 0 replies; 7+ messages in thread
From: rjuju (@rjuju) @ 2025-08-24 01:03 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
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.
^ permalink raw [nested|flat] 7+ messages in thread
end of thread, other threads:[~2025-08-24 01:03 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-08-23 10:07 [pgvector/pgvector] PR #890: Use NIL for empty lists "rjuju (@rjuju)" <noreply+rjuju@github.com>
2025-08-23 10:31 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-08-23 10:31 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-08-23 10:31 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-08-24 00:22 ` "rjuju (@rjuju)" <noreply+rjuju@github.com>
2025-08-24 00:43 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-08-24 01:03 ` "rjuju (@rjuju)" <noreply+rjuju@github.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox