mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
Add "own_hash" to pg_stat_kind_info
This is a follow-up of 44539786b8, to reflect the value of the new
"own_hash" option to pg_stat_kind_info. Thanks to this change, it
becomes possible to know if a stats kind has the idea to use its own
shared hashtable in pgstats.
Bump catalog version.
Author: Sami Imseih <samimseih@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/CAA5RZ0supQBxSkh=CWB39=j+cL3hHcLPki3tcBk0B1r4fesg_g@mail.gmail.com
This commit is contained in:
@@ -3574,6 +3574,19 @@ description | Waiting for a newly initialized WAL file to reach durable storage
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry">
|
||||
<para role="column_definition">
|
||||
<structfield>own_hash</structfield> <type>boolean</type>
|
||||
</para>
|
||||
<para>
|
||||
For variable-numbered statistics kinds, true if entries of this kind
|
||||
are stored in a dedicated hash table, false if they are stored in the
|
||||
shared hash table. False for fixed-numbered statistics kinds.
|
||||
</para>
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry role="catalog_table_entry">
|
||||
<para role="column_definition">
|
||||
|
||||
@@ -1290,6 +1290,7 @@ CREATE VIEW pg_stat_kind_info AS
|
||||
k.fixed_amount,
|
||||
k.accessed_across_databases,
|
||||
k.write_to_file,
|
||||
k.own_hash,
|
||||
k.entry_count
|
||||
FROM pg_stat_get_kind_info() k;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
Datum
|
||||
pg_stat_get_kind_info(PG_FUNCTION_ARGS)
|
||||
{
|
||||
#define PG_STAT_KIND_INFO_COLS 7
|
||||
#define PG_STAT_KIND_INFO_COLS 8
|
||||
ReturnSetInfo *rsinfo;
|
||||
|
||||
InitMaterializedSRF(fcinfo, 0);
|
||||
@@ -54,15 +54,16 @@ pg_stat_get_kind_info(PG_FUNCTION_ARGS)
|
||||
values[3] = BoolGetDatum(info->fixed_amount);
|
||||
values[4] = BoolGetDatum(info->accessed_across_databases);
|
||||
values[5] = BoolGetDatum(info->write_to_file);
|
||||
values[6] = BoolGetDatum(info->own_hash);
|
||||
|
||||
/*
|
||||
* When track_entry_count is disabled, use NULL. Fixed-sized stats
|
||||
* kinds report NULL here.
|
||||
*/
|
||||
if (info->track_entry_count)
|
||||
values[6] = Int64GetDatum(pgstat_get_entry_count(kind));
|
||||
values[7] = Int64GetDatum(pgstat_get_entry_count(kind));
|
||||
else
|
||||
nulls[6] = true;
|
||||
nulls[7] = true;
|
||||
|
||||
tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls);
|
||||
}
|
||||
|
||||
@@ -57,6 +57,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 202610061
|
||||
#define CATALOG_VERSION_NO 202610131
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6075,9 +6075,10 @@
|
||||
{ oid => '8683', descr => 'statistics: information about statistics kinds',
|
||||
proname => 'pg_stat_get_kind_info', prorows => '20', proretset => 't',
|
||||
provolatile => 'v', proparallel => 'r', prorettype => 'record',
|
||||
proargtypes => '', proallargtypes => '{int4,text,bool,bool,bool,bool,int8}',
|
||||
proargmodes => '{o,o,o,o,o,o,o}',
|
||||
proargnames => '{id,name,builtin,fixed_amount,accessed_across_databases,write_to_file,entry_count}',
|
||||
proargtypes => '',
|
||||
proallargtypes => '{int4,text,bool,bool,bool,bool,bool,int8}',
|
||||
proargmodes => '{o,o,o,o,o,o,o,o}',
|
||||
proargnames => '{id,name,builtin,fixed_amount,accessed_across_databases,write_to_file,own_hash,entry_count}',
|
||||
prosrc => 'pg_stat_get_kind_info' },
|
||||
|
||||
{ oid => '1136', descr => 'statistics: information about WAL activity',
|
||||
|
||||
@@ -33,12 +33,12 @@ $node->safe_psql('postgres', q(CREATE EXTENSION test_custom_fixed_stats));
|
||||
$result = $node->safe_psql(
|
||||
'postgres',
|
||||
q(SELECT id, name, builtin, fixed_amount, accessed_across_databases,
|
||||
write_to_file
|
||||
write_to_file, own_hash
|
||||
FROM pg_stat_kind_info
|
||||
WHERE name LIKE 'test_custom%' ORDER BY id));
|
||||
is( $result,
|
||||
qq{25|test_custom_var_stats|f|f|t|t
|
||||
26|test_custom_fixed_stats|f|t|f|t},
|
||||
qq{25|test_custom_var_stats|f|f|t|t|f
|
||||
26|test_custom_fixed_stats|f|t|f|t|f},
|
||||
"custom stats kinds visible in pg_stat_kind_info");
|
||||
|
||||
my @var_stats_kinds = (
|
||||
@@ -66,6 +66,10 @@ foreach my $stats_kind (@var_stats_kinds)
|
||||
"'$kind_name'");
|
||||
$node->restart;
|
||||
|
||||
$result = $node->safe_psql('postgres',
|
||||
"SELECT own_hash FROM pg_stat_kind_info WHERE name = '$kind_name'");
|
||||
is($result, $own_hash, "dedicated hash reported for $kind_name");
|
||||
|
||||
# Create entries for variable-sized stats.
|
||||
$node->safe_psql('postgres',
|
||||
q(select test_custom_stats_var_create('entry1', 'Test entry 1')));
|
||||
|
||||
@@ -1973,8 +1973,9 @@ pg_stat_kind_info| SELECT id,
|
||||
fixed_amount,
|
||||
accessed_across_databases,
|
||||
write_to_file,
|
||||
own_hash,
|
||||
entry_count
|
||||
FROM pg_stat_get_kind_info() k(id, name, builtin, fixed_amount, accessed_across_databases, write_to_file, entry_count);
|
||||
FROM pg_stat_get_kind_info() k(id, name, builtin, fixed_amount, accessed_across_databases, write_to_file, own_hash, entry_count);
|
||||
pg_stat_lock| SELECT locktype,
|
||||
waits,
|
||||
wait_time,
|
||||
|
||||
Reference in New Issue
Block a user