From bddb9b01a6372d4d1f511911cedfcdb97f4bdf0d Mon Sep 17 00:00:00 2001 From: roseduan Date: Thu, 11 Jun 2026 08:32:31 +0000 Subject: [PATCH] Fix: pg_task / pg_task_run_history column reorder with catversion bump Some non-varlen fields (int32 nodeport, bool active in pg_task; timestamptz start_time / end_time in pg_task_run_history) were declared after CATALOG_VARLEN, which trips LLVM bitcode emission during JIT compilation. Move them ahead of the varlen block. Because this rearranges the on-disk pg_attribute layout, bump CATALOG_VERSION_NO so an upgraded binary refuses to start against a pre-reorder cluster instead of crashing at runtime with SIGSEGV in heap_form_tuple on the first CREATE TASK. Adjust ruleutils.c pg_get_dynamic_table_schedule() to fetch the schedule via heap_getattr() since &task->schedule on the Form struct is no longer valid for varlen-section fields. --- src/backend/utils/adt/ruleutils.c | 17 +++++++++++------ src/include/catalog/catversion.h | 2 +- src/include/catalog/pg_task.h | 8 +++++--- src/include/catalog/pg_task_run_history.h | 12 +++++++----- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index d60a38a0a0a..fd9c4daea67 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -13158,14 +13158,16 @@ flatten_reloptions(Oid relid) Datum pg_get_dynamic_table_schedule(PG_FUNCTION_ARGS) { - Oid relid = PG_GETARG_OID(0); - Relation pg_task; - StringInfoData buf; - char *username; + Oid relid = PG_GETARG_OID(0); + Relation pg_task; + StringInfoData buf; + char *username; SysScanDesc scanDescriptor = NULL; - ScanKeyData scanKey[2]; + ScanKeyData scanKey[2]; HeapTuple heapTuple = NULL; Form_pg_task task = NULL; + bool isnull; + Datum datum; if (!get_rel_relisdynamic(relid)) { @@ -13209,7 +13211,10 @@ pg_get_dynamic_table_schedule(PG_FUNCTION_ARGS) task = (Form_pg_task) GETSTRUCT(heapTuple); resetStringInfo(&buf); - appendStringInfo(&buf, "%s", text_to_cstring(&task->schedule)); + datum = heap_getattr(heapTuple, Anum_pg_task_schedule, + RelationGetDescr(pg_task), &isnull); + if (!isnull) + appendStringInfo(&buf, "%s", TextDatumGetCString(datum)); systable_endscan(scanDescriptor); table_close(pg_task, AccessShareLock); diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 3de2e549f4c..851e58debc3 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -60,6 +60,6 @@ */ /* 3yyymmddN */ -#define CATALOG_VERSION_NO 302512051 +#define CATALOG_VERSION_NO 302606111 #endif diff --git a/src/include/catalog/pg_task.h b/src/include/catalog/pg_task.h index 387d5945748..e58128b7b65 100644 --- a/src/include/catalog/pg_task.h +++ b/src/include/catalog/pg_task.h @@ -39,14 +39,16 @@ CATALOG(pg_task,9637,TaskRelationId) BKI_SHARED_RELATION { Oid jobid; + int32 nodeport; + bool active BKI_DEFAULT(t); +#ifdef CATALOG_VARLEN /* variable-length fields start here */ text schedule; text command; text nodename; - int32 nodeport; text database; text username; - bool active BKI_DEFAULT(t); - text jobname; + text jobname BKI_FORCE_NULL; +#endif } FormData_pg_task; typedef FormData_pg_task *Form_pg_task; diff --git a/src/include/catalog/pg_task_run_history.h b/src/include/catalog/pg_task_run_history.h index fdb636c7f00..74bd5883a46 100644 --- a/src/include/catalog/pg_task_run_history.h +++ b/src/include/catalog/pg_task_run_history.h @@ -41,16 +41,18 @@ */ CATALOG(pg_task_run_history,9993,TaskRunHistoryRelationId) BKI_SHARED_RELATION { - Oid runid; - Oid jobid; + Oid runid; + Oid jobid; int32 job_pid BKI_DEFAULT(0); + timestamptz start_time BKI_FORCE_NULL; + timestamptz end_time BKI_FORCE_NULL; +#ifdef CATALOG_VARLEN /* variable-length fields start here */ text database; text username; text command; text status; - text return_message; - timestamptz start_time; - timestamptz end_time; + text return_message BKI_FORCE_NULL; +#endif } FormData_pg_task_run_history; typedef FormData_pg_task_run_history *Form_pg_task_run_history;