[PATCH] fdo#57950: Remove some chained appends in connectivity and..

Marcos Souza (via Code Review) gerrit at gerrit.libreoffice.org
Sat Jan 19 04:15:04 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1768

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/68/1768/1

fdo#57950: Remove some chained appends in connectivity and..

... remove some RTL* macros.

Change-Id: I919d17e14334c9220b47775355512df8dfa00bca
---
M connectivity/source/drivers/postgresql/pq_xkeys.cxx
M connectivity/source/drivers/postgresql/pq_xtable.cxx
M connectivity/source/drivers/postgresql/pq_xtables.cxx
M connectivity/source/drivers/postgresql/pq_xuser.cxx
M connectivity/source/drivers/postgresql/pq_xusers.cxx
M connectivity/source/drivers/postgresql/pq_xview.cxx
M connectivity/source/drivers/postgresql/pq_xviews.cxx
7 files changed, 75 insertions(+), 215 deletions(-)



diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.cxx b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
index 314924d..2a8d521 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeys.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
@@ -98,7 +98,6 @@
 
 namespace pq_sdbc_driver
 {
-#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
 
 Keys::Keys(
         const ::rtl::Reference< RefCountedMutex > & refMutex,
@@ -127,57 +126,16 @@
 static sal_Int32 string2keyrule( const rtl::OUString & rule )
 {
     sal_Int32 ret = com::sun::star::sdbc::KeyRule::NO_ACTION;
-    if( rule.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "r" ) ) == 0 )
+    if( rule == "r" )
         ret = com::sun::star::sdbc::KeyRule::RESTRICT;
-    else if( rule.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "c" ) ) == 0 )
+    else if( rule == "c" )
         ret = com::sun::star::sdbc::KeyRule::CASCADE;
-    else if( rule.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "n" ) ) == 0 )
+    else if( rule == "n" )
         ret = com::sun::star::sdbc::KeyRule::SET_NULL;
-    else if( rule.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "d" ) ) == 0 )
+    else if( rule == "d" )
         ret = com::sun::star::sdbc::KeyRule::SET_DEFAULT;
     return ret;
 }
-
-
-
-// static void fillAttnum2attnameMap(
-//     Int2StringMap &map,
-//     const Reference< com::sun::star::sdbc::XConnection > &conn,
-//     const rtl::OUString &schema,
-//     const rtl::OUString &table )
-// {
-//     Reference< XPreparedStatement > prep = conn->prepareStatement(
-//         ASCII_STR( "SELECT attname,attnum "
-//                    "FROM pg_attribute "
-//                          "INNER JOIN pg_class ON attrelid = pg_class.oid "
-//                          "INNER JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid "
-//                    "WHERE relname=? AND nspname=?" ) );
-
-//     Reference< XParameters > paras( prep, UNO_QUERY );
-//     paras->setString( 1 , table );
-//     paras->setString( 2 , schema );
-//     Reference< XResultSet > rs = prep->executeQuery();
-
-//     Reference< XRow > xRow( rs , UNO_QUERY );
-//     while( rs->next() )
-//     {
-//         map[ xRow->getInt(2) ] = xRow->getString(1);
-//     }
-// }
-
-// static Sequence< rtl::OUString > resolveColumnNames(
-//     const Int2StringMap &map, const rtl::OUString &array )
-// {
-//     Sequence< sal_Int32 > intArray = string2intarray( array );
-//     Sequence< ::rtl::OUString > ret( intArray.getLength() );
-//     for( int i = 0; i < intArray.getLength() ; i ++ )
-//     {
-//         Int2StringMap::const_iterator ii = map.find( intArray[i] );
-//         if( ii != map.end() )
-//             ret[i] = ii->second;
-//     }
-//     return ret;
-// }
 
 void Keys::refresh()
     throw (::com::sun::star::uno::RuntimeException)
