public inbox for [email protected]help / color / mirror / Atom feed
Add pg_freespacemap extension sql test 5+ messages / 3 participants [nested] [flat]
* Add pg_freespacemap extension sql test @ 2022-03-08 14:39 Dong Wook Lee <[email protected]> 0 siblings, 2 replies; 5+ messages in thread From: Dong Wook Lee @ 2022-03-08 14:39 UTC (permalink / raw) To: pgsql-hackers Hi, I just added some tests for the pg_freespacemap extension because the test coverage was 0 percent. But I don't know if I did it correctly. --- Regards Lee Dong Wook Attachments: [application/octet-stream] 0001_add_link_fsm.patch (653B, ../../CAAcByaJ5KW3bd7fJr=jPEyK8M_UzXJFHHBVuOcBe+JHD8txRyQ@mail.gmail.com/3-0001_add_link_fsm.patch) download | inline diff: diff --git a/doc/src/sgml/pgfreespacemap.sgml b/doc/src/sgml/pgfreespacemap.sgml index 5025498249..0ab3307e9c 100644 --- a/doc/src/sgml/pgfreespacemap.sgml +++ b/doc/src/sgml/pgfreespacemap.sgml @@ -9,7 +9,7 @@ <para> The <filename>pg_freespacemap</filename> module provides a means for examining the - free space map (FSM). It provides a function called + <link linkend="storage-fsm">free space map</link> (FSM). It provides a function called <function>pg_freespace</function>, or two overloaded functions, to be precise. The functions show the value recorded in the free space map for a given page, or for all pages in the relation. ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Add pg_freespacemap extension sql test @ 2022-03-08 14:43 Dong Wook Lee <[email protected]> parent: Dong Wook Lee <[email protected]> 1 sibling, 0 replies; 5+ messages in thread From: Dong Wook Lee @ 2022-03-08 14:43 UTC (permalink / raw) To: pgsql-hackers I'm sorry for attaching the wrong patch file. 2022년 3월 8일 (화) 오후 11:39, Dong Wook Lee <[email protected]>님이 작성: > Hi, > I just added some tests for the pg_freespacemap extension because the test > coverage was 0 percent. > But I don't know if I did it correctly. > > --- > Regards > Lee Dong Wook > Attachments: [application/octet-stream] 0001_add_test_pg_fsm.patch (2.0K, ../../CAAcByaKWYktP-DdZMZ-NSKiuXK5XtGKTKM5P8ae1EfNF2EKguA@mail.gmail.com/3-0001_add_test_pg_fsm.patch) download | inline diff: diff --git a/contrib/pg_freespacemap/Makefile b/contrib/pg_freespacemap/Makefile index da40b80c7c..2d525a1284 100644 --- a/contrib/pg_freespacemap/Makefile +++ b/contrib/pg_freespacemap/Makefile @@ -10,6 +10,8 @@ DATA = pg_freespacemap--1.1.sql pg_freespacemap--1.1--1.2.sql \ pg_freespacemap--1.0--1.1.sql PGFILEDESC = "pg_freespacemap - monitoring of free space map" +REGRESS = pg_freespacemap + ifdef USE_PGXS PG_CONFIG = pg_config PGXS := $(shell $(PG_CONFIG) --pgxs) diff --git a/contrib/pg_freespacemap/expected/pg_freespacemap.out b/contrib/pg_freespacemap/expected/pg_freespacemap.out new file mode 100644 index 0000000000..fc975b9050 --- /dev/null +++ b/contrib/pg_freespacemap/expected/pg_freespacemap.out @@ -0,0 +1,36 @@ +CREATE EXTENSION pg_freespacemap; +CREATE TABLE t1(c1 int); +INSERT INTO t1 VALUES (generate_series(1, 1000)); +VACUUM t1; +SELECT * FROM pg_freespace('t1'); + blkno | avail +-------+------- + 0 | 0 + 1 | 0 + 2 | 0 + 3 | 0 + 4 | 4704 +(5 rows) + +DELETE FROM t1 WHERE c1 <= 10; +VACUUM t1; +SELECT * FROM pg_freespace('t1'); + blkno | avail +-------+------- + 0 | 320 + 1 | 0 + 2 | 0 + 3 | 0 + 4 | 4704 +(5 rows) + +SELECT * FROM pg_freespace('t1', 0); + pg_freespace +-------------- + 320 +(1 row) + +SELECT * FROM pg_freespace('t1', -1); +ERROR: invalid block number +SELECT * FROM pg_freespace('t1', 4294967295); +ERROR: invalid block number diff --git a/contrib/pg_freespacemap/sql/pg_freespacemap.sql b/contrib/pg_freespacemap/sql/pg_freespacemap.sql new file mode 100644 index 0000000000..cc175322cd --- /dev/null +++ b/contrib/pg_freespacemap/sql/pg_freespacemap.sql @@ -0,0 +1,17 @@ +CREATE EXTENSION pg_freespacemap; + +CREATE TABLE t1(c1 int); + +INSERT INTO t1 VALUES (generate_series(1, 1000)); +VACUUM t1; + +SELECT * FROM pg_freespace('t1'); + +DELETE FROM t1 WHERE c1 <= 10; +VACUUM t1; + +SELECT * FROM pg_freespace('t1'); +SELECT * FROM pg_freespace('t1', 0); + +SELECT * FROM pg_freespace('t1', -1); +SELECT * FROM pg_freespace('t1', 4294967295); ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Add pg_freespacemap extension sql test @ 2022-03-08 14:45 Justin Pryzby <[email protected]> parent: Dong Wook Lee <[email protected]> 1 sibling, 1 reply; 5+ messages in thread From: Justin Pryzby @ 2022-03-08 14:45 UTC (permalink / raw) To: Dong Wook Lee <[email protected]>; +Cc: pgsql-hackers On Tue, Mar 08, 2022 at 11:39:08PM +0900, Dong Wook Lee wrote: > Hi, > I just added some tests for the pg_freespacemap extension because the test > coverage was 0 percent. > But I don't know if I did it correctly. The patch only touches doc/*.sgml. I suppose you forgot to use "git add". -- Justin ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Add pg_freespacemap extension sql test @ 2022-03-08 14:54 Dong Wook Lee <[email protected]> parent: Justin Pryzby <[email protected]> 0 siblings, 0 replies; 5+ messages in thread From: Dong Wook Lee @ 2022-03-08 14:54 UTC (permalink / raw) To: Justin Pryzby <[email protected]>; +Cc: pgsql-hackers That's right, so I attached the correct file again. 2022년 3월 8일 (화) 오후 11:45, Justin Pryzby <[email protected]>님이 작성: > On Tue, Mar 08, 2022 at 11:39:08PM +0900, Dong Wook Lee wrote: > > Hi, > > I just added some tests for the pg_freespacemap extension because the > test > > coverage was 0 percent. > > But I don't know if I did it correctly. > > The patch only touches doc/*.sgml. > I suppose you forgot to use "git add". > > -- > Justin > ^ permalink raw reply [nested|flat] 5+ messages in thread
* [PATCH v1 1/1] remove WaitEventCustomCounterData @ 2026-07-09 02:50 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 5+ messages in thread From: Nathan Bossart @ 2026-07-09 02:50 UTC (permalink / raw) --- src/backend/utils/activity/wait_event.c | 29 ++++++------------------- src/tools/pgindent/typedefs.list | 1 - 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/backend/utils/activity/wait_event.c b/src/backend/utils/activity/wait_event.c index 95635c7f56c..7ee6f99fb50 100644 --- a/src/backend/utils/activity/wait_event.c +++ b/src/backend/utils/activity/wait_event.c @@ -81,14 +81,7 @@ typedef struct WaitEventCustomEntryByName /* dynamic allocation counter for custom wait events */ -typedef struct WaitEventCustomCounterData -{ - int nextId; /* next ID to assign */ - slock_t mutex; /* protects the counter */ -} WaitEventCustomCounterData; - -/* pointer to the shared memory */ -static WaitEventCustomCounterData *WaitEventCustomCounter; +static int *WaitEventCustomCounter; /* first event ID of custom wait events */ #define WAIT_EVENT_CUSTOM_INITIAL_ID 1 @@ -110,8 +103,8 @@ const ShmemCallbacks WaitEventCustomShmemCallbacks = { static void WaitEventCustomShmemRequest(void *arg) { - ShmemRequestStruct(.name = "WaitEventCustomCounterData", - .size = sizeof(WaitEventCustomCounterData), + ShmemRequestStruct(.name = "WaitEventCustomCounter", + .size = sizeof(int), .ptr = (void **) &WaitEventCustomCounter, ); ShmemRequestHash(.name = "WaitEventCustom hash by wait event information", @@ -134,9 +127,8 @@ WaitEventCustomShmemRequest(void *arg) static void WaitEventCustomShmemInit(void *arg) { - /* initialize the allocation counter and its spinlock. */ - WaitEventCustomCounter->nextId = WAIT_EVENT_CUSTOM_INITIAL_ID; - SpinLockInit(&WaitEventCustomCounter->mutex); + /* initialize the allocation counter */ + *WaitEventCustomCounter = WAIT_EVENT_CUSTOM_INITIAL_ID; } /* @@ -221,19 +213,12 @@ WaitEventCustomNew(uint32 classId, const char *wait_event_name) } /* Allocate a new event Id */ - SpinLockAcquire(&WaitEventCustomCounter->mutex); - - if (WaitEventCustomCounter->nextId >= WAIT_EVENT_CUSTOM_HASH_SIZE) - { - SpinLockRelease(&WaitEventCustomCounter->mutex); + if (*WaitEventCustomCounter >= WAIT_EVENT_CUSTOM_HASH_SIZE) ereport(ERROR, errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), errmsg("too many custom wait events")); - } - - eventId = WaitEventCustomCounter->nextId++; - SpinLockRelease(&WaitEventCustomCounter->mutex); + eventId = (*WaitEventCustomCounter)++; /* Register the new wait event */ wait_event_info = classId | eventId; diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index ffb413ab612..3174e0e4ab8 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -3418,7 +3418,6 @@ WaitEvent WaitEventActivity WaitEventBuffer WaitEventClient -WaitEventCustomCounterData WaitEventCustomEntryByInfo WaitEventCustomEntryByName WaitEventIO -- 2.50.1 (Apple Git-155) --65l7A33W789+zwjF-- ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2026-07-09 02:50 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2022-03-08 14:39 Add pg_freespacemap extension sql test Dong Wook Lee <[email protected]> 2022-03-08 14:43 ` Dong Wook Lee <[email protected]> 2022-03-08 14:45 ` Justin Pryzby <[email protected]> 2022-03-08 14:54 ` Dong Wook Lee <[email protected]> 2026-07-09 02:50 [PATCH v1 1/1] remove WaitEventCustomCounterData Nathan Bossart <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox