Skip to content

Commit b11b3b7

Browse files
Do not use ERRCODE_INTERNAL_ERROR for user errors
This code is reserved for internal program errors, i.e. bugs. This commit fixes only some of these existing incorrect codes, we have more.
1 parent 3a2c482 commit b11b3b7

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/chunk_adaptive.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,14 +433,18 @@ ts_calculate_chunk_interval(PG_FUNCTION_ARGS)
433433
elog(ERROR, "invalid number of arguments");
434434

435435
if (chunk_target_size_bytes < 0)
436-
elog(ERROR, "chunk_target_size must be positive");
436+
ereport(ERROR,
437+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
438+
errmsg("chunk_target_size must be positive")));
437439

438440
elog(DEBUG1, "[adaptive] chunk_target_size_bytes=" UINT64_FORMAT, chunk_target_size_bytes);
439441

440442
hypertable_id = ts_dimension_get_hypertable_id(dimension_id);
441443

442444
if (hypertable_id <= 0)
443-
elog(ERROR, "could not find a matching hypertable for dimension %u", dimension_id);
445+
ereport(ERROR,
446+
(errcode(ERRCODE_NO_DATA_FOUND),
447+
errmsg("could not find a matching hypertable for dimension %u", dimension_id)));
444448

445449
ht = ts_hypertable_get_by_id(hypertable_id);
446450

tsl/src/compression/create.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,9 +1006,10 @@ validate_hypertable_for_compression(Hypertable *ht)
10061006
if (strncmp(NameStr(attr->attname),
10071007
COMPRESSION_COLUMN_METADATA_PREFIX,
10081008
strlen(COMPRESSION_COLUMN_METADATA_PREFIX)) == 0)
1009-
elog(ERROR,
1010-
"cannot convert tables with reserved column prefix '%s' to columnstore",
1011-
COMPRESSION_COLUMN_METADATA_PREFIX);
1009+
ereport(ERROR,
1010+
(errcode(ERRCODE_RESERVED_NAME),
1011+
errmsg("cannot convert tables with reserved column prefix '%s' to columnstore",
1012+
COMPRESSION_COLUMN_METADATA_PREFIX)));
10121013
}
10131014

10141015
if (row_size > MaxHeapTupleSize)

0 commit comments

Comments
 (0)