@@ -186,12 +144,10 @@
     {
         if( isLog( m_pSettings, LogLevel::INFO ) )
         {
-            rtl::OStringBuffer buf;
-            buf.append( "sdbcx.Keys get refreshed for table " );
-            buf.append( OUStringToOString( m_schemaName, m_pSettings->encoding ) );
-            buf.append( "." );
-            buf.append( OUStringToOString( m_tableName,m_pSettings->encoding ) );
-            log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear().getStr() );
+            OString buf( "sdbcx.Keys get refreshed for table " +
+                         OUStringToOString( m_schemaName, m_pSettings->encoding ) +
+                         "." + OUStringToOString( m_tableName,m_pSettings->encoding ));
+            log( m_pSettings, LogLevel::INFO, buf.getStr() );
         }
 
         osl::MutexGuard guard( m_refMutex->mutex );
@@ -201,7 +157,6 @@
         fillAttnum2attnameMap( mainMap, m_origin, m_schemaName, m_tableName );
 
         Reference< XPreparedStatement > stmt = m_origin->prepareStatement(
-            ASCII_STR(
                 "SELECT  conname, "            // 1
                         "contype, "            // 2
                         "confupdtype, "        // 3
@@ -214,7 +169,7 @@
                       "INNER JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid "
                       "LEFT JOIN pg_class AS class2 ON confrelid = class2.oid "
                       "LEFT JOIN pg_namespace AS nmsp2 ON class2.relnamespace=nmsp2.oid "
-                "WHERE pg_class.relname = ? AND pg_namespace.nspname = ?" ) );
+                "WHERE pg_class.relname = ? AND pg_namespace.nspname = ?" );
 
         Reference< XParameters > paras( stmt, UNO_QUERY );
         paras->setString( 1 , m_tableName );
@@ -250,9 +205,7 @@
             if( com::sun::star::sdbcx::KeyType::FOREIGN == keyType )
             {
                 OUStringBuffer buf( 128 );
-                buf.append( xRow->getString( 6 ) );
-                buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "." ) );
-                buf.append( xRow->getString( 5 ) );
+                buf.append( xRow->getString( 6 ) + "." + xRow->getString( 5 ) );
                 pKey->setPropertyValue_NoBroadcast_public(
                     st.REFERENCED_TABLE, makeAny( buf.makeStringAndClear() ) );
 
@@ -295,9 +248,9 @@
     osl::MutexGuard guard( m_refMutex->mutex );
 
     OUStringBuffer buf( 128 );
-    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE " ) );
+    buf.append( "ALTER TABLE " );
     bufferQuoteQualifiedIdentifier( buf, m_schemaName, m_tableName, m_pSettings );
-    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " ADD " ) );
+    buf.append( " ADD " );
     bufferKey2TableConstraint( buf, descriptor, m_pSettings );
 
     Reference< XStatement > stmt =
@@ -315,11 +268,8 @@
     if( index < 0 ||  index >= m_values.getLength() )
     {
         OUStringBuffer buf( 128 );
-        buf.appendAscii( "TABLES: Index out of range (allowed 0 to " );
-        buf.append( (sal_Int32)(m_values.getLength() -1) );
-        buf.appendAscii( ", got " );
-        buf.append( index );
-        buf.appendAscii( ")" );
+        buf.append( "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.getLength() -1) +
+                    ", got " + OUString::number( index ) + ")" );
         throw com::sun::star::lang::IndexOutOfBoundsException(
             buf.makeStringAndClear(), *this );
     }
@@ -329,9 +279,9 @@
     m_values[index] >>= set;
 
     OUStringBuffer buf( 128 );
-    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE " ) );
+    buf.append( "ALTER TABLE " );
     bufferQuoteQualifiedIdentifier( buf, m_schemaName, m_tableName, m_pSettings );
-    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " DROP CONSTRAINT " ) );
+    buf.append( " DROP CONSTRAINT " );
     bufferQuoteIdentifier( buf, extractStringProperty( set , getStatics().NAME ), m_pSettings );
     m_origin->createStatement()->executeUpdate( buf.makeStringAndClear() );
 
