File tree Expand file tree Collapse file tree 4 files changed +98
-1
lines changed Expand file tree Collapse file tree 4 files changed +98
-1
lines changed Original file line number Diff line number Diff line change @@ -254,13 +254,28 @@ const baseExtensions: Extension[] = [
254254 only as a last resort.
255255 ` ,
256256 shortDescription : 'Perform low-level surgery on relation data' ,
257- docs : 'https://www.postgresql.org/docs/18/dict-int .html' ,
257+ docs : 'https://www.postgresql.org/docs/current/pgsurgery .html' ,
258258 tags : [ 'postgres extension' , 'postgres/contrib' ] ,
259259 importPath : '@electric-sql/pglite/contrib/pg_surgery' ,
260260 importName : 'pg_surgery' ,
261261 core : true ,
262262 size : 2635 ,
263263 } ,
264+ {
265+ name : 'pg_visibility' ,
266+ description : `
267+ The pg_visibility module provides a means for examining the visibility map (VM)
268+ and page-level visibility information of a table. It also provides functions to
269+ check the integrity of a visibility map and to force it to be rebuilt.
270+ ` ,
271+ shortDescription : 'Visibility map information and utilities' ,
272+ docs : 'https://www.postgresql.org/docs/current/pgvisibility.html' ,
273+ tags : [ 'postgres extension' , 'postgres/contrib' ] ,
274+ importPath : '@electric-sql/pglite/contrib/pg_visibility' ,
275+ importName : 'pg_visibility' ,
276+ core : true ,
277+ size : 4159 ,
278+ } ,
264279 {
265280 name : 'pg_freespacemap' ,
266281 description : `
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export { pg_buffercache } from '@electric-sql/pglite/contrib/pg_buffercache'
2020export { pg_freespacemap } from '@electric-sql/pglite/contrib/pg_freespacemap'
2121export { pg_surgery } from '@electric-sql/pglite/contrib/pg_surgery'
2222export { pg_trgm } from '@electric-sql/pglite/contrib/pg_trgm'
23+ export { pg_visibility } from '@electric-sql/pglite/contrib/pg_visibility'
2324export { seg } from '@electric-sql/pglite/contrib/seg'
2425export { tablefunc } from '@electric-sql/pglite/contrib/tablefunc'
2526export { tcn } from '@electric-sql/pglite/contrib/tcn'
Original file line number Diff line number Diff line change 1+ import type {
2+ Extension ,
3+ ExtensionSetupResult ,
4+ PGliteInterface ,
5+ } from '../interface'
6+
7+ const setup = async ( _pg : PGliteInterface , _emscriptenOpts : any ) => {
8+ return {
9+ bundlePath : new URL ( '../../release/pg_visibility.tar.gz' , import . meta. url ) ,
10+ } satisfies ExtensionSetupResult
11+ }
12+
13+ export const pg_visibility = {
14+ name : 'pg_visibility' ,
15+ setup,
16+ } satisfies Extension
Original file line number Diff line number Diff line change 1+ import { it , expect } from 'vitest'
2+ import { PGlite } from '../../dist/index.js'
3+ import { pg_visibility } from '../../dist/contrib/pg_visibility.js'
4+
5+ it ( 'pg_visibility' , async ( ) => {
6+ const pg = await PGlite . create ( {
7+ extensions : {
8+ pg_visibility,
9+ } ,
10+ } )
11+
12+ await pg . exec ( 'CREATE EXTENSION IF NOT EXISTS pg_visibility;' )
13+
14+ await pg . exec ( `
15+ CREATE TABLE IF NOT EXISTS test (
16+ id SERIAL PRIMARY KEY,
17+ name TEXT
18+ );
19+ ` )
20+
21+ await pg . exec ( `
22+ INSERT INTO test (name) VALUES ('test');
23+ UPDATE test SET name = 'test2';
24+ SELECT * FROM test;
25+ ` )
26+
27+ const visible = await pg . query ( `
28+ -- Show all invisible tuples in a specific table using pg_visibility
29+ SELECT *
30+ FROM pg_visibility('test')
31+ WHERE all_visible = false;
32+ ` )
33+
34+ expect ( visible . rows ) . toEqual ( [
35+ {
36+ blkno : 0 ,
37+ all_visible : false ,
38+ all_frozen : false ,
39+ pd_all_visible : false ,
40+ } ,
41+ ] )
42+
43+ const visibilityMap = await pg . query ( `
44+ -- Check visibility map status for a table
45+ SELECT *
46+ FROM pg_visibility_map('test');
47+ ` )
48+
49+ expect ( visibilityMap . rows ) . toEqual ( [
50+ {
51+ blkno : 0 ,
52+ all_visible : false ,
53+ all_frozen : false ,
54+ } ,
55+ ] )
56+
57+ const frozen = await pg . query ( `
58+ -- Find pages with all-frozen tuples
59+ SELECT *
60+ FROM pg_visibility('test')
61+ WHERE all_frozen = true;
62+ ` )
63+
64+ expect ( frozen . rows ) . toEqual ( [ ] )
65+ } )
You can’t perform that action at this time.
0 commit comments