Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace ERRCODE_INTERNAL_ERROR with appropriate code #7417

Merged
merged 7 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/upload_ci_stats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ then
match($0, /^(test| ) ([^ ]+)[ ]+\.\.\.[ ]+([^ ]+) (|\(.*\))[ ]+([0-9]+) ms$/, a) {
print ENVIRON["JOB_DATE"], a[2], tolower(a[3] (a[4] ? (" " a[4]) : "")), a[5];
}
match($0, /^([^0-9]+) [0-9]+ +- ([^ ]+) +([0-9]+) ms/, a) {
print ENVIRON["JOB_DATE"], a[2], a[1], a[3];
match($0, /^([^0-9]+) [0-9]+ +[-+] ([^ ]+) +([0-9]+) ms/, a) {
print ENVIRON["JOB_DATE"], a[2], a[1], a[3];
}
' installcheck.log > tests.tsv

Expand Down
9 changes: 9 additions & 0 deletions src/chunk_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,9 @@ Datum
ts_chunk_index_clone(PG_FUNCTION_ARGS)
{
Oid chunk_index_oid = PG_GETARG_OID(0);
if (!OidIsValid(chunk_index_oid))
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid chunk index")));

Relation chunk_index_rel;
Relation hypertable_rel;
Relation chunk_rel;
Expand Down Expand Up @@ -1228,7 +1231,13 @@ Datum
ts_chunk_index_replace(PG_FUNCTION_ARGS)
{
Oid chunk_index_oid_old = PG_GETARG_OID(0);
if (!OidIsValid(chunk_index_oid_old))
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid chunk index")));

Oid chunk_index_oid_new = PG_GETARG_OID(1);
if (!OidIsValid(chunk_index_oid_new))
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid chunk index")));

Relation index_rel;
Chunk *chunk;
ChunkIndexMapping cim;
Expand Down
5 changes: 4 additions & 1 deletion src/nodes/chunk_dispatch/chunk_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ ts_chunk_dispatch_get_chunk_insert_state(ChunkDispatch *dispatch, Point *point,
* Frozen chunks require at least PG14.
*/
if (chunk && ts_chunk_is_frozen(chunk))
elog(ERROR, "cannot INSERT into frozen chunk \"%s\"", get_rel_name(chunk->table_id));
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot INSERT into frozen chunk \"%s\"",
get_rel_name(chunk->table_id))));
if (chunk && IS_OSM_CHUNK(chunk))
{
const Dimension *time_dim =
Expand Down
3 changes: 2 additions & 1 deletion src/telemetry/telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,8 @@ ts_telemetry_main(const char *host, const char *path, const char *service)
* throw an error, so we capture the error here and print debugging
* information. */
ereport(NOTICE,
(errmsg("malformed telemetry response body"),
(errcode(ERRCODE_DATA_EXCEPTION),
errmsg("malformed telemetry response body"),
errdetail("host=%s, service=%s, path=%s: %s",
host,
service,
Expand Down
5 changes: 3 additions & 2 deletions src/ts_catalog/tablespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,11 @@ ts_tablespace_attach_internal(Name tspcname, Oid hypertable_oid, bool if_not_att
CatalogSecurityContext sec_ctx;

if (NULL == tspcname)
elog(ERROR, "invalid tablespace name");
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid tablespace name")));

if (!OidIsValid(hypertable_oid))
elog(ERROR, "invalid hypertable");
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid hypertable")));

tspc_oid = get_tablespace_oid(NameStr(*tspcname), true);

Expand Down
4 changes: 3 additions & 1 deletion src/with_clause_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ parse_arg(WithClauseDefinition arg, DefElem *def)
Oid typIOParam;

if (!OidIsValid(arg.type_id))
elog(ERROR, "argument \"%s.%s\" not implemented", def->defnamespace, def->defname);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_PARAMETER),
errmsg("argument \"%s.%s\" not implemented", def->defnamespace, def->defname)));

if (def->arg != NULL)
value = defGetString(def);
Expand Down
11 changes: 7 additions & 4 deletions test/src/telemetry/test_telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ test_factory(ConnectionType type, int status, char *host, int port)
ts_connection_destroy(conn);

if (!ts_http_response_state_valid_status(rsp))
elog(ERROR,
"endpoint sent back unexpected HTTP status: %d",
ts_http_response_state_status_code(rsp));
ereport(ERROR,
(errcode(ERRCODE_IO_ERROR),
errmsg("endpoint sent back unexpected HTTP status: %d",
ts_http_response_state_status_code(rsp))));

json = DirectFunctionCall1(jsonb_in, CStringGetDatum(ts_http_response_state_body_start(rsp)));

Expand All @@ -135,7 +136,9 @@ ts_test_status_ssl(PG_FUNCTION_ARGS)
char buf[128] = { '\0' };

if (status / 100 != 2)
elog(ERROR, "endpoint sent back unexpected HTTP status: %d", status);
ereport(ERROR,
(errcode(ERRCODE_IO_ERROR),
errmsg("endpoint sent back unexpected HTTP status: %d", status)));

snprintf(buf, sizeof(buf) - 1, "{\"status\":%d}", status);

Expand Down
3 changes: 2 additions & 1 deletion tsl/src/bgw_policy/compression_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ policy_compression_check(PG_FUNCTION_ARGS)

if (PG_ARGISNULL(0))
{
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("config must not be NULL")));
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), errmsg("config must not be NULL")));
}

