1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

pageinspect: Change block number arguments to bigint

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
This commit is contained in:
Peter Eisentraut
2021-01-19 10:28:05 +01:00
parent ee79a548e7
commit f18aa1b203
18 changed files with 328 additions and 31 deletions

View File

@ -19,7 +19,7 @@
<variablelist>
<varlistentry>
<term>
<function>get_raw_page(relname text, fork text, blkno int) returns bytea</function>
<function>get_raw_page(relname text, fork text, blkno bigint) returns bytea</function>
<indexterm>
<primary>get_raw_page</primary>
</indexterm>
@ -40,7 +40,7 @@
<varlistentry>
<term>
<function>get_raw_page(relname text, blkno int) returns bytea</function>
<function>get_raw_page(relname text, blkno bigint) returns bytea</function>
</term>
<listitem>
@ -91,7 +91,7 @@ test=# SELECT * FROM page_header(get_raw_page('pg_class', 0));
<varlistentry>
<term>
<function>page_checksum(page bytea, blkno int4) returns smallint</function>
<function>page_checksum(page bytea, blkno bigint) returns smallint</function>
<indexterm>
<primary>page_checksum</primary>
</indexterm>
@ -315,7 +315,7 @@ allequalimage | f
<varlistentry>
<term>
<function>bt_page_stats(relname text, blkno int) returns record</function>
<function>bt_page_stats(relname text, blkno bigint) returns record</function>
<indexterm>
<primary>bt_page_stats</primary>
</indexterm>
@ -346,7 +346,7 @@ btpo_flags | 3
<varlistentry>
<term>
<function>bt_page_items(relname text, blkno int) returns setof record</function>
<function>bt_page_items(relname text, blkno bigint) returns setof record</function>
<indexterm>
<primary>bt_page_items</primary>
</indexterm>
@ -845,7 +845,7 @@ test=# SELECT * FROM hash_page_items(get_raw_page('con_hash_index', 1)) LIMIT 5;
<varlistentry>
<term>
<function>hash_bitmap_info(index oid, blkno int) returns record</function>
<function>hash_bitmap_info(index oid, blkno bigint) returns record</function>
<indexterm>
<primary>hash_bitmap_info</primary>
</indexterm>