summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/postgresql/pq_statement.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/postgresql/pq_statement.cxx')
-rw-r--r--connectivity/source/drivers/postgresql/pq_statement.cxx71
1 files changed, 33 insertions, 38 deletions
diff --git a/connectivity/source/drivers/postgresql/pq_statement.cxx b/connectivity/source/drivers/postgresql/pq_statement.cxx
index 946d25b0c91e..5867d5cdbf33 100644
--- a/connectivity/source/drivers/postgresql/pq_statement.cxx
+++ b/connectivity/source/drivers/postgresql/pq_statement.cxx
@@ -44,7 +44,6 @@
#include <osl/time.h>
#include <rtl/ustrbuf.hxx>
-#include <rtl/strbuf.hxx>
#include <comphelper/sequence.hxx>
@@ -60,6 +59,7 @@
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <cstddef>
#include <string.h>
#include <string_view>
@@ -103,31 +103,31 @@ static ::cppu::IPropertyArrayHelper & getStatementPropertyArrayHelper()
static ::cppu::OPropertyArrayHelper arrayHelper(
Sequence<Property>{
Property(
- "CursorName", 0,
+ u"CursorName"_ustr, 0,
::cppu::UnoType<OUString>::get() , 0 ),
Property(
- "EscapeProcessing", 1,
+ u"EscapeProcessing"_ustr, 1,
cppu::UnoType<bool>::get() , 0 ),
Property(
- "FetchDirection", 2,
+ u"FetchDirection"_ustr, 2,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
- "FetchSize", 3,
+ u"FetchSize"_ustr, 3,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
- "MaxFieldSize", 4,
+ u"MaxFieldSize"_ustr, 4,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
- "MaxRows", 5,
+ u"MaxRows"_ustr, 5,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
- "QueryTimeOut", 6,
+ u"QueryTimeOut"_ustr, 6,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
- "ResultSetConcurrency", 7,
+ u"ResultSetConcurrency"_ustr, 7,
::cppu::UnoType<sal_Int32>::get() , 0 ),
Property(
- "ResultSetType", 8,
+ u"ResultSetType"_ustr, 8,
::cppu::UnoType<sal_Int32>::get() , 0 )},
true );
@@ -162,7 +162,7 @@ void Statement::checkClosed()
{
if( ! m_pSettings || ! m_pSettings->pConnection )
throw SQLException(
- "pq_driver: Statement or connection has already been closed !",
+ u"pq_driver: Statement or connection has already been closed !"_ustr,
*this, OUString(),1,Any());
}
@@ -253,10 +253,10 @@ static void raiseSQLException(
buf.append( "]" );
}
buf.append(
- OUString( errorMsg, strlen(errorMsg) , ConnectionSettings::encoding ) );
- buf.append( " (caused by statement '" );
- buf.append( OStringToOUString( sql, ConnectionSettings::encoding ) );
- buf.append( "')" );
+ OUString( errorMsg, strlen(errorMsg) , ConnectionSettings::encoding )
+ + " (caused by statement '"
+ + OStringToOUString( sql, ConnectionSettings::encoding )
+ + "')" );
OUString error = buf.makeStringAndClear();
SAL_WARN("connectivity.postgresql", error);
throw SQLException( error, owner, OUString(), 1, Any() );
@@ -430,8 +430,8 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data )
&table);
// check, whether the columns are in the result set (required !)
- int i;
- for( i = 0 ; i < static_cast<int>(sourceTableKeys.size()) ; i ++ )
+ std::size_t i;
+ for( i = 0 ; i < sourceTableKeys.size() ; i ++ )
{
if( -1 == PQfnumber(
result,
@@ -442,12 +442,12 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data )
}
}
- if( !sourceTableKeys.empty() && i == static_cast<int>(sourceTableKeys.size()) )
+ if( !sourceTableKeys.empty() && i == sourceTableKeys.size() )
{
*(data->pLastResultset) =
UpdateableResultSet::createFromPGResultSet(
data->refMutex, data->owner, data->ppSettings, result,
- schema, table,sourceTableKeys );
+ schema, table, std::move(sourceTableKeys) );
}
else if( ! table.getLength() )
{
@@ -456,15 +456,12 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data )
}
else if( !sourceTableKeys.empty() )
{
- OStringBuffer buf( 128 );
- buf.append( "can't support updateable resultset for table " );
- buf.append( OUStringToOString( schema, ConnectionSettings::encoding ) );
- buf.append( "." );
- 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], ConnectionSettings::encoding ) );
- buf.append( " is missing )" );
- aReason = buf.makeStringAndClear();
+ aReason = "can't support updateable resultset for table "
+ + OUStringToOString( schema, ConnectionSettings::encoding ) + "."
+ + OUStringToOString( table, ConnectionSettings::encoding )
+ + ", because resultset does not contain a part of the primary key ( column "
+ + OUStringToOString( sourceTableKeys[i], ConnectionSettings::encoding )
+ + " is missing )";
}
else
{
@@ -534,12 +531,12 @@ static Sequence< OUString > getPrimaryKeyColumnNames(
// retrieve the primary key ...
Reference< XPreparedStatement > stmt = connection->prepareStatement(
- "SELECT conkey " // 7
+ u"SELECT conkey " // 7
"FROM pg_constraint INNER JOIN pg_class ON conrelid = pg_class.oid "
"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 = ? AND pg_constraint.contype='p'" );
+ "WHERE pg_class.relname = ? AND pg_namespace.nspname = ? AND pg_constraint.contype='p'"_ustr );
DisposeGuard guard( stmt );
Reference< XParameters > paras( stmt, UNO_QUERY );
paras->setString( 1 , tableName );
@@ -559,7 +556,7 @@ static void getAutoValues(
const Reference< XConnection > & connection,
const OUString &schemaName,
const OUString & tableName,
- ConnectionSettings *pConnectionSettings )
+ const ConnectionSettings *pConnectionSettings )
{
OUString strDefaultValue = getColExprForDefaultSettingVal(pConnectionSettings);
Reference< XPreparedStatement > stmt = connection->prepareStatement(
@@ -593,7 +590,7 @@ Reference< XResultSet > getGeneratedValuesFromLastInsert(
ConnectionSettings *pConnectionSettings,
const Reference< XConnection > &connection,
sal_Int32 nLastOid,
- const OUString & lastTableInserted,
+ std::u16string_view lastTableInserted,
const OString & lastQuery )
{
Reference< XResultSet > ret;
@@ -602,7 +599,7 @@ Reference< XResultSet > getGeneratedValuesFromLastInsert(
splitConcatenatedIdentifier(
lastTableInserted, &schemaName, &tableName );
- if( nLastOid && lastTableInserted.getLength() )
+ if( nLastOid && lastTableInserted.size() )
{
OUStringBuffer buf( 128 );
buf.append( "SELECT * FROM " );
@@ -610,11 +607,10 @@ Reference< XResultSet > getGeneratedValuesFromLastInsert(
bufferQuoteQualifiedIdentifier(buf, schemaName, tableName, pConnectionSettings );
else
bufferQuoteIdentifier( buf, lastTableInserted, pConnectionSettings );
- buf.append( " WHERE oid = " );
- buf.append( nLastOid );
+ buf.append( " WHERE oid = " + OUString::number(nLastOid) );
query = buf.makeStringAndClear();
}
- else if ( lastTableInserted.getLength() && lastQuery.getLength() )
+ else if ( lastTableInserted.size() && lastQuery.getLength() )
{
// extract nameValue Pairs
String2StringMap namedValues;
@@ -703,8 +699,7 @@ Reference< XResultSet > getGeneratedValuesFromLastInsert(
if( bAdditionalCondition )
buf.append( " AND " );
bufferQuoteIdentifier( buf, columnNameUnicode, pConnectionSettings );
- buf.append( " = " );
- buf.append( value );
+ buf.append( " = " + value );
bAdditionalCondition = true;
}
query = buf.makeStringAndClear();