Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2eff9e6

Browse files
committed
Add helper routines to retrieve data for custom fixed-numbered pgstats
This is useful for extensions to get snapshot and shmem data for customcumulative statistics when these have a fixed number of objects, so asthese do not need to know about the snapshot internals, aka pgStatLocal.An upcoming commit introducing an example template for custom cumulativestats with fixed-numbered objects will make use of these. I havenoticed that this is useful for extension developers while hacking myown example, actually.Author: Michael PaquierReviewed-by: Dmitry Dolgov, Bertrand DrouvotDiscussion:https://postgr.es/m/Zmqm9j5EO0I4W8dx@paquier.xyz
1 parent8036d73 commit2eff9e6

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

‎src/include/utils/pgstat_internal.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ static inline int pgstat_cmp_hash_key(const void *a, const void *b, size_t size,
525525
staticinlineuint32pgstat_hash_hash_key(constvoid*d,size_tsize,void*arg);
526526
staticinlinesize_tpgstat_get_entry_len(PgStat_Kindkind);
527527
staticinlinevoid*pgstat_get_entry_data(PgStat_Kindkind,PgStatShared_Common*entry);
528+
staticinlinevoid*pgstat_get_custom_shmem_data(PgStat_Kindkind);
529+
staticinlinevoid*pgstat_get_custom_snapshot_data(PgStat_Kindkind);
528530

529531

530532
/*
@@ -842,4 +844,34 @@ pgstat_get_entry_data(PgStat_Kind kind, PgStatShared_Common *entry)
842844
return ((char*) (entry))+off;
843845
}
844846

847+
/*
848+
* Returns a pointer to the shared memory area of custom stats for
849+
* fixed-numbered statistics.
850+
*/
851+
staticinlinevoid*
852+
pgstat_get_custom_shmem_data(PgStat_Kindkind)
853+
{
854+
intidx=kind-PGSTAT_KIND_CUSTOM_MIN;
855+
856+
Assert(pgstat_is_kind_custom(kind));
857+
Assert(pgstat_get_kind_info(kind)->fixed_amount);
858+
859+
returnpgStatLocal.shmem->custom_data[idx];
860+
}
861+
862+
/*
863+
* Returns a pointer to the portion of custom data for fixed-numbered
864+
* statistics in the current snapshot.
865+
*/
866+
staticinlinevoid*
867+
pgstat_get_custom_snapshot_data(PgStat_Kindkind)
868+
{
869+
intidx=kind-PGSTAT_KIND_CUSTOM_MIN;
870+
871+
Assert(pgstat_is_kind_custom(kind));
872+
Assert(pgstat_get_kind_info(kind)->fixed_amount);
873+
874+
returnpgStatLocal.snapshot.custom_data[idx];
875+
}
876+
845877
#endif/* PGSTAT_INTERNAL_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp