One-off attempt at catalog hacking to turn bytea column into text - Mailing list pgsql-general

From Vlad Romascanu
Subject One-off attempt at catalog hacking to turn bytea column into text
Date
Msg-id BANLkTimFQCKEOD_TQd1rR0jo3MTqkk36=Q@mail.gmail.com
Whole thread Raw
Responses Re: One-off attempt at catalog hacking to turn bytea column into text  (Noah Misch <noah@leadboat.com>)
List 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 by date:

Previous
From: Andreas Joseph Krogh
Date:
Subject: Re: Table name as parameter
Next
From: Eric Ridge
Date:
Subject: Index bloat with "USING GIN(varchar[])" index?