diff options
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r-- | src/backend/utils/adt/pgstatfuncs.c | 37 | ||||
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 33 |
2 files changed, 57 insertions, 13 deletions
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 7e89a8048d5..1fe33df2756 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -204,6 +204,24 @@ PG_STAT_GET_FUNCENTRY_FLOAT8_MS(total_time) PG_STAT_GET_FUNCENTRY_FLOAT8_MS(self_time) Datum +pg_stat_get_function_stat_reset_time(PG_FUNCTION_ARGS) +{ + Oid funcid = PG_GETARG_OID(0); + TimestampTz result; + PgStat_StatFuncEntry *funcentry; + + if ((funcentry = pgstat_fetch_stat_funcentry(funcid)) == NULL) + result = 0; + else + result = funcentry->stat_reset_timestamp; + + if (result == 0) + PG_RETURN_NULL(); + else + PG_RETURN_TIMESTAMPTZ(result); +} + +Datum pg_stat_get_backend_idset(PG_FUNCTION_ARGS) { FuncCallContext *funcctx; @@ -2103,7 +2121,7 @@ pg_stat_get_archiver(PG_FUNCTION_ARGS) Datum pg_stat_get_replication_slot(PG_FUNCTION_ARGS) { -#define PG_STAT_GET_REPLICATION_SLOT_COLS 10 +#define PG_STAT_GET_REPLICATION_SLOT_COLS 11 text *slotname_text = PG_GETARG_TEXT_P(0); NameData slotname; TupleDesc tupdesc; @@ -2128,11 +2146,13 @@ pg_stat_get_replication_slot(PG_FUNCTION_ARGS) INT8OID, -1, 0); TupleDescInitEntry(tupdesc, (AttrNumber) 7, "stream_bytes", INT8OID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 8, "total_txns", + TupleDescInitEntry(tupdesc, (AttrNumber) 8, "mem_exceeded_count", + INT8OID, -1, 0); + TupleDescInitEntry(tupdesc, (AttrNumber) 9, "total_txns", INT8OID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 9, "total_bytes", + TupleDescInitEntry(tupdesc, (AttrNumber) 10, "total_bytes", INT8OID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 10, "stats_reset", + TupleDescInitEntry(tupdesc, (AttrNumber) 11, "stats_reset", TIMESTAMPTZOID, -1, 0); BlessTupleDesc(tupdesc); @@ -2155,13 +2175,14 @@ pg_stat_get_replication_slot(PG_FUNCTION_ARGS) values[4] = Int64GetDatum(slotent->stream_txns); values[5] = Int64GetDatum(slotent->stream_count); values[6] = Int64GetDatum(slotent->stream_bytes); - values[7] = Int64GetDatum(slotent->total_txns); - values[8] = Int64GetDatum(slotent->total_bytes); + values[7] = Int64GetDatum(slotent->mem_exceeded_count); + values[8] = Int64GetDatum(slotent->total_txns); + values[9] = Int64GetDatum(slotent->total_bytes); if (slotent->stat_reset_timestamp == 0) - nulls[9] = true; + nulls[10] = true; else - values[9] = TimestampTzGetDatum(slotent->stat_reset_timestamp); + values[10] = TimestampTzGetDatum(slotent->stat_reset_timestamp); /* Returns the record as Datum */ PG_RETURN_DATUM(HeapTupleGetDatum(heap_form_tuple(tupdesc, values, nulls))); diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 21663af6979..050eef97a4c 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -8751,8 +8751,16 @@ get_parameter(Param *param, deparse_context *context) subplan = find_param_generator(param, context, &column); if (subplan) { - appendStringInfo(context->buf, "(%s%s).col%d", + const char *nameprefix; + + if (subplan->isInitPlan) + nameprefix = "InitPlan "; + else + nameprefix = "SubPlan "; + + appendStringInfo(context->buf, "(%s%s%s).col%d", subplan->useHashTable ? "hashed " : "", + nameprefix, subplan->plan_name, column + 1); return; @@ -9589,11 +9597,19 @@ get_rule_expr(Node *node, deparse_context *context, } else { + const char *nameprefix; + /* No referencing Params, so show the SubPlan's name */ + if (subplan->isInitPlan) + nameprefix = "InitPlan "; + else + nameprefix = "SubPlan "; if (subplan->useHashTable) - appendStringInfo(buf, "hashed %s)", subplan->plan_name); + appendStringInfo(buf, "hashed %s%s)", + nameprefix, subplan->plan_name); else - appendStringInfo(buf, "%s)", subplan->plan_name); + appendStringInfo(buf, "%s%s)", + nameprefix, subplan->plan_name); } } break; @@ -9613,11 +9629,18 @@ get_rule_expr(Node *node, deparse_context *context, foreach(lc, asplan->subplans) { SubPlan *splan = lfirst_node(SubPlan, lc); + const char *nameprefix; + if (splan->isInitPlan) + nameprefix = "InitPlan "; + else + nameprefix = "SubPlan "; if (splan->useHashTable) - appendStringInfo(buf, "hashed %s", splan->plan_name); + appendStringInfo(buf, "hashed %s%s", nameprefix, + splan->plan_name); else - appendStringInfoString(buf, splan->plan_name); + appendStringInfo(buf, "%s%s", nameprefix, + splan->plan_name); if (lnext(asplan->subplans, lc)) appendStringInfoString(buf, " or "); } |