Re: [HACKERS] PATCH: pageinspect / add page_checksum and bt_page_items(bytea) - Mailing list pgsql-hackers

From Ashutosh Sharma
Subject Re: [HACKERS] PATCH: pageinspect / add page_checksum and bt_page_items(bytea)
Date
Msg-id CAE9k0PkvB4tAR6iFvF3CWtY0yHURxqD_n+7OicFW_4F7V8TYug@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] PATCH: pageinspect / add page_checksum andbt_page_items(bytea)  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Responses Re: [HACKERS] PATCH: pageinspect / add page_checksum andbt_page_items(bytea)  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
Hi,

>
>> 2) It seems like you have choosen wrong datatype for page_checksum. I
>> am getting negative checksum value when trying to run below query. I
>> think the return type for the SQL function page_checksum should be
>> 'integer' instead of 'smallint'.
>>
>> postgres=# SELECT page_checksum(get_raw_page('pg_class', 0), 100);
>>  page_checksum
>> ---------------
>>         -19532
>> (1 row)
>>
>> Above problem also exist in case of page_header. I am facing similar
>> problem with page_header as well.
>>
>> postgres=# SELECT page_header(get_raw_page('pg_class', 0));
>>                  page_header
>> ---------------------------------------------
>>  (0/2891538,-28949,1,220,7216,8192,8192,4,0)
>> (1 row)
>>
>
> No. This is consistent with page_header() which is also using smallint for
> the checksum value.
>

Yes. But, as i said earlier I am getting negative checksum value for
page_header as well. Isn't that wrong. For eg. When I debug the
following query, i could pd_checksum value as '40074' in gdb where
page_header shows it as '-25462'.

SELECT page_header(get_raw_page('pg_class', 0));

(gdb) p    page->pd_checksum
$2 = 40074

postgres=# SELECT page_header(get_raw_page('pg_class', 0));                page_header
---------------------------------------------(0/304EDE0,-25462,1,220,7432,8192,8192,4,0)
(1 row)

I think pd_checksum in PageHeaderData is defined as uint16 (0 to
65,535) whereas in SQL function for page_header it is defined as
smallint (-32768 to +32767).

--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [HACKERS] scram and \password
Next
From: Pavel Stehule
Date:
Subject: [HACKERS] ToDo: listagg is in ANSI/SQL:2016