long names get truncated

Поиск
Список
Период
Сортировка
От A.M.
Тема long names get truncated
Дата
Msg-id 7241A9E9-EC5A-44F6-B67C-659D10D49F6D@themactionfaction.com
обсуждение исходный текст
Список pgsql-general
Hello,

I was bitten by a length-truncated role name used in a script since the truncation only raises a NOTICE. The symptom
wasthat the some GRANTs ended up on the wrong objects after name truncation. 

Then, I experimented with tables with long names and was surprised by the truncation behavior:

test=# create table longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong(a int);
NOTICE:  identifier "longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong" will be truncated to
"longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglon"
CREATE TABLE
test=# \d longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong
Did not find any relation named "longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong".
test=# drop table longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglongNOT; --SURPRISE!
NOTICE:  identifier "longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglongnot" will be truncated to
"longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglon"
DROP TABLE

One really has to pay attention to the length limits (63 bytes):

1) Name truncation is not an error.
2) psql \d doesn't work with long names- perhaps the same auto-truncation rules should apply?
3) DROPping a non-existent table with a truncated identifier unintentionally drops the long name table.

For those curious, I hit the limits prefixing roles with UUIDs for automated testing so that database-global objects
canbe deleted after the test.  

I wish there were a way to turn the truncation into an error. Is there some better way I could have caught this?

Cheers,
M

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

Предыдущее
От: Darren Duncan
Дата:
Сообщение: Re: [HACKERS] Creating temp tables inside read only transactions
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] Creating temp tables inside read only transactions