BUG #9204: truncate_identifier may be called unnecessarily on escaped quoted identifiers - Mailing list pgsql-bugs

From pythonesque@gmail.com
Subject BUG #9204: truncate_identifier may be called unnecessarily on escaped quoted identifiers
Date
Msg-id 20140213024415.2708.54432@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #9204: truncate_identifier may be called unnecessarily on escaped quoted identifiers
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      9204
Logged by:          Joshua Yanovski
Email address:      pythonesque@gmail.com
PostgreSQL version: 9.3.2
Operating system:   Ubuntu 12.0.4
Description:

As in description.  This follows from how these are scanned in scan.l:

    ident = litbuf_udeescape('\\', yyscanner);
if (yyextra->literallen >= NAMEDATALEN)
truncate_identifier(ident, yyextra->literallen, true);

Because literallen is the length of the original string, this does
unnecessary work (and reports a misleading notice) if the resulting string
is shorter.

psql -v 'VERBOSITY=verbose' -c "select
U&\"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcd\\3737\"
FROM dummy"
NOTICE:  42622: identifier
"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcd㜷" will be
truncated to
"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcd㜷"
LOCATION:  truncate_identifier, scansup.c:195

It is a pretty borderline edge case and doesn't have any serious
consequences, but it does seem like it should be easy to fix without a huge
hit to efficiency, considering that the length can be calculated in constant
time from known information in litbuf_udeescape.

pgsql-bugs by date:

Previous
From: rotten@windfish.net
Date:
Subject: BUG #9202: C Functions crash database too easily
Next
From: sharvarichorghe@gmail.com
Date:
Subject: BUG #9207: Functions Updations