diff --git a/connectivity/source/drivers/postgresql/pq_xtable.cxx b/connectivity/source/drivers/postgresql/pq_xtable.cxx
index e0eb97b..e6210ea 100644
--- a/connectivity/source/drivers/postgresql/pq_xtable.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xtable.cxx
@@ -77,10 +77,6 @@
 using osl::MutexGuard;
 using osl::Mutex;
 
-using rtl::OUString;
-using rtl::OUStringBuffer;
-using rtl::OUStringToOString;
-
 using com::sun::star::container::XNameAccess;
 using com::sun::star::container::XIndexAccess;
 using com::sun::star::container::ElementExistException;
@@ -227,9 +223,9 @@
             try
             {
                 OUStringBuffer buf(128);
-                buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
+                buf.append( "ALTER TABLE" );
                 bufferQuoteQualifiedIdentifier(buf, schema, oldName, m_pSettings );
-                buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("SET SCHEMA" ) );
+                buf.append( "SET SCHEMA" );
                 bufferQuoteIdentifier( buf, newSchemaName, m_pSettings );
                 Reference< XStatement > statement = m_conn->createStatement();
                 statement->executeUpdate( buf.makeStringAndClear() );
@@ -239,9 +235,8 @@
             }
             catch( com::sun::star::sdbc::SQLException &e )
             {
-                OUStringBuffer buf( e.Message );
-                buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "(NOTE: Only postgresql server >= V8.1 support changing a table's schema)" ) );
-                e.Message = buf.makeStringAndClear();
+                OUString buf( e.Message + "(NOTE: Only postgresql server >= V8.1 support changing a table's schema)" );
+                e.Message = buf;
                 throw;
             }
 
@@ -249,9 +244,9 @@
         if( ! newTableName.equals( oldName ) ) // might also be just the change of a schema name
         {
             OUStringBuffer buf(128);
-            buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
+            buf.append( "ALTER TABLE" );
             bufferQuoteQualifiedIdentifier(buf, schema, oldName, m_pSettings );
-            buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("RENAME TO" ) );
+            buf.append( "RENAME TO" );
             bufferQuoteIdentifier( buf, newTableName, m_pSettings );
             Reference< XStatement > statement = m_conn->createStatement();
             statement->executeUpdate( buf.makeStringAndClear() );
diff --git a/connectivity/source/drivers/postgresql/pq_xtables.cxx b/connectivity/source/drivers/postgresql/pq_xtables.cxx
index b7e20f7..705adcf 100644
--- a/connectivity/source/drivers/postgresql/pq_xtables.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xtables.cxx
@@ -72,10 +72,6 @@
 
 using osl::MutexGuard;
 
-using rtl::OUString;
-using rtl::OUStringBuffer;
-using rtl::OUStringToOString;
-
 using com::sun::star::beans::XPropertySet;
 
 using com::sun::star::uno::Any;
@@ -93,7 +89,6 @@
 using com::sun::star::lang::WrappedTargetException;
 
 using com::sun::star::sdbc::XRow;
-//  using com::sun::star::sdbc::DataType;
 using com::sun::star::sdbc::XCloseable;
 using com::sun::star::sdbc::XStatement;
 using com::sun::star::sdbc::XResultSet;
@@ -103,7 +98,6 @@
 using com::sun::star::sdbcx::XColumnsSupplier;
 using com::sun::star::sdbcx::XKeysSupplier;
 using com::sun::star::sdbcx::XViewsSupplier;
-//  using com::sun::star::sdbcx::Privilege;
 
 namespace pq_sdbc_driver
 {
@@ -173,7 +167,7 @@
                 m_values.realloc( tableIndex );
                 m_values[currentTableIndex] = makeAny( prop );
                 OUStringBuffer buf( name.getLength() + schema.getLength() + 1);
-                buf.append( schema ).appendAscii( "." ).append( name );
+                buf.append( schema + "." + name );
                 map[ buf.makeStringAndClear() ] = currentTableIndex;
             }
         }
