Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c3cedda

Browse files
committed
small fixes here and there
1 parent 24bc7d8 commit c3cedda

File tree

3 files changed

+12
-23
lines changed

3 files changed

+12
-23
lines changed

src/partition_creation.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -432,29 +432,28 @@ create_partitions_for_value_internal(Oid relid, Datum value, Oid value_type,
432432
}
433433
}
434434
else
435-
elog(ERROR, "pg_pathman's config does not contain relation \"%s\"",
435+
elog(ERROR, "table \"%s\" is not partitioned",
436436
get_rel_name_or_relid(relid));
437437
}
438438
PG_CATCH();
439439
{
440-
ErrorData *edata;
440+
ErrorData *error;
441441

442442
/* Simply rethrow ERROR if we're in backend */
443443
if (!is_background_worker)
444444
PG_RE_THROW();
445445

446446
/* Switch to the original context & copy edata */
447447
MemoryContextSwitchTo(old_mcxt);
448-
edata = CopyErrorData();
448+
error = CopyErrorData();
449449
FlushErrorState();
450450

451451
/* Produce log message if we're in BGW */
452-
ereport(LOG,
453-
(errmsg(CppAsString(create_partitions_for_value_internal) ": %s [%u]",
454-
edata->message, MyProcPid),
455-
(edata->detail) ? errdetail("%s", edata->detail) : 0));
452+
error->elevel = LOG;
453+
error->message = psprintf(CppAsString(create_partitions_for_value_internal)
454+
": %s [%u]", error->message, MyProcPid);
456455

457-
FreeErrorData(edata);
456+
ReThrowError(error);
458457

459458
/* Reset 'partid' in case of error */
460459
partid = InvalidOid;

src/partition_filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ select_partition_for_insert(Datum value, Oid value_type,
439439
else if (nparts == 0)
440440
{
441441
selected_partid = create_partitions_for_value(parent_relid,
442-
value, prel->ev_type);
442+
value, value_type);
443443

444444
/* get_pathman_relation_info() will refresh this entry */
445445
invalidate_pathman_relation_info(parent_relid, NULL);

src/pl_funcs.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,6 @@ add_to_pathman_config(PG_FUNCTION_ARGS)
765765
Datum expr_datum;
766766

767767
PathmanInitState init_state;
768-
MemoryContext old_mcxt = CurrentMemoryContext;
769768

770769
if (!PG_ARGISNULL(0))
771770
{
@@ -887,20 +886,11 @@ add_to_pathman_config(PG_FUNCTION_ARGS)
887886
}
888887
PG_CATCH();
889888
{
890-
ErrorData *edata;
891-
892-
/* Switch to the original context & copy edata */
893-
MemoryContextSwitchTo(old_mcxt);
894-
edata = CopyErrorData();
895-
FlushErrorState();
896-
897889
/* We have to restore all changed flags */
898890
restore_pathman_init_state(&init_state);
899891

900-
/* Show error message */
901-
elog(ERROR, "%s", edata->message);
902-
903-
FreeErrorData(edata);
892+
/* Rethrow ERROR */
893+
PG_RE_THROW();
904894
}
905895
PG_END_TRY();
906896
}
@@ -1262,11 +1252,11 @@ pathman_update_trigger_func(PG_FUNCTION_ARGS)
12621252
elog(ERROR, ERR_PART_ATTR_MULTIPLE);
12631253
else if (nparts == 0)
12641254
{
1265-
target_relid = create_partitions_for_value(PrelParentRelid(prel),
1255+
target_relid = create_partitions_for_value(parent_relid,
12661256
value, value_type);
12671257

12681258
/* get_pathman_relation_info() will refresh this entry */
1269-
invalidate_pathman_relation_info(PrelParentRelid(prel), NULL);
1259+
invalidate_pathman_relation_info(parent_relid, NULL);
12701260
}
12711261
else target_relid = parts[0];
12721262

0 commit comments

Comments
 (0)