BUG #9204: truncate_identifier may be called unnecessarily on escaped quoted identifiers

From: pythonesque(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #9204: truncate_identifier may be called unnecessarily on escaped quoted identifiers
Date: 2014-02-13 02:44:15
Message-ID: 20140213024415.2708.54432@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 9204
Logged by: Joshua Yanovski
Email address: pythonesque(at)gmail(dot)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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message sharvarichorghe 2014-02-13 10:19:12 BUG #9207: Functions Updations
Previous Message rotten 2014-02-12 20:53:02 BUG #9202: C Functions crash database too easily