Re: [HACKERS] ALTER TABLE .. ALTER COLUMN .. ERROR: attribute .. has wrong type

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] ALTER TABLE .. ALTER COLUMN .. ERROR: attribute .. has wrong type
Дата
Msg-id 26761.1483989025@sss.pgh.pa.us
обсуждение исходный текст
Ответы Re: [HACKERS] ALTER TABLE .. ALTER COLUMN .. ERROR: attribute .. haswrong type  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> Tom Lane wrote:
>> [ pokes around... ]  The code I was thinking of is convert_tuples_by_name
>> in access/common/tupconvert.c.  There's a bit of an API mismatch in that
>> it wants to wrap the mapping array in a TupleConversionMap struct; but
>> maybe we could refactor tupconvert.c to offer a way to get just the map
>> array.

> Ah, nice gadget.  I think the attached patch should do.

Looks reasonable to me.

>>> I also modified the algorithm to use the relcache instead of walking the
>>> child's attribute list for each parent attribute (that was silly).

>> Hmm.  That might be better in a big-O sense but I doubt it's faster for
>> reasonable numbers of columns.

> Hm, I was thinking in unreasonable numbers of columns, keeping in mind
> that they can appear in arbitrary order in child tables.  Then again,
> that probably seldom occurs in real databases.  I suppose this could
> become an issue with table partitioning becoming more common, but I'm
> okay with deferring the optimization work.

It occurred to me that it'd be really easy to improve
convert_tuples_by_name so that, rather than having the inner loop
start from j = 0 every time, it starts from the attribute after the
last match (and loops around if needed, so that it still examines
every child attribute).  I think this would keep it at more-or-less
linear time for all but very contrived child tables.

Since your patch is touching that code I won't do anything about it
right now, but maybe later.
        regards, tom lane



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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] increasing the default WAL segment size
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: [HACKERS] Allow controlling location of tmp_install