policy_compression_read_and_validate_config(PG_GETARG_JSONB_P(0), &policy_data);
Expand Down
4 changes: 3 additions & 1 deletion tsl/src/nodes/decompress_chunk/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ constify_tableoid_walker(Node *node, ConstifyTableOidContext *ctx)
* segfault if any system columns get through
*/
if (var->varattno < SelfItemPointerAttributeNumber)
elog(ERROR, "transparent decompression only supports tableoid system column");
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("transparent decompression only supports tableoid system column")));

return node;
}
Expand Down
4 changes: 3 additions & 1 deletion tsl/src/nodes/decompress_chunk/planner.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ check_for_system_columns(Bitmapset *attrs_used)
bit = bms_next_member(attrs_used, bit);

if (bit > 0 && bit + FirstLowInvalidHeapAttributeNumber < 0)
elog(ERROR, "transparent decompression only supports tableoid system column");
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("transparent decompression only supports tableoid system column")));
}
}

Expand Down
7 changes: 4 additions & 3 deletions tsl/src/nodes/frozen_chunk_dml/frozen_chunk_dml.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ frozen_chunk_dml_exec(CustomScanState *node)
{
FrozenChunkDmlState *state = (FrozenChunkDmlState *) node;
Oid chunk_relid = state->chunk_relid;
elog(ERROR,
"cannot update/delete rows from chunk \"%s\" as it is frozen",
get_rel_name(chunk_relid));
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("cannot update/delete rows from chunk \"%s\" as it is frozen",
get_rel_name(chunk_relid))));
return NULL;
}

Expand Down
4 changes: 2 additions & 2 deletions tsl/test/shared/expected/compat.out
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ WARNING: function _timescaledb_internal.chunk_id_from_relid(oid) is deprecated

SELECT _timescaledb_internal.chunk_index_clone(0);
WARNING: function _timescaledb_internal.chunk_index_clone(oid) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.
ERROR: could not open relation with OID 0
ERROR: invalid chunk index
SELECT _timescaledb_internal.chunk_index_replace(0,0);
WARNING: function _timescaledb_internal.chunk_index_replace(oid,oid) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.
ERROR: could not open relation with OID 0
ERROR: invalid chunk index
SELECT _timescaledb_internal.chunk_status(0);
WARNING: function _timescaledb_internal.chunk_status(regclass) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.
ERROR: invalid Oid
Expand Down
Loading