pg_freespacemap: Use SQL-standard function bodies

72a5b1fc8804 was the piece missing for the conversion of this module.
pg_freespace is bumped to 1.3, with its function pg_freespace(regclass)
converted to this new style.

There are other modules in the tree that need a similar treatment; these
will be handled later.

Author: Tom Lane
Reviewed-by: Ronan Dunklau
Discussion: https://postgr.es/m/3395418.1618352794@sss.pgh.pa.us
This commit is contained in:
Michael Paquier 2024-11-12 17:28:03 +09:00
parent db22b90024
commit 3f323eba89
4 changed files with 18 additions and 2 deletions

@ -6,7 +6,9 @@ OBJS = \
pg_freespacemap.o
EXTENSION = pg_freespacemap
DATA = pg_freespacemap--1.1.sql pg_freespacemap--1.1--1.2.sql \
DATA = pg_freespacemap--1.1.sql \
pg_freespacemap--1.2--1.3.sql \
pg_freespacemap--1.1--1.2.sql \
pg_freespacemap--1.0--1.1.sql
PGFILEDESC = "pg_freespacemap - monitoring of free space map"

@ -20,6 +20,7 @@ install_data(
'pg_freespacemap--1.0--1.1.sql',
'pg_freespacemap--1.1--1.2.sql',
'pg_freespacemap--1.1.sql',
'pg_freespacemap--1.2--1.3.sql',
'pg_freespacemap.control',
kwargs: contrib_data_args,
)

@ -0,0 +1,13 @@
/* contrib/pg_freespacemap/pg_freespacemap--1.2--1.3.sql */
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
\echo Use "ALTER EXTENSION pg_freespacemap UPDATE TO '1.3'" to load this file. \quit
CREATE OR REPLACE FUNCTION
pg_freespace(rel regclass, blkno OUT bigint, avail OUT int2)
RETURNS SETOF RECORD
LANGUAGE SQL PARALLEL SAFE
BEGIN ATOMIC
SELECT blkno, pg_freespace($1, blkno) AS avail
FROM generate_series(0, pg_relation_size($1) / current_setting('block_size')::bigint - 1) AS blkno;
END;

@ -1,5 +1,5 @@
# pg_freespacemap extension
comment = 'examine the free space map (FSM)'
default_version = '1.2'
default_version = '1.3'
module_pathname = '$libdir/pg_freespacemap'
relocatable = true