diff options
Diffstat (limited to 'connectivity/source/drivers/postgresql')
13 files changed, 51 insertions, 53 deletions
diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx index 89de976b0592..9ea84719f800 100644 --- a/connectivity/source/drivers/postgresql/pq_connection.cxx +++ b/connectivity/source/drivers/postgresql/pq_connection.cxx @@ -277,7 +277,7 @@ Reference< XPreparedStatement > Connection::prepareStatement( const OUString& sq MutexGuard guard( m_refMutex->mutex ); checkClosed(); - OString byteSql = OUStringToOString( sql, m_settings.encoding ); + OString byteSql = OUStringToOString( sql, ConnectionSettings::encoding ); PreparedStatement *stmt = new PreparedStatement( m_refMutex, this, &m_settings, byteSql ); Reference< XPreparedStatement > ret = stmt; @@ -366,7 +366,7 @@ OUString Connection::getCatalog() throw (SQLException, RuntimeException, std::ex OUString(), 1, Any() ); } char * p = PQdb(m_settings.pConnection ); - return OUString( p, strlen(p) , m_settings.encoding ); + return OUString( p, strlen(p) , ConnectionSettings::encoding ); } void Connection::setTransactionIsolation( sal_Int32 ) @@ -524,7 +524,7 @@ void Connection::initialize( const Sequence< Any >& aArguments ) nColon = url.indexOf( ':' , 1+ nColon ); if( nColon != -1 ) { - o = OUStringToOString( url.getStr()+nColon+1, m_settings.encoding ); + o = OUStringToOString( url.getStr()+nColon+1, ConnectionSettings::encoding ); } } { @@ -540,7 +540,7 @@ void Connection::initialize( const Sequence< Any >& aArguments ) OUString errorMessage; if ( err != nullptr) { - errorMessage = OUString( err, strlen(err), m_settings.encoding ); + errorMessage = OUString( err, strlen(err), ConnectionSettings::encoding ); free(err); } else @@ -564,7 +564,7 @@ void Connection::initialize( const Sequence< Any >& aArguments ) } } } - properties2arrays( args , tc, m_settings.encoding, keywords, values ); + properties2arrays( args , tc, ConnectionSettings::encoding, keywords, values ); keywords.push_back(nullptr, SAL_NO_ACQUIRE); values.push_back(nullptr, SAL_NO_ACQUIRE); @@ -679,7 +679,7 @@ bool isLog(ConnectionSettings *settings, LogLevel nLevel) void log(ConnectionSettings *settings, LogLevel nLevel, const OUString &logString) { - log(settings, nLevel, OUStringToOString(logString, settings->encoding ).getStr()); + log( settings, nLevel, OUStringToOString( logString, ConnectionSettings::encoding ).getStr() ); } void log(ConnectionSettings *settings, LogLevel nLevel, const char *str) { diff --git a/connectivity/source/drivers/postgresql/pq_connection.hxx b/connectivity/source/drivers/postgresql/pq_connection.hxx index f4c24ed9f5fd..cfb4cccf1b9c 100644 --- a/connectivity/source/drivers/postgresql/pq_connection.hxx +++ b/connectivity/source/drivers/postgresql/pq_connection.hxx @@ -98,7 +98,6 @@ class Views; struct ConnectionSettings { ConnectionSettings() : - encoding( RTL_TEXTENCODING_UTF8), pConnection(nullptr), maxNameLen(0), maxIndexKeys(0), @@ -108,7 +107,7 @@ struct ConnectionSettings logFile( nullptr ), m_nLogLevel(LogLevel::Info) {} - rtl_TextEncoding encoding; + static const rtl_TextEncoding encoding = RTL_TEXTENCODING_UTF8; PGconn *pConnection; sal_Int32 maxNameLen; sal_Int32 maxIndexKeys; diff --git a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx index 860ffe4324da..d809da7e3eb1 100644 --- a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx +++ b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx @@ -218,7 +218,7 @@ void PreparedStatement::checkColumnIndex( sal_Int32 parameterIndex ) buf.append( ", got " ); buf.append( parameterIndex ); buf.append( ", statement '" ); - buf.append( OStringToOUString( m_stmt, m_pSettings->encoding ) ); + buf.append( OStringToOUString( m_stmt, ConnectionSettings::encoding ) ); buf.append( "')" ); throw SQLException( buf.makeStringAndClear(), *this, OUString(), 1, Any () ); } @@ -287,7 +287,7 @@ void PreparedStatement::raiseSQLException( const char * errorMsg ) OUStringBuffer buf(128); buf.append( "pq_driver: "); buf.append( - OUString( errorMsg, strlen(errorMsg) , m_pSettings->encoding ) ); + OUString( errorMsg, strlen(errorMsg) , ConnectionSettings::encoding ) ); buf.append( " (caused by statement '" ); buf.appendAscii( m_executedStatement.getStr() ); buf.append( "')" ); @@ -521,7 +521,7 @@ void PreparedStatement::setString( sal_Int32 parameterIndex, const OUString& x ) checkColumnIndex( parameterIndex ); OStringBuffer buf( 20 ); buf.append( "'" ); - OString y = OUStringToOString( x, m_pSettings->encoding ); + OString y = OUStringToOString( x, ConnectionSettings::encoding ); buf.ensureCapacity( y.getLength() * 2 + 2 ); int len = PQescapeString( const_cast<char*>(buf.getStr())+1, y.getStr() , y.getLength() ); buf.setLength( 1 + len ); diff --git a/connectivity/source/drivers/postgresql/pq_resultset.cxx b/connectivity/source/drivers/postgresql/pq_resultset.cxx index 1e7ed65b4989..e569b88da9c7 100644 --- a/connectivity/source/drivers/postgresql/pq_resultset.cxx +++ b/connectivity/source/drivers/postgresql/pq_resultset.cxx @@ -121,7 +121,7 @@ Any ResultSet::getValue( sal_Int32 columnIndex ) ret <<= OUString( PQgetvalue( m_result, m_row , columnIndex -1 ) , PQgetlength( m_result, m_row , columnIndex -1 ) , - (*m_ppSettings)->encoding ); + ConnectionSettings::encoding ); } return ret; @@ -160,7 +160,7 @@ sal_Int32 ResultSet::findColumn( const OUString& columnName ) MutexGuard guard( m_refMutex->mutex ); checkClosed(); sal_Int32 res = PQfnumber( m_result, - OUStringToOString( columnName, (*m_ppSettings)->encoding ).getStr()); + OUStringToOString( columnName, ConnectionSettings::encoding ).getStr()); /* PQfnumber return -1 for not found, which is what we want * other than that we use col number as 1-based not 0-based */ if(res >= 0) diff --git a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx index c2e64df1efcc..2a256a70fe14 100644 --- a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx +++ b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx @@ -144,7 +144,7 @@ ResultSetMetaData::ResultSetMetaData( & ( m_colDesc[col].precision ), & ( m_colDesc[col].scale ) ); char *name = PQfname( pResult, col ); - m_colDesc[col].name = OUString( name, strlen(name) , (*m_ppSettings)->encoding ); + m_colDesc[col].name = OUString( name, strlen(name) , ConnectionSettings::encoding ); m_colDesc[col].typeOid = PQftype( pResult, col ); m_colDesc[col].type = css::sdbc::DataType::LONGVARCHAR; } diff --git a/connectivity/source/drivers/postgresql/pq_statement.cxx b/connectivity/source/drivers/postgresql/pq_statement.cxx index f6394fd6b27c..5aaef394e089 100644 --- a/connectivity/source/drivers/postgresql/pq_statement.cxx +++ b/connectivity/source/drivers/postgresql/pq_statement.cxx @@ -243,7 +243,7 @@ void Statement::raiseSQLException( OUStringBuffer buf(128); buf.append( "pq_driver: "); buf.append( - OUString( errorMsg, strlen(errorMsg) , m_pSettings->encoding ) ); + OUString( errorMsg, strlen(errorMsg), ConnectionSettings::encoding ) ); buf.append( " (caused by statement '" ); buf.append( sql ); buf.append( "')" ); @@ -294,9 +294,9 @@ static void raiseSQLException( buf.append( "]" ); } buf.append( - OUString( errorMsg, strlen(errorMsg) , pSettings->encoding ) ); + OUString( errorMsg, strlen(errorMsg) , ConnectionSettings::encoding ) ); buf.append( " (caused by statement '" ); - buf.append( OStringToOUString( sql, pSettings->encoding ) ); + buf.append( OStringToOUString( sql, ConnectionSettings::encoding ) ); buf.append( "')" ); OUString error = buf.makeStringAndClear(); log(pSettings, LogLevel::Error, error); @@ -351,7 +351,7 @@ static std::vector< OUString > lookupKeys( { OStringBuffer buf( 128 ); buf.append( "Can't offer updateable result set because table " ); - buf.append( OUStringToOString(name, pSettings->encoding) ); + buf.append( OUStringToOString(name, ConnectionSettings::encoding) ); buf.append( " is duplicated, add schema to resolve ambiguity" ); log(pSettings, LogLevel::Info, buf.makeStringAndClear().getStr()); } @@ -368,7 +368,7 @@ static std::vector< OUString > lookupKeys( { OStringBuffer buf( 128 ); buf.append( "Can't offer updateable result set ( table " ); - buf.append( OUStringToOString(table, pSettings->encoding) ); + buf.append( OUStringToOString(table, ConnectionSettings::encoding) ); buf.append( " is unknown)" ); log(pSettings, LogLevel::Info, buf.makeStringAndClear().getStr()); } @@ -415,7 +415,7 @@ static std::vector< OUString > lookupKeys( { OStringBuffer buf( 128 ); buf.append( "Can't offer updateable result set ( table " ); - buf.append( OUStringToOString(table, pSettings->encoding) ); + buf.append( OUStringToOString(table, ConnectionSettings::encoding) ); buf.append( " does not have a primary key)" ); log(pSettings, LogLevel::Info, buf.makeStringAndClear().getStr()); } @@ -454,8 +454,8 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) // in case it was a single insert, extract the name of the table, // otherwise the table name is empty *(data->pLastTableInserted) = - extractTableFromInsert( OStringToOUString( cmd, pSettings->encoding ) ); - if (isLog(pSettings, LogLevel::Sql)) + extractTableFromInsert( OStringToOUString( cmd, ConnectionSettings::encoding ) ); + if( isLog( pSettings, LogLevel::Sql ) ) { OStringBuffer buf( 128 ); buf.append( "executed command '" ); @@ -472,7 +472,7 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) buf.append( *(data->pLastOidInserted) ); buf.append( ", diagnosedTable=" ); buf.append( - OUStringToOString( *data->pLastTableInserted, pSettings->encoding ) ); + OUStringToOString( *data->pLastTableInserted, ConnectionSettings::encoding ) ); } log(pSettings, LogLevel::Sql, buf.makeStringAndClear().getStr()); } @@ -490,7 +490,7 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) tokenizeSQL( cmd, vec ); OUString sourceTable = OStringToOUString( - extractSingleTableFromSelect( vec ), pSettings->encoding ); + extractSingleTableFromSelect( vec ), ConnectionSettings::encoding ); if( data->concurrency == css::sdbc::ResultSetConcurrency::UPDATABLE ) @@ -513,7 +513,7 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) if( -1 == PQfnumber( result, OUStringToOString( sourceTableKeys[i] , - pSettings->encoding ).getStr()) ) + ConnectionSettings::encoding ).getStr()) ) { break; } @@ -539,11 +539,11 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) { OStringBuffer buf( 128 ); buf.append( "can't support updateable resultset for table " ); - buf.append( OUStringToOString( schema, pSettings->encoding ) ); + buf.append( OUStringToOString( schema, ConnectionSettings::encoding ) ); buf.append( "." ); - buf.append( OUStringToOString( table, pSettings->encoding ) ); + buf.append( OUStringToOString( table, ConnectionSettings::encoding ) ); buf.append( ", because resultset does not contain a part of the primary key ( column " ); - buf.append( OUStringToOString( sourceTableKeys[i], pSettings->encoding ) ); + buf.append( OUStringToOString( sourceTableKeys[i], ConnectionSettings::encoding ) ); buf.append( " is missing )" ); aReason = buf.makeStringAndClear(); } @@ -552,9 +552,9 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) OStringBuffer buf( 128 ); buf.append( "can't support updateable resultset for table " ); - buf.append( OUStringToOString( schema, pSettings->encoding ) ); + buf.append( OUStringToOString( schema, ConnectionSettings::encoding ) ); buf.append( "." ); - buf.append( OUStringToOString( table, pSettings->encoding ) ); + buf.append( OUStringToOString( table, ConnectionSettings::encoding ) ); buf.append( ", because resultset table does not have a primary key " ); aReason = buf.makeStringAndClear(); } @@ -580,7 +580,7 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) new FakedUpdateableResultSet( data->refMutex, data->owner, data->ppSettings,result, schema, table, - OStringToOUString( aReason, pSettings->encoding) ); + OStringToOUString( aReason, ConnectionSettings::encoding) ); } } @@ -751,13 +751,13 @@ Reference< XResultSet > getGeneratedValuesFromLastInsert( for( int i = 0 ; i < keyColumnNames.getLength() ; i ++ ) { OUString value; - OString columnName = OUStringToOString( keyColumnNames[i], pConnectionSettings->encoding ); + OString columnName = OUStringToOString( keyColumnNames[i], ConnectionSettings::encoding ); String2StringMap::const_iterator ii = namedValues.begin(); for( ; ii != namedValues.end() ; ++ii ) { if( columnName.equalsIgnoreAsciiCase( ii->first ) ) { - value = OStringToOUString( ii->second , pConnectionSettings->encoding ); + value = OStringToOUString( ii->second , ConnectionSettings::encoding ); break; } } diff --git a/connectivity/source/drivers/postgresql/pq_tools.cxx b/connectivity/source/drivers/postgresql/pq_tools.cxx index 4e6df8b0fdf2..53a75134d0be 100644 --- a/connectivity/source/drivers/postgresql/pq_tools.cxx +++ b/connectivity/source/drivers/postgresql/pq_tools.cxx @@ -96,7 +96,7 @@ OUString concatQualified( const OUString & a, const OUString &b) static inline OString iOUStringToOString( const OUString& str, ConnectionSettings *settings) { OSL_ENSURE(settings, "pgsql-sdbc: OUStringToOString got NULL settings"); - return OUStringToOString( str, settings->encoding ); + return OUStringToOString( str, ConnectionSettings::encoding ); } OString OUStringToOString( const OUString& str, ConnectionSettings *settings) { @@ -118,7 +118,7 @@ void bufferEscapeConstant( OUStringBuffer & buf, const OUString & value, Connect // (X/Open SQL CLI, March 1995, ISBN: 1-85912-081-4, X/Open Document Number: C451) // 22018 is for "Invalid character value" and seems to be the best match. // We have no good XInterface Reference to pass here, so just give NULL - throw SQLException(OUString(errstr, strlen(errstr), settings->encoding), + throw SQLException(OUString(errstr, strlen(errstr), ConnectionSettings::encoding), nullptr, OUString("22018"), -1, @@ -164,7 +164,7 @@ static inline void ibufferQuoteIdentifier( OUStringBuffer & buf, const OUString { char *errstr = PQerrorMessage(settings->pConnection); // Implementation-defined SQLACCESS error - throw SQLException(OUString(errstr, strlen(errstr), settings->encoding), + throw SQLException(OUString(errstr, strlen(errstr), ConnectionSettings::encoding), nullptr, OUString("22018"), -1, diff --git a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx index ca28001d07c1..64033eb9d647 100644 --- a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx +++ b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx @@ -92,14 +92,13 @@ css::uno::Reference< css::sdbc::XCloseable > UpdateableResultSet::createFromPGRe const OUString &table, const std::vector< OUString > &primaryKey ) { - ConnectionSettings *pSettings = *ppSettings; sal_Int32 columnCount = PQnfields( result ); sal_Int32 rowCount = PQntuples( result ); std::vector< OUString > columnNames( columnCount ); for( int i = 0 ; i < columnCount ; i ++ ) { char * name = PQfname( result, i ); - columnNames[i] = OUString( name, strlen(name), pSettings->encoding ); + columnNames[i] = OUString( name, strlen(name), ConnectionSettings::encoding ); } std::vector< std::vector< Any > > data( rowCount ); @@ -115,7 +114,7 @@ css::uno::Reference< css::sdbc::XCloseable > UpdateableResultSet::createFromPGRe char * val = PQgetvalue( result, row, col ); aRow[col] = makeAny( - OUString( val, strlen( val ) , (*ppSettings)->encoding ) ); + OUString( val, strlen( val ), ConnectionSettings::encoding ) ); } } data[row] = aRow; diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx index 512554a53ad7..cfb4bc5af733 100644 --- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx @@ -284,10 +284,10 @@ void Columns::refresh() { OStringBuffer buf; buf.append( "sdbcx.Columns get refreshed for table " ); - buf.append( OUStringToOString( m_schemaName, m_pSettings->encoding ) ); + buf.append( OUStringToOString( m_schemaName, ConnectionSettings::encoding ) ); buf.append( "." ); - buf.append( OUStringToOString( m_tableName, m_pSettings->encoding ) ); - log(m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr()); + buf.append( OUStringToOString( m_tableName, ConnectionSettings::encoding ) ); + log( m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr() ); } osl::MutexGuard guard( m_refMutex->mutex ); diff --git a/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx index 5446e5da2132..b8b4738a045a 100644 --- a/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx @@ -109,8 +109,8 @@ void IndexColumns::refresh() { OStringBuffer buf; buf.append( "sdbcx.IndexColumns get refreshed for index " ); - buf.append( OUStringToOString( m_indexName, m_pSettings->encoding ) ); - log(m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr()); + buf.append( OUStringToOString( m_indexName, ConnectionSettings::encoding ) ); + log( m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr() ); } osl::MutexGuard guard( m_refMutex->mutex ); diff --git a/connectivity/source/drivers/postgresql/pq_xindexes.cxx b/connectivity/source/drivers/postgresql/pq_xindexes.cxx index cb46da6fb30a..b5f2c871eff0 100644 --- a/connectivity/source/drivers/postgresql/pq_xindexes.cxx +++ b/connectivity/source/drivers/postgresql/pq_xindexes.cxx @@ -98,10 +98,10 @@ void Indexes::refresh() { OStringBuffer buf; buf.append( "sdbcx.Indexes get refreshed for table " ); - buf.append( OUStringToOString( m_schemaName, m_pSettings->encoding ) ); + buf.append( OUStringToOString( m_schemaName, ConnectionSettings::encoding ) ); buf.append( "." ); - buf.append( OUStringToOString( m_tableName,m_pSettings->encoding ) ); - log(m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr()); + buf.append( OUStringToOString( m_tableName, ConnectionSettings::encoding ) ); + log( m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr() ); } osl::MutexGuard guard( m_refMutex->mutex ); diff --git a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx index 75ee394352fa..e5e1ddb748c8 100644 --- a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx @@ -95,10 +95,10 @@ void KeyColumns::refresh() { OStringBuffer buf; buf.append( "sdbcx.KeyColumns get refreshed for table " ); - buf.append( OUStringToOString( m_schemaName, m_pSettings->encoding ) ); + buf.append( OUStringToOString( m_schemaName, ConnectionSettings::encoding ) ); buf.append( "." ); - buf.append( OUStringToOString( m_tableName, m_pSettings->encoding ) ); - log(m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr()); + buf.append( OUStringToOString( m_tableName, ConnectionSettings::encoding ) ); + log( m_pSettings, LogLevel::Info, buf.makeStringAndClear().getStr() ); } osl::MutexGuard guard( m_refMutex->mutex ); diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.cxx b/connectivity/source/drivers/postgresql/pq_xkeys.cxx index f1d5de67dafe..ddfbdbca7d56 100644 --- a/connectivity/source/drivers/postgresql/pq_xkeys.cxx +++ b/connectivity/source/drivers/postgresql/pq_xkeys.cxx @@ -113,9 +113,9 @@ void Keys::refresh() if (isLog(m_pSettings, LogLevel::Info)) { 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()); + OUStringToOString( m_schemaName, ConnectionSettings::encoding ) + + "." + OUStringToOString( m_tableName, ConnectionSettings::encoding )); + log( m_pSettings, LogLevel::Info, buf.getStr() ); } osl::MutexGuard guard( m_refMutex->mutex ); |