Re: How to update stavaluesN columns in pg_statistics (type anyarry)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: How to update stavaluesN columns in pg_statistics (type anyarry)
Дата
Msg-id 26334.1243008327@sss.pgh.pa.us
обсуждение исходный текст
Ответ на How to update stavaluesN columns in pg_statistics (type anyarry)  (Keith Hayden <keith.c.hayden@googlemail.com>)
Ответы Re: How to update stavaluesN columns in pg_statistics (type anyarry)  (Keith Hayden <keith.c.hayden@googlemail.com>)
Список pgsql-general
Keith Hayden <keith.c.hayden@googlemail.com> writes:
> I need to spoof statistics, and so need to update the stavaluesN columns in
> pg_statistics, which are of type anyarray. Can this be done using an UPDATE
> statement ? I have tried using array[...] and '{...}' syntax with no luck.
> Any other ideas as to how to achieve this ?

I've done it successfully but it's not something you should consider for
any sort of production purpose.  IIRC the non-obvious part is that the
columns are declared anyarray which has alignment 'd', but if you want
to stick in an array of, say, integer then that only has alignment 'i'.
I think what I did to make it work was to temporarily change the
typalign entry in _int4's pg_type row to 'd' ... this was in a test
database so I wasn't afraid of how badly it might break ;-)

Something that might actually be sustainable is to take advantage
of the planner statistics hook function that is new in 8.4.  That is,
make a hook function that shoves in the values you want at the time
of use, rather than modifying pg_statistic directly.

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: question on serial key
Следующее
От: Nico Sabbi
Дата:
Сообщение: I can't drop a user if I don't drop his grants beforehand??????????????????