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 d43f4390e0.

Change-Id: I8f33fd68ec09d67dd6d38ae50d8ae156f11c5357
Reviewed-on: https://gerrit.libreoffice.org/26593
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
This commit is contained in:
Lionel Elie Mamane
2016-06-23 10:33:38 +00:00
committed by Julien Nabet
parent 145e2dfc45
commit b6976604ca
8 changed files with 10 additions and 33 deletions

View File

@@ -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;
}
}

View File

@@ -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();

View File

@@ -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);

View File

@@ -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
{

View File

@@ -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;
}

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -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;
}