diff options
Diffstat (limited to 'connectivity/source/drivers/postgresql/pq_xviews.cxx')
-rw-r--r-- | connectivity/source/drivers/postgresql/pq_xviews.cxx | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/connectivity/source/drivers/postgresql/pq_xviews.cxx b/connectivity/source/drivers/postgresql/pq_xviews.cxx index ac684a16c124..b50fb9510746 100644 --- a/connectivity/source/drivers/postgresql/pq_xviews.cxx +++ b/connectivity/source/drivers/postgresql/pq_xviews.cxx @@ -34,12 +34,14 @@ * ************************************************************************/ +#include <rtl/ref.hxx> #include <rtl/ustrbuf.hxx> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #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" @@ -51,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; @@ -83,7 +85,7 @@ void Views::refresh() Reference< XStatement > stmt = m_origin->createStatement(); - Reference< XResultSet > rs = stmt->executeQuery("SELECT " + Reference< XResultSet > rs = stmt->executeQuery(u"SELECT " "DISTINCT ON( pg_namespace.nspname, relname) " // needed because of duplicates "pg_namespace.nspname," // 1 "relname," // 2 @@ -91,7 +93,7 @@ void Views::refresh() "FROM pg_namespace, pg_class, pg_rewrite " "WHERE pg_namespace.oid = relnamespace " "AND pg_class.oid = ev_class " - "AND relkind=\'v\'" ); + "AND relkind=\'v\'"_ustr ); Reference< XRow > xRow( rs , UNO_QUERY ); @@ -106,15 +108,15 @@ void Views::refresh() table = xRow->getString( 2 ); command = xRow->getString( 3 ); - View *pView = new View (m_xMutex, m_origin, m_pSettings ); + 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; } @@ -148,7 +150,7 @@ void Views::appendByDescriptor( buf.append( "CREATE VIEW "); bufferQuoteQualifiedIdentifier( buf, schema, name, m_pSettings ); - buf.append(" AS " ).append( command ); + buf.append(" AS " + command ); stmt->executeUpdate( buf.makeStringAndClear() ); @@ -174,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) @@ -204,13 +206,12 @@ Reference< css::container::XNameAccess > Views::create( const ::rtl::Reference< comphelper::RefCountedMutex > & refMutex, const css::uno::Reference< css::sdbc::XConnection > & origin, ConnectionSettings *pSettings, - Views **ppViews) + rtl::Reference<Views> *ppViews) { *ppViews = new Views( refMutex, origin, pSettings ); - Reference< css::container::XNameAccess > ret = *ppViews; (*ppViews)->refresh(); - return ret; + return *ppViews; } }; |