summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/postgresql/pq_xindexes.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/postgresql/pq_xindexes.cxx')
-rw-r--r--connectivity/source/drivers/postgresql/pq_xindexes.cxx31
1 files changed, 17 insertions, 14 deletions
diff --git a/connectivity/source/drivers/postgresql/pq_xindexes.cxx b/connectivity/source/drivers/postgresql/pq_xindexes.cxx
index 2f6df914f0a2..bff96216c568 100644
--- a/connectivity/source/drivers/postgresql/pq_xindexes.cxx
+++ b/connectivity/source/drivers/postgresql/pq_xindexes.cxx
@@ -35,6 +35,7 @@
************************************************************************/
#include <sal/log.hxx>
+#include <rtl/ref.hxx>
#include <rtl/ustrbuf.hxx>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
@@ -42,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"
@@ -54,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;
@@ -77,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 ))
{
}
@@ -133,7 +135,7 @@ void Indexes::refresh()
static const sal_Int32 C_IS_PRIMARY = 6;
static const sal_Int32 C_COLUMNS = 7;
OUString currentIndexName = row->getString( C_INDEXNAME );
- Index *pIndex =
+ rtl::Reference<Index> pIndex =
new Index( m_xMutex, m_origin, m_pSettings,
m_schemaName, m_tableName );
@@ -148,20 +150,21 @@ 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());
+ auto columnNamesRange = asNonConstRange(columnNames);
for( size_t columns = 0 ; columns < seq.size() ; columns ++ )
{
- columnNames[columns] = column2NameMap[ seq[columns] ];
+ columnNamesRange[columns] = column2NameMap[ seq[columns] ];
}
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;
}
@@ -233,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 "
@@ -268,10 +271,10 @@ Reference< css::container::XNameAccess > Indexes::create(
const OUString & schemaName,
const OUString & tableName)
{
- Indexes *pIndexes = new Indexes( refMutex, origin, pSettings, schemaName, tableName );
- Reference< css::container::XNameAccess > ret = pIndexes;
+ rtl::Reference<Indexes> pIndexes
+ = new Indexes( refMutex, origin, pSettings, schemaName, tableName );
pIndexes->refresh();
- return ret;
+ return pIndexes;
}