@@ -208,7 +202,7 @@
                 }
                 else
                 {
-                    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
+                    buf.append( ", " );
                 }
                 Reference< XPropertySet > column( xEnum->nextElement(), UNO_QUERY );
                 OUString name = extractStringProperty( column, st.NAME );
@@ -225,12 +219,12 @@
                     column->getPropertyValue( st.TYPE ) >>= dataType;
                     if( com::sun::star::sdbc::DataType::INTEGER == dataType )
                     {
-                        buf.appendAscii( " serial  ");
+                        buf.append( " serial  ");
                         isNullable = sal_False;
                     }
                     else if( com::sun::star::sdbc::DataType::BIGINT == dataType )
                     {
-                        buf.appendAscii( " serial8 " );
+                        buf.append( " serial8 " );
                         isNullable = sal_False;
                     }
                     else
@@ -246,9 +240,7 @@
                 }
 
                 if( ! isNullable )
-//                     buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " NULL " ) );
-//                 else
-                    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " NOT NULL " ) );
+                    buf.append( " NOT NULL " );
 
             }
         }
@@ -266,7 +258,7 @@
             Reference< XEnumeration > xEnum = keys->createEnumeration();
             while( xEnum.is() && xEnum->hasMoreElements() )
             {
-                buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
+                buf.append( ", " );
                 Reference< XPropertySet > key( xEnum->nextElement(), UNO_QUERY );
                 bufferKey2TableConstraint( buf, key, settings );
             }
@@ -292,9 +284,9 @@
     TransactionGuard transaction( stmt );
 
     OUStringBuffer buf( 128 );
-    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("CREATE TABLE" ) );
+    buf.append( "CREATE TABLE" );
     bufferQuoteQualifiedIdentifier( buf, schema, name , m_pSettings);
-    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "(" ) );
+    buf.append( "(" );
 
     // columns
     Reference< XColumnsSupplier > supplier( descriptor, UNO_QUERY );
@@ -302,7 +294,7 @@
 
     appendKeyList( buf, Reference< XKeysSupplier >( descriptor, UNO_QUERY ), m_pSettings );
 
-    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ") " ) );
+    buf.append( ") " );
     // execute the creation !
     transaction.executeUpdate( buf.makeStringAndClear() );
 
@@ -311,9 +303,9 @@
     if( description.getLength() )
     {
         buf = OUStringBuffer( 128 );
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "COMMENT ON TABLE" ) );
+        buf.append( "COMMENT ON TABLE" );
         bufferQuoteQualifiedIdentifier( buf, schema, name, m_pSettings );
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "IS " ) );
+        buf.append( "IS " );
         bufferQuoteConstant( buf, description, m_pSettings);
 
         transaction.executeUpdate( buf.makeStringAndClear() );
@@ -335,10 +327,10 @@
                 if( description.getLength() )
                 {
                     buf = OUStringBuffer( 128 );
-                    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "COMMENT ON COLUMN " ) );
+                    buf.append( "COMMENT ON COLUMN " );
                     bufferQuoteQualifiedIdentifier(
                         buf, schema, name, extractStringProperty( column, st.NAME ), m_pSettings );
-                    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "IS " ) );
+                    buf.append( "IS " );
                     bufferQuoteConstant( buf, description, m_pSettings );
                     transaction.executeUpdate( buf.makeStringAndClear() );
                 }
@@ -352,38 +344,7 @@
         // TODO: cheaper recalculate
 //        Container::append( concatQualified( schema, name ), descriptor ); // maintain the lists
     refresh();
