Re: [HACKERS] Re: [HACKERS] Is it necessary to rewrite table while increasing the scale of datatype numeric?

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: [HACKERS] Re: [HACKERS] Is it necessary to rewrite table while increasing the scale of datatype numeric?
Дата
Msg-id CAM-w4HN1YLqyuRf5q6dvfzHuvxHojpCqK2xtpGt2Bh1x+of6DQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Re: [HACKERS] Is it necessary to rewrite table while increasing the scale of datatype numeric?  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Ответы Re: [HACKERS] Re: [HACKERS] Re: [HACKERS] Is it necessary to rewrite table while increasing the scale of datatype numeric?  (Robert Haas <robertmhaas@gmail.com>)
Re: [HACKERS] Re: [HACKERS] Is it necessary to rewrite table while increasing the scale of datatype numeric?  (Jeff Janes <jeff.janes@gmail.com>)
Re: Re: [HACKERS] Re: [HACKERS] Is it necessary to rewrite table while increasing the scale of datatype numeric?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers

On Thu, Sep 5, 2013 at 8:53 PM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
Greg Stark escribió:

> The main difficulty is that Postgres is very extensible. So to implement
> this you need to think bigger than NUMERIC. It should also be possible to
> alter a column from varchar(5) to varchar(10) for example (but not the
> other way around).

We already allow that.  See commits
8f9fe6edce358f7904e0db119416b4d1080a83aa and
3cc0800829a6dda5347497337b0cf43848da4acf

Ah, nice. i missed that.

So the issue here is that NUMERIC has an additional concept of scale that is buried in the values and that this scale is set based on the typmod that was in effect when the value was stored. If you change the typmod on the column it currently rescales all the values in the table? There's even a comment to that effect on the commit you pointed at.

But I wonder if we could just declare that that's not what the scale typmod does. That it's just a maximum scale but it's perfectly valid for NUMERIC data with lower scales to be stored in a column than the typmod says. In a way the current behaviour is like bpchar but it would be nice if it was more like varchar


--
greg

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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [PERFORM] encouraging index-only scans
Следующее
От: Andres Freund
Дата:
Сообщение: Re: [PERFORM] encouraging index-only scans