Skip to content

Commit b77baf6

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 b77baf6

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

src/chunk_adaptive.c

Lines changed: 7 additions & 3 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_UNDEFINED_OBJECT),
447+
errmsg("could not find a matching hypertable for dimension %u", dimension_id)));
444448

445449
ht = ts_hypertable_get_by_id(hypertable_id);
446450

@@ -830,7 +834,7 @@ ChunkSizingInfo *
830834
ts_chunk_sizing_info_get_default_disabled(Oid table_relid)
831835
{
832836
ChunkSizingInfo *chunk_sizing_info = palloc(sizeof(*chunk_sizing_info));
833-
*chunk_sizing_info = (ChunkSizingInfo){
837+
*chunk_sizing_info = (ChunkSizingInfo) {
834838
.table_relid = table_relid,
835839
.target_size = NULL,
836840
.func = get_default_chunk_sizing_fn_oid(),

tsl/src/compression/create.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,10 @@ build_columndefs(CompressionSettings *settings, Oid src_reloid)
310310
if (strncmp(NameStr(attr->attname),
311311
COMPRESSION_COLUMN_METADATA_PREFIX,
312312
strlen(COMPRESSION_COLUMN_METADATA_PREFIX)) == 0)
313-
elog(ERROR,
314-
"cannot compress tables with reserved column prefix '%s'",
315-
COMPRESSION_COLUMN_METADATA_PREFIX);
313+
ereport(ERROR,
314+
(errcode(ERRCODE_RESERVED_NAME),
315+
errmsg("cannot convert tables with reserved column prefix '%s'",
316+
COMPRESSION_COLUMN_METADATA_PREFIX)));
316317

317318
bool is_segmentby = ts_array_is_member(segmentby, NameStr(attr->attname));
318319
if (is_segmentby)
@@ -466,9 +467,10 @@ build_columndef_singlecolumn(const char *colname, Oid typid)
466467
if (strncmp(colname,
467468
COMPRESSION_COLUMN_METADATA_PREFIX,
468469
strlen(COMPRESSION_COLUMN_METADATA_PREFIX)) == 0)
469-
elog(ERROR,
470-
"cannot compress tables with reserved column prefix '%s'",
471-
COMPRESSION_COLUMN_METADATA_PREFIX);
470+
ereport(ERROR,
471+
(errcode(ERRCODE_RESERVED_NAME),
472+
errmsg("cannot convert tables with reserved column prefix '%s'",
473+
COMPRESSION_COLUMN_METADATA_PREFIX)));
472474

473475
return makeColumnDef(colname, compresseddata_oid, -1 /*typmod*/, 0 /*collation*/);
474476
}
@@ -1006,9 +1008,10 @@ validate_hypertable_for_compression(Hypertable *ht)
10061008
if (strncmp(NameStr(attr->attname),
10071009
COMPRESSION_COLUMN_METADATA_PREFIX,
10081010
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);
1011+
ereport(ERROR,
1012+
(errcode(ERRCODE_RESERVED_NAME),
1013+
errmsg("cannot convert tables with reserved column prefix '%s' to columnstore",
1014+
COMPRESSION_COLUMN_METADATA_PREFIX)));
10121015
}
10131016

10141017
if (row_size > MaxHeapTupleSize)
@@ -1430,9 +1433,10 @@ tsl_process_compress_table_rename_column(Hypertable *ht, const RenameStmt *stmt)
14301433
if (strncmp(stmt->newname,
14311434
COMPRESSION_COLUMN_METADATA_PREFIX,
14321435
strlen(COMPRESSION_COLUMN_METADATA_PREFIX)) == 0)
1433-
elog(ERROR,
1434-
"cannot convert tables with reserved column prefix '%s' to columnstore",
1435-
COMPRESSION_COLUMN_METADATA_PREFIX);
1436+
ereport(ERROR,
1437+
(errcode(ERRCODE_RESERVED_NAME),
1438+
errmsg("cannot convert tables with reserved column prefix '%s' to columnstore",
1439+
COMPRESSION_COLUMN_METADATA_PREFIX)));
14361440

14371441
if (!TS_HYPERTABLE_HAS_COMPRESSION_TABLE(ht))
14381442
{

0 commit comments

Comments
 (0)