From: | A(dot)M(dot) <agentm(at)themactionfaction(dot)com> |
---|---|
To: | Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | long names get truncated |
Date: | 2011-07-08 23:29:09 |
Message-ID: | 7241A9E9-EC5A-44F6-B67C-659D10D49F6D@themactionfaction.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 was that 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 can be 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
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2011-07-09 02:17:41 | Re: BUG #6099: Does pgcluster support hibernate? |
Previous Message | Darren Duncan | 2011-07-08 19:34:08 | Re: [HACKERS] Creating temp tables inside read only transactions |