diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2016-06-23 10:33:38 +0000 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2016-08-07 16:53:23 +0000 |
commit | b6976604ca15259af3a3ee95e10d24937bd63b9a (patch) | |
tree | 51dcd0891a19780c405692f5eeed0e9ad98e207d /connectivity | |
parent | 145e2dfc4501cb3fa01a1771cb6829b5945df4a6 (diff) |
Revert "tdf#67302 Resolving tablesSupplier name clash for postgresql"
As explained in https://bugs.documentfoundation.org/67302
this is the right thing to do in that directory, but cannot
be comitted in isolation. All callers of that function in
all of LibreOffice need to be adapted to the new syntax
of the returned value (that is that the value is now properly escaped). This needs to be done at the same time in all drivers and all places that call this API (+documented in the release notes).
This reverts commit d43f4390e006716ca538ad92d09bd012179efd66.
Change-Id: I8f33fd68ec09d67dd6d38ae50d8ae156f11c5357
Reviewed-on: https://gerrit.libreoffice.org/26593
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'connectivity')
8 files changed, 10 insertions, 33 deletions
diff --git a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx index cec6070a767a..c2e64df1efcc 100644 --- a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx +++ b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx @@ -212,9 +212,7 @@ void ResultSetMetaData::checkTable() { const OUString name (getTableName ( 1 )); const OUString schema (getSchemaName( 1 )); - const OUString EscapedName (name.replaceAll("\"","\"\"" )); - const OUString EscapedSchema ( schema.replaceAll("\"","\"\"")); - const OUString composedName( schema.isEmpty() ? name : ("\"" + EscapedSchema + "\".\"" + EscapedName + "\"") ); + const OUString composedName( schema.isEmpty() ? name : (schema + "." + name) ); tables->getByName( composedName ) >>= m_table; } } diff --git a/connectivity/source/drivers/postgresql/pq_tools.cxx b/connectivity/source/drivers/postgresql/pq_tools.cxx index 2d0bc57e6cd5..4e6df8b0fdf2 100644 --- a/connectivity/source/drivers/postgresql/pq_tools.cxx +++ b/connectivity/source/drivers/postgresql/pq_tools.cxx @@ -463,20 +463,6 @@ void splitSQL( const OString & sql, OStringVector &vec ) } -void splitDoubleQuoteEscapedIdentifiers( const OUString & source, OUString *first, OUString *second) -{ - int a = source.indexOf("\".\""); - OString tempstring = OUStringToOString(source , RTL_TEXTENCODING_UTF8); - if(a > 0) - { - //remove start and end double quote as well as escaped double quotes - *first =OStringToOUString(OString(&tempstring.getStr()[1],a-2) , RTL_TEXTENCODING_UTF8); - *first=first->replaceAll("\"\"","\""); - *second =OStringToOUString(OString(&tempstring.getStr()[a+2],source.getLength()-a-2) , RTL_TEXTENCODING_UTF8); - *second=second->replaceAll("\"\"","\""); - } -} - void tokenizeSQL( const OString & sql, OStringVector &vec ) { int length = sql.getLength(); diff --git a/connectivity/source/drivers/postgresql/pq_tools.hxx b/connectivity/source/drivers/postgresql/pq_tools.hxx index 8c17c287f368..6ab147c76d39 100644 --- a/connectivity/source/drivers/postgresql/pq_tools.hxx +++ b/connectivity/source/drivers/postgresql/pq_tools.hxx @@ -111,7 +111,6 @@ OUString array2String( const css::uno::Sequence< css::uno::Any > &seq ); css::uno::Reference< css::sdbc::XConnection > extractConnectionFromStatement( const css::uno::Reference< css::uno::XInterface > & stmt ); -void splitDoubleQuoteEscapedIdentifiers( const OUString & source, OUString *first, OUString *second); void splitConcatenatedIdentifier( const OUString & source, OUString *first, OUString *second); diff --git a/connectivity/source/drivers/postgresql/pq_xtable.cxx b/connectivity/source/drivers/postgresql/pq_xtable.cxx index 8e0ae92164f0..4b8d4518c1f4 100644 --- a/connectivity/source/drivers/postgresql/pq_xtable.cxx +++ b/connectivity/source/drivers/postgresql/pq_xtable.cxx @@ -154,13 +154,12 @@ void Table::rename( const OUString& newName ) OUString newTableName; OUString newSchemaName; - //changing schema + dot + table-name to "schema"."table-name" // OOo2.0 passes schema + dot + new-table-name while // OO1.1.x passes new Name without schema // in case name contains a dot, it is interpreted as schema.tablename - if( newName.indexOf( "\".\"" ) >= 0 ) + if( newName.indexOf( '.' ) >= 0 ) { - splitDoubleQuoteEscapedIdentifiers( newName, &newSchemaName, &newTableName ); + splitConcatenatedIdentifier( newName, &newSchemaName, &newTableName ); } else { diff --git a/connectivity/source/drivers/postgresql/pq_xtables.cxx b/connectivity/source/drivers/postgresql/pq_xtables.cxx index ce3a17ec2d5c..63e6c6aeebf9 100644 --- a/connectivity/source/drivers/postgresql/pq_xtables.cxx +++ b/connectivity/source/drivers/postgresql/pq_xtables.cxx @@ -133,10 +133,8 @@ void Tables::refresh() { m_values.push_back( makeAny( prop ) ); - OUString EscapedName = /* ::dbtools::composeTableNameForSelect(); */ name.replaceAll("\"","\"\""); - OUString EscapedSchema = schema.replaceAll("\"","\"\""); - OUStringBuffer buf( EscapedName.getLength() + EscapedSchema.getLength() + 1); - buf.append("\"" + EscapedSchema + "\".\"" + EscapedName + "\""); + OUStringBuffer buf( name.getLength() + schema.getLength() + 1); + buf.append( schema + "." + name ); map[ buf.makeStringAndClear() ] = tableIndex; ++tableIndex; } diff --git a/connectivity/source/drivers/postgresql/pq_xtables.hxx b/connectivity/source/drivers/postgresql/pq_xtables.hxx index 9e542abe0f6a..c2e45f0fef43 100644 --- a/connectivity/source/drivers/postgresql/pq_xtables.hxx +++ b/connectivity/source/drivers/postgresql/pq_xtables.hxx @@ -38,7 +38,7 @@ #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_XTABLES_HXX #include "pq_xcontainer.hxx" -#include "connectivity/dbtools.hxx" + namespace pq_sdbc_driver { diff --git a/connectivity/source/drivers/postgresql/pq_xview.cxx b/connectivity/source/drivers/postgresql/pq_xview.cxx index 2ed4ece90a82..c42f533a410f 100644 --- a/connectivity/source/drivers/postgresql/pq_xview.cxx +++ b/connectivity/source/drivers/postgresql/pq_xview.cxx @@ -102,13 +102,12 @@ void View::rename( const OUString& newName ) OUString newTableName; OUString newSchemaName; - //changing schema + dot + table-name to "schema"."table-name" // OOo2.0 passes schema + dot + new-table-name while // OO1.1.x passes new Name without schema // in case name contains a dot, it is interpreted as schema.tablename - if( newName.indexOf( "\".\"" ) >= 0 ) + if( newName.indexOf( '.' ) >= 0 ) { - splitDoubleQuoteEscapedIdentifiers( newName, &newSchemaName, &newTableName ); + splitConcatenatedIdentifier( newName, &newSchemaName, &newTableName ); } else { diff --git a/connectivity/source/drivers/postgresql/pq_xviews.cxx b/connectivity/source/drivers/postgresql/pq_xviews.cxx index 0e471bcc989c..cd12d586687c 100644 --- a/connectivity/source/drivers/postgresql/pq_xviews.cxx +++ b/connectivity/source/drivers/postgresql/pq_xviews.cxx @@ -114,10 +114,8 @@ void Views::refresh() { m_values.push_back( makeAny( prop ) ); - OUString EscapedTable = table.replaceAll("\"","\"\""); - OUString EscapedSchema = schema.replaceAll("\"","\"\""); - OUStringBuffer buf( EscapedTable.getLength() + EscapedSchema.getLength() + 1); - buf.append("\"" + EscapedSchema + "\".\"" + EscapedTable + "\""); + OUStringBuffer buf( table.getLength() + schema.getLength() + 1); + buf.append( schema + "." + table ); map[ buf.makeStringAndClear() ] = viewIndex; ++viewIndex; } |