pg.ddx.io pgvector/pgvector GitHub issues and pull requests
help / color / mirror / Atom feed[pgvector/pgvector] PR #657: Add error codes to a few errors
6+ messages / 3 participants
[nested] [flat]
* [pgvector/pgvector] PR #657: Add error codes to a few errors
@ 2024-08-23 16:44 "hlinnaka (@hlinnaka)" <noreply+hlinnaka@github.com>
0 siblings, 0 replies; 6+ messages in thread
From: hlinnaka (@hlinnaka) @ 2024-08-23 16:44 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
With elog(), you get XX000 "internal_error", which sounds scary.
It's not self-evident what the right error codes for some of these errors are, but I tried to use my best judgment.
inline patch 1: src/hnswbuild.c, src/hnswutils.c, src/ivfbuild.c (+30/-10 lines) download inline-1.patch
diff --git a/src/hnswbuild.c b/src/hnswbuild.c
index 727eec371..8bd0b4add 100644
--- a/src/hnswbuild.c
+++ b/src/hnswbuild.c
@@ -192,7 +192,9 @@ CreateGraphPages(HnswBuildState * buildstate)
/* Initial size check */
if (etupSize > HNSW_TUPLE_ALLOC_SIZE)
- elog(ERROR, "index tuple too large");
+ ereport(ERROR,
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("index tuple too large")));
HnswSetElementTuple(base, etup, element);
@@ -696,17 +698,25 @@ InitBuildState(HnswBuildState * buildstate, Relation heap, Relation index, Index
/* Disallow varbit since require fixed dimensions */
if (TupleDescAttr(index->rd_att, 0)->atttypid == VARBITOID)
- elog(ERROR, "type not supported for hnsw index");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("type not supported for hnsw index")));
/* Require column to have dimensions to be indexed */
if (buildstate->dimensions < 0)
- elog(ERROR, "column does not have dimensions");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("column does not have dimensions")));
if (buildstate->dimensions > buildstate->typeInfo->maxDimensions)
- elog(ERROR, "column cannot have more than %d dimensions for hnsw index", buildstate->typeInfo->maxDimensions);
+ ereport(ERROR,
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("column cannot have more than %d dimensions for hnsw index", buildstate->typeInfo->maxDimensions)));
if (buildstate->efConstruction < 2 * buildstate->m)
- elog(ERROR, "ef_construction must be greater than or equal to 2 * m");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("ef_construction must be greater than or equal to 2 * m")));
buildstate->reltuples = 0;
buildstate->indtuples = 0;
diff --git a/src/hnswutils.c b/src/hnswutils.c
index 96c50263a..754c280ff 100644
--- a/src/hnswutils.c
+++ b/src/hnswutils.c
@@ -1280,7 +1280,9 @@ SparsevecCheckValue(Pointer v)
SparseVector *vec = (SparseVector *) v;
if (vec->nnz > HNSW_MAX_NNZ)
- elog(ERROR, "sparsevec cannot have more than %d non-zero elements for hnsw index", HNSW_MAX_NNZ);
+ ereport(ERROR,
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("sparsevec cannot have more than %d non-zero elements for hnsw index", HNSW_MAX_NNZ)));
}
/*
diff --git a/src/ivfbuild.c b/src/ivfbuild.c
index b9e97c8fa..76dff32b0 100644
--- a/src/ivfbuild.c
+++ b/src/ivfbuild.c
@@ -335,14 +335,20 @@ InitBuildState(IvfflatBuildState * buildstate, Relation heap, Relation index, In
/* Disallow varbit since require fixed dimensions */
if (TupleDescAttr(index->rd_att, 0)->atttypid == VARBITOID)
- elog(ERROR, "type not supported for ivfflat index");
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("type not supported for ivfflat index")));
/* Require column to have dimensions to be indexed */
if (buildstate->dimensions < 0)
- elog(ERROR, "column does not have dimensions");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("column does not have dimensions")));
if (buildstate->dimensions > buildstate->typeInfo->maxDimensions)
- elog(ERROR, "column cannot have more than %d dimensions for ivfflat index", buildstate->typeInfo->maxDimensions);
+ ereport(ERROR,
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("column cannot have more than %d dimensions for ivfflat index", buildstate->typeInfo->maxDimensions)));
buildstate->reltuples = 0;
buildstate->indtuples = 0;
@@ -355,7 +361,9 @@ InitBuildState(IvfflatBuildState * buildstate, Relation heap, Relation index, In
/* Require more than one dimension for spherical k-means */
if (buildstate->kmeansnormprocinfo != NULL && buildstate->dimensions == 1)
- elog(ERROR, "dimensions must be greater than one for this opclass");
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("dimensions must be greater than one for this opclass")));
/* Create tuple description for sorting */
buildstate->tupdesc = CreateTemplateTupleDesc(3);
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] PR #657 (approved): Add error codes to a few errors
@ 2024-08-23 18:26 "jkatz (@jkatz)" <noreply+jkatz@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: jkatz (@jkatz) @ 2024-08-23 18:26 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] PR #657: Add error codes to a few errors
@ 2024-08-23 22:08 "ankane (@ankane)" <noreply+ankane@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: ankane (@ankane) @ 2024-08-23 22:08 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Thanks @hlinnaka, makes sense to me. Going to wait until 0.8.0 to merge since it's a slightly breaking change.
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] PR #657: Add error codes to a few errors
@ 2024-09-20 01:04 "ankane (@ankane)" <noreply+ankane@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: ankane (@ankane) @ 2024-09-20 01:04 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@ankane merged this (commit 7117513532e4).
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] PR #657: Add error codes to a few errors
@ 2024-09-20 01:04 "ankane (@ankane)" <noreply+ankane@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: ankane (@ankane) @ 2024-09-20 01:04 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
@ankane closed this.
^ permalink raw [nested|flat] 6+ messages in thread
* Re: [pgvector/pgvector] PR #657: Add error codes to a few errors
@ 2024-09-20 01:04 "ankane (@ankane)" <noreply+ankane@github.com>
4 siblings, 0 replies; 6+ messages in thread
From: ankane (@ankane) @ 2024-09-20 01:04 UTC (permalink / raw)
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Starting to merge 0.8.0 work. Thanks again @hlinnaka!
^ permalink raw [nested|flat] 6+ messages in thread
end of thread, other threads:[~2024-09-20 01:04 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-08-23 16:44 [pgvector/pgvector] PR #657: Add error codes to a few errors "hlinnaka (@hlinnaka)" <noreply+hlinnaka@github.com>
2024-08-23 18:26 ` Re: [pgvector/pgvector] PR #657 (approved): Add error codes to a few errors "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-08-23 22:08 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-09-20 01:04 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-09-20 01:04 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-09-20 01:04 ` "ankane (@ankane)" <noreply+ankane@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