gpdb icon indicating copy to clipboard operation
gpdb copied to clipboard

WIP: Implement type input functions for extended statistics types

Open dgkimura opened this issue 4 years ago • 3 comments

In order for gpsd/minirepro to restore dumped extended statistics (stxdndistinct, stxddependencies, stxdmcv) we need provide an input function to parse pg_ndistinct strings (today we get the ERROR "cannot accept a value of type pg_ndistinct" when we try to do an insert).

Alternative to the approach we tried:

  1. do something similar to syncrep_gram.y.
  2. Instead of returning pretty output from _out function, we could return byte arrays like for pg_mcv_list() and have a separate SRF, like pg_mcv_list_items() to pretty format the contents. That way the input function trivially becomes a bytea_in followed by a deserialize.

We have opened this PR to get early feedback on our approach before we apply the same approach to other extended statistics fields.

TODO: catalog bump TODO: more tests? TODO: submit patch to upstream TODO: Take same approach to implement input functions for pg_dependencies

Upstream discussion which provides context as to why _in and _recv functions were not implemented for ndistinct: https://www.postgresql.org/message-id/20170201225248.aajzts2on4ka4ky5%40alvherre.pgsql

Future Work Notes: We should probably just call bytea_in followed by a statext_mcv_deserialize in the body of pg_mcv_list_in as the text format for pg_mcv_list is a bytea. To implement the recv functions, we can do a bytearecv() followed by a deserialize function as a sanity check.

Co-authored-by: Soumyadeep Chakraborty [email protected]

dgkimura avatar Dec 19 '20 01:12 dgkimura

Another approach here that leverages flex/bison and thus is probably more robust... https://github.com/dgkimura/postgres/commit/02d4bb300a384db62ef5766db5fe105c7bd6ef1a

dgkimura avatar Jan 03 '21 07:01 dgkimura

Another approach here that leverages flex/bison and thus is probably more robust... dgkimura/postgres@02d4bb3

I added minor feedback to that. That approach looks good! Lets implement for the the other statistics types and port it on this branch.

soumyadeep2007 avatar Jan 05 '21 00:01 soumyadeep2007

Seems this is important functionality we would like to have for 7X version. Need to wrap-it up before freezing catalog changes.

ashwinstar avatar Sep 02 '22 19:09 ashwinstar