diff options
author | Michael Paquier <michael@paquier.xyz> | 2024-09-18 12:44:15 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2024-09-18 12:44:15 +0900 |
commit | b14e9ce7d55c75ffa160b07765eb9dffde70b5fa (patch) | |
tree | 4f4d177f99d9f755a0dd068578943afcc1035a75 /src/test | |
parent | ac04aa84a7f06635748278e6ff4bd74751bb3e8e (diff) |
Extend PgStat_HashKey.objid from 4 to 8 bytes
This opens the possibility to define keys for more types of statistics
kinds in PgStat_HashKey, the first case being 8-byte query IDs for
statistics like pg_stat_statements.
This increases the size of PgStat_HashKey from 12 to 16 bytes, while
PgStatShared_HashEntry, entry stored in the dshash for pgstats, keeps
the same size due to alignment.
xl_xact_stats_item, that tracks the stats items to drop in commit WAL
records, is increased from 12 to 16 bytes. Note that individual chunks
in commit WAL records should be multiples of sizeof(int), hence 8-byte
object IDs are stored as two uint32, based on a suggestion from Heikki
Linnakangas.
While on it, the field of PgStat_HashKey is renamed from "objoid" to
"objid", as for some stats kinds this field does not refer to OIDs but
just IDs, like for replication slot stats.
This commit bumps the following format variables:
- PGSTAT_FILE_FORMAT_ID, as PgStat_HashKey is written to the stats file
for non-serialized stats kinds in the dshash table.
- XLOG_PAGE_MAGIC for the changes in xl_xact_stats_item.
- Catalog version, for the SQL function pg_stat_have_stats().
Reviewed-by: Bertrand Drouvot
Discussion: https://postgr.es/m/ZsvTS9EW79Up8I62@paquier.xyz
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/modules/injection_points/injection_stats.c | 4 | ||||
-rw-r--r-- | src/test/recovery/t/029_stats_restart.pl | 4 | ||||
-rw-r--r-- | src/test/regress/expected/stats.out | 2 | ||||
-rw-r--r-- | src/test/regress/sql/stats.sql | 2 |
4 files changed, 6 insertions, 6 deletions
diff --git a/src/test/modules/injection_points/injection_stats.c b/src/test/modules/injection_points/injection_stats.c index 582686a0a83..d89d0559134 100644 --- a/src/test/modules/injection_points/injection_stats.c +++ b/src/test/modules/injection_points/injection_stats.c @@ -51,9 +51,9 @@ static const PgStat_KindInfo injection_stats = { }; /* - * Compute stats entry idx from point name with a 4-byte hash. + * Compute stats entry idx from point name with an 8-byte hash. */ -#define PGSTAT_INJ_IDX(name) hash_bytes((const unsigned char *) name, strlen(name)) +#define PGSTAT_INJ_IDX(name) hash_bytes_extended((const unsigned char *) name, strlen(name), 0) /* * Kind ID reserved for statistics of injection points. diff --git a/src/test/recovery/t/029_stats_restart.pl b/src/test/recovery/t/029_stats_restart.pl index 93a7209f69a..d14ac124181 100644 --- a/src/test/recovery/t/029_stats_restart.pl +++ b/src/test/recovery/t/029_stats_restart.pl @@ -292,10 +292,10 @@ sub trigger_funcrel_stat sub have_stats { - my ($kind, $dboid, $objoid) = @_; + my ($kind, $dboid, $objid) = @_; return $node->safe_psql($connect_db, - "SELECT pg_stat_have_stats('$kind', $dboid, $objoid)"); + "SELECT pg_stat_have_stats('$kind', $dboid, $objid)"); } sub overwrite_file diff --git a/src/test/regress/expected/stats.out b/src/test/regress/expected/stats.out index 6e08898b183..56771f83edf 100644 --- a/src/test/regress/expected/stats.out +++ b/src/test/regress/expected/stats.out @@ -1120,7 +1120,7 @@ SELECT pg_stat_have_stats('bgwriter', 0, 0); -- unknown stats kinds error out SELECT pg_stat_have_stats('zaphod', 0, 0); ERROR: invalid statistics kind: "zaphod" --- db stats have objoid 0 +-- db stats have objid 0 SELECT pg_stat_have_stats('database', :dboid, 1); pg_stat_have_stats -------------------- diff --git a/src/test/regress/sql/stats.sql b/src/test/regress/sql/stats.sql index d8ac0d06f48..7147cc2f895 100644 --- a/src/test/regress/sql/stats.sql +++ b/src/test/regress/sql/stats.sql @@ -542,7 +542,7 @@ ROLLBACK; SELECT pg_stat_have_stats('bgwriter', 0, 0); -- unknown stats kinds error out SELECT pg_stat_have_stats('zaphod', 0, 0); --- db stats have objoid 0 +-- db stats have objid 0 SELECT pg_stat_have_stats('database', :dboid, 1); SELECT pg_stat_have_stats('database', :dboid, 0); |