File: pg_freespacemap--1.2--1.3.sql

package info (click to toggle)
postgresql-18 18.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 156,452 kB
  • sloc: ansic: 993,977; sql: 127,739; perl: 59,135; xml: 30,905; yacc: 21,023; lex: 9,000; makefile: 6,883; sh: 5,372; cpp: 988; python: 710; asm: 40; sed: 3
file content (13 lines) | stat: -rw-r--r-- 554 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
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'::bigint, pg_relation_size($1) / current_setting('block_size'::text)::bigint - '1'::bigint) AS blkno;
END;