2010-10-12 15:55:21 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-25 16:56:16 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2009-12-11 09:51:25 +01:00
|
|
|
|
|
|
|
#include "mysqlc_propertyids.hxx"
|
|
|
|
#include "mysqlc_general.hxx"
|
|
|
|
#include "mysqlc_resultset.hxx"
|
|
|
|
#include "mysqlc_resultsetmetadata.hxx"
|
|
|
|
|
|
|
|
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
2014-01-31 03:09:23 -02:00
|
|
|
#include <com/sun/star/lang/DisposedException.hpp>
|
|
|
|
#include <com/sun/star/sdbc/DataType.hpp>
|
2010-07-09 08:01:25 +02:00
|
|
|
#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
|
|
|
|
#include <com/sun/star/sdbc/ResultSetType.hpp>
|
|
|
|
#include <com/sun/star/sdbc/FetchDirection.hpp>
|
2014-01-31 03:09:23 -02:00
|
|
|
#include <com/sun/star/sdbcx/CompareBookmark.hpp>
|
|
|
|
#include <cppuhelper/supportsservice.hxx>
|
2009-12-11 09:51:25 +01:00
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
using namespace rtl;
|
|
|
|
#include <comphelper/string.hxx>
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
2009-12-11 09:51:25 +01:00
|
|
|
using namespace connectivity::mysqlc;
|
|
|
|
using namespace cppu;
|
2018-06-17 18:09:43 +02:00
|
|
|
using namespace com::sun::star;
|
2009-12-11 09:51:25 +01:00
|
|
|
using namespace com::sun::star::lang;
|
|
|
|
using namespace com::sun::star::beans;
|
|
|
|
using namespace com::sun::star::sdbc;
|
|
|
|
using namespace com::sun::star::sdbcx;
|
|
|
|
using namespace com::sun::star::container;
|
|
|
|
using namespace com::sun::star::io;
|
|
|
|
using namespace com::sun::star::util;
|
2018-06-17 18:09:43 +02:00
|
|
|
using namespace ::comphelper;
|
2009-12-11 09:51:25 +01:00
|
|
|
using ::osl::MutexGuard;
|
|
|
|
|
|
|
|
#include <cppconn/resultset.h>
|
|
|
|
#include <cppconn/resultset_metadata.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
// copied from string misc, it should be replaced when library is not an
|
|
|
|
// extension anymore
|
|
|
|
std::vector<OUString> lcl_split(const OUString& rStr, sal_Unicode cSeparator)
|
|
|
|
{
|
|
|
|
std::vector< OUString > vec;
|
|
|
|
sal_Int32 idx = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
OUString kw =
|
|
|
|
rStr.getToken(0, cSeparator, idx);
|
|
|
|
kw = kw.trim();
|
|
|
|
if (!kw.isEmpty())
|
|
|
|
{
|
|
|
|
vec.push_back(kw);
|
|
|
|
}
|
|
|
|
} while (idx >= 0);
|
|
|
|
return vec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-19 11:43:51 +01:00
|
|
|
rtl::OUString SAL_CALL OResultSet::getImplementationName()
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
2014-12-19 11:43:51 +01:00
|
|
|
return rtl::OUString( "com.sun.star.sdbcx.mysqlc.ResultSet" );
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Sequence< rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames()
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Sequence< rtl::OUString > aSupported(2);
|
2013-11-15 11:05:19 +02:00
|
|
|
aSupported[0] = "com.sun.star.sdbc.ResultSet";
|
|
|
|
aSupported[1] = "com.sun.star.sdbcx.ResultSet";
|
2015-02-11 13:20:49 +02:00
|
|
|
return aSupported;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2014-12-19 11:43:51 +01:00
|
|
|
sal_Bool SAL_CALL OResultSet::supportsService(const rtl::OUString& _rServiceName)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
2014-01-31 03:09:23 -02:00
|
|
|
return cppu::supportsService(this, _rServiceName);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
OResultSet::OResultSet(OConnection& rConn, OCommonStatement * pStmt, MYSQL_RES * pResult, rtl_TextEncoding _encoding )
|
2009-12-11 09:51:25 +01:00
|
|
|
: OResultSet_BASE(m_aMutex)
|
|
|
|
,OPropertySetHelper(OResultSet_BASE::rBHelper)
|
2018-06-17 18:09:43 +02:00
|
|
|
,m_rConnection(rConn)
|
|
|
|
,m_pMysql(rConn.getMysqlConnection())
|
2015-06-08 16:26:34 +02:00
|
|
|
,m_aStatement(static_cast<OWeakObject*>(pStmt))
|
2015-11-10 10:19:59 +01:00
|
|
|
,m_xMetaData(nullptr)
|
2018-06-17 18:09:43 +02:00
|
|
|
,m_pResult(pResult)
|
2009-12-11 09:51:25 +01:00
|
|
|
,fieldCount( 0 )
|
|
|
|
,m_encoding( _encoding )
|
|
|
|
{
|
2018-06-17 18:09:43 +02:00
|
|
|
fieldCount = mysql_num_fields(pResult);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
OResultSet::~OResultSet()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void OResultSet::disposing()
|
|
|
|
{
|
|
|
|
OPropertySetHelper::disposing();
|
|
|
|
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
|
2015-11-10 10:19:59 +01:00
|
|
|
m_aStatement = nullptr;
|
|
|
|
m_xMetaData = nullptr;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Any SAL_CALL OResultSet::queryInterface(const Type & rType)
|
|
|
|
{
|
|
|
|
Any aRet = OPropertySetHelper::queryInterface(rType);
|
|
|
|
if (!aRet.hasValue()) {
|
|
|
|
aRet = OResultSet_BASE::queryInterface(rType);
|
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Sequence< Type > SAL_CALL OResultSet::getTypes()
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
2014-05-23 22:11:27 +02:00
|
|
|
OTypeCollection aTypes( cppu::UnoType<XMultiPropertySet>::get(),
|
|
|
|
cppu::UnoType<XFastPropertySet>::get(),
|
|
|
|
cppu::UnoType<XPropertySet>::get());
|
2009-12-11 09:51:25 +01:00
|
|
|
|
|
|
|
return concatSequences(aTypes.getTypes(), OResultSet_BASE::getTypes());
|
|
|
|
}
|
|
|
|
|
2014-12-19 11:43:51 +01:00
|
|
|
sal_Int32 SAL_CALL OResultSet::findColumn(const rtl::OUString& columnName)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
MYSQL_FIELD* pFields = mysql_fetch_field(m_pResult);
|
|
|
|
for(unsigned int i = 0; i< fieldCount; ++i)
|
|
|
|
{
|
|
|
|
if(columnName.equalsIgnoreAsciiCaseAscii(pFields[i].name))
|
|
|
|
return i + 1; // sdbc indexes from 1
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
2018-06-17 18:09:43 +02:00
|
|
|
|
2013-09-12 10:37:31 +01:00
|
|
|
throw SQLException(
|
|
|
|
"The column name '" + columnName + "' is not valid.",
|
|
|
|
*this,
|
2014-12-19 11:43:51 +01:00
|
|
|
rtl::OUString("42S22"),
|
2013-09-12 10:37:31 +01:00
|
|
|
0,
|
|
|
|
Any()
|
|
|
|
);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream(sal_Int32 column)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getBinaryStream", *this);
|
2015-11-10 10:19:59 +01:00
|
|
|
return nullptr;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream(sal_Int32 column)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getCharacterStream", *this);
|
2015-11-10 10:19:59 +01:00
|
|
|
return nullptr;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::getBoolean(sal_Int32 column)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
2018-06-17 18:09:43 +02:00
|
|
|
|
|
|
|
char* pValue = m_aRow[column-1];
|
|
|
|
if(!pValue)
|
|
|
|
{
|
|
|
|
m_bWasNull = true;
|
|
|
|
return false;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
2018-06-17 18:09:43 +02:00
|
|
|
|
|
|
|
m_bWasNull = false;
|
|
|
|
return static_cast<bool>(std::atoi(pValue));
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int8 SAL_CALL OResultSet::getByte(sal_Int32 column)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
2018-06-17 18:09:43 +02:00
|
|
|
|
|
|
|
char* pValue = m_aRow[column-1];
|
|
|
|
if(!pValue)
|
|
|
|
{
|
|
|
|
m_bWasNull = true;
|
|
|
|
return 0;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
2018-06-17 18:09:43 +02:00
|
|
|
|
|
|
|
m_bWasNull = false;
|
|
|
|
return static_cast<sal_Int8>(std::atoi(pValue));
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes(sal_Int32 column)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
char* pValue = m_aRow[column-1];
|
|
|
|
if(!pValue)
|
|
|
|
{
|
|
|
|
m_bWasNull = true;
|
|
|
|
return uno::Sequence< sal_Int8>();
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
2018-06-17 18:09:43 +02:00
|
|
|
m_bWasNull = false;
|
|
|
|
return uno::Sequence< sal_Int8 > (reinterpret_cast<sal_Int8 const *>(
|
|
|
|
pValue), m_aLengths[column-1]);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Date SAL_CALL OResultSet::getDate(sal_Int32 column)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
Date d; // TODO initialize
|
|
|
|
char* dateStr = m_aRow[column-1];
|
|
|
|
if(!dateStr)
|
|
|
|
{
|
|
|
|
m_bWasNull = true;
|
|
|
|
return d;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
2018-06-17 18:09:43 +02:00
|
|
|
|
|
|
|
rtl::OString dateString(dateStr);
|
|
|
|
rtl::OString token;
|
|
|
|
sal_Int32 nIndex = 0, i=0;
|
|
|
|
do {
|
|
|
|
token = dateString.getToken (0, '-', nIndex);
|
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
d.Year = static_cast<sal_uInt16>(token.toUInt32());
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
d.Month = static_cast<sal_uInt16>(token.toUInt32());
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
d.Day = static_cast<sal_uInt16>(token.toUInt32());
|
|
|
|
break;
|
|
|
|
default:;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
} while (nIndex >= 0);
|
|
|
|
m_bWasNull = false;
|
2009-12-11 09:51:25 +01:00
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
|
|
|
double SAL_CALL OResultSet::getDouble(sal_Int32 column)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
2018-06-17 18:09:43 +02:00
|
|
|
|
|
|
|
char* pValue = m_aRow[column-1];
|
|
|
|
if(!pValue)
|
|
|
|
{
|
|
|
|
m_bWasNull = true;
|
|
|
|
return 0.0;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
2018-06-17 18:09:43 +02:00
|
|
|
|
|
|
|
m_bWasNull = false;
|
|
|
|
return std::strtod(pValue, nullptr);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
float SAL_CALL OResultSet::getFloat(sal_Int32 column)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
2018-06-17 18:09:43 +02:00
|
|
|
|
|
|
|
char* pValue = m_aRow[column-1];
|
|
|
|
if(!pValue)
|
|
|
|
{
|
|
|
|
m_bWasNull = true;
|
|
|
|
return 0.0f;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
2018-06-17 18:09:43 +02:00
|
|
|
|
|
|
|
m_bWasNull = false;
|
|
|
|
return std::strtod(pValue, nullptr);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 SAL_CALL OResultSet::getInt(sal_Int32 column)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
2018-06-17 18:09:43 +02:00
|
|
|
char* pValue = m_aRow[column-1];
|
|
|
|
if(!pValue)
|
|
|
|
{
|
|
|
|
m_bWasNull = true;
|
|
|
|
return 0;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
2018-06-17 18:09:43 +02:00
|
|
|
|
|
|
|
m_bWasNull = false;
|
|
|
|
return std::atoi(pValue);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 SAL_CALL OResultSet::getRow()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
return static_cast<sal_Int32>(mysql_field_tell(m_pResult));
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int64 SAL_CALL OResultSet::getLong(sal_Int32 column)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
2018-06-17 18:09:43 +02:00
|
|
|
|
|
|
|
char* pValue = m_aRow[column-1];
|
|
|
|
if(!pValue)
|
|
|
|
{
|
|
|
|
m_bWasNull = true;
|
|
|
|
return 0LL;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
2018-06-17 18:09:43 +02:00
|
|
|
|
|
|
|
m_bWasNull = false;
|
|
|
|
return std::atol(pValue);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData()
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
2018-06-17 18:09:43 +02:00
|
|
|
if (!m_xMetaData.is()) {
|
|
|
|
m_xMetaData = new OResultSetMetaData(m_rConnection, m_pResult, m_encoding);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
return m_xMetaData;
|
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Reference< XArray > SAL_CALL OResultSet::getArray(sal_Int32 column)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getArray", *this);
|
2015-11-10 10:19:59 +01:00
|
|
|
return nullptr;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Reference< XClob > SAL_CALL OResultSet::getClob(sal_Int32 column)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getClob", *this);
|
2015-11-10 10:19:59 +01:00
|
|
|
return nullptr;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Reference< XBlob > SAL_CALL OResultSet::getBlob(sal_Int32 column)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getBlob", *this);
|
2015-11-10 10:19:59 +01:00
|
|
|
return nullptr;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Reference< XRef > SAL_CALL OResultSet::getRef(sal_Int32 column)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getRef", *this);
|
2015-11-10 10:19:59 +01:00
|
|
|
return nullptr;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
Any SAL_CALL OResultSet::getObject(sal_Int32 column, const uno::Reference< XNameAccess >& /* typeMap */)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
|
|
|
|
Any aRet= Any();
|
|
|
|
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getObject", *this);
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int16 SAL_CALL OResultSet::getShort(sal_Int32 column)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
2018-06-17 18:09:43 +02:00
|
|
|
checkColumnIndex(column);
|
2009-12-11 09:51:25 +01:00
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
char* pValue = m_aRow[column-1];
|
|
|
|
if(!pValue)
|
|
|
|
{
|
|
|
|
m_bWasNull = true;
|
|
|
|
return 0;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
2018-06-17 18:09:43 +02:00
|
|
|
m_bWasNull = false;
|
|
|
|
return std::atoi(pValue);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2014-12-19 11:43:51 +01:00
|
|
|
rtl::OUString SAL_CALL OResultSet::getString(sal_Int32 column)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
char* pValue = m_aRow[column-1];
|
|
|
|
if(!pValue)
|
|
|
|
{
|
|
|
|
m_bWasNull = true;
|
|
|
|
return rtl::OUString{};
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
2018-06-17 18:09:43 +02:00
|
|
|
m_bWasNull = false;
|
|
|
|
return rtl::OUString(pValue, static_cast<sal_Int32>(m_aLengths[column-1]), m_encoding);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Time SAL_CALL OResultSet::getTime(sal_Int32 column)
|
|
|
|
{
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
|
|
|
|
checkColumnIndex(column);
|
2018-06-17 18:09:43 +02:00
|
|
|
Time t; // initialize
|
|
|
|
char* pValue = m_aRow[column-1];
|
|
|
|
if(!pValue)
|
|
|
|
{
|
|
|
|
m_bWasNull = true;
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
rtl::OUString timeString{pValue, static_cast<sal_Int32>(m_aLengths[column-1]), m_encoding};
|
2014-12-19 11:43:51 +01:00
|
|
|
rtl::OUString token;
|
2009-12-11 09:51:25 +01:00
|
|
|
sal_Int32 nIndex, i=0;
|
|
|
|
|
|
|
|
nIndex = timeString.indexOf(' ') + 1;
|
|
|
|
do {
|
|
|
|
token = timeString.getToken (0, ':', nIndex);
|
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2013-06-14 18:18:37 +02:00
|
|
|
t.Hours = static_cast<sal_uInt16>(token.toUInt32());
|
2009-12-11 09:51:25 +01:00
|
|
|
break;
|
|
|
|
case 1:
|
2013-06-14 18:18:37 +02:00
|
|
|
t.Minutes = static_cast<sal_uInt16>(token.toUInt32());
|
2009-12-11 09:51:25 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2013-06-14 18:18:37 +02:00
|
|
|
t.Seconds = static_cast<sal_uInt16>(token.toUInt32());
|
2009-12-11 09:51:25 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
} while (nIndex >= 0);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
m_bWasNull = false;
|
2009-12-11 09:51:25 +01:00
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
DateTime SAL_CALL OResultSet::getTimestamp(sal_Int32 column)
|
|
|
|
{
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkColumnIndex(column);
|
2018-06-17 18:09:43 +02:00
|
|
|
|
|
|
|
char* pValue = m_aRow[column-1];
|
|
|
|
if(!pValue)
|
|
|
|
{
|
|
|
|
m_bWasNull = true;
|
|
|
|
return DateTime{}; // init
|
|
|
|
}
|
|
|
|
|
|
|
|
// YY-MM-DD HH:MM:SS
|
|
|
|
std::vector<rtl::OUString> dateAndTime = lcl_split(rtl::OUString{pValue,
|
|
|
|
static_cast<sal_Int32>(m_aLengths[column-1]), m_encoding},
|
|
|
|
u' ');
|
|
|
|
|
|
|
|
auto dateParts = lcl_split(dateAndTime.at(0), u'-');
|
|
|
|
auto timeParts = lcl_split(dateAndTime.at(1), u':');
|
|
|
|
|
2009-12-11 09:51:25 +01:00
|
|
|
DateTime dt;
|
2018-06-17 18:09:43 +02:00
|
|
|
|
|
|
|
dt.Year = dateParts.at(0).toUInt32();
|
|
|
|
dt.Month = dateParts.at(1).toUInt32();
|
|
|
|
dt.Day = dateParts.at(2).toUInt32();
|
|
|
|
dt.Hours = timeParts.at(0).toUInt32();
|
|
|
|
dt.Minutes = timeParts.at(1).toUInt32();
|
|
|
|
dt.Seconds = timeParts.at(2).toUInt32();
|
|
|
|
m_bWasNull = false;
|
2009-12-11 09:51:25 +01:00
|
|
|
return dt;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::isBeforeFirst()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
return m_nCurrentField == 0;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::isAfterLast()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
return m_nCurrentField >= static_cast<sal_Int32>(fieldCount);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::isFirst()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
return m_nCurrentField == 1 && !isAfterLast();
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::isLast()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
return mysql_field_tell(m_pResult) == fieldCount;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::beforeFirst()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::beforeFirst", *this);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::afterLast()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::afterLast", *this);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 10:37:08 +01:00
|
|
|
void SAL_CALL OResultSet::close()
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
mysql_free_result(m_pResult);
|
2015-04-28 15:34:17 +01:00
|
|
|
dispose();
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2017-01-27 10:37:08 +01:00
|
|
|
sal_Bool SAL_CALL OResultSet::first()
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
mysql_data_seek(m_pResult, 0);
|
|
|
|
next();
|
|
|
|
|
|
|
|
return true;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::last()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
mysql_data_seek(m_pResult, fieldCount-1);
|
|
|
|
next();
|
|
|
|
|
|
|
|
return true;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::absolute(sal_Int32 row)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
sal_Int32 nFields = static_cast<sal_Int32>(fieldCount);
|
|
|
|
sal_Int32 nToGo = row < 0 ? nFields - row : row-1;
|
|
|
|
|
|
|
|
if(nToGo >= nFields)
|
|
|
|
nToGo = nFields - 1;
|
|
|
|
if(nToGo < 0)
|
|
|
|
nToGo = 0;
|
|
|
|
|
|
|
|
mysql_data_seek(m_pResult, nToGo);
|
|
|
|
next();
|
|
|
|
|
|
|
|
return true;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::relative(sal_Int32 row)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
sal_Int32 nFields = static_cast<sal_Int32>(fieldCount);
|
|
|
|
if(row == 0)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
sal_Int32 nToGo = m_nCurrentField + row;
|
|
|
|
if(nToGo >= nFields)
|
|
|
|
nToGo = nFields - 1;
|
|
|
|
if(nToGo < 0)
|
|
|
|
nToGo = 0;
|
|
|
|
|
|
|
|
mysql_data_seek(m_pResult, nToGo);
|
|
|
|
next();
|
|
|
|
|
|
|
|
return true;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::previous()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
if(m_nCurrentField <= 1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
mysql_data_seek(m_pResult, m_nCurrentField-2);
|
|
|
|
next();
|
|
|
|
return true;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Reference< uno::XInterface > SAL_CALL OResultSet::getStatement()
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
|
|
|
return m_aStatement.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::rowDeleted()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2016-04-20 17:18:05 +02:00
|
|
|
return false;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::rowInserted()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2016-04-20 17:18:05 +02:00
|
|
|
return false;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::rowUpdated()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2016-04-20 17:18:05 +02:00
|
|
|
return false;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::next()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
m_aRow = mysql_fetch_row(m_pResult);
|
|
|
|
m_aLengths = mysql_fetch_lengths(m_pResult);
|
|
|
|
m_nCurrentField = mysql_field_tell(m_pResult);
|
|
|
|
|
|
|
|
unsigned errorNum = mysql_errno(m_pMysql);
|
|
|
|
if(errorNum)
|
|
|
|
mysqlc_sdbc_driver::throwSQLExceptionWithMsg(mysql_error(m_pMysql),
|
|
|
|
errorNum, *this, m_encoding);
|
|
|
|
|
|
|
|
return m_aRow != nullptr;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::wasNull()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
return m_bWasNull;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::cancel()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::clearWarnings()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Any SAL_CALL OResultSet::getWarnings()
|
|
|
|
{
|
|
|
|
Any aRet= Any();
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::insertRow()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
// you only have to implement this if you want to insert new rows
|
2010-07-09 08:01:25 +02:00
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::insertRow", *this);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::updateRow()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
|
|
|
// only when you allow updates
|
2010-07-09 08:01:25 +02:00
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateRow", *this);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::deleteRow()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
2010-07-09 08:01:25 +02:00
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::deleteRow", *this);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::cancelRowUpdates()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
2010-07-09 08:01:25 +02:00
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::cancelRowUpdates", *this);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::moveToInsertRow()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
|
|
|
// only when you allow insert's
|
2010-07-09 08:01:25 +02:00
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::moveToInsertRow", *this);
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::moveToCurrentRow()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::updateNull(sal_Int32 column)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateNull", *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::updateBoolean(sal_Int32 column, sal_Bool /* x */)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateBoolean", *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::updateByte(sal_Int32 column, sal_Int8 /* x */)
|
|
|
|
{
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateByte", *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::updateShort(sal_Int32 column, sal_Int16 /* x */)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateShort", *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::updateInt(sal_Int32 column, sal_Int32 /* x */)
|
|
|
|
{
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateInt", *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::updateLong(sal_Int32 column, sal_Int64 /* x */)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateLong", *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::updateFloat(sal_Int32 column, float /* x */)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateFloat", *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::updateDouble(sal_Int32 column, double /* x */)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateDouble", *this);
|
|
|
|
}
|
|
|
|
|
2014-12-19 11:43:51 +01:00
|
|
|
void SAL_CALL OResultSet::updateString(sal_Int32 column, const rtl::OUString& /* x */)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateString", *this);
|
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
void SAL_CALL OResultSet::updateBytes(sal_Int32 column, const uno::Sequence< sal_Int8 >& /* x */)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateBytes", *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::updateDate(sal_Int32 column, const Date& /* x */)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateDate", *this);
|
|
|
|
}
|
|
|
|
|
2014-10-01 10:35:19 +02:00
|
|
|
void SAL_CALL OResultSet::updateTime(sal_Int32 column, const Time& /* x */)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateTime", *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::updateTimestamp(sal_Int32 column, const DateTime& /* x */)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateTimestamp", *this);
|
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
void SAL_CALL OResultSet::updateBinaryStream(sal_Int32 column, const uno::Reference< XInputStream >& /* x */,
|
2009-12-11 09:51:25 +01:00
|
|
|
sal_Int32 /* length */)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateBinaryStream", *this);
|
|
|
|
}
|
|
|
|
|
2018-06-17 18:09:43 +02:00
|
|
|
void SAL_CALL OResultSet::updateCharacterStream(sal_Int32 column, const uno::Reference< XInputStream >& /* x */,
|
2009-12-11 09:51:25 +01:00
|
|
|
sal_Int32 /* length */)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateCharacterStream", *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::refreshRow()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::refreshRow", *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::updateObject(sal_Int32 column, const Any& /* x */)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateObject", *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::updateNumericObject(sal_Int32 column, const Any& /* x */, sal_Int32 /* scale */)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
checkColumnIndex(column);
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::updateNumericObject", *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// XRowLocate
|
|
|
|
Any SAL_CALL OResultSet::getBookmark()
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
Any aRet = Any();
|
|
|
|
|
|
|
|
// if you don't want to support bookmark you must remove the XRowLocate interface
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::getBookmark", *this);
|
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::moveToBookmark(const Any& /* bookmark */)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
2016-04-20 17:18:05 +02:00
|
|
|
return false;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark(const Any& /* bookmark */, sal_Int32 /* rows */)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::moveRelativeToBookmark", *this);
|
2016-04-20 17:18:05 +02:00
|
|
|
return false;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 SAL_CALL OResultSet::compareBookmarks(const Any& /* n1 */, const Any& /* n2 */)
|
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
|
|
|
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::compareBookmarks", *this);
|
|
|
|
|
|
|
|
return CompareBookmark::NOT_EQUAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks()
|
|
|
|
{
|
2016-04-20 17:18:05 +02:00
|
|
|
return false;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 SAL_CALL OResultSet::hashBookmark(const Any& /* bookmark */)
|
|
|
|
{
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::hashBookmark", *this);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XDeleteRows
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows(const uno::Sequence< Any >& /* rows */)
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
|
|
|
MutexGuard aGuard(m_aMutex);
|
|
|
|
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Sequence< sal_Int32 > aRet = uno::Sequence< sal_Int32 >();
|
2009-12-11 09:51:25 +01:00
|
|
|
|
|
|
|
mysqlc_sdbc_driver::throwFeatureNotImplementedException("OResultSet::deleteRows", *this);
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
IPropertyArrayHelper * OResultSet::createArrayHelper() const
|
|
|
|
{
|
2018-06-17 18:09:43 +02:00
|
|
|
uno::Sequence< Property > aProps(5);
|
2009-12-11 09:51:25 +01:00
|
|
|
Property* pProperties = aProps.getArray();
|
|
|
|
sal_Int32 nPos = 0;
|
2015-03-25 12:46:55 +01:00
|
|
|
pProperties[nPos++] = Property("FetchDirection", PROPERTY_ID_FETCHDIRECTION, cppu::UnoType<sal_Int32>::get(), 0);
|
|
|
|
pProperties[nPos++] = Property("FetchSize", PROPERTY_ID_FETCHSIZE, cppu::UnoType<sal_Int32>::get(), 0);
|
|
|
|
pProperties[nPos++] = Property("IsBookmarkable",
|
2015-04-01 08:40:06 +02:00
|
|
|
PROPERTY_ID_ISBOOKMARKABLE, cppu::UnoType<bool>::get(), PropertyAttribute::READONLY);
|
2015-03-25 12:46:55 +01:00
|
|
|
pProperties[nPos++] = Property("ResultSetConcurrency",
|
2014-05-11 22:50:37 +02:00
|
|
|
PROPERTY_ID_RESULTSETCONCURRENCY, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY);
|
2015-03-25 12:46:55 +01:00
|
|
|
pProperties[nPos++] = Property("ResultSetType",
|
2014-05-11 22:50:37 +02:00
|
|
|
PROPERTY_ID_RESULTSETTYPE, cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY);
|
2009-12-11 09:51:25 +01:00
|
|
|
|
|
|
|
return new OPropertyArrayHelper(aProps);
|
|
|
|
}
|
|
|
|
|
|
|
|
IPropertyArrayHelper & OResultSet::getInfoHelper()
|
|
|
|
{
|
2015-04-13 12:35:57 +02:00
|
|
|
return *getArrayHelper();
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool OResultSet::convertFastPropertyValue(Any & /* rConvertedValue */,
|
|
|
|
Any & /* rOldValue */,
|
|
|
|
sal_Int32 nHandle,
|
|
|
|
const Any& /* rValue */)
|
|
|
|
{
|
|
|
|
switch (nHandle) {
|
|
|
|
case PROPERTY_ID_ISBOOKMARKABLE:
|
|
|
|
case PROPERTY_ID_CURSORNAME:
|
|
|
|
case PROPERTY_ID_RESULTSETCONCURRENCY:
|
|
|
|
case PROPERTY_ID_RESULTSETTYPE:
|
2015-10-23 14:35:25 +02:00
|
|
|
throw css::lang::IllegalArgumentException();
|
2009-12-11 09:51:25 +01:00
|
|
|
case PROPERTY_ID_FETCHDIRECTION:
|
|
|
|
case PROPERTY_ID_FETCHSIZE:
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
2016-04-20 17:18:05 +02:00
|
|
|
return false;
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void OResultSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& /* rValue */)
|
|
|
|
{
|
|
|
|
switch (nHandle) {
|
|
|
|
case PROPERTY_ID_ISBOOKMARKABLE:
|
|
|
|
case PROPERTY_ID_CURSORNAME:
|
|
|
|
case PROPERTY_ID_RESULTSETCONCURRENCY:
|
|
|
|
case PROPERTY_ID_RESULTSETTYPE:
|
2018-06-17 18:09:43 +02:00
|
|
|
throw uno::Exception("cannot set prop " + rtl::OUString::number(nHandle), nullptr);
|
2009-12-11 09:51:25 +01:00
|
|
|
case PROPERTY_ID_FETCHDIRECTION:
|
|
|
|
break;
|
|
|
|
case PROPERTY_ID_FETCHSIZE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OResultSet::getFastPropertyValue(Any& _rValue, sal_Int32 nHandle) const
|
|
|
|
{
|
|
|
|
switch (nHandle) {
|
|
|
|
case PROPERTY_ID_ISBOOKMARKABLE:
|
2016-04-20 17:18:05 +02:00
|
|
|
_rValue <<= false;
|
2009-12-11 09:51:25 +01:00
|
|
|
break;
|
|
|
|
case PROPERTY_ID_CURSORNAME:
|
2010-07-09 08:01:25 +02:00
|
|
|
break;
|
2009-12-11 09:51:25 +01:00
|
|
|
case PROPERTY_ID_RESULTSETCONCURRENCY:
|
2010-07-09 08:01:25 +02:00
|
|
|
_rValue <<= ResultSetConcurrency::READ_ONLY;
|
|
|
|
break;
|
2009-12-11 09:51:25 +01:00
|
|
|
case PROPERTY_ID_RESULTSETTYPE:
|
2010-07-09 08:01:25 +02:00
|
|
|
_rValue <<= ResultSetType::SCROLL_INSENSITIVE;
|
|
|
|
break;
|
2009-12-11 09:51:25 +01:00
|
|
|
case PROPERTY_ID_FETCHDIRECTION:
|
2010-07-09 08:01:25 +02:00
|
|
|
_rValue <<= FetchDirection::FORWARD;
|
|
|
|
break;
|
2009-12-11 09:51:25 +01:00
|
|
|
case PROPERTY_ID_FETCHSIZE:
|
2010-07-09 08:01:25 +02:00
|
|
|
_rValue <<= sal_Int32(50);
|
|
|
|
break;
|
2009-12-11 09:51:25 +01:00
|
|
|
;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::acquire()
|
|
|
|
throw()
|
|
|
|
{
|
|
|
|
OResultSet_BASE::acquire();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL OResultSet::release()
|
|
|
|
throw()
|
|
|
|
{
|
|
|
|
OResultSet_BASE::release();
|
|
|
|
}
|
|
|
|
|
2017-01-27 10:37:08 +01:00
|
|
|
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo()
|
2009-12-11 09:51:25 +01:00
|
|
|
{
|
2015-02-11 13:20:49 +02:00
|
|
|
return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void OResultSet::checkColumnIndex(sal_Int32 index)
|
|
|
|
{
|
2018-01-12 20:19:40 +01:00
|
|
|
if (index < 1 || index > static_cast<int>(fieldCount)) {
|
2009-12-11 09:51:25 +01:00
|
|
|
/* static object for efficiency or thread safety is a problem ? */
|
2017-06-23 16:05:57 +02:00
|
|
|
throw SQLException("index out of range", *this, rtl::OUString(), 1, Any());
|
2009-12-11 09:51:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:55:21 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|