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

From Robert Haas
Subject Re: [HACKERS] PATCH: pageinspect / add page_checksum and bt_page_items(bytea)
Date
Msg-id CA+TgmoZ4S-5+6sc=MXZpeZ5aSHbtwC=drZm7-mh54Ex2y3TvWw@mail.gmail.com
Whole thread Raw
In response to [HACKERS] PATCH: pageinspect / add page_checksum and bt_page_items(bytea)  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Responses Re: [HACKERS] PATCH: pageinspect / add page_checksum andbt_page_items(bytea)  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
List pgsql-hackers
On Mon, Feb 20, 2017 at 9:43 PM, Tomas Vondra
<tomas.vondra@2ndquadrant.com> wrote:
> BTW I've noticed the pageinspect version is 1.6, but we only have
> pageinspect--1.5.sql (and upgrade script to 1.6). Not sure that's entirely
> intentional?

Actually, that's the New Way.  See 40b449ae84dcf71177d7749a7b0c582b64dc15f0.

+extern Datum bt_metap(PG_FUNCTION_ARGS);
+extern Datum bt_page_items(PG_FUNCTION_ARGS);
+extern Datum bt_page_items_bytea(PG_FUNCTION_ARGS);
+extern Datum bt_page_stats(PG_FUNCTION_ARGS);

Not needed.  PG_FUNCTION_INFO_V1 now does it.

-    values[j++] = psprintf("%d", stat.blkno);
-    values[j++] = psprintf("%c", stat.type);
-    values[j++] = psprintf("%d", stat.live_items);
-    values[j++] = psprintf("%d", stat.dead_items);
-    values[j++] = psprintf("%d", stat.avg_item_size);
-    values[j++] = psprintf("%d", stat.page_size);
-    values[j++] = psprintf("%d", stat.free_size);
-    values[j++] = psprintf("%d", stat.btpo_prev);
-    values[j++] = psprintf("%d", stat.btpo_next);
-    values[j++] = psprintf("%d", (stat.type == 'd') ? stat.btpo.xact : stat.btp
o.level);
-    values[j++] = psprintf("%d", stat.btpo_flags);
+    values[j] = palloc(32);
+    snprintf(values[j++], 32, "%d", stat.blkno);
+    values[j] = palloc(32);
+    snprintf(values[j++], 32, "%c", stat.type);
+    values[j] = palloc(32);
+    snprintf(values[j++], 32, "%d", stat.live_items);
+    values[j] = palloc(32);
+    snprintf(values[j++], 32, "%d", stat.dead_items);
+    values[j] = palloc(32);
+    snprintf(values[j++], 32, "%d", stat.avg_item_size);
+    values[j] = palloc(32);
+    snprintf(values[j++], 32, "%d", stat.page_size);
+    values[j] = palloc(32);
+    snprintf(values[j++], 32, "%d", stat.free_size);
+    values[j] = palloc(32);
+    snprintf(values[j++], 32, "%d", stat.btpo_prev);
+    values[j] = palloc(32);
+    snprintf(values[j++], 32, "%d", stat.btpo_next);
+    values[j] = palloc(32);
+    if (stat.type == 'd')
+        snprintf(values[j++], 32, "%d", stat.btpo.xact);
+    else
+        snprintf(values[j++], 32, "%d", stat.btpo.level);
+    values[j] = palloc(32);
+    snprintf(values[j++], 32, "%d", stat.btpo_flags);

This does not seem like a good idea in any way, and the patch has
several instances of it.

I don't object to the concept, though.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [HACKERS] Instability in select_parallel regression test
Next
From: Amit Kapila
Date:
Subject: Re: [HACKERS] WAL Consistency checking for hash indexes