| From: | Michael Paquier <michael(at)paquier(dot)xyz> | 
|---|---|
| To: | Quan Zongliang <quanzongliang(at)yeah(dot)net> | 
| Cc: | Justin Pryzby <pryzby(at)telsasoft(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org | 
| Subject: | Re: bugfix: when the blocksize is 32k, the function page_header of pageinspect returns negative numbers. | 
| Date: | 2021-07-09 01:50:57 | 
| Message-ID: | YOergRDGZZnP2TKN@paquier.xyz | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
On Fri, Jul 09, 2021 at 09:26:37AM +0800, Quan Zongliang wrote:
> new patch attached
That's mostly fine at quick glance. Here are some comments.
Please add pageinspect--1.9--1.10.sql within the patch.  Using git,
you can do that with a simple "git add".  With the current shape of
the patch, one has to manually copy pageinspect--1.9--1.10.sql into
contrib/pageinspect/ to be able to test it.
+SELECT lower, upper, special, pagesize, version FROM
page_header(get_raw_page('test1', 0));
+ lower | upper | special | pagesize | version
+-------+-------+---------+----------+---------
+    28 |  8152 |    8192 |     8192 |       4
+(1 row)
I would not test all the fields, just pagesize and version perhaps?
+   if (TupleDescAttr(tupdesc, 3)->atttypid == INT2OID)
+       values[3] = UInt16GetDatum(page->pd_lower);
+   else
+       values[3] = Int32GetDatum(page->pd_lower);
Let's make the style more consistent with brinfuncs.c, by grouping all
the fields together in a switch/case, like that:
switch ((TupleDescAttr(tupdesc, 3)->atttypid)):
{
    case INT2OID:
        /* fill in values with UInt16GetDatum() */
	break;
    case INT4OID:
        /* fill in values with Int32GetDatum() */
	break;
    default:
        elog(ERROR, "blah");
}
+ALTER EXTENSION pageinspect UPDATE TO '1.10';
+\df page_header
+SELECT lower, upper, special, pagesize, version FROM page_header(get_raw_page('test1', 0));
No need for this test as page.sql already stresses page_header() for
the latest version.  Perhaps we could just UPDATE TO '1.9' before
running your query to show that it is the last version of pageinspect
where the older page_header() appeared.
The documentation of pageinspect does not require an update, as far as
I can see.  So we are good there.
--
Michael
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2021-07-09 02:03:56 | Re: ERROR: "ft1" is of the wrong type. | 
| Previous Message | Kyotaro Horiguchi | 2021-07-09 01:44:13 | Re: ERROR: "ft1" is of the wrong type. |