-
-    // increase the vector
-//     sal_Int32 index = m_values.getLength();
-//     m_values.realloc( index + 1 );
-
-//     Table * pTable =
-//         new Table( m_refMutex, m_origin, m_pSettings, false /*modifiable*/ );
-//     Reference< com::sun::star::beans::XPropertySet > prop = pTable;
-//     copyProperties( pTable, descriptor );
-//     m_values[index] = makeAny( prop );
-//     OUStringBuffer buf( name.getLength() + 1 + schema.getLength() );
-//     buf.append( schema ).appendAscii( "." ).append( name );
-//     m_name2index[ buf.makeStringAndClear() ] = index;
 }
-
-// void Tables::dropByName( const ::rtl::OUString& elementName )
-//     throw (::com::sun::star::sdbc::SQLException,
-//            ::com::sun::star::container::NoSuchElementException,
-//            ::com::sun::star::uno::RuntimeException)
-// {
-//     String2IntMap::const_iterator ii = m_name2index.find( elementName );
-//     if( ii == m_name2index.end() )
-//     {
-//         OUStringBuffer buf( 128 );
-//         buf.appendAscii( "Table " );
-//         buf.append( elementName );
-//         buf.appendAscii( " is unknown, so it can't be dropped" );
-//         throw com::sun::star::container::NoSuchElementException(
-//             buf.makeStringAndClear(), *this );
-//     }
-//     dropByIndex( ii->second );
-// }
 
 void Tables::dropByIndex( sal_Int32 index )
     throw (::com::sun::star::sdbc::SQLException,
@@ -394,13 +355,9 @@
     if( index < 0 ||  index >= m_values.getLength() )
     {
         OUStringBuffer buf( 128 );
-        buf.appendAscii( "TABLES: Index out of range (allowed 0 to " );
-        buf.append( (sal_Int32) (m_values.getLength() -1) );
-        buf.appendAscii( ", got " );
-        buf.append( index );
-        buf.appendAscii( ")" );
-        throw com::sun::star::lang::IndexOutOfBoundsException(
-            buf.makeStringAndClear(), *this );
+        buf.append( "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.getLength() -1) +
+                    ", got " + OUString::number( index ) + ")" );
+        throw com::sun::star::lang::IndexOutOfBoundsException( buf.makeStringAndClear(), *this );
     }
 
     Reference< XPropertySet > set;
@@ -416,11 +373,11 @@
     else
     {
         OUStringBuffer update( 128 );
-        update.appendAscii( RTL_CONSTASCII_STRINGPARAM( "DROP " ) );
+        update.append( "DROP " );
         if( extractStringProperty( set, st.TYPE ).equals( st.VIEW ) )
-            update.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VIEW " ) );
+            update.append( "VIEW " );
         else
-            update.appendAscii( RTL_CONSTASCII_STRINGPARAM( "TABLE " ) );
+            update.append( "TABLE " );
         bufferQuoteQualifiedIdentifier( update, schema, name, m_pSettings );
         Reference< XStatement > stmt = m_origin->createStatement( );
         DisposeGuard dispGuard( stmt );
diff --git a/connectivity/source/drivers/postgresql/pq_xuser.cxx b/connectivity/source/drivers/postgresql/pq_xuser.cxx
index 39da440..e76b29f 100644
--- a/connectivity/source/drivers/postgresql/pq_xuser.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xuser.cxx
@@ -72,9 +72,6 @@
 using osl::MutexGuard;
 using osl::Mutex;
 
-using rtl::OUString;
-using rtl::OUStringBuffer;
-
 using com::sun::star::container::XNameAccess;
 using com::sun::star::container::XIndexAccess;
 using com::sun::star::container::ElementExistException;
@@ -108,8 +105,6 @@
 
 namespace pq_sdbc_driver
 {
-
-#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
 
 User::User( const ::rtl::Reference< RefCountedMutex > & refMutex,
             const Reference< com::sun::star::sdbc::XConnection > & connection,
@@ -173,9 +168,9 @@
 {
     (void) oldPassword;
     rtl::OUStringBuffer buf(128);
-    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER USER " ) );
+    buf.append( "ALTER USER " );
     bufferQuoteIdentifier( buf, extractStringProperty( this, getStatics().NAME ), m_pSettings );
-    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " PASSWORD " ) );
+    buf.append( " PASSWORD " );
     bufferQuoteConstant( buf, newPassword, m_pSettings );
     Reference< XStatement > stmt = m_conn->createStatement();
     DisposeGuard guard( stmt );
@@ -192,13 +187,9 @@
         rtl::OUString user = extractStringProperty( this, st.NAME );
 
         rtl::OUStringBuffer buf( 128 );
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("User::getPrivileges[") );
-        buf.append( extractStringProperty( this, st.NAME ) );
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "] got called for " ) );
-        buf.append( objName );
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "(type=" ) );
-        buf.append( objType );
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ")" ) );
+        buf.append( "User::getPrivileges[" + extractStringProperty( this, st.NAME ) +
+                    "] got called for " + objName + "(type=" +
+                    OUString::number(objType) + ")");
         log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear() );
     }
     // all privileges
