One-off attempt at catalog hacking to turn bytea column into text

Поиск
Список
Период
Сортировка
От Vlad Romascanu
Тема One-off attempt at catalog hacking to turn bytea column into text
Дата
Msg-id BANLkTimFQCKEOD_TQd1rR0jo3MTqkk36=Q@mail.gmail.com
обсуждение исходный текст
Ответы Re: One-off attempt at catalog hacking to turn bytea column into text
Список pgsql-general
Hello,

As a one-off attempt to change a large table's 'bytea' column to
'text' with minimal I/O (where the 'bytea' contents is already valid
UTF8 and the database encoding is also UTF8, and the column is not
part of any index or anything involving collation), how unsafe is the
following?

UPDATE pg_attribute SET atttypid='text'::regtype::oid WHERE
attrelid=('schema_name.table_name')::regclass AND attname='col_name'
AND atttypid='bytea'::regtype::oid;

Additionally, if the 'bytea' happenned to also explicitly contain a
trailing NUL prior to the "conversion" (i.e. after the hack, the last
byte in the 'text' value would be NUL), would there be any obvious
problems with the above hack?

Thanks,
V.

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

Предыдущее
От: Andreas Joseph Krogh
Дата:
Сообщение: Re: Table name as parameter
Следующее
От: Eric Ridge
Дата:
Сообщение: Index bloat with "USING GIN(varchar[])" index?