mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-12 11:58:03 +02:00
Block numbers are 32-bit unsigned integers. Therefore, the smallest SQL integer type that they can fit in is bigint. However, in the pageinspect module, most input and output parameters dealing with block numbers were declared as int. The behavior with block numbers larger than a signed 32-bit integer was therefore dubious. Change these arguments to type bigint and add some more explicit error checking on the block range. (Other contrib modules appear to do this correctly already.) Since we are changing argument types of existing functions, in order to not misbehave if the binary is updated before the extension is updated, we need to create new C symbols for the entry points, similar to how it's done in other extensions as well. Reported-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://www.postgresql.org/message-id/flat/d8f6bdd536df403b9b33816e9f7e0b9d@G08CNEXMBPEKD05.g08.fujitsu.local
119 lines
2.9 KiB
SQL
119 lines
2.9 KiB
SQL
/* contrib/pageinspect/pageinspect--1.8--1.9.sql */
|
|
|
|
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
|
|
\echo Use "ALTER EXTENSION pageinspect UPDATE TO '1.9'" to load this file. \quit
|
|
|
|
--
|
|
-- gist_page_opaque_info()
|
|
--
|
|
CREATE FUNCTION gist_page_opaque_info(IN page bytea,
|
|
OUT lsn pg_lsn,
|
|
OUT nsn pg_lsn,
|
|
OUT rightlink bigint,
|
|
OUT flags text[])
|
|
AS 'MODULE_PATHNAME', 'gist_page_opaque_info'
|
|
LANGUAGE C STRICT PARALLEL SAFE;
|
|
|
|
|
|
--
|
|
-- gist_page_items_bytea()
|
|
--
|
|
CREATE FUNCTION gist_page_items_bytea(IN page bytea,
|
|
OUT itemoffset smallint,
|
|
OUT ctid tid,
|
|
OUT itemlen smallint,
|
|
OUT key_data bytea)
|
|
RETURNS SETOF record
|
|
AS 'MODULE_PATHNAME', 'gist_page_items_bytea'
|
|
LANGUAGE C STRICT PARALLEL SAFE;
|
|
|
|
--
|
|
-- gist_page_items()
|
|
--
|
|
CREATE FUNCTION gist_page_items(IN page bytea,
|
|
IN index_oid regclass,
|
|
OUT itemoffset smallint,
|
|
OUT ctid tid,
|
|
OUT itemlen smallint,
|
|
OUT keys text)
|
|
RETURNS SETOF record
|
|
AS 'MODULE_PATHNAME', 'gist_page_items'
|
|
LANGUAGE C STRICT PARALLEL SAFE;
|
|
|
|
--
|
|
-- get_raw_page()
|
|
--
|
|
DROP FUNCTION get_raw_page(text, int4);
|
|
CREATE FUNCTION get_raw_page(text, int8)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'get_raw_page_1_9'
|
|
LANGUAGE C STRICT PARALLEL SAFE;
|
|
|
|
DROP FUNCTION get_raw_page(text, text, int4);
|
|
CREATE FUNCTION get_raw_page(text, text, int8)
|
|
RETURNS bytea
|
|
AS 'MODULE_PATHNAME', 'get_raw_page_fork_1_9'
|
|
LANGUAGE C STRICT PARALLEL SAFE;
|
|
|
|
--
|
|
-- page_checksum()
|
|
--
|
|
DROP FUNCTION page_checksum(IN page bytea, IN blkno int4);
|
|
CREATE FUNCTION page_checksum(IN page bytea, IN blkno int8)
|
|
RETURNS smallint
|
|
AS 'MODULE_PATHNAME', 'page_checksum_1_9'
|
|
LANGUAGE C STRICT PARALLEL SAFE;
|
|
|
|
--
|
|
-- bt_page_stats()
|
|
--
|
|
DROP FUNCTION bt_page_stats(text, int4);
|
|
CREATE FUNCTION bt_page_stats(IN relname text, IN blkno int8,
|
|
OUT blkno int8,
|
|
OUT type "char",
|
|
OUT live_items int4,
|
|
OUT dead_items int4,
|
|
OUT avg_item_size int4,
|
|
OUT page_size int4,
|
|
OUT free_size int4,
|
|
OUT btpo_prev int8,
|
|
OUT btpo_next int8,
|
|
OUT btpo int4,
|
|
OUT btpo_flags int4)
|
|
AS 'MODULE_PATHNAME', 'bt_page_stats_1_9'
|
|
LANGUAGE C STRICT PARALLEL SAFE;
|
|
|
|
--
|
|
-- bt_page_items()
|
|
--
|
|
DROP FUNCTION bt_page_items(text, int4);
|
|
CREATE FUNCTION bt_page_items(IN relname text, IN blkno int8,
|
|
OUT itemoffset smallint,
|
|
OUT ctid tid,
|
|
OUT itemlen smallint,
|
|
OUT nulls bool,
|
|
OUT vars bool,
|
|
OUT data text,
|
|
OUT dead boolean,
|
|
OUT htid tid,
|
|
OUT tids tid[])
|
|
RETURNS SETOF record
|
|
AS 'MODULE_PATHNAME', 'bt_page_items_1_9'
|
|
LANGUAGE C STRICT PARALLEL SAFE;
|
|
|
|
--
|
|
-- brin_page_items()
|
|
--
|
|
DROP FUNCTION brin_page_items(IN page bytea, IN index_oid regclass);
|
|
CREATE FUNCTION brin_page_items(IN page bytea, IN index_oid regclass,
|
|
OUT itemoffset int,
|
|
OUT blknum int8,
|
|
OUT attnum int,
|
|
OUT allnulls bool,
|
|
OUT hasnulls bool,
|
|
OUT placeholder bool,
|
|
OUT value text)
|
|
RETURNS SETOF record
|
|
AS 'MODULE_PATHNAME', 'brin_page_items'
|
|
LANGUAGE C STRICT PARALLEL SAFE;
|