@@ -217,18 +208,16 @@
     throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
 {
     (void) objName; (void) objType; (void) objPrivileges;
-    throw com::sun::star::sdbc::SQLException(
-        ASCII_STR( "pq_driver: privilege change not implemented yet" ),
-        *this, OUString(), 1, Any() );
+    throw com::sun::star::sdbc::SQLException("pq_driver: privilege change not implemented yet",
+                                             *this, OUString(), 1, Any() );
 }
 
 void User::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges )
     throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
 {
     (void) objName; (void) objType; (void) objPrivileges;
-    throw com::sun::star::sdbc::SQLException(
-        ASCII_STR( "pq_driver: privilege change not implemented yet" ),
-        *this, OUString(), 1, Any() );
+    throw com::sun::star::sdbc::SQLException("pq_driver: privilege change not implemented yet",
+                                             *this, OUString(), 1, Any() );
 }
 
 //______________________________________________________________________________________
diff --git a/connectivity/source/drivers/postgresql/pq_xusers.cxx b/connectivity/source/drivers/postgresql/pq_xusers.cxx
index 390bc47..fcc17d0 100644
--- a/connectivity/source/drivers/postgresql/pq_xusers.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xusers.cxx
@@ -96,7 +96,6 @@
 
 namespace pq_sdbc_driver
 {
-#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
 Users::Users(
         const ::rtl::Reference< RefCountedMutex > & refMutex,
         const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection >  & origin,
@@ -117,8 +116,7 @@
 
         Reference< XStatement > stmt = m_origin->createStatement();
 
-        Reference< XResultSet > rs =
-            stmt->executeQuery( ASCII_STR( "SELECT usename FROM pg_shadow" ) );
+        Reference< XResultSet > rs = stmt->executeQuery( "SELECT usename FROM pg_shadow" );
 
         Reference< XRow > xRow( rs , UNO_QUERY );
 
@@ -164,9 +162,9 @@
     osl::MutexGuard guard( m_refMutex->mutex );
 
     OUStringBuffer update( 128 );
-    update.appendAscii( RTL_CONSTASCII_STRINGPARAM( "CREATE USER " ) );
+    update.append( "CREATE USER " );
     bufferQuoteIdentifier( update, extractStringProperty( descriptor, getStatics().NAME ), m_pSettings );
-    update.appendAscii( RTL_CONSTASCII_STRINGPARAM( " PASSWORD " ) );
+    update.append( " PASSWORD " );
     bufferQuoteConstant( update, extractStringProperty( descriptor, getStatics().PASSWORD ), m_pSettings );
 
     Reference< XStatement > stmt = m_origin->createStatement( );
diff --git a/connectivity/source/drivers/postgresql/pq_xview.cxx b/connectivity/source/drivers/postgresql/pq_xview.cxx
index dde838d..baee259 100644
--- a/connectivity/source/drivers/postgresql/pq_xview.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xview.cxx
@@ -73,10 +73,6 @@
 using osl::MutexGuard;
 using osl::Mutex;
 
-using rtl::OUString;
-using rtl::OUStringBuffer;
-using rtl::OUStringToOString;
-
 using com::sun::star::container::XNameAccess;
 using com::sun::star::container::XIndexAccess;
 using com::sun::star::container::ElementExistException;
@@ -110,7 +106,6 @@
 
 namespace pq_sdbc_driver
 {
-#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
 
 View::View( const ::rtl::Reference< RefCountedMutex > & refMutex,
             const Reference< com::sun::star::sdbc::XConnection > & connection,
@@ -167,9 +162,9 @@
         try
         {
             OUStringBuffer buf(128);
-            buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
+            buf.append( "ALTER TABLE" );
             bufferQuoteQualifiedIdentifier(buf, schema, oldName, m_pSettings );
-            buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("SET SCHEMA" ) );
+            buf.append( "SET SCHEMA" );
             bufferQuoteIdentifier( buf, newSchemaName, m_pSettings );
             Reference< XStatement > statement = m_conn->createStatement();
             statement->executeUpdate( buf.makeStringAndClear() );
@@ -179,9 +174,8 @@
         }
         catch( com::sun::star::sdbc::SQLException &e )
         {
-            OUStringBuffer buf( e.Message );
-            buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "(NOTE: Only postgresql server >= V8.1 support changing a table's schema)" ) );
-            e.Message = buf.makeStringAndClear();
+            OUString buf( e.Message + "(NOTE: Only postgresql server >= V8.1 support changing a table's schema)" );
+            e.Message = buf;
             throw;
         }
 
@@ -189,9 +183,9 @@
     if( ! oldName.equals( newTableName ) )
     {
         OUStringBuffer buf(128);
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "ALTER TABLE" ) );
+        buf.appendAscii( "ALTER TABLE" );
         bufferQuoteQualifiedIdentifier( buf, schema, oldName, m_pSettings );
