Re: pageinspect patch, for showing tuple data - Mailing list pgsql-hackers
From | Nikolay Shaplov |
---|---|
Subject | Re: pageinspect patch, for showing tuple data |
Date | |
Msg-id | 1843389.bPVmqBx2FJ@nataraj-amd64 Whole thread Raw |
In response to | Re: pageinspect patch, for showing tuple data (Michael Paquier <michael.paquier@gmail.com>) |
Responses |
Re: pageinspect patch, for showing tuple data
|
List | pgsql-hackers |
В письме от 10 сентября 2015 15:46:25 пользователь Michael Paquier написал: > > So if move tuple data parsing into separate function, then we have to pass > > these values alongside the tuple data. This is not convenient at all. > > So I did it in a way you see in the patch. > > Why is it not convenient at all? Yes, you have a point, we need those > fields to be able to parse the t_data properly. Still the possibility > to show individual fields of a tuple as a bytea array either with > toasted or detoasted values is a concept completely different from > simply showing the page items, which is what, it seems to me, > heap_page_items is aimed to only do. Hence, As t_infomask2, t_infomask > and t_bits are already available as return fields of heap_page_items, > we should simply add a function like that: > heap_page_item_parse(Oid relid, bytea data, t_infomask2 int, > t_infomask int, t_bits int, bool force_detoast, warning_mode bool) > returns bytea[] Just compare two expressions: select * from heap_page_item_attrs(get_raw_page('test', 0),'test'::regclass); and select lp, lp_off, lp_flags, lp_len, t_xmin, t_xmax, t_field3, t_ctid, t_infomask2, t_infomask, t_hoff, t_bits, t_oid, tuple_data_parse ( t_data, t_infomask, t_infomask2, t_bits, 'test'::regclass, true, false) from heap_page_item_attrs(get_raw_page('test', 0)); The second variant is a total mess and almost unsable... Though I've discussed this issue with friedns, and we came to conclusion that it might be good to implement tuple_data_parse and then implement easy to use heap_page_item_attrs in pure SQL, using heap_page_items and tuple_data_parse. That would keep usage simplicity, and make code more simple as you offer. The only one argument against it is that in internal representation t_bist is binary, and in sql output it is string with '0' and '1' characters. We will have to convert it back to binary mode. This is not difficult, but just useless convertations there and back again. What do you think about this solution? > Note that the data corruption checks apply only to this function as > far as I understand, so I think that things could be actually split > into two independent patches: > 1) Upgrade heap_page_items to add the tuple data as bytea. > 2) Add the new function able to parse those fields appropriately. > > As this code, as you justly mentioned, is aimed mainly for educational > purposes to understand a page structure, we should definitely make it > as simple as possible at code level, and it seems to me that this > comes with a separate SQL interface to control tuple data parsing as a > bytea[]. We are doing no favor to our users to complicate the code of > pageinspect.c as this patch is doing in its current state, especially > if beginners want to have a look at it. > > >> Actually not two functions, but just one, with an extra flag to be > >> able to enforce detoasting on the field values where this can be done. > > > > Yeah, I also thought about it. But did not come to any final conclusion. > > Should we add forth argument, that enables detoasting, instead of adding > > separate function? > > This is definitely something you want to control with a switch. Ok.Let's come to the final decision with tuple_data_parse, and i will add this switch there and to pure sql heap_page_item_attrs -- Nikolay Shaplov Postgres Professional: http://www.postgrespro.com Russian Postgres Company
pgsql-hackers by date: