Bug 67302 - TablesSupplier name clash when dots in schema/table name
Summary: TablesSupplier name clash when dots in schema/table name
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Database (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
QA Contact:
URL:
Whiteboard: EasyHack DifficultyInteresting SkillC...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-25 13:27 UTC by Lionel Elie Mamane
Modified: 2015-01-03 17:40 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Lionel Elie Mamane 2013-07-25 13:27:25 UTC
The implementations of interface XTablesSupplier.getTables() in LibreOffice currently return a XNameAccess that uses:
  schemaName + "." + tableName
as "name" to access the tables.

However, this scheme can make collisions between
 schemaName == "foo"
 tableName == "bar.qux"
and
 schemaName == "foo.bar"
 tableName == "qux"

because in both cases, the name resolves to "foo.bar.qux".

The XNameAccess should rather use properly quoted and escaped names, that is:
 '"' + escapeDoubleQuotes(schemaName) + '"."' + escapeDoubleQuotes(tableName) + '"'

double quotes should be escaped by repeating them.

At the same time, all callers to this interface have to be changed, too. The whole name construction business should be done by a utility function, most probably ::dbtools::composeTableNameForSelect (which needs to be changed to handle double quotes in names...).


Implementations of XTablesSupplier:

 1) MySQL driver: I haven't found where the name is constructed; possibly
    in db-agnostic dbaccess/ or connectivity/source/sdbcx or connectivity/source/commontools
    code.

 2) PostgreSQL driver: pq_xtables.cxx function Tables::refresh code snippet:

                buf.append( schema ).appendAscii( "." ).append( name );
                map[ buf.makeStringAndClear() ] = currentTableIndex;


    callers that need to be also modified:
    pq_resultsetmetadata.cxx function ResultSetMetaData::checkTable
Comment 1 Björn Michaelsen 2013-10-04 18:47:14 UTC
adding LibreOffice developer list as CC to unresolved EasyHacks for better visibility.

see e.g. http://nabble.documentfoundation.org/minutes-of-ESC-call-td4076214.html for details
Comment 2 Alex Thurgood 2015-01-03 17:40:20 UTC
Adding self to CC if not already on


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.