summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/postgresql
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/postgresql')
-rw-r--r--connectivity/source/drivers/postgresql/pq_array.hxx13
-rw-r--r--connectivity/source/drivers/postgresql/pq_connection.cxx17
-rw-r--r--connectivity/source/drivers/postgresql/pq_connection.hxx2
-rw-r--r--connectivity/source/drivers/postgresql/pq_databasemetadata.cxx64
-rw-r--r--connectivity/source/drivers/postgresql/pq_databasemetadata.hxx4
-rw-r--r--connectivity/source/drivers/postgresql/pq_driver.cxx6
-rw-r--r--connectivity/source/drivers/postgresql/pq_driver.hxx7
-rw-r--r--connectivity/source/drivers/postgresql/pq_fakedupdateableresultset.cxx5
-rw-r--r--connectivity/source/drivers/postgresql/pq_fakedupdateableresultset.hxx2
-rw-r--r--connectivity/source/drivers/postgresql/pq_preparedstatement.cxx24
-rw-r--r--connectivity/source/drivers/postgresql/pq_preparedstatement.hxx2
-rw-r--r--connectivity/source/drivers/postgresql/pq_resultset.cxx9
-rw-r--r--connectivity/source/drivers/postgresql/pq_resultset.hxx4
-rw-r--r--connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx20
-rw-r--r--connectivity/source/drivers/postgresql/pq_resultsetmetadata.hxx8
-rw-r--r--connectivity/source/drivers/postgresql/pq_statement.cxx27
-rw-r--r--connectivity/source/drivers/postgresql/pq_statement.hxx2
-rw-r--r--connectivity/source/drivers/postgresql/pq_statics.cxx62
-rw-r--r--connectivity/source/drivers/postgresql/pq_statics.hxx20
-rw-r--r--connectivity/source/drivers/postgresql/pq_tools.cxx96
-rw-r--r--connectivity/source/drivers/postgresql/pq_tools.hxx6
-rw-r--r--connectivity/source/drivers/postgresql/pq_updateableresultset.cxx8
-rw-r--r--connectivity/source/drivers/postgresql/pq_updateableresultset.hxx9
-rw-r--r--connectivity/source/drivers/postgresql/pq_xbase.cxx10
-rw-r--r--connectivity/source/drivers/postgresql/pq_xbase.hxx5
-rw-r--r--connectivity/source/drivers/postgresql/pq_xcolumn.cxx1
-rw-r--r--connectivity/source/drivers/postgresql/pq_xcolumns.cxx40
-rw-r--r--connectivity/source/drivers/postgresql/pq_xcolumns.hxx4
-rw-r--r--connectivity/source/drivers/postgresql/pq_xcontainer.cxx32
-rw-r--r--connectivity/source/drivers/postgresql/pq_xcontainer.hxx6
-rw-r--r--connectivity/source/drivers/postgresql/pq_xindex.cxx9
-rw-r--r--connectivity/source/drivers/postgresql/pq_xindex.hxx4
-rw-r--r--connectivity/source/drivers/postgresql/pq_xindexcolumn.cxx1
-rw-r--r--connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx16
-rw-r--r--connectivity/source/drivers/postgresql/pq_xindexcolumns.hxx6
-rw-r--r--connectivity/source/drivers/postgresql/pq_xindexes.cxx19
-rw-r--r--connectivity/source/drivers/postgresql/pq_xindexes.hxx4
-rw-r--r--connectivity/source/drivers/postgresql/pq_xkey.cxx9
-rw-r--r--connectivity/source/drivers/postgresql/pq_xkey.hxx4
-rw-r--r--connectivity/source/drivers/postgresql/pq_xkeycolumn.cxx1
-rw-r--r--connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx14
-rw-r--r--connectivity/source/drivers/postgresql/pq_xkeycolumns.hxx4
-rw-r--r--connectivity/source/drivers/postgresql/pq_xkeys.cxx30
-rw-r--r--connectivity/source/drivers/postgresql/pq_xkeys.hxx4
-rw-r--r--connectivity/source/drivers/postgresql/pq_xtable.cxx10
-rw-r--r--connectivity/source/drivers/postgresql/pq_xtable.hxx7
-rw-r--r--connectivity/source/drivers/postgresql/pq_xtables.cxx18
-rw-r--r--connectivity/source/drivers/postgresql/pq_xuser.hxx5
-rw-r--r--connectivity/source/drivers/postgresql/pq_xusers.cxx9
-rw-r--r--connectivity/source/drivers/postgresql/pq_xview.cxx8
-rw-r--r--connectivity/source/drivers/postgresql/pq_xview.hxx6
-rw-r--r--connectivity/source/drivers/postgresql/pq_xviews.cxx13
52 files changed, 342 insertions, 374 deletions
diff --git a/connectivity/source/drivers/postgresql/pq_array.hxx b/connectivity/source/drivers/postgresql/pq_array.hxx
index b847d646a913..589fe063d234 100644
--- a/connectivity/source/drivers/postgresql/pq_array.hxx
+++ b/connectivity/source/drivers/postgresql/pq_array.hxx
@@ -39,6 +39,7 @@
#include <com/sun/star/sdbc/XArray.hpp>
#include "pq_connection.hxx"
+#include <utility>
#include <vector>
namespace pq_sdbc_driver
@@ -53,14 +54,14 @@ class Array : public cppu::WeakImplHelper< css::sdbc::XArray >
public:
Array(
- const rtl::Reference< comphelper::RefCountedMutex > & mutex,
+ rtl::Reference< comphelper::RefCountedMutex > mutex,
std::vector< css::uno::Any > && data,
- const css::uno::Reference< css::uno::XInterface > & owner,
- const css::uno::Reference< css::script::XTypeConverter > &tc) :
+ css::uno::Reference< css::uno::XInterface > owner,
+ css::uno::Reference< css::script::XTypeConverter > tc) :
m_data( std::move(data) ),
- m_owner( owner ),
- m_tc( tc ),
- m_xMutex( mutex )
+ m_owner(std::move( owner )),
+ m_tc(std::move( tc )),
+ m_xMutex(std::move( mutex ))
{}
public: // XArray
diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx
index 6661a97d5669..091479f87f95 100644
--- a/connectivity/source/drivers/postgresql/pq_connection.cxx
+++ b/connectivity/source/drivers/postgresql/pq_connection.cxx
@@ -34,6 +34,7 @@
*
************************************************************************/
+#include <utility>
#include <vector>
#include <string.h>
@@ -96,8 +97,8 @@ class ClosableReference : public cppu::WeakImplHelper< css::uno::XReference >
rtl::Reference<Connection> m_conn;
::rtl::ByteSequence m_id;
public:
- ClosableReference( const ::rtl::ByteSequence & id , Connection *that )
- : m_conn( that ), m_id( id )
+ ClosableReference( ::rtl::ByteSequence id , Connection *that )
+ : m_conn( that ), m_id(std::move( id ))
{
}
@@ -115,9 +116,9 @@ public:
Connection::Connection(
const rtl::Reference< comphelper::RefCountedMutex > &refMutex,
- const css::uno::Reference< css::uno::XComponentContext > & ctx )
+ css::uno::Reference< css::uno::XComponentContext > ctx )
: ConnectionBase( refMutex->GetMutex() ),
- m_ctx( ctx ) ,
+ m_ctx(std::move( ctx )) ,
m_xMutex( refMutex )
{
}
@@ -330,7 +331,15 @@ class cstr_vector
std::vector<char*> values;
std::vector<bool> acquired;
public:
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 14
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif
cstr_vector () { values.reserve(8); acquired.reserve(8); }
+#if defined __GNUC__ && !defined __clang__ && __GNUC__ == 14
+#pragma GCC diagnostic pop
+#endif
~cstr_vector ()
{
OSL_ENSURE(values.size() == acquired.size(), "pq_connection: cstr_vector values and acquired size mismatch");
diff --git a/connectivity/source/drivers/postgresql/pq_connection.hxx b/connectivity/source/drivers/postgresql/pq_connection.hxx
index f30483f70938..2bba070a7273 100644
--- a/connectivity/source/drivers/postgresql/pq_connection.hxx
+++ b/connectivity/source/drivers/postgresql/pq_connection.hxx
@@ -134,7 +134,7 @@ private:
public:
Connection(
const rtl::Reference< comphelper::RefCountedMutex > &refMutex,
- const css::uno::Reference< css::uno::XComponentContext > & ctx );
+ css::uno::Reference< css::uno::XComponentContext > ctx );
virtual ~Connection( ) override;
diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
index c3280e07bf15..1fbcb1aa69f5 100644
--- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
@@ -84,6 +84,7 @@
#include <com/sun/star/sdbc/IndexType.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbc/ColumnSearch.hpp>
+#include <utility>
using ::osl::MutexGuard;
@@ -114,12 +115,12 @@ namespace pq_sdbc_driver
#define DEFERRABILITY_NONE 7
DatabaseMetaData::DatabaseMetaData(
- const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
- const css::uno::Reference< css::sdbc::XConnection > & origin,
+ ::rtl::Reference< comphelper::RefCountedMutex > refMutex,
+ css::uno::Reference< css::sdbc::XConnection > origin,
ConnectionSettings *pSettings )
- : m_xMutex( refMutex ),
+ : m_xMutex(std::move( refMutex )),
m_pSettings( pSettings ),
- m_origin( origin ),
+ m_origin(std::move( origin )),
m_getIntSetting_stmt ( m_origin->prepareStatement("SELECT setting FROM pg_catalog.pg_settings WHERE name=?") )
{
init_getReferences_stmt();
@@ -210,10 +211,10 @@ sal_Int32 DatabaseMetaData::getDriverMinorVersion( )
sal_Bool DatabaseMetaData::usesLocalFiles( )
{
// LEM TODO:
- // http://wiki.openoffice.org/wiki/Documentation/DevGuide/Database/XDatabaseMetaData_Interface
+ // https://wiki.documentfoundation.org/Documentation/DevGuide/Database_Access#XDatabaseMetaData_Interface
// says "Returns true when the catalog name of the
// database should not appear in the DatasourceBrowser
- // of OpenOffice.org API, otherwise false is returned."
+ // of LibreOffice API, otherwise false is returned."
// So, hmmm, think about it.
return false;
}
@@ -310,8 +311,8 @@ OUString DatabaseMetaData::getSQLKeywords( )
}
OUString DatabaseMetaData::getNumericFunctions( )
{
- // See http://www.postgresql.org/docs/9.1/static/functions-math.html
- // LEM TODO: Err... http://wiki.openoffice.org/wiki/Documentation/DevGuide/Database/Support_Scalar_Functions
+ // See https://www.postgresql.org/docs/9.1/static/functions-math.html
+ // LEM TODO: Err... https://wiki.documentfoundation.org/Documentation/DevGuide/Database_Access#Support_Scalar_Functions
// says this should be "Open Group CLI" names, not PostgreSQL names.
// Currently this is just a list of supported functions in PostgreSQL, with PostgreSQL names.
// And it is my job to map from Open Group CLI names/syntax to PostgreSQL names/syntax. Where? By parsing the SQL???
@@ -1185,30 +1186,30 @@ css::uno::Reference< XResultSet > DatabaseMetaData::getTables(
namespace
{
// sort no schema first, then "public", then normal schemas, then internal schemas
- int compare_schema(const OUString &nsA, std::u16string_view nsB)
+ int compare_schema(std::u16string_view nsA, std::u16string_view nsB)
{
- if (nsA.isEmpty())
+ if (nsA.empty())
{
return nsB.empty() ? 0 : -1;
}
else if (nsB.empty())
{
- assert(!nsA.isEmpty());
+ assert(!nsA.empty());
return 1;
}
- else if(nsA == "public")
+ else if(nsA == u"public")
{
return (nsB == u"public") ? 0 : -1;
}
else if(nsB == u"public")
{
- assert(nsA != "public");
+ assert(nsA != u"public");
return 1;
}
- else if(nsA.startsWith("pg_"))
+ else if(o3tl::starts_with(nsA, u"pg_"))
{
if(o3tl::starts_with(nsB, u"pg_"))
- return nsA.compareTo(nsB);
+ return nsA.compare(nsB);
else
return 1;
}
@@ -1218,7 +1219,7 @@ namespace
}
else
{
- return nsA.compareTo(nsB);
+ return nsA.compare(nsB);
}
}
@@ -1364,9 +1365,9 @@ namespace {
{
DatabaseTypeDescription()
{}
- DatabaseTypeDescription( const OUString &name, const OUString & type ) :
- typeName( name ),
- typeType( type )
+ DatabaseTypeDescription( OUString name, OUString type ) :
+ typeName(std::move( name )),
+ typeType(std::move( type ))
{}
DatabaseTypeDescription( const DatabaseTypeDescription &source ) :
typeName( source.typeName ),
@@ -1405,8 +1406,7 @@ static void columnMetaData2DatabaseTypeDescription(
oidMap[row->getInt(12)] = DatabaseTypeDescription();
if( domains )
queryBuf.append( " OR " );
- queryBuf.append( "oid = " );
- queryBuf.append( row->getInt(12 ) );
+ queryBuf.append( "oid = " + OUString::number( row->getInt(12 ) ) );
domains ++;
}
}
@@ -2086,45 +2086,45 @@ namespace
OUString nameB;
a[0 /*TYPE_NAME*/] >>= nameA;
b[0 /*TYPE_NAME*/] >>= nameB;
- OUString nsA, tnA, nsB, tnB;
+ std::u16string_view nsA, tnA, nsB, tnB;
// parse typename into schema and typename
sal_Int32 nIndex=0;
- nsA = nameA.getToken(0, '.', nIndex);
+ nsA = o3tl::getToken(nameA, 0, '.', nIndex);
if (nIndex<0)
{
tnA = nsA;
- nsA.clear();
+ nsA = std::u16string_view();
}
else
{
- tnA = nameA.getToken(0, '.', nIndex);
+ tnA = o3tl::getToken(nameA, 0, '.', nIndex);
assert(nIndex < 0);
}
nIndex=0;
- nsB = nameB.getToken(0, '.', nIndex);
+ nsB = o3tl::getToken(nameB, 0, '.', nIndex);
if (nIndex<0)
{
tnB = nsB;
- nsB.clear();
+ nsB = std::u16string_view();
}
else
{
- tnB = nameB.getToken(0, '.', nIndex);
+ tnB = o3tl::getToken(nameB, 0, '.', nIndex);
assert(nIndex < 0);
}
const int ns_comp = compare_schema(nsA, nsB);
if(ns_comp == 0)
{
- if(nsA.isEmpty())
+ if(nsA.empty())
{
- assert(nsB.isEmpty());
+ assert(nsB.empty());
// within each type category, sort privileged choice first
- if( tnA == "int4" || tnA == "varchar" || tnA == "char" || tnA == "text")
+ if( tnA == u"int4" || tnA == u"varchar" || tnA == u"char" || tnA == u"text")
return true;
- if( tnB == "int4" || tnB == "varchar" || tnB == "char" || tnB == "text")
+ if( tnB == u"int4" || tnB == u"varchar" || tnB == u"char" || tnB == u"text")
return false;
}
return nameA.compareTo( nameB ) < 0;
diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.hxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.hxx
index 134f72cf0186..4e8b717a96b2 100644
--- a/connectivity/source/drivers/postgresql/pq_databasemetadata.hxx
+++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.hxx
@@ -74,8 +74,8 @@ class DatabaseMetaData :
public:
DatabaseMetaData(
- const ::rtl::Reference< comphelper::RefCountedMutex > & reMutex,
- const css::uno::Reference< css::sdbc::XConnection > & origin,
+ ::rtl::Reference< comphelper::RefCountedMutex > reMutex,
+ css::uno::Reference< css::sdbc::XConnection > origin,
ConnectionSettings *pSettings
);
diff --git a/connectivity/source/drivers/postgresql/pq_driver.cxx b/connectivity/source/drivers/postgresql/pq_driver.cxx
index 09fe61ab2824..8e07123a2b0f 100644
--- a/connectivity/source/drivers/postgresql/pq_driver.cxx
+++ b/connectivity/source/drivers/postgresql/pq_driver.cxx
@@ -40,12 +40,6 @@
#include "pq_driver.hxx"
-using osl::MutexGuard;
-
-using com::sun::star::lang::XSingleComponentFactory;
-using com::sun::star::lang::XServiceInfo;
-using com::sun::star::lang::XComponent;
-
using com::sun::star::uno::Sequence;
using com::sun::star::uno::Reference;
using com::sun::star::uno::XInterface;
diff --git a/connectivity/source/drivers/postgresql/pq_driver.hxx b/connectivity/source/drivers/postgresql/pq_driver.hxx
index 6be6a39484f3..31d407f36965 100644
--- a/connectivity/source/drivers/postgresql/pq_driver.hxx
+++ b/connectivity/source/drivers/postgresql/pq_driver.hxx
@@ -36,9 +36,9 @@
#pragma once
-#include <osl/mutex.hxx>
#include <sal/macros.h>
#include <cppuhelper/compbase.hxx>
+#include <cppuhelper/basemutex.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -54,7 +54,6 @@ namespace pq_sdbc_driver
SAL_STRINGIFY(PQ_SDBC_MINOR) "." \
SAL_STRINGIFY(PQ_SDBC_MICRO)
-struct MutexHolder { osl::Mutex m_mutex; };
// use this to switch off sdbc support !
// typedef cppu::WeakComponentImplHelper<
// css::sdbc::XDriver,
@@ -64,14 +63,14 @@ typedef cppu::WeakComponentImplHelper<
css::sdbc::XDriver,
css::lang::XServiceInfo,
css::sdbcx::XDataDefinitionSupplier > DriverBase ;
-class Driver : public MutexHolder, public DriverBase
+class Driver : public cppu::BaseMutex, public DriverBase
{
css::uno::Reference< css::uno::XComponentContext > m_ctx;
css::uno::Reference< css::lang::XMultiComponentFactory > m_smgr;
public:
explicit Driver ( const css::uno::Reference < css::uno::XComponentContext > & ctx )
- : DriverBase( m_mutex ),
+ : DriverBase( m_aMutex ),
m_ctx( ctx ),
m_smgr( ctx->getServiceManager() )
{}
diff --git a/connectivity/source/drivers/postgresql/pq_fakedupdateableresultset.cxx b/connectivity/source/drivers/postgresql/pq_fakedupdateableresultset.cxx
index a75897ccb211..216a25220355 100644
--- a/connectivity/source/drivers/postgresql/pq_fakedupdateableresultset.cxx
+++ b/connectivity/source/drivers/postgresql/pq_fakedupdateableresultset.cxx
@@ -38,6 +38,7 @@
#include <com/sun/star/sdbc/SQLException.hpp>
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/queryinterface.hxx>
+#include <utility>
using com::sun::star::uno::Sequence;
@@ -58,9 +59,9 @@ FakedUpdateableResultSet::FakedUpdateableResultSet(
PGresult *result,
const OUString &schema,
const OUString &table,
- const OUString &aReason )
+ OUString aReason )
: ResultSet( mutex, owner, pSettings, result, schema, table ),
- m_aReason( aReason )
+ m_aReason(std::move( aReason ))
{}
diff --git a/connectivity/source/drivers/postgresql/pq_fakedupdateableresultset.hxx b/connectivity/source/drivers/postgresql/pq_fakedupdateableresultset.hxx
index c2907aeb0290..44e7dc9bcf13 100644
--- a/connectivity/source/drivers/postgresql/pq_fakedupdateableresultset.hxx
+++ b/connectivity/source/drivers/postgresql/pq_fakedupdateableresultset.hxx
@@ -61,7 +61,7 @@ public:
PGresult *result,
const OUString &schema,
const OUString &table,
- const OUString &aReason );
+ OUString aReason );
public: // XInterface
virtual void SAL_CALL acquire() noexcept override { ResultSet::acquire(); }
diff --git a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
index 344c27175850..e616e9b22966 100644
--- a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
+++ b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx
@@ -40,7 +40,7 @@
#include "pq_statics.hxx"
#include "pq_statement.hxx"
-#include <o3tl/deleter.hxx>
+#include <o3tl/safeint.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/ustrbuf.hxx>
@@ -57,6 +57,7 @@
#include <string_view>
#include <connectivity/dbconversion.hxx>
+#include <utility>
using osl::MutexGuard;
@@ -149,12 +150,12 @@ PreparedStatement::PreparedStatement(
const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const Reference< XConnection > & conn,
struct ConnectionSettings *pSettings,
- const OString & stmt )
+ OString stmt )
: PreparedStatement_BASE(refMutex->GetMutex())
, OPropertySetHelper(PreparedStatement_BASE::rBHelper)
, m_connection(conn)
, m_pSettings(pSettings)
- , m_stmt(stmt)
+ , m_stmt(std::move(stmt))
, m_xMutex(refMutex)
, m_multipleResultAvailable(false)
, m_multipleResultUpdateCount(0)
@@ -198,7 +199,7 @@ PreparedStatement::~PreparedStatement()
void PreparedStatement::checkColumnIndex( sal_Int32 parameterIndex )
{
- if( parameterIndex < 1 || parameterIndex > static_cast<sal_Int32>(m_vars.size()) )
+ if( parameterIndex < 1 || o3tl::make_unsigned(parameterIndex) > m_vars.size() )
{
throw SQLException(
"pq_preparedstatement: parameter index out of range (expected 1 to "
@@ -262,10 +263,9 @@ void PreparedStatement::close( )
void PreparedStatement::raiseSQLException( const char * errorMsg )
{
OUStringBuffer buf(128);
- buf.append( "pq_driver: ");
- buf.append(
- OUString( errorMsg, strlen(errorMsg) , ConnectionSettings::encoding ) );
- buf.append( " (caused by statement '" );
+ buf.append( "pq_driver: "
+ + OUString( errorMsg, strlen(errorMsg) , ConnectionSettings::encoding )
+ + " (caused by statement '" );
buf.appendAscii( m_executedStatement.getStr() );
buf.append( "')" );
OUString error = buf.makeStringAndClear();
@@ -390,7 +390,7 @@ void PreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 )
MutexGuard guard( m_xMutex->GetMutex() );
checkClosed();
checkColumnIndex( parameterIndex );
- m_vars[parameterIndex-1] = OString( "NULL" );
+ m_vars[parameterIndex-1] = "NULL"_ostr;
}
void PreparedStatement::setObjectNull(
@@ -399,7 +399,7 @@ void PreparedStatement::setObjectNull(
MutexGuard guard( m_xMutex->GetMutex() );
checkClosed();
checkColumnIndex( parameterIndex );
- m_vars[parameterIndex-1] = OString( "NULL" );
+ m_vars[parameterIndex-1] = "NULL"_ostr;
}
@@ -409,9 +409,9 @@ void PreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x )
checkClosed();
checkColumnIndex( parameterIndex );
if( x )
- m_vars[parameterIndex-1] = OString( "'t'" );
+ m_vars[parameterIndex-1] = "'t'"_ostr;
else
- m_vars[parameterIndex-1] = OString( "'f'" );
+ m_vars[parameterIndex-1] = "'f'"_ostr;
}
void PreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x )
diff --git a/connectivity/source/drivers/postgresql/pq_preparedstatement.hxx b/connectivity/source/drivers/postgresql/pq_preparedstatement.hxx
index 4755efbe0368..ed81420cec7d 100644
--- a/connectivity/source/drivers/postgresql/pq_preparedstatement.hxx
+++ b/connectivity/source/drivers/postgresql/pq_preparedstatement.hxx
@@ -98,7 +98,7 @@ public:
PreparedStatement( const rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const css::uno::Reference< css::sdbc::XConnection> & con,
struct ConnectionSettings *pSettings,
- const OString &stmt );
+ OString stmt );
virtual ~PreparedStatement() override;
public: // XInterface
diff --git a/connectivity/source/drivers/postgresql/pq_resultset.cxx b/connectivity/source/drivers/postgresql/pq_resultset.cxx
index 556bae92d5be..0058041c87b5 100644
--- a/connectivity/source/drivers/postgresql/pq_resultset.cxx
+++ b/connectivity/source/drivers/postgresql/pq_resultset.cxx
@@ -44,6 +44,7 @@
#include <com/sun/star/sdbc/ResultSetType.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdbc/SQLException.hpp>
+#include <utility>
using osl::MutexGuard;
@@ -79,14 +80,14 @@ ResultSet::ResultSet( const ::rtl::Reference< comphelper::RefCountedMutex > & re
const Reference< XInterface > & owner,
ConnectionSettings **ppSettings,
PGresult * result,
- const OUString &schema,
- const OUString &table)
+ OUString schema,
+ OUString table)
: BaseResultSet(
refMutex, owner, PQntuples( result ),
PQnfields( result ),(*ppSettings)->tc ),
m_result( result ),
- m_schema( schema ),
- m_table( table ),
+ m_schema(std::move( schema )),
+ m_table(std::move( table )),
m_ppSettings( ppSettings )
{
// LEM TODO: shouldn't these things be inherited from the statement or something like that?
diff --git a/connectivity/source/drivers/postgresql/pq_resultset.hxx b/connectivity/source/drivers/postgresql/pq_resultset.hxx
index 340e34b70c3b..cf2888bf5b93 100644
--- a/connectivity/source/drivers/postgresql/pq_resultset.hxx
+++ b/connectivity/source/drivers/postgresql/pq_resultset.hxx
@@ -72,8 +72,8 @@ public:
const css::uno::Reference< css::uno::XInterface > &owner,
ConnectionSettings **pSettings,
PGresult *result,
- const OUString &schema,
- const OUString &table );
+ OUString schema,
+ OUString table );
virtual ~ResultSet() override;
public: // XCloseable
diff --git a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx
index fbe10f82dacb..26b11de27985 100644
--- a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx
@@ -46,6 +46,7 @@
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/sdbc/SQLException.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
+#include <utility>
#include <string.h>
@@ -113,18 +114,18 @@ static void extractPrecisionAndScale( sal_Int32 atttypmod, sal_Int32 *precision,
}
ResultSetMetaData::ResultSetMetaData(
- const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
- const css::uno::Reference< css::sdbc::XResultSet > & origin,
+ ::rtl::Reference< comphelper::RefCountedMutex > refMutex,
+ css::uno::Reference< css::sdbc::XResultSet > origin,
ResultSet * pResultSet,
ConnectionSettings **ppSettings,
PGresult const *pResult,
- const OUString &schemaName,
- const OUString &tableName ) :
- m_xMutex( refMutex ),
+ OUString schemaName,
+ OUString tableName ) :
+ m_xMutex(std::move( refMutex )),
m_ppSettings( ppSettings ),
- m_origin( origin ),
- m_tableName( tableName ),
- m_schemaName( schemaName ),
+ m_origin(std::move( origin )),
+ m_tableName(std::move( tableName )),
+ m_schemaName(std::move( schemaName )),
m_colDesc( PQnfields( pResult ) ),
m_pResultSet( pResultSet ),
m_checkedForTable( false ),
@@ -166,8 +167,7 @@ void ResultSetMetaData::checkForTypes()
if( i > 0 )
buf.append( " OR " );
int oid = m_colDesc[i].typeOid;
- buf.append( "oid=" );
- buf.append( static_cast<sal_Int32>(oid) );
+ buf.append( "oid=" + OUString::number(static_cast<sal_Int32>(oid)) );
}
Reference< XResultSet > rs = stmt->executeQuery( buf.makeStringAndClear() );
Reference< XRow > xRow( rs, UNO_QUERY );
diff --git a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.hxx b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.hxx
index 67e34d44d257..71c98190ba2b 100644
--- a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.hxx
+++ b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.hxx
@@ -89,13 +89,13 @@ class ResultSetMetaData :
public:
ResultSetMetaData(
- const ::rtl::Reference< comphelper::RefCountedMutex > & reMutex,
- const css::uno::Reference< css::sdbc::XResultSet > & origin,
+ ::rtl::Reference< comphelper::RefCountedMutex > reMutex,
+ css::uno::Reference< css::sdbc::XResultSet > origin,
ResultSet *pResultSet,
ConnectionSettings **pSettings,
PGresult const *pResult,
- const OUString &schemaName,
- const OUString &tableName );
+ OUString schemaName,
+ OUString tableName );
public:
// Methods
diff --git a/connectivity/source/drivers/postgresql/pq_statement.cxx b/connectivity/source/drivers/postgresql/pq_statement.cxx
index 7db4b20536e2..648faa69811b 100644
--- a/connectivity/source/drivers/postgresql/pq_statement.cxx
+++ b/connectivity/source/drivers/postgresql/pq_statement.cxx
@@ -59,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>
@@ -252,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() );
@@ -429,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,
@@ -441,7 +442,7 @@ 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(
@@ -589,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;
@@ -598,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 " );
@@ -606,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;
@@ -699,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();
diff --git a/connectivity/source/drivers/postgresql/pq_statement.hxx b/connectivity/source/drivers/postgresql/pq_statement.hxx
index fae6568bb505..816d2a55afaa 100644
--- a/connectivity/source/drivers/postgresql/pq_statement.hxx
+++ b/connectivity/source/drivers/postgresql/pq_statement.hxx
@@ -189,7 +189,7 @@ css::uno::Reference< css::sdbc::XResultSet > getGeneratedValuesFromLastInsert(
ConnectionSettings *pConnectionSettings,
const css::uno::Reference< css::sdbc::XConnection > &connection,
sal_Int32 nLastOid,
- const OUString & lastTableInserted,
+ std::u16string_view lastTableInserted,
const OString & lastQuery );
diff --git a/connectivity/source/drivers/postgresql/pq_statics.cxx b/connectivity/source/drivers/postgresql/pq_statics.cxx
index 7169f4617821..f69556202240 100644
--- a/connectivity/source/drivers/postgresql/pq_statics.cxx
+++ b/connectivity/source/drivers/postgresql/pq_statics.cxx
@@ -35,9 +35,9 @@
************************************************************************/
#include "pq_statics.hxx"
-#include "pq_updateableresultset.hxx"
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <utility>
using com::sun::star::uno::Sequence;
using com::sun::star::uno::Any;
@@ -69,8 +69,8 @@ struct BaseTypeDef { const char * typeName; sal_Int32 value; };
struct PropertyDef
{
- PropertyDef( const OUString &str, const Type &t )
- : name( str ) , type( t ) {}
+ PropertyDef( OUString str, const Type &t )
+ : name(std::move( str )) , type( t ) {}
OUString name;
css::uno::Type type;
};
@@ -197,7 +197,7 @@ Statics & getStatics()
PropertyDef( statics.TYPE , tString )
};
ist.pProps = createPropertyArrayHelper(
- tableDef, SAL_N_ELEMENTS(tableDef), READONLY );
+ tableDef, std::size(tableDef), READONLY );
statics.refl.tableDescriptor.implName =
"org.openoffice.comp.pq.sdbcx.TableDescriptor";
@@ -211,7 +211,7 @@ Statics & getStatics()
PropertyDef( statics.SCHEMA_NAME , tString )
};
statics.refl.tableDescriptor.pProps = createPropertyArrayHelper(
- tableDescDef, SAL_N_ELEMENTS(tableDescDef), 0 );
+ tableDescDef, std::size(tableDescDef), 0 );
// Column props set
statics.refl.column.implName = "org.openoffice.comp.pq.sdbcx.Column";
@@ -233,7 +233,7 @@ Statics & getStatics()
PropertyDefEx( statics.TYPE_NAME , tString ,READONLY)
};
statics.refl.column.pProps = createPropertyArrayHelper(
- columnDef, SAL_N_ELEMENTS(columnDef) );
+ columnDef, std::size(columnDef) );
statics.refl.columnDescriptor.implName =
"org.openoffice.comp.pq.sdbcx.ColumnDescriptor";
@@ -256,7 +256,7 @@ Statics & getStatics()
};
statics.refl.columnDescriptor.pProps = createPropertyArrayHelper(
- columnDescDef, SAL_N_ELEMENTS(columnDescDef), 0 );
+ columnDescDef, std::size(columnDescDef), 0 );
// Key properties
statics.refl.key.implName = "org.openoffice.comp.pq.sdbcx.Key";
@@ -272,7 +272,7 @@ Statics & getStatics()
PropertyDef( statics.UPDATE_RULE, tInt )
};
statics.refl.key.pProps = createPropertyArrayHelper(
- keyDef, SAL_N_ELEMENTS(keyDef), READONLY );
+ keyDef, std::size(keyDef), READONLY );
// Key properties
@@ -288,7 +288,7 @@ Statics & getStatics()
PropertyDef( statics.UPDATE_RULE, tInt )
};
statics.refl.keyDescriptor.pProps = createPropertyArrayHelper(
- keyDescDef, SAL_N_ELEMENTS(keyDescDef), 0 );
+ keyDescDef, std::size(keyDescDef), 0 );
// KeyColumn props set
@@ -311,7 +311,7 @@ Statics & getStatics()
PropertyDef( statics.TYPE_NAME , tString )
};
statics.refl.keycolumn.pProps = createPropertyArrayHelper(
- keycolumnDef, SAL_N_ELEMENTS(keycolumnDef), READONLY );
+ keycolumnDef, std::size(keycolumnDef), READONLY );
// KeyColumn props set
statics.refl.keycolumnDescriptor.implName =
@@ -324,7 +324,7 @@ Statics & getStatics()
PropertyDef( statics.RELATED_COLUMN, tString )
};
statics.refl.keycolumnDescriptor.pProps = createPropertyArrayHelper(
- keycolumnDescDef, SAL_N_ELEMENTS(keycolumnDescDef), 0 );
+ keycolumnDescDef, std::size(keycolumnDescDef), 0 );
// view props set
statics.refl.view.implName = "org.openoffice.comp.pq.sdbcx.View";
@@ -338,13 +338,13 @@ Statics & getStatics()
PropertyDef( statics.SCHEMA_NAME , tString )
};
statics.refl.view.pProps = createPropertyArrayHelper(
- viewDef, SAL_N_ELEMENTS(viewDef), READONLY );
+ viewDef, std::size(viewDef), READONLY );
// view props set
statics.refl.viewDescriptor.implName = "org.openoffice.comp.pq.sdbcx.ViewDescriptor";
statics.refl.viewDescriptor.serviceNames = { "com.sun.star.sdbcx.ViewDescriptor" };
statics.refl.viewDescriptor.pProps = createPropertyArrayHelper(
- viewDef, SAL_N_ELEMENTS(viewDef), 0 ); // reuse view, as it is identical
+ viewDef, std::size(viewDef), 0 ); // reuse view, as it is identical
// user props set
statics.refl.user.implName = "org.openoffice.comp.pq.sdbcx.User";
statics.refl.user.serviceNames = { "com.sun.star.sdbcx.User" };
@@ -353,7 +353,7 @@ Statics & getStatics()
PropertyDef( statics.NAME , tString )
};
statics.refl.user.pProps = createPropertyArrayHelper(
- userDefRO, SAL_N_ELEMENTS(userDefRO), READONLY );
+ userDefRO, std::size(userDefRO), READONLY );
// user props set
statics.refl.userDescriptor.implName =
@@ -365,7 +365,7 @@ Statics & getStatics()
PropertyDef( statics.PASSWORD , tString )
};
statics.refl.userDescriptor.pProps = createPropertyArrayHelper(
- userDefWR, SAL_N_ELEMENTS(userDefWR), 0 );
+ userDefWR, std::size(userDefWR), 0 );
// index props set
statics.refl.index.implName = "org.openoffice.comp.pq.sdbcx.Index";
@@ -380,14 +380,14 @@ Statics & getStatics()
PropertyDef( statics.PRIVATE_COLUMN_INDEXES, tStringSequence )
};
statics.refl.index.pProps = createPropertyArrayHelper(
- indexDef, SAL_N_ELEMENTS(indexDef), READONLY );
+ indexDef, std::size(indexDef), READONLY );
// index props set
statics.refl.indexDescriptor.implName =
"org.openoffice.comp.pq.sdbcx.IndexDescriptor";
statics.refl.indexDescriptor.serviceNames = { "com.sun.star.sdbcx.IndexDescriptor" };
statics.refl.indexDescriptor.pProps = createPropertyArrayHelper(
- indexDef, SAL_N_ELEMENTS(indexDef), 0 );
+ indexDef, std::size(indexDef), 0 );
// indexColumn props set
statics.refl.indexColumn.implName = "org.openoffice.comp.pq.sdbcx.IndexColumn";
@@ -409,7 +409,7 @@ Statics & getStatics()
PropertyDef( statics.TYPE_NAME , tString )
};
statics.refl.indexColumn.pProps = createPropertyArrayHelper(
- indexColumnDef, SAL_N_ELEMENTS(indexColumnDef), READONLY );
+ indexColumnDef, std::size(indexColumnDef), READONLY );
// indexColumn props set
statics.refl.indexColumnDescriptor.implName =
@@ -422,31 +422,7 @@ Statics & getStatics()
PropertyDef( statics.NAME , tString )
};
statics.refl.indexColumnDescriptor.pProps = createPropertyArrayHelper(
- indexColumnDescDef, SAL_N_ELEMENTS(indexColumnDescDef), 0 );
-
- // resultset
- statics.refl.resultSet.implName = "org.openoffice.comp.pq.ResultSet";
- statics.refl.resultSet.serviceNames = { "com.sun.star.sdbc.ResultSet" };
- statics.refl.resultSet.types = UpdateableResultSet::getStaticTypes( false /* updateable */ );
- PropertyDef resultSet[] =
- {
- PropertyDef( statics.CURSOR_NAME , tString ),
- PropertyDef( statics.ESCAPE_PROCESSING , tBool ),
- PropertyDef( statics.FETCH_DIRECTION , tInt ),
- PropertyDef( statics.FETCH_SIZE , tInt ),
- PropertyDef( statics.IS_BOOKMARKABLE , tBool ),
- PropertyDef( statics.RESULT_SET_CONCURRENCY , tInt ),
- PropertyDef( statics.RESULT_SET_TYPE , tInt )
- };
- statics.refl.resultSet.pProps = createPropertyArrayHelper(
- resultSet, SAL_N_ELEMENTS(resultSet), 0 );
-
- // updateableResultset
- statics.refl.updateableResultSet.implName = "org.openoffice.comp.pq.UpdateableResultSet";
- statics.refl.updateableResultSet.serviceNames = { "com.sun.star.sdbc.ResultSet" };
- statics.refl.updateableResultSet.types = UpdateableResultSet::getStaticTypes( true /* updateable */ );
- statics.refl.updateableResultSet.pProps = createPropertyArrayHelper(
- resultSet, SAL_N_ELEMENTS(resultSet), 0 );
+ indexColumnDescDef, std::size(indexColumnDescDef), 0 );
// databasemetadata
statics.tablesRowNames = std::vector< OUString > ( 5 );
diff --git a/connectivity/source/drivers/postgresql/pq_statics.hxx b/connectivity/source/drivers/postgresql/pq_statics.hxx
index 7b776ff84308..4e745e4086ee 100644
--- a/connectivity/source/drivers/postgresql/pq_statics.hxx
+++ b/connectivity/source/drivers/postgresql/pq_statics.hxx
@@ -37,6 +37,7 @@
#pragma once
#include <unordered_map>
+#include <utility>
#include <vector>
#include <com/sun/star/uno/Any.hxx>
@@ -50,20 +51,20 @@ namespace pq_sdbc_driver
struct ColumnMetaData
{
ColumnMetaData(
- const OUString &_columnName,
- const OUString &_tableName,
- const OUString &_schemaTableName,
- const OUString &_typeName,
+ OUString _columnName,
+ OUString _tableName,
+ OUString _schemaTableName,
+ OUString _typeName,
sal_Int32 _type,
sal_Int32 _precision,
sal_Int32 _scale,
bool _isCurrency,
bool _isNullable,
bool _isAutoIncrement ) :
- columnName( _columnName ),
- tableName( _tableName ),
- schemaTableName( _schemaTableName ),
- typeName( _typeName ),
+ columnName(std::move( _columnName )),
+ tableName(std::move( _tableName )),
+ schemaTableName(std::move( _schemaTableName )),
+ typeName(std::move( _typeName )),
type( _type ),
precision( _precision ),
scale( _scale ),
@@ -122,9 +123,6 @@ struct ReflectionImplementations
struct ImplementationStatics indexDescriptor;
struct ImplementationStatics indexColumn;
struct ImplementationStatics indexColumnDescriptor;
-
- struct ImplementationStatics updateableResultSet;
- struct ImplementationStatics resultSet;
};
const sal_Int32 TABLE_INDEX_CATALOG = 0;
diff --git a/connectivity/source/drivers/postgresql/pq_tools.cxx b/connectivity/source/drivers/postgresql/pq_tools.cxx
index 9b75d69ba46c..fb42f864f97e 100644
--- a/connectivity/source/drivers/postgresql/pq_tools.cxx
+++ b/connectivity/source/drivers/postgresql/pq_tools.cxx
@@ -37,6 +37,7 @@
#include <sal/config.h>
#include <o3tl/any.hxx>
+#include <o3tl/string_view.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
@@ -79,7 +80,6 @@ using com::sun::star::uno::Reference;
using com::sun::star::uno::Sequence;
using com::sun::star::uno::XInterface;
using com::sun::star::uno::Any;
-using com::sun::star::uno::makeAny;
using com::sun::star::container::XEnumeration;
using com::sun::star::container::XEnumerationAccess;
@@ -125,7 +125,7 @@ void bufferEscapeConstant( OUStringBuffer & buf, std::u16string_view value, Conn
strbuf.setLength( len );
// Previously here RTL_TEXTENCODING_ASCII_US; as we set the PostgreSQL client_encoding to UTF8,
// we get UTF8 here, too. I'm not sure why it worked well before...
- buf.append( OStringToOUString( strbuf.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ) );
+ buf.append( OStringToOUString( strbuf, RTL_TEXTENCODING_UTF8 ) );
}
static void ibufferQuoteConstant( OUStringBuffer & buf, std::u16string_view value, ConnectionSettings *settings )
@@ -315,30 +315,30 @@ bool isWhitespace( sal_Unicode c )
return ' ' == c || 9 == c || 10 == c || 13 == c;
}
-OUString extractTableFromInsert( const OUString & sql )
+OUString extractTableFromInsert( std::u16string_view sql )
{
OUString ret;
- int i = 0;
- while (i < sql.getLength() && isWhitespace(sql[i])) { i++; }
+ size_t i = 0;
+ while (i < sql.size() && isWhitespace(sql[i])) { i++; }
- if( sql.matchIgnoreAsciiCase("insert", i) )
+ if( o3tl::matchIgnoreAsciiCase(sql, u"insert", i) )
{
i += 6;
- while (i < sql.getLength() && isWhitespace(sql[i])) { i++; }
- if( sql.matchIgnoreAsciiCase("into", i) )
+ while (i < sql.size() && isWhitespace(sql[i])) { i++; }
+ if( o3tl::matchIgnoreAsciiCase(sql, u"into", i) )
{
i +=4;
- while (i < sql.getLength() && isWhitespace(sql[i])) { i++; }
+ while (i < sql.size() && isWhitespace(sql[i])) { i++; }
int start = i;
bool quote = (sql[i] == '"');
- for( i++ ; i < sql.getLength() ; i ++ )
+ for( i++ ; i < sql.size() ; i ++ )
{
if( quote && sql[i] == '"' )
{
- while (i < sql.getLength() && isWhitespace(sql[i])) { i++; }
+ while (i < sql.size() && isWhitespace(sql[i])) { i++; }
if( '.' == sql[i] )
{
- while (i < sql.getLength() && isWhitespace(sql[i])) { i++; }
+ while (i < sql.size() && isWhitespace(sql[i])) { i++; }
if( '"' == sql[i] )
{
// the second part of the table name does not use quotes
@@ -361,7 +361,7 @@ OUString extractTableFromInsert( const OUString & sql )
}
}
}
- ret = sql.copy(start, i - start ).trim();
+ ret = o3tl::trim(sql.substr(start, i - start ));
// printf( "pq_statement: parsed table name %s from insert\n" ,
// OUStringToOString( ret, RTL_TEXTENCODING_ASCII_US).getStr() );
}
@@ -416,7 +416,7 @@ void splitSQL( const OString & sql, std::vector< OString > &vec )
{
if( '"' == c )
{
- vec.push_back( OString( &sql.getStr()[start], i-start+1 ) );
+ vec.emplace_back( &sql.getStr()[start], i-start+1 );
start = i + 1;
doubleQuote = false;
}
@@ -431,7 +431,7 @@ void splitSQL( const OString & sql, std::vector< OString > &vec )
}
else if( '\'' == c )
{
- vec.push_back( OString( &sql.getStr()[start], i - start +1 ) );
+ vec.emplace_back( &sql.getStr()[start], i - start +1 );
start = i + 1; // leave single quotes !
singleQuote = false;
}
@@ -440,20 +440,20 @@ void splitSQL( const OString & sql, std::vector< OString > &vec )
{
if( '"' == c )
{
- vec.push_back( OString( &sql.getStr()[start], i - start ) );
+ vec.emplace_back( &sql.getStr()[start], i - start );
doubleQuote = true;
start = i;
}
else if( '\'' == c )
{
- vec.push_back( OString( &sql.getStr()[start], i - start ) );
+ vec.emplace_back( &sql.getStr()[start], i - start );
singleQuote = true;
start = i;
}
}
}
if( start < i )
- vec.push_back( OString( &sql.getStr()[start] , i - start ) );
+ vec.emplace_back( &sql.getStr()[start] , i - start );
// for( i = 0 ; i < vec.size() ; i ++ )
// printf( "%s!" , vec[i].getStr() );
@@ -476,7 +476,7 @@ void tokenizeSQL( const OString & sql, std::vector< OString > &vec )
{
if( '"' == c )
{
- vec.push_back( OString( &sql.getStr()[start], i-start ) );
+ vec.emplace_back( &sql.getStr()[start], i-start );
start = i + 1;
doubleQuote = false;
}
@@ -485,7 +485,7 @@ void tokenizeSQL( const OString & sql, std::vector< OString > &vec )
{
if( '\'' == c )
{
- vec.push_back( OString( &sql.getStr()[start], i - start +1 ) );
+ vec.emplace_back( &sql.getStr()[start], i - start +1 );
start = i + 1; // leave single quotes !
singleQuote = false;
}
@@ -508,15 +508,15 @@ void tokenizeSQL( const OString & sql, std::vector< OString > &vec )
start ++; // skip additional whitespace
else
{
- vec.push_back( OString( &sql.getStr()[start], i - start ) );
+ vec.emplace_back( &sql.getStr()[start], i - start );
start = i +1;
}
}
else if( ',' == c || isOperator( c ) || '(' == c || ')' == c )
{
if( i - start )
- vec.push_back( OString( &sql.getStr()[start], i - start ) );
- vec.push_back( OString( &sql.getStr()[i], 1 ) );
+ vec.emplace_back( &sql.getStr()[start], i - start );
+ vec.emplace_back( &sql.getStr()[i], 1 );
start = i + 1;
}
else if( '.' == c )
@@ -529,15 +529,15 @@ void tokenizeSQL( const OString & sql, std::vector< OString > &vec )
else
{
if( i - start )
- vec.push_back( OString( &sql.getStr()[start], i - start ) );
- vec.push_back( OString( "." ) );
+ vec.emplace_back( &sql.getStr()[start], i - start );
+ vec.emplace_back( "." );
start = i + 1;
}
}
}
}
if( start < i )
- vec.push_back( OString( &sql.getStr()[start] , i - start ) );
+ vec.emplace_back( &sql.getStr()[start] , i - start );
// for( i = 0 ; i < vec.size() ; i ++ )
// printf( "%s!" , vec[i].getStr() );
@@ -596,12 +596,12 @@ OUString array2String( const css::uno::Sequence< Any > &seq )
}
-std::vector< Any > parseArray( const OUString & str )
+std::vector< Any > parseArray( std::u16string_view str )
{
- int len = str.getLength();
+ size_t len = str.size();
bool doubleQuote = false;
int brackets = 0;
- int i = 0;
+ size_t i = 0;
OUStringBuffer current;
std::vector<Any> elements;
@@ -644,7 +644,7 @@ std::vector< Any > parseArray( const OUString & str )
if( brackets == 0 )
{
if( !current.isEmpty() || doubleQuotedValue )
- elements.push_back( makeAny( current.makeStringAndClear() ) );
+ elements.emplace_back( current.makeStringAndClear() );
}
else
{
@@ -673,7 +673,7 @@ std::vector< Any > parseArray( const OUString & str )
else if( ',' == c && brackets == 1)
{
doubleQuotedValue = false;
- elements.push_back( makeAny( current.makeStringAndClear() ) );
+ elements.emplace_back( current.makeStringAndClear() );
}
else if( isWhitespace( c ) )
{
@@ -840,17 +840,17 @@ OUString getColExprForDefaultSettingVal(ConnectionSettings const *settings)
OUString("pg_get_expr(pg_attrdef.adbin, pg_attrdef.adrelid, true)");
}
-css::uno::Sequence< sal_Int32 > string2intarray( const OUString & str )
+css::uno::Sequence< sal_Int32 > string2intarray( std::u16string_view str )
{
css::uno::Sequence< sal_Int32 > ret;
- const sal_Int32 strlen = str.getLength();
- if( str.getLength() > 1 )
+ const sal_Int32 strlen = str.size();
+ if( strlen > 1 )
{
sal_Int32 start = 0;
sal_uInt32 c;
for (;;)
{
- c = str.iterateCodePoints(&start);
+ c = o3tl::iterateCodePoints(str, &start);
if (!iswspace(c))
break;
if ( start == strlen)
@@ -860,7 +860,7 @@ css::uno::Sequence< sal_Int32 > string2intarray( const OUString & str )
return ret;
for (;;)
{
- c = str.iterateCodePoints(&start);
+ c = o3tl::iterateCodePoints(str, &start);
if ( !iswspace(c) )
break;
if ( start == strlen)
@@ -879,7 +879,7 @@ css::uno::Sequence< sal_Int32 > string2intarray( const OUString & str )
break;
if ( start == strlen)
return ret;
- c=str.iterateCodePoints(&start);
+ c = o3tl::iterateCodePoints(str, &start);
} while ( c );
do
{
@@ -888,20 +888,20 @@ css::uno::Sequence< sal_Int32 > string2intarray( const OUString & str )
if ( start == strlen)
return ret;
digits.append(OUString(&c, 1));
- c = str.iterateCodePoints(&start);
+ c = o3tl::iterateCodePoints(str, &start);
} while ( c );
- vec.push_back( digits.makeStringAndClear().toInt32() );
+ vec.push_back( o3tl::toInt32(digits) );
do
{
if(!iswspace(c))
break;
if ( start == strlen)
return ret;
- c = str.iterateCodePoints(&start);
+ c = o3tl::iterateCodePoints(str, &start);
} while ( c );
if ( c == L'}' )
break;
- if ( str.iterateCodePoints(&start) != L',' )
+ if ( o3tl::iterateCodePoints(str, &start) != L',' )
return ret;
if ( start == strlen)
return ret;
@@ -943,19 +943,17 @@ OUString sqltype2string( const Reference< XPropertySet > & desc )
case css::sdbc::DataType::VARCHAR:
case css::sdbc::DataType::CHAR:
{
- typeName.append( "(" );
- typeName.append( precision );
- typeName.append( ")" );
+ typeName.append( "(" + OUString::number(precision) + ")" );
break;
}
case css::sdbc::DataType::DECIMAL:
case css::sdbc::DataType::NUMERIC:
{
- typeName.append( "(" );
- typeName.append( precision );
- typeName.append( "," );
- typeName.append( extractIntProperty( desc, getStatics().SCALE ) );
- typeName.append( ")" );
+ typeName.append( "("
+ + OUString::number(precision)
+ + ","
+ + OUString::number(extractIntProperty( desc, getStatics().SCALE ))
+ + ")" );
break;
}
default:
diff --git a/connectivity/source/drivers/postgresql/pq_tools.hxx b/connectivity/source/drivers/postgresql/pq_tools.hxx
index 1f9356ed41d3..c5f9174111ca 100644
--- a/connectivity/source/drivers/postgresql/pq_tools.hxx
+++ b/connectivity/source/drivers/postgresql/pq_tools.hxx
@@ -106,7 +106,7 @@ bool extractBoolProperty(
void disposeNoThrow( const css::uno::Reference< css::uno::XInterface > & r );
void disposeObject( const css::uno::Reference< css::uno::XInterface > & r );
-OUString extractTableFromInsert( const OUString & sql );
+OUString extractTableFromInsert( std::u16string_view sql );
OString extractSingleTableFromSelect( const std::vector< OString > &vec );
OUString getColExprForDefaultSettingVal(ConnectionSettings const *settings);
@@ -115,7 +115,7 @@ void tokenizeSQL( const OString & sql, std::vector< OString > &vec );
void splitSQL( const OString & sql, std::vector< OString > &vec );
std::vector< sal_Int32 > parseIntArray( const OUString & str );
/// @throws css::sdbc::SQLException
-std::vector< css::uno::Any > parseArray( const OUString & str );
+std::vector< css::uno::Any > parseArray( std::u16string_view str );
OUString array2String( const css::uno::Sequence< css::uno::Any > &seq );
@@ -131,7 +131,7 @@ void fillAttnum2attnameMap(
const OUString &schema,
const OUString &table );
-css::uno::Sequence< sal_Int32 > string2intarray( const OUString & str );
+css::uno::Sequence< sal_Int32 > string2intarray( std::u16string_view str );
css::uno::Sequence< OUString > convertMappedIntArray2StringArray(
const Int2StringMap &map, const css::uno::Sequence< sal_Int32> &source );
diff --git a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx
index 5c1b23e82175..49eb65cd9fbf 100644
--- a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx
+++ b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx
@@ -296,8 +296,8 @@ void UpdateableResultSet::updateRow( )
buf.append( ", " );
columns ++;
- buf.append( m_columnNames[i] );
- buf.append( " = " );
+ buf.append( m_columnNames[i]
+ + " = " );
bufferQuoteAnyConstant( buf, m_updateableField[i].value, *m_ppSettings );
// OUString val;
// m_updateableField[i].value >>= val;
@@ -342,8 +342,8 @@ void UpdateableResultSet::deleteRow( )
OUStringBuffer buf( 128 );
buf.append( "DELETE FROM " );
bufferQuoteQualifiedIdentifier( buf, m_schema, m_table, *m_ppSettings );
- buf.append( " " );
- buf.append( buildWhereClause() );
+ buf.append( " "
+ + buildWhereClause() );
stmt->executeUpdate( buf.makeStringAndClear() );
diff --git a/connectivity/source/drivers/postgresql/pq_updateableresultset.hxx b/connectivity/source/drivers/postgresql/pq_updateableresultset.hxx
index 1beeadc31e98..52cb513a5856 100644
--- a/connectivity/source/drivers/postgresql/pq_updateableresultset.hxx
+++ b/connectivity/source/drivers/postgresql/pq_updateableresultset.hxx
@@ -44,6 +44,7 @@
#include <com/sun/star/sdbc/ResultSetType.hpp>
#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <utility>
namespace pq_sdbc_driver
{
@@ -78,13 +79,13 @@ private:
std::vector< OUString >&& colNames,
std::vector< std::vector< css::uno::Any > >&& data,
ConnectionSettings **ppSettings,
- const OUString &schema,
- const OUString &table,
+ OUString schema,
+ OUString table,
std::vector< OUString >&& primaryKey)
: SequenceResultSet( mutex, owner, std::move(colNames), std::move(data), (*ppSettings)->tc ),
m_ppSettings( ppSettings ),
- m_schema( schema ),
- m_table( table ),
+ m_schema(std::move( schema )),
+ m_table(std::move( table )),
m_primaryKey( std::move(primaryKey) ),
m_insertRow( false )
{
diff --git a/connectivity/source/drivers/postgresql/pq_xbase.cxx b/connectivity/source/drivers/postgresql/pq_xbase.cxx
index 1fec4130a9db..001046aa52fa 100644
--- a/connectivity/source/drivers/postgresql/pq_xbase.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xbase.cxx
@@ -36,7 +36,9 @@
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/sequence.hxx>
+#include <utility>
+#include "pq_statics.hxx"
#include "pq_tools.hxx"
#include "pq_xbase.hxx"
@@ -55,18 +57,18 @@ namespace pq_sdbc_driver
{
ReflectionBase::ReflectionBase(
- const OUString &implName,
+ OUString implName,
const css::uno::Sequence< OUString > &supportedServices,
const ::rtl::Reference< comphelper::RefCountedMutex >& refMutex,
- const css::uno::Reference< css::sdbc::XConnection > &conn,
+ css::uno::Reference< css::sdbc::XConnection > conn,
ConnectionSettings *pSettings,
cppu::IPropertyArrayHelper & props /* must survive this object !*/ )
: ReflectionBase_BASE( refMutex->GetMutex() ),
OPropertySetHelper( ReflectionBase_BASE::rBHelper ),
- m_implName( implName ),
+ m_implName(std::move( implName )),
m_supportedServices( supportedServices ),
m_xMutex( refMutex ),
- m_conn( conn ),
+ m_conn(std::move( conn )),
m_pSettings( pSettings ),
m_propsDesc( props ),
m_values( props.getProperties().getLength() )
diff --git a/connectivity/source/drivers/postgresql/pq_xbase.hxx b/connectivity/source/drivers/postgresql/pq_xbase.hxx
index 80e553325c93..e4ca16fd5e6a 100644
--- a/connectivity/source/drivers/postgresql/pq_xbase.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xbase.hxx
@@ -36,7 +36,6 @@
#pragma once
#include <cppuhelper/propshlp.hxx>
-#include <cppuhelper/component.hxx>
#include <cppuhelper/compbase.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -66,10 +65,10 @@ protected:
std::vector< css::uno::Any > m_values;
public:
ReflectionBase(
- const OUString &implName,
+ OUString implName,
const css::uno::Sequence< OUString > &supportedServices,
const ::rtl::Reference< comphelper::RefCountedMutex >& refMutex,
- const css::uno::Reference< css::sdbc::XConnection > &conn,
+ css::uno::Reference< css::sdbc::XConnection > conn,
ConnectionSettings *pSettings,
cppu::IPropertyArrayHelper & props /* must survive this object !*/ );
diff --git a/connectivity/source/drivers/postgresql/pq_xcolumn.cxx b/connectivity/source/drivers/postgresql/pq_xcolumn.cxx
index 33e57a1a5445..b19d95c3c994 100644
--- a/connectivity/source/drivers/postgresql/pq_xcolumn.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xcolumn.cxx
@@ -38,6 +38,7 @@
#include <rtl/ref.hxx>
+#include "pq_statics.hxx"
#include "pq_xcolumn.hxx"
using com::sun::star::uno::Reference;
diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
index 82d595628db3..2902879c49b0 100644
--- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx
@@ -38,6 +38,7 @@
#include <string_view>
+#include <o3tl/safeint.hxx>
#include <o3tl/string_view.hxx>
#include <rtl/ref.hxx>
#include <rtl/ustrbuf.hxx>
@@ -49,6 +50,7 @@
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <cppuhelper/exc_hlp.hxx>
+#include <utility>
#include "pq_xcolumns.hxx"
#include "pq_xcolumn.hxx"
@@ -61,7 +63,6 @@ using osl::MutexGuard;
using com::sun::star::beans::XPropertySet;
using com::sun::star::uno::Any;
-using com::sun::star::uno::makeAny;
using com::sun::star::uno::UNO_QUERY;
using com::sun::star::uno::Reference;
using com::sun::star::uno::RuntimeException;
@@ -75,9 +76,9 @@ using com::sun::star::sdbc::SQLException;
namespace pq_sdbc_driver
{
-static Any isCurrency( const OUString & typeName )
+static Any isCurrency( std::u16string_view typeName )
{
- return Any( typeName.equalsIgnoreAsciiCase("money") );
+ return Any( o3tl::equalsIgnoreAsciiCase(typeName, u"money") );
}
// static sal_Bool isAutoIncrement8( const OUString & typeName )
@@ -109,11 +110,11 @@ Columns::Columns(
const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const css::uno::Reference< css::sdbc::XConnection > & origin,
ConnectionSettings *pSettings,
- const OUString &schemaName,
- const OUString &tableName)
+ OUString schemaName,
+ OUString tableName)
: Container( refMutex, origin, pSettings, "COLUMN" ),
- m_schemaName( schemaName ),
- m_tableName( tableName )
+ m_schemaName(std::move( schemaName )),
+ m_tableName(std::move( tableName ))
{}
Columns::~Columns()
@@ -185,25 +186,25 @@ OUString columnMetaData2SDBCX(
OUString typeName = xRow->getString( TYPE_NAME );
pBase->setPropertyValue_NoBroadcast_public(
- st.NAME, makeAny( name ) );
+ st.NAME, Any( name ) );
pBase->setPropertyValue_NoBroadcast_public(
- st.TYPE, makeAny( xRow->getInt( DATA_TYPE ) ) );
+ st.TYPE, Any( xRow->getInt( DATA_TYPE ) ) );
pBase->setPropertyValue_NoBroadcast_public(
- st.TYPE_NAME, makeAny( typeName ) );
+ st.TYPE_NAME, Any( typeName ) );
pBase->setPropertyValue_NoBroadcast_public(
- st.PRECISION, makeAny( xRow->getInt( COLUMN_SIZE ) ) );
+ st.PRECISION, Any( xRow->getInt( COLUMN_SIZE ) ) );
pBase->setPropertyValue_NoBroadcast_public(
- st.SCALE, makeAny( xRow->getInt( DECIMAL_DIGITS ) ) );
+ st.SCALE, Any( xRow->getInt( DECIMAL_DIGITS ) ) );
pBase->setPropertyValue_NoBroadcast_public(
- st.IS_NULLABLE, makeAny( xRow->getInt( IS_NULLABLE ) ) );
+ st.IS_NULLABLE, Any( xRow->getInt( IS_NULLABLE ) ) );
pBase->setPropertyValue_NoBroadcast_public(
- st.DEFAULT_VALUE, makeAny( xRow->getString( DEFAULT_VALUE ) ) );
+ st.DEFAULT_VALUE, Any( xRow->getString( DEFAULT_VALUE ) ) );
// pBase->setPropertyValue_NoBroadcast_public(
// st.DESCRIPTION, makeAny( xRow->getString( DESCRIPTION ) ) );
@@ -213,7 +214,7 @@ OUString columnMetaData2SDBCX(
// st.HELP_TEXT, makeAny( xRow->getString( DESCRIPTION ) ) );
// else // for key columns, etc. ...
pBase->setPropertyValue_NoBroadcast_public(
- st.DESCRIPTION, makeAny( xRow->getString( DESCRIPTION ) ) );
+ st.DESCRIPTION, Any( xRow->getString( DESCRIPTION ) ) );
// maybe a better criterion than the type name can be found in future
@@ -316,7 +317,7 @@ void Columns::refresh()
// name ) );
{
- m_values.push_back( makeAny( prop ) );
+ m_values.emplace_back(prop);
map[ name ] = columnIndex;
++columnIndex;
}
@@ -405,11 +406,10 @@ void alterColumnByDescriptor(
bufferQuoteQualifiedIdentifier( buf, schemaName, tableName, settings );
buf.append( "ALTER COLUMN" );
bufferQuoteIdentifier( buf, futureColumnName, settings );
- buf.append( "SET DEFAULT " );
// LEM TODO: check out
// default value is not quoted, caller needs to quote himself (otherwise
// how to pass e.g. nextval('something' ) ????
- buf.append( futureDefaultValue );
+ buf.append( "SET DEFAULT " + futureDefaultValue );
// bufferQuoteConstant( buf, defaultValue, encoding );
transaction.executeUpdate( buf.makeStringAndClear() );
}
@@ -461,7 +461,7 @@ void Columns::appendByDescriptor(
osl::MutexGuard guard( m_xMutex->GetMutex() );
Statics & st = getStatics();
Reference< XPropertySet > past = createDataDescriptor();
- past->setPropertyValue( st.IS_NULLABLE, makeAny( css::sdbc::ColumnValue::NULLABLE ) );
+ past->setPropertyValue( st.IS_NULLABLE, Any( css::sdbc::ColumnValue::NULLABLE ) );
alterColumnByDescriptor(
m_schemaName, m_tableName, m_pSettings, m_origin->createStatement() , past, future );
@@ -493,7 +493,7 @@ void Columns::appendByDescriptor(
void Columns::dropByIndex( sal_Int32 index )
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
- if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) )
+ if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() )
{
throw css::lang::IndexOutOfBoundsException(
"COLUMNS: Index out of range (allowed 0 to "
diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.hxx b/connectivity/source/drivers/postgresql/pq_xcolumns.hxx
index aa91a9754218..8ff8fcfbd95c 100644
--- a/connectivity/source/drivers/postgresql/pq_xcolumns.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xcolumns.hxx
@@ -80,8 +80,8 @@ private:
const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const css::uno::Reference< css::sdbc::XConnection > & origin,
ConnectionSettings *pSettings,
- const OUString &schemaName,
- const OUString &tableName);
+ OUString schemaName,
+ OUString tableName);
virtual ~Columns() override;
diff --git a/connectivity/source/drivers/postgresql/pq_xcontainer.cxx b/connectivity/source/drivers/postgresql/pq_xcontainer.cxx
index d2bcf941a68d..131148c3e192 100644
--- a/connectivity/source/drivers/postgresql/pq_xcontainer.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xcontainer.cxx
@@ -36,7 +36,10 @@
#include <com/sun/star/container/ElementExistException.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <comphelper/diagnose_ex.hxx>
#include <cppuhelper/implbase.hxx>
+#include <o3tl/safeint.hxx>
+#include <utility>
#include "pq_xcontainer.hxx"
#include "pq_statics.hxx"
@@ -47,7 +50,6 @@ using osl::MutexGuard;
using com::sun::star::beans::XPropertySet;
using com::sun::star::uno::Any;
-using com::sun::star::uno::makeAny;
using com::sun::star::uno::Type;
using com::sun::star::uno::XInterface;
using com::sun::star::uno::Reference;
@@ -76,7 +78,7 @@ public:
const OUString & name,
const Any & newElement,
const OUString & oldElement ) :
- m_event( source, makeAny( name ), newElement, makeAny(oldElement) )
+ m_event( source, Any( name ), newElement, Any(oldElement) )
{}
virtual void fire( XEventListener * listener ) const override
@@ -97,7 +99,7 @@ public:
const Reference< XInterface > & source,
const OUString & name,
const Any & newElement ) :
- m_event( source, makeAny( name ), newElement, Any() )
+ m_event( source, Any( name ), newElement, Any() )
{}
virtual void fire( XEventListener * listener ) const override
@@ -118,7 +120,7 @@ public:
RemovedBroadcaster(
const Reference< XInterface > & source,
const OUString & name) :
- m_event( source, makeAny( name ), Any(), Any() )
+ m_event( source, Any( name ), Any(), Any() )
{}
virtual void fire( XEventListener * listener ) const override
@@ -136,14 +138,14 @@ public:
Container::Container(
const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
- const css::uno::Reference< css::sdbc::XConnection > & origin,
+ css::uno::Reference< css::sdbc::XConnection > origin,
ConnectionSettings *pSettings,
- const OUString &type)
+ OUString type)
: ContainerBase( refMutex->GetMutex() ),
m_xMutex( refMutex ),
m_pSettings( pSettings ),
- m_origin( origin ),
- m_type( type )
+ m_origin(std::move( origin )),
+ m_type(std::move( type ))
{
}
@@ -156,7 +158,7 @@ Any Container::getByName( const OUString& aName )
"Element " + aName + " unknown in " + m_type + "-Container",
*this );
}
- OSL_ASSERT( ii->second >= 0 && ii->second < static_cast<int>(m_values.size()) );
+ OSL_ASSERT( ii->second >= 0 && o3tl::make_unsigned(ii->second) < m_values.size() );
return m_values[ ii->second ];
}
@@ -189,7 +191,7 @@ sal_Bool Container::hasElements( )
Any Container::getByIndex( sal_Int32 Index )
{
- if( Index < 0 || Index >= static_cast<sal_Int32>(m_values.size()) )
+ if( Index < 0 || o3tl::make_unsigned(Index) >= m_values.size() )
{
throw IndexOutOfBoundsException(
"Index " + OUString::number( Index )
@@ -299,7 +301,7 @@ void Container::dropByName( const OUString& elementName )
void Container::dropByIndex( sal_Int32 index )
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
- if( index < 0 || index >=static_cast<sal_Int32>(m_values.size()) )
+ if( index < 0 || o3tl::make_unsigned(index) >=m_values.size() )
{
throw css::lang::IndexOutOfBoundsException(
"Index out of range (allowed 0 to "
@@ -350,10 +352,10 @@ void Container::append(
}
int index = m_values.size();
- m_values.push_back( makeAny( descriptor ) );
+ m_values.emplace_back(descriptor);
m_name2index[name] = index;
- fire( InsertedBroadcaster( *this, name, makeAny( descriptor ) ) );
+ fire( InsertedBroadcaster( *this, name, Any( descriptor ) ) );
}
void Container::appendByDescriptor(
@@ -391,13 +393,13 @@ void Container::fire( const EventBroadcastHelper &helper )
}
catch ( css::uno::RuntimeException & )
{
- OSL_ENSURE( false, "exception caught" );
+ TOOLS_WARN_EXCEPTION( "connectivity.postgresql", "exception caught" );
// loose coupling, a runtime exception shall not break anything
// TODO: log away as warning !
}
catch( css::uno::Exception & )
{
- OSL_ENSURE( false, "exception from listener flying through" );
+ TOOLS_WARN_EXCEPTION( "connectivity.postgresql", "exception from listener flying through" );
throw;
}
}
diff --git a/connectivity/source/drivers/postgresql/pq_xcontainer.hxx b/connectivity/source/drivers/postgresql/pq_xcontainer.hxx
index 1e17fef28db5..4b6c190b0a59 100644
--- a/connectivity/source/drivers/postgresql/pq_xcontainer.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xcontainer.hxx
@@ -53,8 +53,6 @@
#include <unordered_map>
-#include "pq_statics.hxx"
-
namespace pq_sdbc_driver
{
@@ -119,9 +117,9 @@ protected:
public:
Container(
const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
- const css::uno::Reference< css::sdbc::XConnection > & origin,
+ css::uno::Reference< css::sdbc::XConnection > origin,
ConnectionSettings *pSettings,
- const OUString & type // for exception messages
+ OUString type // for exception messages
);
public: // XIndexAccess
diff --git a/connectivity/source/drivers/postgresql/pq_xindex.cxx b/connectivity/source/drivers/postgresql/pq_xindex.cxx
index 5a96eeeb119d..4753b5fd4e3c 100644
--- a/connectivity/source/drivers/postgresql/pq_xindex.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xindex.cxx
@@ -37,6 +37,7 @@
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/queryinterface.hxx>
#include <rtl/ref.hxx>
+#include <utility>
#include "pq_xindex.hxx"
#include "pq_xindexcolumns.hxx"
@@ -58,8 +59,8 @@ namespace pq_sdbc_driver
Index::Index( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const Reference< css::sdbc::XConnection > & connection,
ConnectionSettings *pSettings,
- const OUString & schemaName,
- const OUString & tableName )
+ OUString schemaName,
+ OUString tableName )
: ReflectionBase(
getStatics().refl.index.implName,
getStatics().refl.index.serviceNames,
@@ -67,8 +68,8 @@ Index::Index( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
connection,
pSettings,
* getStatics().refl.index.pProps ),
- m_schemaName( schemaName ),
- m_tableName( tableName )
+ m_schemaName(std::move( schemaName )),
+ m_tableName(std::move( tableName ))
{}
Reference< XPropertySet > Index::createDataDescriptor( )
diff --git a/connectivity/source/drivers/postgresql/pq_xindex.hxx b/connectivity/source/drivers/postgresql/pq_xindex.hxx
index 46275ad3aafa..8ccf45660467 100644
--- a/connectivity/source/drivers/postgresql/pq_xindex.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xindex.hxx
@@ -61,8 +61,8 @@ public:
Index( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const css::uno::Reference< css::sdbc::XConnection > & connection,
ConnectionSettings *pSettings,
- const OUString &schemaName,
- const OUString &tableName);
+ OUString schemaName,
+ OUString tableName);
public: // XInterface
virtual void SAL_CALL acquire() noexcept override { ReflectionBase::acquire(); }
diff --git a/connectivity/source/drivers/postgresql/pq_xindexcolumn.cxx b/connectivity/source/drivers/postgresql/pq_xindexcolumn.cxx
index 58cae851f441..fe72059bc15a 100644
--- a/connectivity/source/drivers/postgresql/pq_xindexcolumn.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xindexcolumn.cxx
@@ -38,6 +38,7 @@
#include <rtl/ref.hxx>
+#include "pq_statics.hxx"
#include "pq_xindexcolumn.hxx"
using com::sun::star::uno::Reference;
diff --git a/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx
index 1e0039ecc6e1..2bca00e13b77 100644
--- a/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx
@@ -37,6 +37,7 @@
#include <sal/log.hxx>
#include <string_view>
+#include <utility>
#include <vector>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
@@ -56,7 +57,6 @@ using osl::MutexGuard;
using com::sun::star::beans::XPropertySet;
using com::sun::star::uno::Any;
-using com::sun::star::uno::makeAny;
using com::sun::star::uno::UNO_QUERY;
using com::sun::star::uno::Reference;
using com::sun::star::uno::Sequence;
@@ -73,14 +73,14 @@ IndexColumns::IndexColumns(
const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const css::uno::Reference< css::sdbc::XConnection > & origin,
ConnectionSettings *pSettings,
- const OUString &schemaName,
- const OUString &tableName,
- const OUString &indexName,
+ OUString schemaName,
+ OUString tableName,
+ OUString indexName,
const css::uno::Sequence< OUString > &columns )
: Container( refMutex, origin, pSettings, "INDEX_COLUMN" ),
- m_schemaName( schemaName ),
- m_tableName( tableName ),
- m_indexName( indexName ),
+ m_schemaName(std::move( schemaName )),
+ m_tableName(std::move( tableName )),
+ m_indexName(std::move( indexName )),
m_columns( columns )
{}
@@ -131,7 +131,7 @@ void IndexColumns::refresh()
columnMetaData2SDBCX( pIndexColumn.get(), xRow );
pIndexColumn->setPropertyValue_NoBroadcast_public(
- st.IS_ASCENDING , makeAny( false ) );
+ st.IS_ASCENDING , Any( false ) );
m_values[ index ] <<= prop;
m_name2index[ columnName ] = index;
diff --git a/connectivity/source/drivers/postgresql/pq_xindexcolumns.hxx b/connectivity/source/drivers/postgresql/pq_xindexcolumns.hxx
index eaaa709e671a..a838d5d66908 100644
--- a/connectivity/source/drivers/postgresql/pq_xindexcolumns.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xindexcolumns.hxx
@@ -63,9 +63,9 @@ private:
const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const css::uno::Reference< css::sdbc::XConnection > & origin,
ConnectionSettings *pSettings,
- const OUString &schemaName,
- const OUString &tableName,
- const OUString &indexName,
+ OUString schemaName,
+ OUString tableName,
+ OUString indexName,
const css::uno::Sequence< OUString > &columns );
virtual ~IndexColumns() override;
diff --git a/connectivity/source/drivers/postgresql/pq_xindexes.cxx b/connectivity/source/drivers/postgresql/pq_xindexes.cxx
index 332a9a9e5311..bff96216c568 100644
--- a/connectivity/source/drivers/postgresql/pq_xindexes.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xindexes.cxx
@@ -43,6 +43,8 @@
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XParameters.hpp>
#include <cppuhelper/exc_hlp.hxx>
+#include <o3tl/safeint.hxx>
+#include <utility>
#include "pq_xindexes.hxx"
#include "pq_xindex.hxx"
@@ -55,7 +57,6 @@ using osl::MutexGuard;
using com::sun::star::beans::XPropertySet;
using com::sun::star::uno::Any;
-using com::sun::star::uno::makeAny;
using com::sun::star::uno::UNO_QUERY;
using com::sun::star::uno::Reference;
using com::sun::star::uno::Sequence;
@@ -78,11 +79,11 @@ Indexes::Indexes(
const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const css::uno::Reference< css::sdbc::XConnection > & origin,
ConnectionSettings *pSettings,
- const OUString &schemaName,
- const OUString &tableName)
+ OUString schemaName,
+ OUString tableName)
: Container( refMutex, origin, pSettings, getStatics().KEY ),
- m_schemaName( schemaName ),
- m_tableName( tableName )
+ m_schemaName(std::move( schemaName )),
+ m_tableName(std::move( tableName ))
{
}
@@ -149,7 +150,7 @@ void Indexes::refresh()
pIndex->setPropertyValue_NoBroadcast_public(
st.IS_CLUSTERED, Any( isClusterd ) );
pIndex->setPropertyValue_NoBroadcast_public(
- st.NAME, makeAny( currentIndexName ) );
+ st.NAME, Any( currentIndexName ) );
std::vector< sal_Int32 > seq = parseIntArray( row->getString( C_COLUMNS ) );
Sequence< OUString > columnNames(seq.size());
@@ -160,10 +161,10 @@ void Indexes::refresh()
}
pIndex->setPropertyValue_NoBroadcast_public(
- st.PRIVATE_COLUMN_INDEXES, makeAny( columnNames ));
+ st.PRIVATE_COLUMN_INDEXES, Any( columnNames ));
{
- m_values.push_back( makeAny( prop ) );
+ m_values.emplace_back(prop);
map[ currentIndexName ] = index;
++index;
}
@@ -235,7 +236,7 @@ void Indexes::dropByIndex( sal_Int32 index )
osl::MutexGuard guard( m_xMutex->GetMutex() );
- if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) )
+ if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() )
{
throw css::lang::IndexOutOfBoundsException(
"Indexes: Index out of range (allowed 0 to "
diff --git a/connectivity/source/drivers/postgresql/pq_xindexes.hxx b/connectivity/source/drivers/postgresql/pq_xindexes.hxx
index c2e81f61751f..536d17b96198 100644
--- a/connectivity/source/drivers/postgresql/pq_xindexes.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xindexes.hxx
@@ -58,8 +58,8 @@ private:
const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const css::uno::Reference< css::sdbc::XConnection > & origin,
ConnectionSettings *pSettings,
- const OUString &schemaName,
- const OUString &tableName);
+ OUString schemaName,
+ OUString tableName);
virtual ~Indexes() override;
diff --git a/connectivity/source/drivers/postgresql/pq_xkey.cxx b/connectivity/source/drivers/postgresql/pq_xkey.cxx
index e2777824568f..81d1f7a86eb6 100644
--- a/connectivity/source/drivers/postgresql/pq_xkey.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkey.cxx
@@ -37,6 +37,7 @@
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/queryinterface.hxx>
#include <rtl/ref.hxx>
+#include <utility>
#include "pq_xkey.hxx"
#include "pq_xkeycolumns.hxx"
@@ -57,8 +58,8 @@ namespace pq_sdbc_driver
Key::Key( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const Reference< css::sdbc::XConnection > & connection,
ConnectionSettings *pSettings,
- const OUString & schemaName,
- const OUString & tableName )
+ OUString schemaName,
+ OUString tableName )
: ReflectionBase(
getStatics().refl.key.implName,
getStatics().refl.key.serviceNames,
@@ -66,8 +67,8 @@ Key::Key( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
connection,
pSettings,
* getStatics().refl.key.pProps ),
- m_schemaName( schemaName ),
- m_tableName( tableName )
+ m_schemaName(std::move( schemaName )),
+ m_tableName(std::move( tableName ))
{}
Reference< XPropertySet > Key::createDataDescriptor( )
diff --git a/connectivity/source/drivers/postgresql/pq_xkey.hxx b/connectivity/source/drivers/postgresql/pq_xkey.hxx
index d231e1e89945..68f05fd27d4e 100644
--- a/connectivity/source/drivers/postgresql/pq_xkey.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xkey.hxx
@@ -61,8 +61,8 @@ public:
Key( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const css::uno::Reference< css::sdbc::XConnection > & connection,
ConnectionSettings *pSettings,
- const OUString &schemaName,
- const OUString &tableName);
+ OUString schemaName,
+ OUString tableName);
public: // XInterface
virtual void SAL_CALL acquire() noexcept override { ReflectionBase::acquire(); }
diff --git a/connectivity/source/drivers/postgresql/pq_xkeycolumn.cxx b/connectivity/source/drivers/postgresql/pq_xkeycolumn.cxx
index 10c3dbb474cd..30eef179716c 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeycolumn.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeycolumn.cxx
@@ -38,6 +38,7 @@
#include <rtl/ref.hxx>
+#include "pq_statics.hxx"
#include "pq_xkeycolumn.hxx"
using com::sun::star::uno::Reference;
diff --git a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx
index 6dcbe07d4117..89f63ceb5a65 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx
@@ -40,6 +40,7 @@
#include <com/sun/star/sdbc/XRow.hpp>
#include <cppuhelper/exc_hlp.hxx>
#include <rtl/ref.hxx>
+#include <utility>
#include "pq_xcolumns.hxx"
#include "pq_xkeycolumns.hxx"
@@ -52,7 +53,6 @@ using osl::MutexGuard;
using com::sun::star::beans::XPropertySet;
using com::sun::star::uno::Any;
-using com::sun::star::uno::makeAny;
using com::sun::star::uno::UNO_QUERY;
using com::sun::star::uno::Reference;
using com::sun::star::uno::Sequence;
@@ -69,13 +69,13 @@ KeyColumns::KeyColumns(
const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const css::uno::Reference< css::sdbc::XConnection > & origin,
ConnectionSettings *pSettings,
- const OUString &schemaName,
- const OUString &tableName,
+ OUString schemaName,
+ OUString tableName,
const Sequence< OUString > &columnNames,
const Sequence< OUString > &foreignColumnNames )
: Container( refMutex, origin, pSettings, "KEY_COLUMN" ),
- m_schemaName( schemaName ),
- m_tableName( tableName ),
+ m_schemaName(std::move( schemaName )),
+ m_tableName(std::move( tableName )),
m_columnNames( columnNames ),
m_foreignColumnNames( foreignColumnNames )
{}
@@ -126,11 +126,11 @@ void KeyColumns::refresh()
if( keyindex < m_foreignColumnNames.getLength() )
{
pKeyColumn->setPropertyValue_NoBroadcast_public(
- st.RELATED_COLUMN, makeAny( m_foreignColumnNames[keyindex]) );
+ st.RELATED_COLUMN, Any( m_foreignColumnNames[keyindex]) );
}
{
- m_values.push_back( makeAny( prop ) );
+ m_values.emplace_back(prop);
map[ name ] = columnIndex;
++columnIndex;
}
diff --git a/connectivity/source/drivers/postgresql/pq_xkeycolumns.hxx b/connectivity/source/drivers/postgresql/pq_xkeycolumns.hxx
index 0c56fd189e9a..60bbd0c0de36 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeycolumns.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeycolumns.hxx
@@ -63,8 +63,8 @@ private:
const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const css::uno::Reference< css::sdbc::XConnection > & origin,
ConnectionSettings *pSettings,
- const OUString &schemaName,
- const OUString &tableName,
+ OUString schemaName,
+ OUString tableName,
const css::uno::Sequence< OUString > &keyColumns,
const css::uno::Sequence< OUString > &foreignColumnNames);
diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.cxx b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
index 84507202fa9a..0758be630e04 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeys.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeys.cxx
@@ -49,6 +49,8 @@
#include <com/sun/star/sdbc/KeyRule.hpp>
#include <com/sun/star/sdbcx/KeyType.hpp>
#include <cppuhelper/exc_hlp.hxx>
+#include <o3tl/safeint.hxx>
+#include <utility>
#include "pq_xkeys.hxx"
#include "pq_xkey.hxx"
@@ -60,7 +62,7 @@ using osl::MutexGuard;
using css::beans::XPropertySet;
-using com::sun::star::uno::makeAny;
+using com::sun::star::uno::Any;
using com::sun::star::uno::UNO_QUERY;
using com::sun::star::uno::Reference;
@@ -78,11 +80,11 @@ Keys::Keys(
const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const css::uno::Reference< css::sdbc::XConnection > & origin,
ConnectionSettings *pSettings,
- const OUString &schemaName,
- const OUString &tableName)
+ OUString schemaName,
+ OUString tableName)
: Container( refMutex, origin, pSettings, getStatics().KEY ),
- m_schemaName( schemaName ),
- m_tableName( tableName )
+ m_schemaName(std::move( schemaName )),
+ m_tableName(std::move( tableName ))
{}
Keys::~Keys()
@@ -156,16 +158,16 @@ void Keys::refresh()
Reference< css::beans::XPropertySet > prop = pKey;
pKey->setPropertyValue_NoBroadcast_public(
- st.NAME, makeAny( xRow->getString( 1 ) ) );
+ st.NAME, Any( xRow->getString( 1 ) ) );
sal_Int32 keyType = string2keytype( xRow->getString(2) );
- pKey->setPropertyValue_NoBroadcast_public( st.TYPE, makeAny( keyType ) );
+ pKey->setPropertyValue_NoBroadcast_public( st.TYPE, Any( keyType ) );
pKey->setPropertyValue_NoBroadcast_public(
- st.UPDATE_RULE, makeAny( string2keyrule( xRow->getString(3) ) ) );
+ st.UPDATE_RULE, Any( string2keyrule( xRow->getString(3) ) ) );
pKey->setPropertyValue_NoBroadcast_public(
- st.DELETE_RULE, makeAny( string2keyrule( xRow->getString(4) ) ) );
+ st.DELETE_RULE, Any( string2keyrule( xRow->getString(4) ) ) );
pKey->setPropertyValue_NoBroadcast_public(
st.PRIVATE_COLUMNS,
- makeAny(
+ Any(
convertMappedIntArray2StringArray(
mainMap,
string2intarray( xRow->getString( 7 ) ) ) ) );
@@ -174,13 +176,13 @@ void Keys::refresh()
{
OUString buf = xRow->getString( 6 ) + "." + xRow->getString( 5 );
pKey->setPropertyValue_NoBroadcast_public(
- st.REFERENCED_TABLE, makeAny( buf ) );
+ st.REFERENCED_TABLE, Any( buf ) );
Int2StringMap foreignMap;
fillAttnum2attnameMap( foreignMap, m_origin, xRow->getString(6), xRow->getString(5));
pKey->setPropertyValue_NoBroadcast_public(
st.PRIVATE_FOREIGN_COLUMNS,
- makeAny(
+ Any(
convertMappedIntArray2StringArray(
foreignMap,
string2intarray( xRow->getString(8) ) ) ) );
@@ -189,7 +191,7 @@ void Keys::refresh()
{
map[ xRow->getString( 1 ) ] = keyIndex;
- m_values.push_back( makeAny( prop ) );
+ m_values.push_back( Any( prop ) );
++keyIndex;
}
}
@@ -226,7 +228,7 @@ void Keys::appendByDescriptor(
void Keys::dropByIndex( sal_Int32 index )
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
- if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) )
+ if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() )
{
throw css::lang::IndexOutOfBoundsException(
"TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1)
diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.hxx b/connectivity/source/drivers/postgresql/pq_xkeys.hxx
index fe1afef35a4b..ef6376d4d780 100644
--- a/connectivity/source/drivers/postgresql/pq_xkeys.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xkeys.hxx
@@ -58,8 +58,8 @@ private:
const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex,
const css::uno::Reference< css::sdbc::XConnection > & origin,
ConnectionSettings *pSettings,
- const OUString &schemaName,
- const OUString &tableName);
+ OUString schemaName,
+ OUString tableName);
virtual ~Keys() override;
diff --git a/connectivity/source/drivers/postgresql/pq_xtable.cxx b/connectivity/source/drivers/postgresql/pq_xtable.cxx
index 9ac52f1df0ff..de8196f9fecd 100644
--- a/connectivity/source/drivers/postgresql/pq_xtable.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xtable.cxx
@@ -60,7 +60,6 @@ using com::sun::star::uno::Reference;
using com::sun::star::uno::UNO_QUERY;
using com::sun::star::uno::Sequence;
using com::sun::star::uno::Any;
-using com::sun::star::uno::makeAny;
using com::sun::star::uno::Type;
using com::sun::star::beans::XPropertySet;
@@ -168,7 +167,7 @@ void Table::rename( const OUString& newName )
if( Xrename.is() )
{
Xrename->rename( newName );
- setPropertyValue_NoBroadcast_public( st.SCHEMA_NAME, makeAny(newSchemaName) );
+ setPropertyValue_NoBroadcast_public( st.SCHEMA_NAME, Any(newSchemaName) );
}
}
else
@@ -185,14 +184,13 @@ void Table::rename( const OUString& newName )
bufferQuoteIdentifier( buf, newSchemaName, m_pSettings );
Reference< XStatement > statement = m_conn->createStatement();
statement->executeUpdate( buf.makeStringAndClear() );
- setPropertyValue_NoBroadcast_public( st.SCHEMA_NAME, makeAny(newSchemaName) );
+ setPropertyValue_NoBroadcast_public( st.SCHEMA_NAME, Any(newSchemaName) );
disposeNoThrow( statement );
schema = newSchemaName;
}
catch( css::sdbc::SQLException &e )
{
- OUString buf( e.Message + "(NOTE: Only postgresql server >= V8.1 support changing a table's schema)" );
- e.Message = buf;
+ e.Message += "(NOTE: Only postgresql server >= V8.1 support changing a table's schema)";
throw;
}
@@ -209,7 +207,7 @@ void Table::rename( const OUString& newName )
disposeNoThrow( statement );
}
}
- setPropertyValue_NoBroadcast_public( st.NAME, makeAny(newTableName) );
+ setPropertyValue_NoBroadcast_public( st.NAME, Any(newTableName) );
// inform the container of the name change !
if( m_pSettings->tables.is() )
{
diff --git a/connectivity/source/drivers/postgresql/pq_xtable.hxx b/connectivity/source/drivers/postgresql/pq_xtable.hxx
index dc1577612db8..7c8ca73f566b 100644
--- a/connectivity/source/drivers/postgresql/pq_xtable.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xtable.hxx
@@ -36,19 +36,14 @@
#pragma once
-#include <cppuhelper/component.hxx>
-#include <cppuhelper/propshlp.hxx>
-
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
#include <com/sun/star/sdbcx/XRename.hpp>
#include <com/sun/star/sdbcx/XAlterTable.hpp>
-#include <com/sun/star/container/XNamed.hpp>
#include "pq_xbase.hxx"
+#include "pq_xcolumns.hxx"
namespace pq_sdbc_driver
{
diff --git a/connectivity/source/drivers/postgresql/pq_xtables.cxx b/connectivity/source/drivers/postgresql/pq_xtables.cxx
index 47606669dd40..423ec81f2166 100644
--- a/connectivity/source/drivers/postgresql/pq_xtables.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xtables.cxx
@@ -43,6 +43,7 @@
#include <com/sun/star/sdbcx/Privilege.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <cppuhelper/exc_hlp.hxx>
+#include <o3tl/safeint.hxx>
#include "pq_xtables.hxx"
#include "pq_xviews.hxx"
@@ -55,7 +56,6 @@ using osl::MutexGuard;
using com::sun::star::beans::XPropertySet;
using com::sun::star::uno::Any;
-using com::sun::star::uno::makeAny;
using com::sun::star::uno::UNO_QUERY;
using com::sun::star::uno::Reference;
using com::sun::star::uno::Sequence;
@@ -111,16 +111,16 @@ void Tables::refresh()
OUString name = xRow->getString( TABLE_INDEX_NAME+1);
OUString schema = xRow->getString( TABLE_INDEX_SCHEMA+1);
pTable->setPropertyValue_NoBroadcast_public(
- st.CATALOG_NAME , makeAny(xRow->getString( TABLE_INDEX_CATALOG+1) ) );
- pTable->setPropertyValue_NoBroadcast_public( st.NAME , makeAny( name ) );
- pTable->setPropertyValue_NoBroadcast_public( st.SCHEMA_NAME , makeAny( schema ));
+ st.CATALOG_NAME , Any(xRow->getString( TABLE_INDEX_CATALOG+1) ) );
+ pTable->setPropertyValue_NoBroadcast_public( st.NAME , Any( name ) );
+ pTable->setPropertyValue_NoBroadcast_public( st.SCHEMA_NAME , Any( schema ));
pTable->setPropertyValue_NoBroadcast_public(
- st.TYPE , makeAny( xRow->getString( TABLE_INDEX_TYPE+1) ) );
+ st.TYPE , Any( xRow->getString( TABLE_INDEX_TYPE+1) ) );
pTable->setPropertyValue_NoBroadcast_public(
- st.DESCRIPTION , makeAny( xRow->getString( TABLE_INDEX_REMARKS+1) ) );
+ st.DESCRIPTION , Any( xRow->getString( TABLE_INDEX_REMARKS+1) ) );
pTable->setPropertyValue_NoBroadcast_public(
st.PRIVILEGES ,
- makeAny( sal_Int32( css::sdbcx::Privilege::SELECT |
+ Any( sal_Int32( css::sdbcx::Privilege::SELECT |
css::sdbcx::Privilege::INSERT |
css::sdbcx::Privilege::UPDATE |
css::sdbcx::Privilege::DELETE |
@@ -131,7 +131,7 @@ void Tables::refresh()
css::sdbcx::Privilege::DROP ) ) );
{
- m_values.push_back( makeAny( prop ) );
+ m_values.push_back( Any( prop ) );
map[ schema + "." + name ] = tableIndex;
++tableIndex;
}
@@ -311,7 +311,7 @@ void Tables::appendByDescriptor(
void Tables::dropByIndex( sal_Int32 index )
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
- if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) )
+ if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() )
{
throw css::lang::IndexOutOfBoundsException(
"TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1)
diff --git a/connectivity/source/drivers/postgresql/pq_xuser.hxx b/connectivity/source/drivers/postgresql/pq_xuser.hxx
index 8072cae415bb..702787a67496 100644
--- a/connectivity/source/drivers/postgresql/pq_xuser.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xuser.hxx
@@ -36,11 +36,6 @@
#pragma once
-#include <cppuhelper/component.hxx>
-#include <cppuhelper/propshlp.hxx>
-
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
#include <com/sun/star/sdbcx/XUser.hpp>
#include "pq_xbase.hxx"
diff --git a/connectivity/source/drivers/postgresql/pq_xusers.cxx b/connectivity/source/drivers/postgresql/pq_xusers.cxx
index bc8b62b1d5b4..08cdf2d1c135 100644
--- a/connectivity/source/drivers/postgresql/pq_xusers.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xusers.cxx
@@ -41,6 +41,7 @@
#include <com/sun/star/sdbc/SQLException.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <cppuhelper/exc_hlp.hxx>
+#include <o3tl/safeint.hxx>
#include "pq_xusers.hxx"
#include "pq_xuser.hxx"
@@ -51,7 +52,7 @@ using osl::MutexGuard;
using com::sun::star::beans::XPropertySet;
-using com::sun::star::uno::makeAny;
+using com::sun::star::uno::Any;
using com::sun::star::uno::UNO_QUERY;
using com::sun::star::uno::Reference;
@@ -98,10 +99,10 @@ void Users::refresh()
OUString name = xRow->getString( 1);
pUser->setPropertyValue_NoBroadcast_public(
- st.NAME , makeAny(xRow->getString( TABLE_INDEX_CATALOG+1) ) );
+ st.NAME , Any(xRow->getString( TABLE_INDEX_CATALOG+1) ) );
{
- m_values.push_back( makeAny( prop ) );
+ m_values.push_back( Any( prop ) );
map[ name ] = tableIndex;
++tableIndex;
}
@@ -151,7 +152,7 @@ void Users::dropByIndex( sal_Int32 index )
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
- if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) )
+ if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() )
{
throw css::lang::IndexOutOfBoundsException(
"USERS: Index out of range (allowed 0 to "
diff --git a/connectivity/source/drivers/postgresql/pq_xview.cxx b/connectivity/source/drivers/postgresql/pq_xview.cxx
index 3652cdee634f..c2e936e9a314 100644
--- a/connectivity/source/drivers/postgresql/pq_xview.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xview.cxx
@@ -52,7 +52,6 @@ using osl::MutexGuard;
using com::sun::star::uno::Reference;
using com::sun::star::uno::Sequence;
using com::sun::star::uno::Any;
-using com::sun::star::uno::makeAny;
using com::sun::star::uno::Type;
using com::sun::star::beans::XPropertySet;
@@ -121,14 +120,13 @@ void View::rename( const OUString& newName )
bufferQuoteIdentifier( buf, newSchemaName, m_pSettings );
Reference< XStatement > statement = m_conn->createStatement();
statement->executeUpdate( buf.makeStringAndClear() );
- setPropertyValue_NoBroadcast_public( st.SCHEMA_NAME, makeAny(newSchemaName) );
+ setPropertyValue_NoBroadcast_public( st.SCHEMA_NAME, Any(newSchemaName) );
disposeNoThrow( statement );
schema = newSchemaName;
}
catch( css::sdbc::SQLException &e )
{
- OUString buf( e.Message + "(NOTE: Only postgresql server >= V8.1 support changing a table's schema)" );
- e.Message = buf;
+ e.Message += "(NOTE: Only postgresql server >= V8.1 support changing a table's schema)";
throw;
}
@@ -142,7 +140,7 @@ void View::rename( const OUString& newName )
bufferQuoteIdentifier( buf, newTableName, m_pSettings );
Reference< XStatement > statement = m_conn->createStatement();
statement->executeUpdate( buf.makeStringAndClear() );
- setPropertyValue_NoBroadcast_public( st.NAME, makeAny(newTableName) );
+ setPropertyValue_NoBroadcast_public( st.NAME, Any(newTableName) );
}
// inform the container of the name change !
diff --git a/connectivity/source/drivers/postgresql/pq_xview.hxx b/connectivity/source/drivers/postgresql/pq_xview.hxx
index 055fd921864f..f68b5535a8d7 100644
--- a/connectivity/source/drivers/postgresql/pq_xview.hxx
+++ b/connectivity/source/drivers/postgresql/pq_xview.hxx
@@ -36,13 +36,7 @@
#pragma once
-#include <cppuhelper/component.hxx>
-#include <cppuhelper/propshlp.hxx>
-
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
#include <com/sun/star/sdbcx/XRename.hpp>
-#include <com/sun/star/container/XNamed.hpp>
#include "pq_xbase.hxx"
diff --git a/connectivity/source/drivers/postgresql/pq_xviews.cxx b/connectivity/source/drivers/postgresql/pq_xviews.cxx
index d71219fa6420..1f5b6c4fa52c 100644
--- a/connectivity/source/drivers/postgresql/pq_xviews.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xviews.cxx
@@ -41,6 +41,7 @@
#include <com/sun/star/sdbc/SQLException.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <cppuhelper/exc_hlp.hxx>
+#include <o3tl/safeint.hxx>
#include "pq_xviews.hxx"
#include "pq_xview.hxx"
@@ -52,7 +53,7 @@ using osl::MutexGuard;
using com::sun::star::beans::XPropertySet;
-using com::sun::star::uno::makeAny;
+using com::sun::star::uno::Any;
using com::sun::star::uno::UNO_QUERY;
using com::sun::star::uno::Reference;
@@ -110,12 +111,12 @@ void Views::refresh()
rtl::Reference<View> pView = new View (m_xMutex, m_origin, m_pSettings );
Reference< css::beans::XPropertySet > prop = pView;
- pView->setPropertyValue_NoBroadcast_public(st.NAME , makeAny(table) );
- pView->setPropertyValue_NoBroadcast_public(st.SCHEMA_NAME, makeAny(schema) );
- pView->setPropertyValue_NoBroadcast_public(st.COMMAND, makeAny(command) );
+ pView->setPropertyValue_NoBroadcast_public(st.NAME , Any(table) );
+ pView->setPropertyValue_NoBroadcast_public(st.SCHEMA_NAME, Any(schema) );
+ pView->setPropertyValue_NoBroadcast_public(st.COMMAND, Any(command) );
{
- m_values.push_back( makeAny( prop ) );
+ m_values.push_back( Any( prop ) );
map[ schema + "." + table ] = viewIndex;
++viewIndex;
}
@@ -175,7 +176,7 @@ void Views::dropByName( const OUString& elementName )
void Views::dropByIndex( sal_Int32 index )
{
osl::MutexGuard guard( m_xMutex->GetMutex() );
- if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) )
+ if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() )
{
throw css::lang::IndexOutOfBoundsException(
"VIEWS: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1)