-        buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("RENAME TO" ) );
+        buf.appendAscii( "RENAME TO" );
         bufferQuoteIdentifier( buf, newTableName, m_pSettings );
         Reference< XStatement > statement = m_conn->createStatement();
         statement->executeUpdate( buf.makeStringAndClear() );
diff --git a/connectivity/source/drivers/postgresql/pq_xviews.cxx b/connectivity/source/drivers/postgresql/pq_xviews.cxx
index b949c1a..39c6856 100644
--- a/connectivity/source/drivers/postgresql/pq_xviews.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xviews.cxx
@@ -99,7 +99,6 @@
 
 namespace pq_sdbc_driver
 {
-#define ASCII_STR(x) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) )
 Views::Views(
         const ::rtl::Reference< RefCountedMutex > & refMutex,
         const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection >  & origin,
@@ -120,16 +119,15 @@
 
         Reference< XStatement > stmt = m_origin->createStatement();
 
-        Reference< XResultSet > rs = stmt->executeQuery(
-            ASCII_STR( "SELECT "
-                              "DISTINCT ON( pg_namespace.nspname, relname) " // needed because of duplicates
-                              "pg_namespace.nspname,"     // 1
-                              "relname,"                  // 2
-                              "pg_get_viewdef(ev_class) " // 3
-                       "FROM pg_namespace, pg_class, pg_rewrite "
-                       "WHERE pg_namespace.oid = relnamespace "
-                             "AND pg_class.oid = ev_class "
-                       "AND relkind='v'" ) );
+        Reference< XResultSet > rs = stmt->executeQuery("SELECT "
+                                                        "DISTINCT ON( pg_namespace.nspname, relname) " // needed because of duplicates
+                                                        "pg_namespace.nspname,"    // 1
+                                                        "relname,"                 // 2
+                                                        "pg_get_viewdef(ev_class) " // 3
+                                                        "FROM pg_namespace, pg_class, pg_rewrite "
+                                                       "WHERE pg_namespace.oid = relnamespace "
+                                                         "AND pg_class.oid = ev_class "
+                                                         "AND relkind=\'v\'" );
 
         Reference< XRow > xRow( rs , UNO_QUERY );
 
@@ -157,7 +155,7 @@
                 m_values.realloc( viewIndex );
                 m_values[currentViewIndex] = makeAny( prop );
                 OUStringBuffer buf( table.getLength() + schema.getLength() + 1);
-                buf.append( schema ).appendAscii( "." ).append( table );
+                buf.append( schema + "." + table );
                 map[ buf.makeStringAndClear() ] = currentViewIndex;
             }
         }
