[PATCH] fdo#57950: Chained appends in postgresql driver
Marcos Souza (via Code Review)
gerrit at gerrit.libreoffice.org
Tue Apr 2 04:33:02 PDT 2013
Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/3170
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/70/3170/1
fdo#57950: Chained appends in postgresql driver
While studing the postgresql driver I found these chained appends.
More will come :)
Change-Id: Ic7bc35f5e65292d2d8a9d51418760c702676e478
---
M connectivity/source/drivers/postgresql/pq_array.cxx
M connectivity/source/drivers/postgresql/pq_baseresultset.cxx
M connectivity/source/drivers/postgresql/pq_connection.cxx
M connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
M connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
M connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx
M connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata.cxx
M connectivity/source/drivers/postgresql/pq_updateableresultset.cxx
M connectivity/source/drivers/postgresql/pq_xbase.cxx
M connectivity/source/drivers/postgresql/pq_xcolumns.cxx
10 files changed, 93 insertions(+), 396 deletions(-)
diff --git a/connectivity/source/drivers/postgresql/pq_array.cxx b/connectivity/source/drivers/postgresql/pq_array.cxx
index 9344bd2..73d7a05 100644
--- a/connectivity/source/drivers/postgresql/pq_array.cxx
+++ b/connectivity/source/drivers/postgresql/pq_array.cxx
@@ -137,16 +137,10 @@
{
if( index >= 1 && index -1 + count <= m_data.getLength() )
return;
- rtl::OUStringBuffer buf;
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Array::getArrayAtIndex(): allowed range for index + count " ) );
- buf.append( m_data.getLength() );
- buf.appendAscii( ", got " );
- buf.append( index );
- buf.appendAscii( " + " );
- buf.append( count );
+ OUString buf( "Array::getArrayAtIndex(): allowed range for index + count " + OUString::number( m_data.getLength() ) +
+ ", got " + OUString::number( index ) + " + " + OUString::number( count ));
- throw SQLException( buf.makeStringAndClear() , *this, rtl::OUString(), 1, Any());
-
+ throw SQLException( buf, *this, "", 1, Any());
}
}
diff --git a/connectivity/source/drivers/postgresql/pq_baseresultset.cxx b/connectivity/source/drivers/postgresql/pq_baseresultset.cxx
index 0f9e0ae..dc9b116 100644
--- a/connectivity/source/drivers/postgresql/pq_baseresultset.cxx
+++ b/connectivity/source/drivers/postgresql/pq_baseresultset.cxx
@@ -664,11 +664,8 @@
}
default:
{
- OUStringBuffer buf(128);
- buf.appendAscii( "pq_resultset: Invalid property handle (" );
- buf.append( nHandle );
- buf.appendAscii( ")" );
- throw IllegalArgumentException( buf.makeStringAndClear(), *this, 2 );
+ throw IllegalArgumentException("pq_resultset: Invalid property handle (" + OUString::number( nHandle ) + ")"
+ , *this, 2 );
}
}
return bRet;
@@ -701,43 +698,27 @@
{
if( index < 1 || index > m_fieldCount )
{
- OUStringBuffer buf(128);
- buf.appendAscii( "pq_resultset: index out of range (" );
- buf.append( index );
- buf.appendAscii( ", allowed range is 1 to " );
- buf.append( m_fieldCount );
- buf.appendAscii( ")" );
- throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any() );
+ throw SQLException( "pq_resultset: index out of range (" + OUString::number( index ) +
+ ", allowed range is 1 to " + OUString::number( m_fieldCount ) + ")"
+ , *this, "", 1, Any() );
}
-
}
void BaseResultSet::checkRowIndex( sal_Bool mustBeOnValidRow )
{
- OUStringBuffer buf( 128 );
- buf.appendAscii( "pq_baseresultset: row index out of range, allowed is " );
+ OUStringBuffer buf("pq_baseresultset: row index out of range, allowed is " );
if( mustBeOnValidRow )
{
if( m_row < 0 || m_row >= m_rowCount )
- {
- buf.appendAscii( "0 to " );
- buf.append( ((sal_Int32)(m_rowCount -1)) );
- buf.appendAscii( ", got " );
- buf.append( m_row );
- throw SQLException( buf.makeStringAndClear(), *this, OUString(),1, Any() );
- }
+ buf.append( "0 to " + OUString::number(m_rowCount -1) );
}
else
{
if( m_row < -1 || m_row > m_rowCount )
- {
- buf.appendAscii( "-1 to " );
- buf.append( m_rowCount );
- buf.appendAscii( ", got " );
- buf.append( m_row );
- throw SQLException( buf.makeStringAndClear(), *this, OUString(),1, Any() );
- }
+ buf.append( "-1 to " + OUString::number( m_rowCount ) );
}
+ buf.append( ", got " + OUString::number( m_row ) );
+ throw SQLException( buf.makeStringAndClear(), *this, OUString(),1, Any() );
}
}
diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx
index e0060e9..bbe4af2 100644
--- a/connectivity/source/drivers/postgresql/pq_connection.cxx
+++ b/connectivity/source/drivers/postgresql/pq_connection.cxx
@@ -85,11 +85,6 @@
#include <com/sun/star/script/Converter.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
-using rtl::OUStringBuffer;
-using rtl::OUString;
-using rtl::OString;
-using rtl::OStringBuffer;
-using rtl::OUStringToOString;
using osl::MutexGuard;
using com::sun::star::container::XNameAccess;
@@ -550,18 +545,14 @@
}
if( aArguments.getLength() != 2 )
{
- OUStringBuffer buf(128);
- buf.appendAscii( "pq_driver: expected 2 arguments, got " );
- buf.append( aArguments.getLength( ) );
- throw IllegalArgumentException(buf.makeStringAndClear(), Reference< XInterface > () , 0 );
+ throw IllegalArgumentException( "pq_driver: expected 2 arguments, got " + OUString::number( aArguments.getLength( ) )
+ , Reference< XInterface > () , 0 );
}
if( ! (aArguments[0] >>= url) )
{
- OUStringBuffer buf(128);
- buf.appendAscii( "pq_driver: expected string as first argument, got " );
- buf.append( aArguments[0].getValueType().getTypeName() );
- throw IllegalArgumentException( buf.makeStringAndClear() , *this, 0 );
+ throw IllegalArgumentException( "pq_driver: expected string as first argument, got " +
+ aArguments[0].getValueType().getTypeName(), *this, 0 );
}
tc->convertTo( aArguments[1], getCppuType( &args ) ) >>= args;
@@ -594,14 +585,10 @@
}
else
errorMessage = OUString("#no error message#");
- OUStringBuffer buf( 128 );
- buf.appendAscii( "Error in database URL '" );
- buf.append( url );
- buf.appendAscii( "':\n" );
- buf.append( errorMessage );
// HY092 is "Invalid attribute/option identifier."
// Just the most likely error; the error might be HY024 "Invalid attribute value".
- throw SQLException( buf.makeStringAndClear(), *this, OUString("HY092"), 5, Any() );
+ throw SQLException( "Error in database URL '" + url + "':\n" + errorMessage
+ , *this, OUString("HY092"), 5, Any() );
}
for ( PQconninfoOption * opt = oOpts.get(); opt->keyword != NULL; ++opt)
@@ -628,13 +615,10 @@
const char * error = PQerrorMessage( m_settings.pConnection );
OUString errorMessage( error, strlen( error) , RTL_TEXTENCODING_ASCII_US );
- buf.appendAscii( "Couldn't establish database connection to '" );
- buf.append( url );
- buf.appendAscii( "'\n" );
- buf.append( errorMessage );
PQfinish( m_settings.pConnection );
m_settings.pConnection = 0;
- throw SQLException( buf.makeStringAndClear(), *this, errorMessage, CONNECTION_BAD, Any() );
+ throw SQLException( "Couldn't establish database connection to '" + url + "'\n" +
+ errorMessage, *this, errorMessage, CONNECTION_BAD, Any() );
}
PQsetClientEncoding( m_settings.pConnection, "UNICODE" );
char *p = PQuser( m_settings.pConnection );
@@ -645,11 +629,7 @@
if( isLog( &m_settings, LogLevel::INFO ) )
{
- OUStringBuffer buf( 128 );
- buf.appendAscii( "connection to '" );
- buf.append( url );
- buf.appendAscii( "' successfully opened" );
- log( &m_settings, LogLevel::INFO, buf.makeStringAndClear() );
+ log( &m_settings, LogLevel::INFO, "connection to '" + url + "' successfully opened" );
}
}
diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
index a7b63df..e9e6dd9 100644
--- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
@@ -1182,12 +1182,8 @@
if( isLog( m_pSettings, LogLevel::INFO ) )
{
- rtl::OUStringBuffer buf( 128 );
- buf.appendAscii( "DatabaseMetaData::getTables got called with " );
- buf.append( schemaPattern );
- buf.appendAscii( "." );
- buf.append( tableNamePattern );
- log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear() );
+ log( m_pSettings, LogLevel::INFO, "DatabaseMetaData::getTables got called with " + schemaPattern +
+ "." + tableNamePattern );
}
// ignore catalog, as a single pq connection does not support multiple catalogs
@@ -1466,8 +1462,7 @@
{
Reference< XRow > row( rs, UNO_QUERY_THROW );
int domains = 0;
- rtl::OUStringBuffer queryBuf(128);
- queryBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SELECT oid,typtype,typname FROM pg_TYPE WHERE " ) );
+ OUStringBuffer queryBuf( "SELECT oid,typtype,typname FROM pg_TYPE WHERE " );
while( rs->next() )
{
if( row->getString( 9 ) == "d" && oidMap.find( row->getInt( 12 ) ) == oidMap.end() )
@@ -1475,7 +1470,7 @@
oidMap[row->getInt(12)] = DatabaseTypeDescription();
if( domains )
queryBuf.appendAscii( " OR " );
- queryBuf.appendAscii( "oid = " );
+ queryBuf.append( "oid = " );
queryBuf.append( row->getInt(12 ), 10 );
domains ++;
}
@@ -1513,14 +1508,8 @@
if( isLog( m_pSettings, LogLevel::INFO ) )
{
- rtl::OUStringBuffer buf( 128 );
- buf.appendAscii( "DatabaseMetaData::getColumns got called with " );
- buf.append( schemaPattern );
- buf.appendAscii( "." );
- buf.append( tableNamePattern );
- buf.appendAscii( "." );
- buf.append( columnNamePattern );
- log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear() );
+ log( m_pSettings, LogLevel::INFO, "DatabaseMetaData::getColumns got called with " +
+ schemaPattern + "." + tableNamePattern + "." + columnNamePattern );
}
// ignore catalog, as a single pq connection
@@ -1697,14 +1686,8 @@
if( isLog( m_pSettings, LogLevel::INFO ) )
{
- rtl::OUStringBuffer buf( 128 );
- buf.appendAscii( "DatabaseMetaData::getColumnPrivileges got called with " );
- buf.append( schema );
- buf.appendAscii( "." );
- buf.append( table );
- buf.appendAscii( "." );
- buf.append( columnNamePattern );
- log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear() );
+ log( m_pSettings, LogLevel::INFO, "DatabaseMetaData::getColumnPrivileges got called with " +
+ schema + "." + table + "." + columnNamePattern );
}
Reference< XParameters > parameters( m_getColumnPrivs_stmt, UNO_QUERY_THROW );
@@ -1728,12 +1711,8 @@
if( isLog( m_pSettings, LogLevel::INFO ) )
{
- rtl::OUStringBuffer buf( 128 );
- buf.appendAscii( "DatabaseMetaData::getTablePrivileges got called with " );
- buf.append( schemaPattern );
- buf.appendAscii( "." );
- buf.append( tableNamePattern );
- log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear() );
+ log( m_pSettings, LogLevel::INFO, "DatabaseMetaData::getTablePrivileges got called with " +
+ schemaPattern + "." + tableNamePattern );
}
Reference< XParameters > parameters( m_getTablePrivs_stmt, UNO_QUERY_THROW );
@@ -1792,12 +1771,8 @@
if( isLog( m_pSettings, LogLevel::INFO ) )
{
- rtl::OUStringBuffer buf( 128 );
- buf.appendAscii( "DatabaseMetaData::getPrimaryKeys got called with " );
- buf.append( schema );
- buf.appendAscii( "." );
- buf.append( table );
- log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear() );
+ log( m_pSettings, LogLevel::INFO, "DatabaseMetaData::getPrimaryKeys got called with " +
+ schema + "." + table );
}
Reference< XPreparedStatement > statement = m_origin->prepareStatement(
diff --git a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
index a8a4058..a82d88a 100644
--- a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
+++ b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
@@ -242,15 +242,10 @@
{
if( parameterIndex < 1 || parameterIndex > (sal_Int32) m_vars.size() )
{
- OUStringBuffer buf( 128 );
- buf.appendAscii( "pq_preparedstatement: parameter index out of range (expected 1 to " );
- buf.append( (sal_Int32 ) m_vars.size() );
- buf.appendAscii( ", got " );
- buf.append( parameterIndex );
- buf.appendAscii( ", statement '" );
- buf.append( OStringToOUString( m_stmt, m_pSettings->encoding ) );
- buf.appendAscii( "')" );
- throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any () );
+ throw SQLException( "pq_preparedstatement: parameter index out of range (expected 1 to " +
+ OUString::number( m_vars.size() ) + ", got " + OUString::number( parameterIndex ) +
+ ", statement '" + OStringToOUString( m_stmt, m_pSettings->encoding ) + "')"
+ , *this, "", 1, Any () );
}
}
void PreparedStatement::checkClosed() throw (SQLException, RuntimeException )
@@ -345,22 +340,20 @@
const char * errorMsg, const char *errorType )
throw( SQLException )
{
- OUStringBuffer buf(128);
- buf.appendAscii( "pq_driver: ");
- if( errorType )
- {
- buf.appendAscii( "[" );
- buf.appendAscii( errorType );
- buf.appendAscii( "]" );
+ OUStringBuffer buf( "pq_driver: ");
+ if( errorType ) {
+ buf.append( "[" );
+ buf.append( errorType );
+ buf.append( "]" );
}
- buf.append(
- rtl::OUString( errorMsg, strlen(errorMsg) , m_pSettings->encoding ) );
- buf.appendAscii( " (caused by statement '" );
- buf.appendAscii( m_executedStatement.getStr() );
- buf.appendAscii( "')" );
+
+ buf.append( OUString( errorMsg, strlen(errorMsg) , m_pSettings->encoding ) +
+ " (caused by statement '" );
+ buf.append( m_executedStatement.getStr() );
+ buf.append( "')" );
OUString error = buf.makeStringAndClear();
log( m_pSettings, LogLevel::ERROR, error );
- throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any() );
+ throw SQLException( error, *this, OUString(), 1, Any() );
}
Reference< XResultSet > PreparedStatement::executeQuery( )
@@ -528,15 +521,10 @@
void PreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x )
throw (SQLException, RuntimeException)
{
-// printf( "setString %d %d\n ", parameterIndex, x);
MutexGuard guard(m_refMutex->mutex );
checkClosed();
checkColumnIndex( parameterIndex );
- OStringBuffer buf( 20 );
- buf.append( "'" );
- buf.append( (sal_Int32) x );
- buf.append( "'" );
- m_vars[parameterIndex-1] = buf.makeStringAndClear();
+ m_vars[parameterIndex-1] = "'" + OString::number( x ) + "'";
}
void PreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x )
@@ -545,11 +533,7 @@
MutexGuard guard(m_refMutex->mutex );
checkClosed();
checkColumnIndex( parameterIndex );
- OStringBuffer buf( 20 );
- buf.append( "'" );
- buf.append( (sal_Int64) x );
- buf.append( "'" );
- m_vars[parameterIndex-1] = buf.makeStringAndClear();
+ m_vars[parameterIndex-1] = "'" + OString::number( x ) + "'";
}
void PreparedStatement::setFloat( sal_Int32 parameterIndex, float x )
@@ -558,11 +542,7 @@
MutexGuard guard(m_refMutex->mutex );
checkClosed();
checkColumnIndex( parameterIndex );
- OStringBuffer buf( 20 );
- buf.append( "'" );
- buf.append( x );
- buf.append( "'" );
- m_vars[parameterIndex-1] = buf.makeStringAndClear();
+ m_vars[parameterIndex-1] = "'" + OString::number( x ) + "'";
}
void PreparedStatement::setDouble( sal_Int32 parameterIndex, double x )
@@ -571,18 +551,12 @@
MutexGuard guard(m_refMutex->mutex );
checkClosed();
checkColumnIndex( parameterIndex );
- OStringBuffer buf( 20 );
- buf.append( "'" );
- buf.append( x );
- buf.append( "'" );
- m_vars[parameterIndex-1] = buf.makeStringAndClear();
+ m_vars[parameterIndex-1] = "'" + OString::number( x ) + "'";
}
void PreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x )
throw (SQLException, RuntimeException)
{
-// printf( "setString %d %s\n ", parameterIndex,
-// OUStringToOString( x , RTL_TEXTENCODING_ASCII_US ).getStr());
MutexGuard guard(m_refMutex->mutex );
checkClosed();
checkColumnIndex( parameterIndex );
@@ -669,10 +643,8 @@
{
if( ! implSetObject( this, parameterIndex, x ))
{
- OUStringBuffer buf;
- buf.append( "pq_preparedstatement::setObject: can't convert value of type " );
- buf.append( x.getValueTypeName() );
- throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any () );
+ throw SQLException( "pq_preparedstatement::setObject: can't convert value of type " + x.getValueTypeName()
+ , *this, "", 1, Any () );
}
}
@@ -699,16 +671,13 @@
}
if( !myString.isEmpty() )
{
-// printf( "setObjectWithInfo %s\n", OUStringToOString(myString,RTL_TEXTENCODING_ASCII_US).getStr());
setString( parameterIndex, myString );
}
else
{
- OUStringBuffer buf;
- buf.append( "pq_preparedstatement::setObjectWithInfo: can't convert value of type " );
- buf.append( x.getValueTypeName() );
- buf.append( " to type DECIMAL or NUMERIC" );
- throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any () );
+ throw SQLException( "pq_preparedstatement::setObjectWithInfo: can't convert value of type " +
+ x.getValueTypeName() + " to type DECIMAL or NUMERIC"
+ , *this, "", 1, Any () );
}
}
else
@@ -830,11 +799,8 @@
}
default:
{
- OUStringBuffer buf(128);
- buf.appendAscii( "pq_statement: Invalid property handle (" );
- buf.append( nHandle );
- buf.appendAscii( ")" );
- throw IllegalArgumentException( buf.makeStringAndClear(), *this, 2 );
+ throw IllegalArgumentException( "pq_statement: Invalid property handle (" + OUString::number( nHandle ) + ")"
+ , *this, 2 );
}
}
return bRet;
diff --git a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx
index 352a7d7..89c7eff 100644
--- a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx
@@ -71,10 +71,6 @@
using osl::Mutex;
using osl::MutexGuard;
-using rtl::OUString;
-using rtl::OUStringBuffer;
-using rtl::OString;
-
using com::sun::star::uno::Any;
using com::sun::star::uno::RuntimeException;
using com::sun::star::uno::Exception;
@@ -184,14 +180,13 @@
Reference< XStatement > stmt =
extractConnectionFromStatement( m_origin->getStatement() )->createStatement();
DisposeGuard guard( stmt );
- OUStringBuffer buf(128);
- buf.appendAscii( "SELECT oid, typname, typtype FROM pg_type WHERE ");
+ OUStringBuffer buf("SELECT oid, typname, typtype FROM pg_type WHERE ");
for( int i = 0 ; i < m_colCount ; i ++ )
{
if( i > 0 )
- buf.appendAscii( " OR " );
+ buf.append( " OR " );
int oid = m_colDesc[i].typeOid;
- buf.appendAscii( "oid=" );
+ buf.append( "oid=" );
buf.append( (sal_Int32) oid, 10 );
}
Reference< XResultSet > rs = stmt->executeQuery( buf.makeStringAndClear() );
@@ -238,7 +233,6 @@
if( tables.is() )
{
OUString name = getTableName( 1 );
-// if( tables->hasByName( name ) )
tables->getByName( name ) >>= m_table;
}
}
@@ -400,21 +394,15 @@
return m_colDesc[column-1].scale;
}
-::rtl::OUString ResultSetMetaData::getTableName( sal_Int32 column )
+OUString ResultSetMetaData::getTableName( sal_Int32 column )
throw (SQLException, RuntimeException)
{
(void) column;
// LEM TODO This is very fishy.. Should probably return the table to which that column belongs!
- rtl::OUString ret;
if( m_tableName.getLength() )
- {
- OUStringBuffer buf( 128 );
- buf.append( m_schemaName );
- buf.appendAscii( "." );
- buf.append( m_tableName );
- ret = buf.makeStringAndClear();
- }
- return ret;
+ return m_schemaName + "." + m_tableName;
+
+ return OUString();
}
::rtl::OUString ResultSetMetaData::getCatalogName( sal_Int32 column )
@@ -501,14 +489,9 @@
{
if( columnIndex < 1 || columnIndex > m_colCount )
{
- OUStringBuffer buf(128);
-
- buf.appendAscii( "pq_resultsetmetadata: index out of range (expected 1 to " );
- buf.append( m_colCount );
- buf.appendAscii( ", got " );
- buf.append( columnIndex );
- throw SQLException(
- buf.makeStringAndClear(), *this, OUString(), 1, Any() );
+ throw SQLException("pq_resultsetmetadata: index out of range (expected 1 to " +
+ OUString::number( m_colCount ) + ", got " + OUString::number( columnIndex )
+ , *this, OUString(), 1, Any() );
}
}
diff --git a/connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata.cxx b/connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata.cxx
index a538e9e..4970aa1 100644
--- a/connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_sequenceresultsetmetadata.cxx
@@ -59,8 +59,6 @@
#include <rtl/ustrbuf.hxx>
-using rtl::OUStringBuffer;
-using rtl::OUString;
using com::sun::star::uno::Any;
using com::sun::star::uno::RuntimeException;
@@ -223,16 +221,10 @@
{
if( columnIndex < 1 || columnIndex > m_colCount )
{
- OUStringBuffer buf(128);
-
- buf.appendAscii( "pq_sequenceresultsetmetadata: index out of range (expected 1 to " );
- buf.append( m_colCount );
- buf.appendAscii( ", got " );
- buf.append( columnIndex );
- throw SQLException(
- buf.makeStringAndClear(), *this, OUString(), 1, Any() );
+ throw SQLException( "pq_sequenceresultsetmetadata: index out of range (expected 1 to " +
+ OUString::number( m_colCount ) + ", got " + OUString::number( columnIndex )
+ , *this, OUString(), 1, Any() );
}
}
-
}
diff --git a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx
index dbbec1e..df4c298 100644
--- a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx
+++ b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx
@@ -72,11 +72,6 @@
using osl::MutexGuard;
-using rtl::OUString;
-using rtl::OUStringBuffer;
-using rtl::OStringBuffer;
-using rtl::OString;
-
using com::sun::star::uno::Reference;
using com::sun::star::uno::makeAny;
using com::sun::star::uno::Sequence;
@@ -209,15 +204,14 @@
OUString ret;
if( m_primaryKey.getLength() )
{
- OUStringBuffer buf( 128 );
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " WHERE " ) );
+ OUStringBuffer buf( " WHERE " );
for( int i = 0 ; i < m_primaryKey.getLength() ; i ++ )
{
if( i > 0 )
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " AND " ) );
+ buf.append( " AND " );
sal_Int32 index = findColumn( m_primaryKey[i] );
bufferQuoteIdentifier( buf, m_primaryKey[i], *m_ppSettings );
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " = " ) );
+ buf.append( " = " );
bufferQuoteConstant( buf, getString( index ), *m_ppSettings );
}
ret = buf.makeStringAndClear();
@@ -238,10 +232,9 @@
"pq_resultset.insertRow: moveToInsertRow has not been called !",
*this, OUString(), 1, Any() );
- OUStringBuffer buf( 128 );
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "INSERT INTO " ) );
+ OUStringBuffer buf( "INSERT INTO " );
bufferQuoteQualifiedIdentifier( buf, m_schema, m_table, *m_ppSettings );
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " ( " ) );
+ buf.append( " ( " );
int columns = 0;
for( UpdateableFieldVector::size_type i = 0 ; i < m_updateableField.size() ; i++ )
@@ -249,12 +242,12 @@
if( m_updateableField[i].isTouched )
{
if( columns > 0 )
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
+ buf.append( ", " );
columns ++;
bufferQuoteIdentifier( buf, m_columnNames[i], *m_ppSettings);
}
}
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " ) VALUES ( " ) );
+ buf.append( " ) VALUES ( " );
columns = 0;
for( UpdateableFieldVector::size_type i = 0 ; i < m_updateableField.size() ; i ++ )
@@ -262,18 +255,13 @@
if( m_updateableField[i].isTouched )
{
if( columns > 0 )
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " , " ) );
+ buf.append( " , " );
columns ++;
bufferQuoteAnyConstant( buf, m_updateableField[i].value, *m_ppSettings );
-
-// OUString val;
-// m_updateableField[i].value >>= val;
-// buf.append( val );
-// rtl::OStringToOUString(val, (*m_ppSettings)->encoding ) );
}
}
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " )" ) );
+ buf.append( " )" );
Reference< XStatement > stmt =
extractConnectionFromStatement(m_owner)->createStatement();
@@ -332,10 +320,9 @@
"pq_resultset.updateRow: moveToCurrentRow has not been called !",
*this, OUString(), 1, Any() );
- OUStringBuffer buf( 128 );
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "UPDATE " ) );
+ OUStringBuffer buf( "UPDATE " );
bufferQuoteQualifiedIdentifier( buf, m_schema, m_table, *m_ppSettings );
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "SET " ) );
+ buf.append( "SET " );
int columns = 0;
for( UpdateableFieldVector::size_type i = 0; i < m_updateableField.size() ; i ++ )
@@ -343,16 +330,11 @@
if( m_updateableField[i].isTouched )
{
if( columns > 0 )
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
+ buf.append( ", " );
columns ++;
- buf.append( m_columnNames[i] );
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" = " ) );
+ buf.append( m_columnNames[i] + " = " );
bufferQuoteAnyConstant( buf, m_updateableField[i].value, *m_ppSettings );
-// OUString val;
-// m_updateableField[i].value >>= val;
-// bufferQuoteConstant( buf, val ):
-// buf.append( val );
}
}
buf.append( buildWhereClause() );
@@ -383,19 +365,15 @@
if( m_row < 0 || m_row >= m_rowCount )
{
- OUStringBuffer buf( 128 );
- buf.appendAscii( "deleteRow cannot be called on invalid row (" );
- buf.append( m_row );
- buf.appendAscii( ")" );
- throw SQLException( buf.makeStringAndClear() , *this, OUString(), 0, Any() );
+ throw SQLException( "deleteRow cannot be called on invalid row (" + OUString::number( m_row ) + ")"
+ , *this, OUString(), 0, Any() );
}
Reference< XStatement > stmt = extractConnectionFromStatement(m_owner)->createStatement();
DisposeGuard dispGuard( stmt );
- OUStringBuffer buf( 128 );
- buf.appendAscii( "DELETE FROM " );
+ OUStringBuffer buf( "DELETE FROM " );
bufferQuoteQualifiedIdentifier( buf, m_schema, m_table, *m_ppSettings );
- buf.appendAscii( " " );
+ buf.append( " " );
buf.append( buildWhereClause() );
stmt->executeUpdate( buf.makeStringAndClear() );
@@ -465,12 +443,6 @@
void UpdateableResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw (SQLException, RuntimeException)
{
updateLong( columnIndex, x );
-// MutexGuard guard( m_refMutex->mutex );
-// checkClosed();
-// checkUpdate( columnIndex );
-
-// m_updateableField[columnIndex-1].value <<= OUString::valueOf( x );
-
}
void UpdateableResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw (SQLException, RuntimeException)
@@ -479,10 +451,6 @@
checkClosed();
checkUpdate( columnIndex );
-// OStringBuffer buf( 20 );
-// buf.append( "'" );
-// buf.append( (sal_Int64) x );
-// buf.append( "'" );
m_updateableField[columnIndex-1].value <<= OUString::valueOf( x );
}
@@ -529,7 +497,6 @@
"pq_preparedstatement.setBytes: Error during converting bytesequence to an SQL conform string",
*this, OUString(), 1, Any() );
}
-// buf.append( (const sal_Char *)escapedString, len -1 );
m_updateableField[columnIndex-1].value <<=
OUString( (sal_Char*) escapedString, len, RTL_TEXTENCODING_ASCII_US );
diff --git a/connectivity/source/drivers/postgresql/pq_xbase.cxx b/connectivity/source/drivers/postgresql/pq_xbase.cxx
index b07315b..a0faea5 100644
--- a/connectivity/source/drivers/postgresql/pq_xbase.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xbase.cxx
@@ -120,12 +120,8 @@
sal_Int32 nHandle = m_propsDesc.getHandleByName( name );
if( -1 == nHandle )
{
- rtl::OUStringBuffer buf(128);
- buf.appendAscii( "Unknown property '" );
- buf.append( name );
- buf.appendAscii( "' in " );
- buf.append( m_implName );
- throw com::sun::star::uno::RuntimeException( buf.makeStringAndClear() , *this );
+ throw com::sun::star::uno::RuntimeException( "Unknown property '" + name + "' in " + m_implName
+ , *this );
}
setFastPropertyValue_NoBroadcast( nHandle , value );
}
@@ -135,23 +131,15 @@
const ::com::sun::star::uno::Any& rValue )
throw (::com::sun::star::uno::Exception)
{
-// rtl::OUString s;
-// rValue >>= s;
-// printf( "setting value (handle %d):%s\n" ,
-// nHandle, rtl::OUStringToOString(s, RTL_TEXTENCODING_ASCII_US).getStr() );
m_values[nHandle] = rValue;
}
void ReflectionBase::getFastPropertyValue(
::com::sun::star::uno::Any& rValue,
sal_Int32 nHandle ) const
+
{
rValue = m_values[nHandle];
-// rtl::OUString s;
-// rValue >>= s;
-// printf( "getting value (handle %d):%s\n" ,
-// nHandle, rtl::OUStringToOString(s, RTL_TEXTENCODING_ASCII_US).getStr() );
-
}
Reference < ::com::sun::star::beans::XPropertySetInfo > ReflectionBase::getPropertySetInfo()
diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
index 15e9690..4dabbd7 100644
--- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xcolumns.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::beans::XPropertyChangeListener;
using com::sun::star::beans::PropertyChangeEvent;
@@ -110,28 +106,9 @@
return Any( &b, getBooleanCppuType() );
}
-// static sal_Bool isAutoIncrement8( const rtl::OUString & typeName )
-// {
-// return typeName.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("serial8")) ||
-// typeName.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("bigserial"));
-// }
-
static Any isAutoIncrement( const rtl::OUString & defaultValue )
{
sal_Bool ret = defaultValue.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "nextval(" ) );
-// printf( "%s %d\n",
-// OUStringToOString(defaultValue, RTL_TEXTENCODING_ASCII_US).getStr(),
-// ret );
-// {
-// static const char * const serials[] =
-// {
-// "serial", "serial4", "serial8", "bigserial", 0
-// };
-// s sal_Bool b = sal_False;
-// for( int i = 0; !b && serials[i] ; i ++ )
-// {
-// b = b || typeName.equalsIgnoreAsciiCaseAscii( serials[i] );
-// }
return Any ( &ret, getBooleanCppuType() );
}
@@ -255,59 +232,6 @@
return name;
}
-
-// class CommentChanger : public cppu::WeakImplHelper1< XPropertyChangeListener >
-// {
-// ::rtl::Reference< RefCountedMutex > m_refMutex;
-// ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > m_connection;
-// ConnectionSettings *m_pSettings;
-// rtl::OUString m_schema;
-// rtl::OUString m_table;
-// rtl::OUString m_column;
-
-// public:
-// CommentChanger(
-// const ::rtl::Reference< RefCountedMutex > & refMutex,
-// const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & connection,
-// ConnectionSettings *pSettings,
-// const rtl::OUString & schema,
-// const rtl::OUString & table,
-// const rtl::OUString & column ) :
-// m_refMutex( refMutex ),
-// m_connection( connection ),
-// m_pSettings( pSettings ),
-// m_schema ( schema ),
-// m_table ( table ),
-// m_column ( column )
-// {}
-
-
-// // Methods
-// virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException)
-// {
-// osl::MutexGuard guard( m_refMutex->mutex );
-// m_connection.clear();
-// }
-// // Methods
-// virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException)
-// {
-// osl::MutexGuard guard( m_refMutex->mutex );
-// OUStringBuffer buf( 128 );
-// OUString comment;
-// evt.NewValue >>= comment;
-// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "COMMENT ON COLUMN" ) );
-// bufferQuoteQualifiedIdentifier( buf, m_schema, m_table , m_column );
-// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "IS " ) );
-// bufferQuoteConstant( buf, comment,m_pSettings->encoding);
-
-// printf( "changing comment of column %s to %s\n",
-// OUStringToOString( m_column, RTL_TEXTENCODING_ASCII_US ).getStr(),
-// OUStringToOString( comment, RTL_TEXTENCODING_ASCII_US ).getStr() );
-
-// m_connection->createStatement()->executeUpdate( buf.makeStringAndClear() );
-// }
-// };
-
void Columns::refresh()
throw (::com::sun::star::uno::RuntimeException)
{
@@ -344,15 +268,6 @@
Reference< com::sun::star::beans::XPropertySet > prop = pColumn;
OUString name = columnMetaData2SDBCX( pColumn, xRow );
-// pColumn->addPropertyChangeListener(
-// st.HELP_TEXT,
-// new CommentChanger(
-// m_refMutex,
-// m_origin,
-// m_pSettings,
-// m_schemaName,
-// m_tableName,
-// name ) );
{
const int currentColumnIndex = columnIndex++;
@@ -382,21 +297,6 @@
{
Statics & st = getStatics();
-// if( past->getPropertyValue( st.TABLE_NAME ) != future->getPropertyValue( st.TABLE_NAME ) ||
-// past->getPropertyValue( st.SCHEMA_NAME ) != future->getPropertyValue( st.SCHEMA_NAME ))
-// {
-// OUStringBuffer buf(128);
-// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Can't move column " ) );
-// buf.append( extractStringProperty( past, st.COLUMN_NAME ) );
-// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " from table " ) );
-// buf.append( extractStringProperty( past, st.TABLE_NAME ) );
-// buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " to table " ) );
-// buf.append( extractStringProperty( past, st.TABLE_NAME ) );
-// throw SQLException( buf.makeStringAndClear(), Reference< XInterface > () );
-// }
-
-// OUString tableName = extractStringProperty( past, st.TABLE_NAME );
-// OUString schemaName = extractStringProperty( past, st.SCHEMA_NAME );
OUString pastColumnName = extractStringProperty( past, st.NAME );
OUString futureColumnName = extractStringProperty( future, st.NAME );
OUString pastTypeName = sqltype2string( past );
@@ -475,11 +375,6 @@
transaction.executeUpdate( buf.makeStringAndClear() );
}
-// OUString futureComment = extractStringProperty( future, st.HELP_TEXT );
-// OUString pastComment = extractStringProperty( past, st.HELP_TEXT );
-// printf( "past Comment %s, futureComment %s\n",
-// OUStringToOString( pastComment, RTL_TEXTENCODING_ASCII_US ).getStr(),
-// OUStringToOString( futureComment, RTL_TEXTENCODING_ASCII_US ).getStr() );
OUString futureComment = extractStringProperty( future, st.DESCRIPTION );
OUString pastComment = extractStringProperty( past, st.DESCRIPTION );
@@ -510,28 +405,6 @@
refresh();
}
-
-// void Columns::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( "Column " );
-// buf.append( elementName );
-// buf.appendAscii( " is unknown in table " );
-// buf.append( m_schemaName );
-// buf.appendAscii( "." );
-// buf.append( m_tableName );
-// buf.appendAscii( ", so it can't be dropped" );
-// throw com::sun::star::container::NoSuchElementException(
-// buf.makeStringAndClear(), *this );
-// }
-// dropByIndex( ii->second );
-// }
void Columns::dropByIndex( sal_Int32 index )
throw (::com::sun::star::sdbc::SQLException,
@@ -592,8 +465,6 @@
return ret;
}
-
-//_____________________________________________________________________________________
ColumnDescriptors::ColumnDescriptors(
const ::rtl::Reference< RefCountedMutex > & refMutex,
const ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > & origin,
--
To view, visit https://gerrit.libreoffice.org/3170
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic7bc35f5e65292d2d8a9d51418760c702676e478
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