@@ -189,10 +187,9 @@
 
     OUStringBuffer buf( 128 );
 
-    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "CREATE VIEW " ) );
+    buf.append( "CREATE VIEW ");
     bufferQuoteQualifiedIdentifier( buf, schema, name, m_pSettings );
-    buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " AS " ) );
-    buf.append( command );
+    buf.append(" AS " + command );
 
     stmt->executeUpdate( buf.makeStringAndClear() );
 
@@ -202,18 +199,6 @@
     {
         m_pSettings->pTablesImpl->refresh();
     }
-    // increase the vector
-//     sal_Int32 index = m_values.getLength();
-//     m_values.realloc( index + 1 );
-
-//     View * pView =
-//         new View( m_refMutex, m_origin, m_pSettings, false /*modifiable*/ );
-//     Reference< com::sun::star::beans::XPropertySet > prop = pTable;
-//     copyProperties( pTable, descriptor );
-//     m_values[index] = makeAny( prop );
-//     OUStringBuffer buf( name.getLength() + 1 + schema.getLength() );
-//     buf.append( schema ).appendAscii( "." ).append( name );
-//     m_name2index[ buf.makeStringAndClear() ] = index;
 }
 
 void Views::dropByName( const ::rtl::OUString& elementName )
@@ -225,9 +210,7 @@
     if( ii == m_name2index.end() )
     {
         OUStringBuffer buf( 128 );
-        buf.appendAscii( "View " );
-        buf.append( elementName );
-        buf.appendAscii( " is unknown, so it can't be dropped" );
+        buf.append( "View " + elementName + " is unknown, so it can't be dropped" );
         throw com::sun::star::container::NoSuchElementException(
             buf.makeStringAndClear(), *this );
     }
@@ -239,17 +222,12 @@
            ::com::sun::star::lang::IndexOutOfBoundsException,
            ::com::sun::star::uno::RuntimeException)
 {
-//     throw SQLException(
-//         ASCII_STR( "view deletion not supported" ), *this, OUString(), 1, Any() );
     osl::MutexGuard guard( m_refMutex->mutex );
     if( index < 0 ||  index >= m_values.getLength() )
     {
         OUStringBuffer buf( 128 );
-        buf.appendAscii( "VIEWS: Index out of range (allowed 0 to " );
-        buf.append( (sal_Int32) (m_values.getLength() -1) );
-        buf.appendAscii( ", got " );
-        buf.append( index );
-        buf.appendAscii( ")" );
+        buf.append( "VIEWS: Index out of range (allowed 0 to " + OUString::number(m_values.getLength() -1) +
+                    ", got " + OUString::number( index ) + ")");
         throw com::sun::star::lang::IndexOutOfBoundsException(
             buf.makeStringAndClear(), *this );
     }
@@ -262,8 +240,7 @@
     set->getPropertyValue( st.NAME ) >>= name;
 
     OUStringBuffer update( 128 );
-    update.appendAscii( "DROP VIEW \"" ).append( schema ).appendAscii( "\".\"" );
-    update.append( name ).appendAscii( "\"" );
+    update.append( "DROP VIEW \"" + schema + "\".\"" + name + "\"" );
 
     Reference< XStatement > stmt = m_origin->createStatement( );
 

-- 
To view, visit https://gerrit.libreoffice.org/1768
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I919d17e14334c9220b47775355512df8dfa00bca
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Marcos Souza <marcos.souza.org at gmail.com>



More information about the LibreOffice mailing list