Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #ifdef GCC
22 : #include <iostream>
23 : #endif
24 : #include "connectivity/sdbcx/VColumn.hxx"
25 : #include "file/FResultSet.hxx"
26 : #include "file/FResultSetMetaData.hxx"
27 : #include <com/sun/star/sdbc/DataType.hpp>
28 : #include <com/sun/star/sdbc/ColumnValue.hpp>
29 : #include <comphelper/property.hxx>
30 : #include <com/sun/star/lang/DisposedException.hpp>
31 : #include <com/sun/star/beans/PropertyAttribute.hpp>
32 : #include <com/sun/star/container/XIndexAccess.hpp>
33 : #include <comphelper/sequence.hxx>
34 : #include <cppuhelper/typeprovider.hxx>
35 : #include "connectivity/dbconversion.hxx"
36 : #include "connectivity/dbtools.hxx"
37 : #include <cppuhelper/propshlp.hxx>
38 : #include <iterator>
39 : #include <tools/debug.hxx>
40 : #include <com/sun/star/sdbc/ResultSetType.hpp>
41 : #include <com/sun/star/sdbc/FetchDirection.hpp>
42 : #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
43 : #include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
44 :
45 : #include <algorithm>
46 : #include <comphelper/extract.hxx>
47 : #include "connectivity/dbexception.hxx"
48 : #include <comphelper/types.hxx>
49 : #include "resource/file_res.hrc"
50 : #include "resource/sharedresources.hxx"
51 : #include <rtl/logfile.hxx>
52 :
53 :
54 : using namespace ::comphelper;
55 : using namespace connectivity;
56 : using namespace connectivity::file;
57 : using namespace ::cppu;
58 : using namespace dbtools;
59 : using namespace com::sun::star::uno;
60 : using namespace com::sun::star::lang;
61 : using namespace com::sun::star::beans;
62 : using namespace com::sun::star::sdbc;
63 : using namespace com::sun::star::sdbcx;
64 : using namespace com::sun::star::container;
65 :
66 : // Maximal number of Rows, that can be processed being sorted with ORDER BY:
67 : #define MAX_KEYSET_SIZE 0x40000 // 256K
68 :
69 : namespace
70 : {
71 0 : void lcl_throwError(sal_uInt16 _nErrorId,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xContext)
72 : {
73 0 : ::connectivity::SharedResources aResources;
74 0 : const ::rtl::OUString sMessage = aResources.getResourceString(_nErrorId);
75 0 : ::dbtools::throwGenericSQLException(sMessage ,_xContext);
76 0 : }
77 : }
78 : //------------------------------------------------------------------------------
79 0 : IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.drivers.file.ResultSet","com.sun.star.sdbc.ResultSet");
80 : DBG_NAME( file_OResultSet )
81 : // -------------------------------------------------------------------------
82 0 : OResultSet::OResultSet(OStatement_Base* pStmt,OSQLParseTreeIterator& _aSQLIterator) : OResultSet_BASE(m_aMutex)
83 : ,::comphelper::OPropertyContainer(OResultSet_BASE::rBHelper)
84 : ,m_aAssignValues(NULL)
85 : ,m_pEvaluationKeySet(NULL)
86 : ,m_aSkipDeletedSet(this)
87 : ,m_pFileSet(NULL)
88 : ,m_pSortIndex(NULL)
89 : ,m_pTable(NULL)
90 0 : ,m_pParseTree(pStmt->getParseTree())
91 : ,m_pSQLAnalyzer(NULL)
92 : ,m_aSQLIterator(_aSQLIterator)
93 : ,m_nFetchSize(0)
94 : ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE)
95 : ,m_nFetchDirection(FetchDirection::FORWARD)
96 : ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE)
97 : ,m_xStatement(*pStmt)
98 : ,m_xMetaData(NULL)
99 0 : ,m_xDBMetaData(pStmt->getOwnConnection()->getMetaData())
100 0 : ,m_nTextEncoding(pStmt->getOwnConnection()->getTextEncoding())
101 : ,m_nRowPos(-1)
102 : ,m_nFilePos(0)
103 : ,m_nLastVisitedPos(-1)
104 : ,m_nRowCountResult(-1)
105 : ,m_nCurrentPosition(0)
106 : ,m_nColumnCount(0)
107 : ,m_bWasNull(sal_False)
108 : ,m_bEOF(sal_False)
109 : ,m_bLastRecord(sal_False)
110 : ,m_bInserted(sal_False)
111 : ,m_bRowUpdated(sal_False)
112 : ,m_bRowInserted(sal_False)
113 : ,m_bRowDeleted(sal_False)
114 0 : ,m_bShowDeleted(pStmt->getOwnConnection()->showDeleted())
115 0 : ,m_bIsCount(sal_False)
116 : {
117 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::OResultSet" );
118 : DBG_CTOR( file_OResultSet, NULL );
119 0 : osl_atomic_increment( &m_refCount );
120 : m_bIsCount = (m_pParseTree &&
121 0 : m_pParseTree->count() > 2 &&
122 0 : SQL_ISRULE(m_pParseTree->getChild(2),scalar_exp_commalist) &&
123 0 : SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0),derived_column) &&
124 0 : SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0)->getChild(0),general_set_fct) &&
125 0 : m_pParseTree->getChild(2)->getChild(0)->getChild(0)->count() == 4
126 0 : );
127 :
128 0 : m_nResultSetConcurrency = isCount() ? ResultSetConcurrency::READ_ONLY : ResultSetConcurrency::UPDATABLE;
129 0 : construct();
130 0 : m_aSkipDeletedSet.SetDeletedVisible(m_bShowDeleted);
131 0 : osl_atomic_decrement( &m_refCount );
132 0 : }
133 :
134 : // -------------------------------------------------------------------------
135 0 : OResultSet::~OResultSet()
136 : {
137 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::~OResultSet" );
138 0 : osl_atomic_increment( &m_refCount );
139 0 : disposing();
140 : DBG_DTOR( file_OResultSet, NULL );
141 0 : }
142 : // -------------------------------------------------------------------------
143 0 : void OResultSet::construct()
144 : {
145 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::construct" );
146 0 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), PROPERTY_ID_FETCHSIZE, 0,&m_nFetchSize, ::getCppuType(static_cast<sal_Int32*>(0)));
147 0 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY,&m_nResultSetType, ::getCppuType(static_cast<sal_Int32*>(0)));
148 0 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), PROPERTY_ID_FETCHDIRECTION, 0,&m_nFetchDirection, ::getCppuType(static_cast<sal_Int32*>(0)));
149 0 : registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY,PropertyAttribute::READONLY,&m_nResultSetConcurrency, ::getCppuType(static_cast<sal_Int32*>(0)));
150 0 : }
151 : // -------------------------------------------------------------------------
152 0 : void OResultSet::disposing(void)
153 : {
154 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::disposing" );
155 0 : OPropertySetHelper::disposing();
156 :
157 0 : ::osl::MutexGuard aGuard(m_aMutex);
158 0 : m_xStatement.clear();
159 0 : m_xMetaData.clear();
160 0 : m_pParseTree = NULL;
161 0 : m_xColNames.clear();
162 0 : m_xColumns = NULL;
163 0 : m_xParamColumns = NULL;
164 0 : m_xColsIdx.clear();
165 :
166 0 : Reference<XComponent> xComp = m_pTable;
167 0 : if ( xComp.is() )
168 0 : xComp->removeEventListener(this);
169 0 : if(m_pTable)
170 : {
171 0 : m_pTable->release();
172 0 : m_pTable = NULL;
173 : }
174 0 : clear();
175 0 : }
176 : // -----------------------------------------------------------------------------
177 0 : void OResultSet::clear()
178 : {
179 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::clear" );
180 0 : m_pFileSet = NULL;
181 0 : DELETEZ(m_pSortIndex);
182 :
183 0 : if(m_aInsertRow.is())
184 0 : m_aInsertRow->get().clear();
185 :
186 0 : m_aSkipDeletedSet.clear();
187 0 : }
188 : // -------------------------------------------------------------------------
189 0 : Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
190 : {
191 : //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::queryInterface" );
192 0 : Any aRet = OPropertySetHelper::queryInterface(rType);
193 0 : return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType);
194 : }
195 : // -------------------------------------------------------------------------
196 0 : Sequence< Type > SAL_CALL OResultSet::getTypes( ) throw(RuntimeException)
197 : {
198 : //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getTypes" );
199 0 : ::osl::MutexGuard aGuard( m_aMutex );
200 :
201 0 : OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
202 0 : ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ),
203 0 : ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
204 :
205 0 : return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
206 : }
207 : // -------------------------------------------------------------------------
208 :
209 0 : sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
210 : {
211 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::findColumn" );
212 0 : ::osl::MutexGuard aGuard( m_aMutex );
213 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
214 :
215 :
216 0 : Reference< XResultSetMetaData > xMeta = getMetaData();
217 0 : sal_Int32 nLen = xMeta->getColumnCount();
218 0 : sal_Int32 i = 1;
219 0 : for(;i<=nLen;++i)
220 0 : if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
221 0 : columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
222 0 : break;
223 0 : return i;
224 : }
225 : // -----------------------------------------------------------------------------
226 0 : const ORowSetValue& OResultSet::getValue(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException)
227 : {
228 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getValue" );
229 0 : ::osl::MutexGuard aGuard( m_aMutex );
230 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
231 :
232 0 : checkIndex(columnIndex );
233 :
234 :
235 0 : m_bWasNull = (m_aSelectRow->get())[columnIndex]->getValue().isNull();
236 0 : return *(m_aSelectRow->get())[columnIndex];
237 : }
238 : // -----------------------------------------------------------------------------
239 0 : void OResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException)
240 : {
241 : //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::checkIndex" );
242 0 : if ( columnIndex <= 0
243 : || columnIndex >= m_nColumnCount )
244 0 : ::dbtools::throwInvalidIndexException(*this);
245 0 : }
246 : // -------------------------------------------------------------------------
247 0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
248 : {
249 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBinaryStream" );
250 0 : return NULL;
251 : }
252 : // -------------------------------------------------------------------------
253 0 : Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
254 : {
255 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getCharacterStream" );
256 0 : return NULL;
257 : }
258 :
259 : // -------------------------------------------------------------------------
260 0 : sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
261 : {
262 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBoolean" );
263 0 : return getValue(columnIndex);
264 : }
265 : // -------------------------------------------------------------------------
266 :
267 0 : sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
268 : {
269 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getByte" );
270 0 : return getValue(columnIndex);
271 : }
272 : // -------------------------------------------------------------------------
273 :
274 0 : Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
275 : {
276 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBytes" );
277 0 : return getValue(columnIndex);
278 : }
279 : // -------------------------------------------------------------------------
280 :
281 0 : ::com::sun::star::util::Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
282 : {
283 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getDate" );
284 0 : return getValue(columnIndex);
285 : }
286 : // -------------------------------------------------------------------------
287 :
288 0 : double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
289 : {
290 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getDouble" );
291 0 : return getValue(columnIndex);
292 : }
293 : // -------------------------------------------------------------------------
294 :
295 0 : float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
296 : {
297 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getFloat" );
298 0 : return getValue(columnIndex);
299 : }
300 : // -------------------------------------------------------------------------
301 :
302 0 : sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
303 : {
304 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getInt" );
305 0 : return getValue(columnIndex);
306 : }
307 : // -------------------------------------------------------------------------
308 :
309 0 : sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException)
310 : {
311 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getRow" );
312 0 : ::osl::MutexGuard aGuard( m_aMutex );
313 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
314 :
315 : OSL_ENSURE((m_bShowDeleted || !m_aRow->isDeleted()),"getRow called for deleted row");
316 :
317 0 : return m_aSkipDeletedSet.getMappedPosition((m_aRow->get())[0]->getValue());
318 : }
319 : // -------------------------------------------------------------------------
320 :
321 0 : sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
322 : {
323 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getLong" );
324 0 : return getValue(columnIndex);
325 : }
326 : // -------------------------------------------------------------------------
327 :
328 0 : Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException)
329 : {
330 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getMetaData" );
331 0 : ::osl::MutexGuard aGuard( m_aMutex );
332 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
333 :
334 :
335 0 : if(!m_xMetaData.is())
336 0 : m_xMetaData = new OResultSetMetaData(m_xColumns,m_aSQLIterator.getTables().begin()->first,m_pTable);
337 0 : return m_xMetaData;
338 : }
339 : // -------------------------------------------------------------------------
340 0 : Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
341 : {
342 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getArray" );
343 0 : return NULL;
344 : }
345 :
346 : // -------------------------------------------------------------------------
347 :
348 0 : Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
349 : {
350 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getClob" );
351 0 : return NULL;
352 : }
353 : // -------------------------------------------------------------------------
354 0 : Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
355 : {
356 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBlob" );
357 0 : return NULL;
358 : }
359 : // -------------------------------------------------------------------------
360 :
361 0 : Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
362 : {
363 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getRef" );
364 0 : return NULL;
365 : }
366 : // -------------------------------------------------------------------------
367 :
368 0 : Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
369 : {
370 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getObject" );
371 0 : return getValue(columnIndex).makeAny();
372 : }
373 : // -------------------------------------------------------------------------
374 :
375 0 : sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
376 : {
377 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getShort" );
378 0 : return getValue(columnIndex);
379 : }
380 : // -------------------------------------------------------------------------
381 0 : ::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
382 : {
383 : //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getString" );
384 0 : return getValue(columnIndex);
385 : }
386 : // -------------------------------------------------------------------------
387 0 : ::com::sun::star::util::Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
388 : {
389 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getTime" );
390 0 : return getValue(columnIndex);
391 : }
392 : // -------------------------------------------------------------------------
393 0 : ::com::sun::star::util::DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
394 : {
395 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getTimestamp" );
396 0 : return getValue(columnIndex);
397 : }
398 : // -------------------------------------------------------------------------
399 :
400 0 : sal_Bool SAL_CALL OResultSet::isAfterLast( ) throw(SQLException, RuntimeException)
401 : {
402 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isAfterLast" );
403 0 : ::osl::MutexGuard aGuard( m_aMutex );
404 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
405 :
406 :
407 0 : return m_nRowPos == sal_Int32(m_pFileSet->get().size());
408 : }
409 : // -------------------------------------------------------------------------
410 0 : sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException)
411 : {
412 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isFirst" );
413 0 : ::osl::MutexGuard aGuard( m_aMutex );
414 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
415 :
416 :
417 0 : return m_nRowPos == 0;
418 : }
419 : // -------------------------------------------------------------------------
420 0 : sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException)
421 : {
422 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isLast" );
423 0 : ::osl::MutexGuard aGuard( m_aMutex );
424 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
425 :
426 :
427 0 : return m_nRowPos == sal_Int32(m_pFileSet->get().size() - 1);
428 : }
429 : // -------------------------------------------------------------------------
430 0 : void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
431 : {
432 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::beforeFirst" );
433 0 : ::osl::MutexGuard aGuard( m_aMutex );
434 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
435 :
436 :
437 0 : if(first())
438 0 : previous();
439 0 : }
440 : // -------------------------------------------------------------------------
441 0 : void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException)
442 : {
443 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::afterLast" );
444 0 : ::osl::MutexGuard aGuard( m_aMutex );
445 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
446 :
447 :
448 0 : if(last())
449 0 : next();
450 0 : m_bEOF = sal_True;
451 0 : }
452 : // -------------------------------------------------------------------------
453 :
454 0 : void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException)
455 : {
456 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::close" );
457 0 : dispose();
458 0 : }
459 : // -------------------------------------------------------------------------
460 :
461 0 : sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException)
462 : {
463 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::first" );
464 0 : ::osl::MutexGuard aGuard( m_aMutex );
465 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
466 0 : return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::FIRST,1,sal_True) : sal_False;
467 : }
468 : // -------------------------------------------------------------------------
469 :
470 0 : sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException)
471 : {
472 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::last" );
473 : // here I know definitely that I stand on the last record
474 0 : ::osl::MutexGuard aGuard( m_aMutex );
475 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
476 0 : return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::LAST,1,sal_True) : sal_False;
477 : }
478 : // -------------------------------------------------------------------------
479 0 : sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
480 : {
481 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::absolute" );
482 0 : ::osl::MutexGuard aGuard( m_aMutex );
483 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
484 0 : return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::ABSOLUTE,row,sal_True) : sal_False;
485 : }
486 : // -------------------------------------------------------------------------
487 0 : sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
488 : {
489 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::relative" );
490 0 : ::osl::MutexGuard aGuard( m_aMutex );
491 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
492 0 : return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::RELATIVE,row,sal_True) : sal_False;
493 : }
494 : // -------------------------------------------------------------------------
495 0 : sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException)
496 : {
497 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::previous" );
498 0 : ::osl::MutexGuard aGuard( m_aMutex );
499 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
500 0 : return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::PRIOR,0,sal_True) : sal_False;
501 : }
502 : // -------------------------------------------------------------------------
503 0 : Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException)
504 : {
505 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getStatement" );
506 0 : ::osl::MutexGuard aGuard( m_aMutex );
507 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
508 :
509 :
510 0 : return m_xStatement;
511 : }
512 : // -------------------------------------------------------------------------
513 :
514 0 : sal_Bool SAL_CALL OResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
515 : {
516 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::rowDeleted" );
517 0 : ::osl::MutexGuard aGuard( m_aMutex );
518 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
519 :
520 :
521 0 : return m_bRowDeleted;
522 : }
523 : // -------------------------------------------------------------------------
524 0 : sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException)
525 0 : { ::osl::MutexGuard aGuard( m_aMutex );
526 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
527 :
528 :
529 0 : return m_bRowInserted;
530 : }
531 : // -------------------------------------------------------------------------
532 0 : sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
533 : {
534 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::rowInserted" );
535 0 : ::osl::MutexGuard aGuard( m_aMutex );
536 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
537 :
538 :
539 0 : return m_bRowUpdated;
540 : }
541 : // -------------------------------------------------------------------------
542 :
543 0 : sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
544 : {
545 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isBeforeFirst" );
546 0 : ::osl::MutexGuard aGuard( m_aMutex );
547 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
548 :
549 :
550 0 : return m_nRowPos == -1;
551 : }
552 : // -------------------------------------------------------------------------
553 0 : sal_Bool OResultSet::evaluate()
554 : {
555 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::evaluate" );
556 : OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::evaluate: Analyzer isn't set!");
557 0 : sal_Bool bRet = sal_True;
558 0 : while(!m_pSQLAnalyzer->evaluateRestriction())
559 : {
560 0 : if(m_pEvaluationKeySet)
561 : {
562 0 : if(m_aEvaluateIter == m_pEvaluationKeySet->end())
563 0 : return sal_False;
564 0 : bRet = m_pTable->seekRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),m_nRowPos);
565 0 : ++m_aEvaluateIter;
566 : }
567 : else
568 0 : bRet = m_pTable->seekRow(IResultSetHelper::NEXT,1,m_nRowPos);
569 0 : if(bRet)
570 : {
571 0 : if(m_pEvaluationKeySet)
572 : {
573 0 : bRet = m_pTable->fetchRow(m_aEvaluateRow,*(m_pTable->getTableColumns()),sal_True,sal_True);
574 0 : evaluate();
575 :
576 : }
577 : else
578 0 : bRet = m_pTable->fetchRow(m_aRow,*m_xColumns,sal_False,sal_True);
579 : }
580 : }
581 :
582 0 : return bRet;
583 : }
584 : // -------------------------------------------------------------------------
585 :
586 0 : sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException)
587 : {
588 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::next" );
589 0 : ::osl::MutexGuard aGuard( m_aMutex );
590 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
591 :
592 0 : return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::NEXT,1,sal_True) : sal_False;
593 : }
594 : // -------------------------------------------------------------------------
595 :
596 0 : sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException)
597 : {
598 : //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::wasNull" );
599 0 : ::osl::MutexGuard aGuard( m_aMutex );
600 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
601 :
602 0 : return m_bWasNull;
603 : }
604 : // -------------------------------------------------------------------------
605 :
606 0 : void SAL_CALL OResultSet::cancel( ) throw(RuntimeException)
607 : {
608 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::cancel" );
609 0 : }
610 : // -------------------------------------------------------------------------
611 0 : void SAL_CALL OResultSet::clearWarnings( ) throw(SQLException, RuntimeException)
612 : {
613 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::clearWarnings" );
614 0 : }
615 : // -------------------------------------------------------------------------
616 0 : Any SAL_CALL OResultSet::getWarnings( ) throw(SQLException, RuntimeException)
617 : {
618 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getWarnings" );
619 0 : return Any();
620 : }
621 : // -------------------------------------------------------------------------
622 0 : void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException)
623 : {
624 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::insertRow" );
625 0 : ::osl::MutexGuard aGuard( m_aMutex );
626 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
627 :
628 :
629 0 : if(!m_bInserted || !m_pTable)
630 0 : throwFunctionSequenceException(*this);
631 :
632 : // we know that we append new rows at the end
633 : // so we have to know where the end is
634 0 : m_aSkipDeletedSet.skipDeleted(IResultSetHelper::LAST,1,sal_False);
635 0 : m_bRowInserted = m_pTable->InsertRow(*m_aInsertRow, sal_True, m_xColsIdx);
636 0 : if(m_bRowInserted && m_pFileSet.is())
637 : {
638 0 : sal_Int32 nPos = (m_aInsertRow->get())[0]->getValue();
639 0 : m_pFileSet->get().push_back(nPos);
640 0 : *(m_aInsertRow->get())[0] = sal_Int32(m_pFileSet->get().size());
641 0 : clearInsertRow();
642 :
643 0 : m_aSkipDeletedSet.insertNewPosition((m_aRow->get())[0]->getValue());
644 0 : }
645 0 : }
646 : // -------------------------------------------------------------------------
647 0 : void SAL_CALL OResultSet::updateRow( ) throw(SQLException, RuntimeException)
648 : {
649 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateRow" );
650 0 : ::osl::MutexGuard aGuard( m_aMutex );
651 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
652 :
653 0 : if(!m_pTable || m_pTable->isReadOnly())
654 0 : lcl_throwError(STR_TABLE_READONLY,*this);
655 :
656 0 : m_bRowUpdated = m_pTable->UpdateRow(*m_aInsertRow, m_aRow,m_xColsIdx);
657 0 : *(m_aInsertRow->get())[0] = (sal_Int32)(m_aRow->get())[0]->getValue();
658 :
659 0 : clearInsertRow();
660 0 : }
661 : // -------------------------------------------------------------------------
662 0 : void SAL_CALL OResultSet::deleteRow() throw(SQLException, RuntimeException)
663 : {
664 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::deleteRow" );
665 0 : ::osl::MutexGuard aGuard( m_aMutex );
666 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
667 :
668 :
669 0 : if(!m_pTable || m_pTable->isReadOnly())
670 0 : lcl_throwError(STR_TABLE_READONLY,*this);
671 0 : if (m_bShowDeleted)
672 0 : lcl_throwError(STR_DELETE_ROW,*this);
673 0 : if(m_aRow->isDeleted())
674 0 : lcl_throwError(STR_ROW_ALREADY_DELETED,*this);
675 :
676 0 : sal_Int32 nPos = (sal_Int32)(m_aRow->get())[0]->getValue();
677 0 : m_bRowDeleted = m_pTable->DeleteRow(*m_xColumns);
678 0 : if(m_bRowDeleted && m_pFileSet.is())
679 : {
680 0 : m_aRow->setDeleted(sal_True);
681 : // don't touch the m_pFileSet member here
682 0 : m_aSkipDeletedSet.deletePosition(nPos);
683 0 : }
684 0 : }
685 : // -------------------------------------------------------------------------
686 0 : void SAL_CALL OResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
687 : {
688 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::cancelRowUpdates" );
689 0 : ::osl::MutexGuard aGuard( m_aMutex );
690 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
691 :
692 :
693 0 : m_bInserted = sal_False;
694 0 : m_bRowUpdated = sal_False;
695 0 : m_bRowInserted = sal_False;
696 0 : m_bRowDeleted = sal_False;
697 :
698 0 : if(m_aInsertRow.is())
699 : {
700 0 : OValueRefVector::Vector::iterator aIter = m_aInsertRow->get().begin()+1;
701 0 : for(;aIter != m_aInsertRow->get().end();++aIter)
702 : {
703 0 : (*aIter)->setBound(sal_False);
704 0 : (*aIter)->setNull();
705 : }
706 0 : }
707 0 : }
708 : // -------------------------------------------------------------------------
709 :
710 0 : void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException)
711 : {
712 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::moveToInsertRow" );
713 0 : ::osl::MutexGuard aGuard( m_aMutex );
714 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
715 :
716 0 : if(!m_pTable || m_pTable->isReadOnly())
717 0 : lcl_throwError(STR_TABLE_READONLY,*this);
718 :
719 0 : m_bInserted = sal_True;
720 :
721 0 : OValueRefVector::Vector::iterator aIter = m_aInsertRow->get().begin()+1;
722 0 : for(;aIter != m_aInsertRow->get().end();++aIter)
723 : {
724 0 : (*aIter)->setBound(sal_False);
725 0 : (*aIter)->setNull();
726 0 : }
727 0 : }
728 : // -------------------------------------------------------------------------
729 :
730 0 : void SAL_CALL OResultSet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
731 : {
732 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::moveToCurrentRow" );
733 0 : }
734 : // -------------------------------------------------------------------------
735 0 : void OResultSet::updateValue(sal_Int32 columnIndex ,const ORowSetValue& x) throw(SQLException, RuntimeException)
736 : {
737 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateValue" );
738 0 : ::osl::MutexGuard aGuard( m_aMutex );
739 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
740 :
741 0 : checkIndex(columnIndex );
742 0 : columnIndex = mapColumn(columnIndex);
743 :
744 0 : (m_aInsertRow->get())[columnIndex]->setBound(sal_True);
745 0 : *(m_aInsertRow->get())[columnIndex] = x;
746 0 : }
747 : // -----------------------------------------------------------------------------
748 :
749 0 : void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
750 : {
751 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateNull" );
752 0 : ORowSetValue aEmpty;
753 0 : updateValue(columnIndex,aEmpty);
754 0 : }
755 : // -------------------------------------------------------------------------
756 :
757 0 : void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
758 : {
759 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateBoolean" );
760 0 : updateValue(columnIndex,x);
761 0 : }
762 : // -------------------------------------------------------------------------
763 0 : void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
764 : {
765 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateByte" );
766 0 : updateValue(columnIndex,x);
767 0 : }
768 : // -------------------------------------------------------------------------
769 :
770 0 : void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
771 : {
772 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateShort" );
773 0 : updateValue(columnIndex,x);
774 0 : }
775 : // -------------------------------------------------------------------------
776 0 : void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
777 : {
778 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateInt" );
779 0 : updateValue(columnIndex,x);
780 0 : }
781 : // -------------------------------------------------------------------------
782 0 : void SAL_CALL OResultSet::updateLong( sal_Int32 /*columnIndex*/, sal_Int64 /*x*/ ) throw(SQLException, RuntimeException)
783 : {
784 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateLong" );
785 0 : ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateLong", *this );
786 0 : }
787 : // -----------------------------------------------------------------------
788 0 : void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException)
789 : {
790 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateFloat" );
791 0 : updateValue(columnIndex,x);
792 0 : }
793 : // -------------------------------------------------------------------------
794 :
795 0 : void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException)
796 : {
797 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateDouble" );
798 0 : updateValue(columnIndex,x);
799 0 : }
800 : // -------------------------------------------------------------------------
801 0 : void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
802 : {
803 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateString" );
804 0 : updateValue(columnIndex,x);
805 0 : }
806 : // -------------------------------------------------------------------------
807 0 : void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
808 : {
809 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateBytes" );
810 0 : updateValue(columnIndex,x);
811 0 : }
812 : // -------------------------------------------------------------------------
813 0 : void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException)
814 : {
815 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateDate" );
816 0 : updateValue(columnIndex,x);
817 0 : }
818 : // -------------------------------------------------------------------------
819 :
820 0 : void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException)
821 : {
822 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateTime" );
823 0 : updateValue(columnIndex,x);
824 0 : }
825 : // -------------------------------------------------------------------------
826 :
827 0 : void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException)
828 : {
829 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateTimestamp" );
830 0 : updateValue(columnIndex,x);
831 0 : }
832 : // -------------------------------------------------------------------------
833 :
834 0 : void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
835 : {
836 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateBinaryStream" );
837 0 : ::osl::MutexGuard aGuard( m_aMutex );
838 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
839 :
840 0 : if(!x.is())
841 0 : ::dbtools::throwFunctionSequenceException(*this);
842 :
843 0 : Sequence<sal_Int8> aSeq;
844 0 : x->readBytes(aSeq,length);
845 0 : updateValue(columnIndex,aSeq);
846 0 : }
847 : // -------------------------------------------------------------------------
848 0 : void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
849 : {
850 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateCharacterStream" );
851 0 : updateBinaryStream(columnIndex,x,length);
852 0 : }
853 : // -------------------------------------------------------------------------
854 0 : void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException)
855 : {
856 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::refreshRow" );
857 0 : ::osl::MutexGuard aGuard( m_aMutex );
858 0 : checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
859 0 : }
860 : // -------------------------------------------------------------------------
861 0 : void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException)
862 : {
863 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateObject" );
864 0 : if (!::dbtools::implUpdateObject(this, columnIndex, x))
865 0 : throw SQLException();
866 0 : }
867 : // -------------------------------------------------------------------------
868 :
869 0 : void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
870 : {
871 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateNumericObject" );
872 0 : if (!::dbtools::implUpdateObject(this, columnIndex, x))
873 0 : throw SQLException();
874 0 : }
875 : // -------------------------------------------------------------------------
876 0 : IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
877 : {
878 : //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::createArrayHelper" );
879 0 : Sequence< Property > aProps;
880 0 : describeProperties(aProps);
881 0 : return new ::cppu::OPropertyArrayHelper(aProps);
882 : }
883 : // -------------------------------------------------------------------------
884 0 : IPropertyArrayHelper & OResultSet::getInfoHelper()
885 : {
886 : //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getInfoHelper" );
887 0 : return *const_cast<OResultSet*>(this)->getArrayHelper();
888 : }
889 :
890 : //------------------------------------------------------------------
891 0 : sal_Bool OResultSet::ExecuteRow(IResultSetHelper::Movement eFirstCursorPosition,
892 : sal_Int32 nFirstOffset,
893 : sal_Bool bEvaluate,
894 : sal_Bool bRetrieveData)
895 : {
896 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::ExecuteRow" );
897 : OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::ExecuteRow: Analyzer isn't set!");
898 :
899 : // For further Fetch-Operations this information may possibly be changed ...
900 0 : IResultSetHelper::Movement eCursorPosition = eFirstCursorPosition;
901 0 : sal_Int32 nOffset = nFirstOffset;
902 :
903 0 : const OSQLColumns & rTableCols = *(m_pTable->getTableColumns());
904 0 : sal_Bool bHasRestriction = m_pSQLAnalyzer->hasRestriction();
905 : again:
906 :
907 : // protect from reading over the end when someboby is inserting while we are reading
908 : // this method works only for dBase at the moment !!!!
909 0 : if (eCursorPosition == IResultSetHelper::NEXT && m_nFilePos == m_nLastVisitedPos)
910 : {
911 0 : return sal_False;
912 : }
913 :
914 0 : if (!m_pTable || !m_pTable->seekRow(eCursorPosition, nOffset, m_nFilePos))
915 : {
916 0 : return sal_False;
917 : }
918 :
919 0 : if (!bEvaluate) // If no evaluation runs, then just fill the results-row
920 : {
921 0 : m_pTable->fetchRow(m_aRow,rTableCols, sal_True,bRetrieveData);
922 : }
923 : else
924 : {
925 0 : m_pTable->fetchRow(m_aEvaluateRow, rTableCols, sal_True,bRetrieveData || bHasRestriction);
926 :
927 0 : if ( ( !m_bShowDeleted
928 0 : && m_aEvaluateRow->isDeleted()
929 : )
930 : || ( bHasRestriction
931 0 : && !m_pSQLAnalyzer->evaluateRestriction()
932 : )
933 : )
934 : { // Evaluate the next record
935 : // delete current row in Keyset
936 0 : if (m_pEvaluationKeySet)
937 : {
938 0 : ++m_aEvaluateIter;
939 0 : if (m_pEvaluationKeySet->end() != m_aEvaluateIter)
940 0 : nOffset = (*m_aEvaluateIter);
941 : else
942 : {
943 0 : return sal_False;
944 : }
945 : }
946 0 : else if (m_pFileSet.is())
947 : {
948 : OSL_ENSURE(eCursorPosition == IResultSetHelper::NEXT, "Falsche CursorPosition!");
949 0 : eCursorPosition = IResultSetHelper::NEXT;
950 0 : nOffset = 1;
951 : }
952 0 : else if (eCursorPosition == IResultSetHelper::FIRST ||
953 : eCursorPosition == IResultSetHelper::NEXT ||
954 : eCursorPosition == IResultSetHelper::ABSOLUTE)
955 : {
956 0 : eCursorPosition = IResultSetHelper::NEXT;
957 0 : nOffset = 1;
958 : }
959 0 : else if (eCursorPosition == IResultSetHelper::LAST ||
960 : eCursorPosition == IResultSetHelper::PRIOR)
961 : {
962 0 : eCursorPosition = IResultSetHelper::PRIOR;
963 0 : nOffset = 1;
964 : }
965 0 : else if (eCursorPosition == IResultSetHelper::RELATIVE)
966 : {
967 0 : eCursorPosition = (nOffset >= 0) ? IResultSetHelper::NEXT : IResultSetHelper::PRIOR;
968 : }
969 : else
970 : {
971 0 : return sal_False;
972 : }
973 : // Try again ...
974 0 : goto again;
975 : }
976 : }
977 :
978 : // Evaluate may only be set,
979 : // if the Keyset will be constructed further
980 0 : if ( ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT )
981 0 : && !isCount()
982 : && bEvaluate
983 : )
984 : {
985 0 : if (m_pSortIndex)
986 : {
987 0 : OKeyValue* pKeyValue = GetOrderbyKeyValue( m_aSelectRow );
988 0 : m_pSortIndex->AddKeyValue(pKeyValue);
989 : }
990 0 : else if (m_pFileSet.is())
991 : {
992 0 : sal_uInt32 nBookmarkValue = Abs((sal_Int32)(m_aEvaluateRow->get())[0]->getValue());
993 0 : m_pFileSet->get().push_back(nBookmarkValue);
994 : }
995 : }
996 0 : else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_UPDATE)
997 : {
998 0 : sal_Bool bOK = sal_True;
999 0 : if (bEvaluate)
1000 : {
1001 : // read the actual result-row
1002 0 : bOK = m_pTable->fetchRow(m_aEvaluateRow, *(m_pTable->getTableColumns()), sal_True,sal_True);
1003 : }
1004 :
1005 0 : if (bOK)
1006 : {
1007 : // just give the values to be changed:
1008 0 : if(!m_pTable->UpdateRow(*m_aAssignValues,m_aEvaluateRow, m_xColsIdx))
1009 0 : return sal_False;
1010 : }
1011 : }
1012 0 : else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_DELETE)
1013 : {
1014 0 : sal_Bool bOK = sal_True;
1015 0 : if (bEvaluate)
1016 : {
1017 0 : bOK = m_pTable->fetchRow(m_aEvaluateRow, *(m_pTable->getTableColumns()), sal_True,sal_True);
1018 : }
1019 0 : if (bOK)
1020 : {
1021 0 : if(!m_pTable->DeleteRow(*m_xColumns))
1022 0 : return sal_False;
1023 : }
1024 : }
1025 0 : return sal_True;
1026 : }
1027 :
1028 : //-------------------------------------------------------------------
1029 0 : sal_Bool OResultSet::Move(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Bool bRetrieveData)
1030 : {
1031 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::Move" );
1032 :
1033 : //IgnoreDeletedRows:
1034 : //
1035 0 : sal_Int32 nTempPos = m_nRowPos;
1036 :
1037 0 : if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT &&
1038 0 : !isCount())
1039 : {
1040 0 : if (!m_pFileSet.is()) //no Index available
1041 : {
1042 : // Normal FETCH
1043 0 : ExecuteRow(eCursorPosition,nOffset,sal_False,bRetrieveData);
1044 :
1045 : // now set the bookmark for outside this is the logical pos and not the file pos
1046 0 : *(*m_aRow->get().begin()) = sal_Int32(m_nRowPos + 1);
1047 : }
1048 : else
1049 : {
1050 0 : switch(eCursorPosition)
1051 : {
1052 : case IResultSetHelper::NEXT:
1053 0 : ++m_nRowPos;
1054 0 : break;
1055 : case IResultSetHelper::PRIOR:
1056 0 : if (m_nRowPos >= 0)
1057 0 : --m_nRowPos;
1058 0 : break;
1059 : case IResultSetHelper::FIRST:
1060 0 : m_nRowPos = 0;
1061 0 : break;
1062 : case IResultSetHelper::LAST:
1063 0 : m_nRowPos = m_pFileSet->get().size() - 1;
1064 0 : break;
1065 : case IResultSetHelper::RELATIVE:
1066 0 : m_nRowPos += nOffset;
1067 0 : break;
1068 : case IResultSetHelper::ABSOLUTE:
1069 : case IResultSetHelper::BOOKMARK:
1070 0 : if ( m_nRowPos == (nOffset -1) )
1071 0 : return sal_True;
1072 0 : m_nRowPos = nOffset -1;
1073 0 : break;
1074 : }
1075 :
1076 : // OffRange?
1077 : // The FileCursor is outside of the valid range, if:
1078 : // a.) m_nRowPos < 1
1079 : // b.) a KeySet exists and m_nRowPos > m_pFileSet->size()
1080 0 : if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && m_nRowPos >= (sal_Int32)m_pFileSet->get().size() )) // && m_pFileSet->IsFrozen()
1081 : {
1082 0 : goto Error;
1083 : }
1084 : else
1085 : {
1086 0 : if (m_nRowPos < (sal_Int32)m_pFileSet->get().size())
1087 : {
1088 : // Fetch via Index
1089 0 : ExecuteRow(IResultSetHelper::BOOKMARK,(m_pFileSet->get())[m_nRowPos],sal_False,bRetrieveData);
1090 :
1091 : // now set the bookmark for outside
1092 0 : *(*m_aRow->get().begin()) = sal_Int32(m_nRowPos + 1);
1093 0 : if ( (bRetrieveData || m_pSQLAnalyzer->hasRestriction()) && m_pSQLAnalyzer->hasFunctions() )
1094 : {
1095 0 : m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping);
1096 : }
1097 : }
1098 : else // Index must be further constructed
1099 : {
1100 : // set first on the last known row
1101 0 : if (!m_pFileSet->get().empty())
1102 : {
1103 0 : m_aFileSetIter = m_pFileSet->get().end()-1;
1104 0 : m_pTable->seekRow(IResultSetHelper::BOOKMARK, *m_aFileSetIter, m_nFilePos);
1105 : }
1106 0 : sal_Bool bOK = sal_True;
1107 : // Determine the number of further Fetches
1108 0 : while (bOK && m_nRowPos >= (sal_Int32)m_pFileSet->get().size())
1109 : {
1110 0 : if (m_pEvaluationKeySet)
1111 : {
1112 0 : if (m_nRowPos >= (sal_Int32)m_pEvaluationKeySet->size())
1113 0 : return sal_False;
1114 0 : else if (m_nRowPos == 0)
1115 : {
1116 0 : m_aEvaluateIter = m_pEvaluationKeySet->begin();
1117 0 : bOK = ExecuteRow(IResultSetHelper::BOOKMARK,*m_aEvaluateIter,sal_True, bRetrieveData);
1118 : }
1119 : else
1120 : {
1121 0 : ++m_aEvaluateIter;
1122 0 : bOK = ExecuteRow(IResultSetHelper::BOOKMARK,*m_aEvaluateIter,sal_True, bRetrieveData);
1123 : }
1124 : }
1125 : else
1126 0 : bOK = ExecuteRow(IResultSetHelper::NEXT,1,sal_True, sal_False);//bRetrieveData);
1127 : }
1128 :
1129 0 : if (bOK)
1130 : {
1131 : // read the results again
1132 0 : m_pTable->fetchRow(m_aRow, *(m_pTable->getTableColumns()), sal_True,bRetrieveData);
1133 :
1134 : // now set the bookmark for outside
1135 0 : *(*m_aRow->get().begin()) = sal_Int32(m_nRowPos + 1);
1136 :
1137 0 : if ( (bRetrieveData || m_pSQLAnalyzer->hasRestriction()) && m_pSQLAnalyzer->hasFunctions() )
1138 : {
1139 0 : m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping);
1140 : }
1141 : }
1142 0 : else if (!m_pFileSet->isFrozen()) // no valid record found
1143 : {
1144 0 : m_pFileSet->setFrozen();
1145 0 : m_pEvaluationKeySet = NULL;
1146 0 : goto Error;
1147 : }
1148 : }
1149 : }
1150 : }
1151 : }
1152 0 : else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT && isCount())
1153 : {
1154 : // Fetch the COUNT(*)
1155 0 : switch (eCursorPosition)
1156 : {
1157 : case IResultSetHelper::NEXT:
1158 0 : ++m_nRowPos;
1159 0 : break;
1160 : case IResultSetHelper::PRIOR:
1161 0 : --m_nRowPos;
1162 0 : break;
1163 : case IResultSetHelper::FIRST:
1164 0 : m_nRowPos = 0;
1165 0 : break;
1166 : case IResultSetHelper::LAST:
1167 0 : m_nRowPos = 0;
1168 0 : break;
1169 : case IResultSetHelper::RELATIVE:
1170 0 : m_nRowPos += nOffset;
1171 0 : break;
1172 : case IResultSetHelper::ABSOLUTE:
1173 : case IResultSetHelper::BOOKMARK:
1174 0 : m_nRowPos = nOffset - 1;
1175 0 : break;
1176 : }
1177 :
1178 0 : if ( m_nRowPos < 0 )
1179 0 : goto Error;
1180 0 : else if (m_nRowPos == 0)
1181 : {
1182 : // put COUNT(*) in result-row
1183 : // (must be the first and only variable in the row)
1184 0 : if (m_aRow->get().size() >= 2)
1185 : {
1186 0 : *(m_aRow->get())[1] = m_nRowCountResult;
1187 0 : *(m_aRow->get())[0] = sal_Int32(1);
1188 0 : (m_aRow->get())[1]->setBound(sal_True);
1189 0 : (m_aSelectRow->get())[1] = (m_aRow->get())[1];
1190 : }
1191 : }
1192 : else
1193 : {
1194 0 : m_bEOF = sal_True;
1195 0 : m_nRowPos = 1;
1196 0 : return sal_False;
1197 : }
1198 : }
1199 : else
1200 : // Fetch only possible at SELECT!
1201 0 : return sal_False;
1202 :
1203 0 : return sal_True;
1204 :
1205 : Error:
1206 : // is the Cursor positioned before the first row
1207 : // then the position will be maintained
1208 0 : if (nTempPos == -1)
1209 0 : m_nRowPos = nTempPos;
1210 : else
1211 : {
1212 0 : switch(eCursorPosition)
1213 : {
1214 : case IResultSetHelper::PRIOR:
1215 : case IResultSetHelper::FIRST:
1216 0 : m_nRowPos = -1;
1217 0 : break;
1218 : case IResultSetHelper::LAST:
1219 : case IResultSetHelper::NEXT:
1220 : case IResultSetHelper::ABSOLUTE:
1221 : case IResultSetHelper::RELATIVE:
1222 0 : if (nOffset > 0)
1223 0 : m_nRowPos = m_pFileSet.is() ? (sal_Int32)m_pFileSet->get().size() : -1;
1224 0 : else if (nOffset < 0)
1225 0 : m_nRowPos = -1;
1226 0 : break;
1227 : case IResultSetHelper::BOOKMARK:
1228 0 : m_nRowPos = nTempPos; // last Position
1229 : }
1230 : }
1231 0 : return sal_False;
1232 : }
1233 : // -------------------------------------------------------------------------
1234 0 : void OResultSet::sortRows()
1235 : {
1236 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::sortRows" );
1237 0 : if (!m_pSQLAnalyzer->hasRestriction() && m_aOrderbyColumnNumber.size() == 1)
1238 : {
1239 : // is just one field given for sorting
1240 : // and this field is indexed, then the Index will be used
1241 0 : Reference<XIndexesSupplier> xIndexSup;
1242 0 : m_pTable->queryInterface(::getCppuType((const Reference<XIndexesSupplier>*)0)) >>= xIndexSup;
1243 :
1244 0 : Reference<XIndexAccess> xIndexes;
1245 0 : if(xIndexSup.is())
1246 : {
1247 0 : xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY);
1248 0 : Reference<XPropertySet> xColProp;
1249 0 : if(m_aOrderbyColumnNumber[0] < xIndexes->getCount())
1250 : {
1251 0 : xColProp.set(xIndexes->getByIndex(m_aOrderbyColumnNumber[0]),UNO_QUERY);
1252 : // iterate through the indexes to find the matching column
1253 0 : const sal_Int32 nCount = xIndexes->getCount();
1254 0 : for(sal_Int32 i=0; i < nCount;++i)
1255 : {
1256 0 : Reference<XColumnsSupplier> xIndex(xIndexes->getByIndex(i),UNO_QUERY);
1257 0 : Reference<XNameAccess> xIndexCols = xIndex->getColumns();
1258 0 : if(xIndexCols->hasByName(comphelper::getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)))))
1259 : {
1260 0 : m_pFileSet = new OKeySet();
1261 :
1262 0 : if(fillIndexValues(xIndex))
1263 0 : return;
1264 : }
1265 0 : }
1266 0 : }
1267 0 : }
1268 : }
1269 :
1270 0 : OSortIndex::TKeyTypeVector eKeyType(m_aOrderbyColumnNumber.size());
1271 0 : ::std::vector<sal_Int32>::iterator aOrderByIter = m_aOrderbyColumnNumber.begin();
1272 0 : for (::std::vector<sal_Int16>::size_type i=0;aOrderByIter != m_aOrderbyColumnNumber.end(); ++aOrderByIter,++i)
1273 : {
1274 : OSL_ENSURE((sal_Int32)m_aSelectRow->get().size() > *aOrderByIter,"Invalid Index");
1275 0 : switch ((*(m_aSelectRow->get().begin()+*aOrderByIter))->getValue().getTypeKind())
1276 : {
1277 : case DataType::CHAR:
1278 : case DataType::VARCHAR:
1279 : case DataType::LONGVARCHAR:
1280 0 : eKeyType[i] = SQL_ORDERBYKEY_STRING;
1281 0 : break;
1282 :
1283 : case DataType::OTHER:
1284 : case DataType::TINYINT:
1285 : case DataType::SMALLINT:
1286 : case DataType::INTEGER:
1287 : case DataType::DECIMAL:
1288 : case DataType::NUMERIC:
1289 : case DataType::REAL:
1290 : case DataType::DOUBLE:
1291 : case DataType::DATE:
1292 : case DataType::TIME:
1293 : case DataType::TIMESTAMP:
1294 : case DataType::BIT:
1295 0 : eKeyType[i] = SQL_ORDERBYKEY_DOUBLE;
1296 0 : break;
1297 :
1298 : // Other types aren't implemented (so they are always FALSE)
1299 : default:
1300 0 : eKeyType[i] = SQL_ORDERBYKEY_NONE;
1301 : OSL_FAIL("OFILECursor::Execute: Datentyp nicht implementiert");
1302 0 : break;
1303 : }
1304 0 : (m_aSelectRow->get())[*aOrderByIter]->setBound(sal_True);
1305 : }
1306 :
1307 0 : m_pSortIndex = new OSortIndex(eKeyType,m_aOrderbyAscending);
1308 :
1309 0 : if (m_pEvaluationKeySet)
1310 : {
1311 0 : m_aEvaluateIter = m_pEvaluationKeySet->begin();
1312 :
1313 0 : while (m_aEvaluateIter != m_pEvaluationKeySet->end())
1314 : {
1315 0 : ExecuteRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),sal_True);
1316 0 : ++m_aEvaluateIter;
1317 : }
1318 : }
1319 : else
1320 : {
1321 0 : while ( ExecuteRow( IResultSetHelper::NEXT, 1, sal_False, sal_True ) )
1322 : {
1323 0 : m_aSelectRow->get()[0]->setValue( m_aRow->get()[0]->getValue() );
1324 0 : if ( m_pSQLAnalyzer->hasFunctions() )
1325 0 : m_pSQLAnalyzer->setSelectionEvaluationResult( m_aSelectRow, m_aColMapping );
1326 0 : const sal_Int32 nBookmark = (*m_aRow->get().begin())->getValue();
1327 0 : ExecuteRow( IResultSetHelper::BOOKMARK, nBookmark, sal_True, sal_False );
1328 : }
1329 : }
1330 :
1331 : // create sorted Keyset
1332 0 : m_pEvaluationKeySet = NULL;
1333 0 : m_pFileSet = NULL;
1334 0 : m_pFileSet = m_pSortIndex->CreateKeySet();
1335 0 : DELETEZ(m_pSortIndex);
1336 : // now access to a sorted set is possible via Index
1337 : }
1338 :
1339 :
1340 : // -------------------------------------------------------------------------
1341 0 : sal_Bool OResultSet::OpenImpl()
1342 : {
1343 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::OpenImpl" );
1344 : OSL_ENSURE(m_pSQLAnalyzer,"No analyzer set with setSqlAnalyzer!");
1345 0 : if(!m_pTable)
1346 : {
1347 0 : const OSQLTables& xTabs = m_aSQLIterator.getTables();
1348 0 : if ((xTabs.begin() == xTabs.end()) || !xTabs.begin()->second.is())
1349 0 : lcl_throwError(STR_QUERY_TOO_COMPLEX,*this);
1350 :
1351 0 : if ( xTabs.size() > 1 || m_aSQLIterator.hasErrors() )
1352 0 : lcl_throwError(STR_QUERY_MORE_TABLES,*this);
1353 :
1354 0 : OSQLTable xTable = xTabs.begin()->second;
1355 0 : m_xColumns = m_aSQLIterator.getSelectColumns();
1356 :
1357 0 : m_xColNames = xTable->getColumns();
1358 0 : m_xColsIdx.set(m_xColNames,UNO_QUERY);
1359 0 : doTableSpecials(xTable);
1360 0 : Reference<XComponent> xComp(xTable,UNO_QUERY);
1361 0 : if(xComp.is())
1362 0 : xComp->addEventListener(this);
1363 : }
1364 :
1365 0 : m_pTable->refreshHeader();
1366 :
1367 0 : sal_Int32 nColumnCount = m_xColsIdx->getCount();
1368 :
1369 0 : initializeRow(m_aRow,nColumnCount);
1370 0 : initializeRow(m_aEvaluateRow,nColumnCount);
1371 0 : initializeRow(m_aInsertRow,nColumnCount);
1372 :
1373 :
1374 0 : m_nResultSetConcurrency = (m_pTable->isReadOnly() || isCount()) ? ResultSetConcurrency::READ_ONLY : ResultSetConcurrency::UPDATABLE;
1375 :
1376 : // create new Index:
1377 0 : m_pFileSet = NULL;
1378 :
1379 : // position at the beginning
1380 0 : m_nRowPos = -1;
1381 0 : m_nFilePos = 0;
1382 0 : m_nRowCountResult = -1;
1383 :
1384 0 : m_nLastVisitedPos = m_pTable->getCurrentLastPos();
1385 :
1386 0 : switch(m_aSQLIterator.getStatementType())
1387 : {
1388 : case SQL_STATEMENT_SELECT:
1389 : {
1390 0 : if(isCount())
1391 : {
1392 0 : if(m_xColumns->get().size() > 1)
1393 0 : lcl_throwError(STR_QUERY_COMPLEX_COUNT,*this);
1394 :
1395 0 : m_nRowCountResult = 0;
1396 : // for now simply iterate over all rows and
1397 : // do all actions (or just count)
1398 : {
1399 0 : sal_Bool bOK = sal_True;
1400 0 : if (m_pEvaluationKeySet)
1401 : {
1402 0 : m_aEvaluateIter = m_pEvaluationKeySet->begin();
1403 0 : bOK = m_aEvaluateIter == m_pEvaluationKeySet->end();
1404 :
1405 : }
1406 0 : while (bOK)
1407 : {
1408 0 : if (m_pEvaluationKeySet)
1409 0 : ExecuteRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),sal_True);
1410 : else
1411 0 : bOK = ExecuteRow(IResultSetHelper::NEXT,1,sal_True);
1412 :
1413 0 : if (bOK)
1414 : {
1415 0 : m_nRowCountResult++;
1416 0 : if(m_pEvaluationKeySet)
1417 : {
1418 0 : ++m_aEvaluateIter;
1419 0 : bOK = m_aEvaluateIter == m_pEvaluationKeySet->end();
1420 : }
1421 : }
1422 : }
1423 :
1424 : // save result of COUNT(*) in m_nRowCountResult.
1425 : // nRowCount (number of Rows in the result) = 1 for this request!
1426 0 : m_pEvaluationKeySet = NULL;
1427 : }
1428 : }
1429 : else
1430 : {
1431 0 : sal_Bool bDistinct = sal_False;
1432 0 : OSQLParseNode *pDistinct = m_pParseTree->getChild(1);
1433 :
1434 : assert(m_aOrderbyColumnNumber.size() ==
1435 : m_aOrderbyAscending.size());
1436 0 : if (pDistinct && pDistinct->getTokenID() == SQL_TOKEN_DISTINCT )
1437 : {
1438 : // To eliminate duplicates we need to sort on all columns.
1439 : // This is not a problem because the SQL spec says that the
1440 : // order of columns that are not specified in ORDER BY
1441 : // clause is undefined, so it doesn't hurt to sort on
1442 : // these; pad the vectors to include them.
1443 0 : for (sal_Int32 i = 1; // 0: bookmark (see setBoundedColumns)
1444 0 : static_cast<size_t>(i) < m_aColMapping.size(); ++i)
1445 : {
1446 0 : if (::std::find(m_aOrderbyColumnNumber.begin(),
1447 0 : m_aOrderbyColumnNumber.end(), i)
1448 0 : == m_aOrderbyColumnNumber.end())
1449 : {
1450 0 : m_aOrderbyColumnNumber.push_back(i);
1451 : // ASC or DESC doesn't matter
1452 0 : m_aOrderbyAscending.push_back(SQL_ASC);
1453 : }
1454 : }
1455 0 : bDistinct = sal_True;
1456 : }
1457 :
1458 0 : if (IsSorted())
1459 0 : sortRows();
1460 :
1461 0 : if (!m_pFileSet.is())
1462 : {
1463 0 : m_pFileSet = new OKeySet();
1464 :
1465 0 : if (!m_pSQLAnalyzer->hasRestriction())
1466 : // now the Keyset can be filled!
1467 : // But be careful: It is assumed, that the FilePositions will be stored as sequence 1..n
1468 : {
1469 0 : if ( m_nLastVisitedPos > 0)
1470 0 : m_pFileSet->get().reserve( m_nLastVisitedPos );
1471 0 : for (sal_Int32 i = 0; i < m_nLastVisitedPos; i++)
1472 0 : m_pFileSet->get().push_back(i + 1);
1473 : }
1474 : }
1475 : OSL_ENSURE(m_pFileSet.is(),"Kein KeySet vorhanden! :-(");
1476 :
1477 0 : if(bDistinct && m_pFileSet.is())
1478 : {
1479 0 : OValueRow aSearchRow = new OValueVector(m_aRow->get().size());
1480 0 : OValueRefVector::Vector::iterator aRowIter = m_aRow->get().begin();
1481 0 : OValueVector::Vector::iterator aSearchIter = aSearchRow->get().begin();
1482 0 : for ( ++aRowIter,++aSearchIter; // the first column is the bookmark column
1483 0 : aRowIter != m_aRow->get().end();
1484 : ++aRowIter,++aSearchIter)
1485 0 : aSearchIter->setBound((*aRowIter)->isBound());
1486 :
1487 0 : size_t nMaxRow = m_pFileSet->get().size();
1488 :
1489 0 : if (nMaxRow)
1490 : {
1491 : #if OSL_DEBUG_LEVEL > 1
1492 : sal_Int32 nFound=0;
1493 : #endif
1494 : sal_Int32 nPos;
1495 : sal_Int32 nKey;
1496 :
1497 0 : for( size_t j = nMaxRow-1; j > 0; --j)
1498 : {
1499 0 : nPos = (m_pFileSet->get())[j];
1500 0 : ExecuteRow(IResultSetHelper::BOOKMARK,nPos,sal_False);
1501 0 : m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping);
1502 : { // copy row values
1503 0 : OValueRefVector::Vector::iterator copyFrom = m_aSelectRow->get().begin();
1504 0 : OValueVector::Vector::iterator copyTo = aSearchRow->get().begin();
1505 0 : for ( ++copyFrom,++copyTo; // the first column is the bookmark column
1506 0 : copyFrom != m_aSelectRow->get().end();
1507 : ++copyFrom,++copyTo)
1508 0 : *copyTo = *(*copyFrom);
1509 : }
1510 :
1511 : // compare with next row
1512 0 : nKey = (m_pFileSet->get())[j-1];
1513 0 : ExecuteRow(IResultSetHelper::BOOKMARK,nKey,sal_False);
1514 0 : m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping);
1515 0 : OValueRefVector::Vector::iterator loopInRow = m_aSelectRow->get().begin();
1516 0 : OValueVector::Vector::iterator existentInSearchRow = aSearchRow->get().begin();
1517 0 : for ( ++loopInRow,++existentInSearchRow; // the first column is the bookmark column
1518 0 : loopInRow != m_aSelectRow->get().end();
1519 : ++loopInRow,++existentInSearchRow)
1520 : {
1521 0 : if ( (*loopInRow)->isBound() && !( *(*loopInRow) == *existentInSearchRow) )
1522 0 : break;
1523 : }
1524 :
1525 0 : if(loopInRow == m_aSelectRow->get().end())
1526 0 : (m_pFileSet->get())[j] = 0; // Rows match -- Mark for deletion by setting key to 0
1527 : #if OSL_DEBUG_LEVEL > 1
1528 : else
1529 : nFound++;
1530 : #endif
1531 : }
1532 :
1533 0 : m_pFileSet->get().erase(::std::remove_if(m_pFileSet->get().begin(),m_pFileSet->get().end(),
1534 : ::std::bind2nd(::std::equal_to<sal_Int32>(),0))
1535 0 : ,m_pFileSet->get().end());
1536 0 : }
1537 : }
1538 : }
1539 0 : } break;
1540 :
1541 : case SQL_STATEMENT_UPDATE:
1542 : case SQL_STATEMENT_DELETE:
1543 : // during processing count the number of processed Rows
1544 0 : m_nRowCountResult = 0;
1545 : // for now simply iterate over all rows and
1546 : // run the actions (or simply count):
1547 : {
1548 :
1549 0 : sal_Bool bOK = sal_True;
1550 0 : if (m_pEvaluationKeySet)
1551 : {
1552 0 : m_aEvaluateIter = m_pEvaluationKeySet->begin();
1553 0 : bOK = m_aEvaluateIter == m_pEvaluationKeySet->end();
1554 :
1555 : }
1556 0 : while (bOK)
1557 : {
1558 0 : if (m_pEvaluationKeySet)
1559 0 : ExecuteRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),sal_True);
1560 : else
1561 0 : bOK = ExecuteRow(IResultSetHelper::NEXT,1,sal_True);
1562 :
1563 0 : if (bOK)
1564 : {
1565 0 : m_nRowCountResult++;
1566 0 : if(m_pEvaluationKeySet)
1567 : {
1568 0 : ++m_aEvaluateIter;
1569 0 : bOK = m_aEvaluateIter == m_pEvaluationKeySet->end();
1570 : }
1571 : }
1572 : }
1573 :
1574 : // save result of COUNT(*) in nRowCountResult.
1575 : // nRowCount (number of rows in the result-set) = 1 for this request!
1576 0 : m_pEvaluationKeySet = NULL;
1577 : }
1578 0 : break;
1579 : case SQL_STATEMENT_INSERT:
1580 0 : m_nRowCountResult = 0;
1581 :
1582 : OSL_ENSURE(m_aAssignValues.is(),"No assign values set!");
1583 0 : if(!m_pTable->InsertRow(*m_aAssignValues, sal_True,m_xColsIdx))
1584 : {
1585 0 : m_nFilePos = 0;
1586 0 : return sal_False;
1587 : }
1588 :
1589 0 : m_nRowCountResult = 1;
1590 0 : break;
1591 : default:
1592 : OSL_FAIL( "OResultSet::OpenImpl: unsupported statement type!" );
1593 0 : break;
1594 : }
1595 :
1596 : // reset FilePos
1597 0 : m_nFilePos = 0;
1598 :
1599 0 : return sal_True;
1600 : }
1601 : //--------------------------------------------------------------------------
1602 0 : Sequence< sal_Int8 > OResultSet::getUnoTunnelImplementationId()
1603 : {
1604 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getUnoTunnelImplementationId" );
1605 : static ::cppu::OImplementationId * pId = 0;
1606 0 : if (! pId)
1607 : {
1608 0 : ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
1609 0 : if (! pId)
1610 : {
1611 0 : static ::cppu::OImplementationId aId;
1612 0 : pId = &aId;
1613 0 : }
1614 : }
1615 0 : return pId->getImplementationId();
1616 : }
1617 :
1618 : // com::sun::star::lang::XUnoTunnel
1619 : //------------------------------------------------------------------
1620 0 : sal_Int64 OResultSet::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
1621 : {
1622 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getSomething" );
1623 0 : return (rId.getLength() == 16 && 0 == memcmp(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
1624 : ? reinterpret_cast< sal_Int64 >( this )
1625 0 : : 0;
1626 : }
1627 : // -----------------------------------------------------------------------------
1628 0 : void OResultSet::setBoundedColumns(const OValueRefRow& _rRow,
1629 : const OValueRefRow& _rSelectRow,
1630 : const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns,
1631 : const Reference<XIndexAccess>& _xNames,
1632 : sal_Bool _bSetColumnMapping,
1633 : const Reference<XDatabaseMetaData>& _xMetaData,
1634 : ::std::vector<sal_Int32>& _rColMapping)
1635 : {
1636 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::setBoundedColumns" );
1637 0 : ::comphelper::UStringMixEqual aCase(_xMetaData->supportsMixedCaseQuotedIdentifiers());
1638 :
1639 0 : Reference<XPropertySet> xTableColumn;
1640 0 : ::rtl::OUString sTableColumnName, sSelectColumnRealName;
1641 :
1642 0 : const ::rtl::OUString sName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
1643 0 : const ::rtl::OUString sRealName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME);
1644 0 : const ::rtl::OUString sType = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE);
1645 :
1646 : typedef ::std::map<OSQLColumns::Vector::iterator,sal_Bool> IterMap;
1647 0 : IterMap aSelectIters;
1648 0 : OValueRefVector::Vector::iterator aRowIter = _rRow->get().begin()+1;
1649 0 : for (sal_Int32 i=0; // the first column is the bookmark column
1650 0 : aRowIter != _rRow->get().end();
1651 : ++i, ++aRowIter
1652 : )
1653 : {
1654 0 : (*aRowIter)->setBound(sal_False);
1655 : try
1656 : {
1657 : // get the table column and it's name
1658 0 : _xNames->getByIndex(i) >>= xTableColumn;
1659 : OSL_ENSURE(xTableColumn.is(), "OResultSet::setBoundedColumns: invalid table column!");
1660 0 : if (xTableColumn.is())
1661 0 : xTableColumn->getPropertyValue(sName) >>= sTableColumnName;
1662 : else
1663 0 : sTableColumnName = ::rtl::OUString();
1664 :
1665 : // look if we have such a select column
1666 : // TODO: would like to have a O(log n) search here ...
1667 0 : for ( OSQLColumns::Vector::iterator aIter = _rxColumns->get().begin();
1668 0 : aIter != _rxColumns->get().end();
1669 : ++aIter
1670 : )
1671 : {
1672 0 : if((*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName))
1673 0 : (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName;
1674 : else
1675 0 : (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName;
1676 :
1677 0 : if ( aCase(sTableColumnName, sSelectColumnRealName) && !(*aRowIter)->isBound() && aSelectIters.end() == aSelectIters.find(aIter) )
1678 : {
1679 0 : aSelectIters.insert(IterMap::value_type(aIter,sal_True));
1680 0 : if(_bSetColumnMapping)
1681 : {
1682 0 : sal_Int32 nSelectColumnPos = aIter - _rxColumns->get().begin() + 1;
1683 : // the getXXX methods are 1-based ...
1684 0 : sal_Int32 nTableColumnPos = i + 1;
1685 : // get first table column is the bookmark column ...
1686 0 : _rColMapping[nSelectColumnPos] = nTableColumnPos;
1687 0 : (_rSelectRow->get())[nSelectColumnPos] = *aRowIter;
1688 : }
1689 :
1690 0 : (*aRowIter)->setBound(sal_True);
1691 0 : sal_Int32 nType = DataType::OTHER;
1692 0 : if (xTableColumn.is())
1693 0 : xTableColumn->getPropertyValue(sType) >>= nType;
1694 0 : (*aRowIter)->setTypeKind(nType);
1695 :
1696 : break;
1697 : }
1698 : }
1699 : }
1700 0 : catch (Exception&)
1701 : {
1702 : OSL_FAIL("OResultSet::setBoundedColumns: caught an Exception!");
1703 : }
1704 : }
1705 : // in this case we got more select columns as columns exist in the table
1706 0 : if ( _bSetColumnMapping && aSelectIters.size() != _rColMapping.size() )
1707 : {
1708 0 : Reference<XNameAccess> xNameAccess(_xNames,UNO_QUERY);
1709 0 : Sequence< ::rtl::OUString > aSelectColumns = xNameAccess->getElementNames();
1710 :
1711 0 : for ( OSQLColumns::Vector::iterator aIter = _rxColumns->get().begin();
1712 0 : aIter != _rxColumns->get().end();
1713 : ++aIter
1714 : )
1715 : {
1716 0 : if ( aSelectIters.end() == aSelectIters.find(aIter) )
1717 : {
1718 0 : if ( (*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName) )
1719 0 : (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName;
1720 : else
1721 0 : (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName;
1722 :
1723 0 : if ( xNameAccess->hasByName( sSelectColumnRealName ) )
1724 : {
1725 0 : aSelectIters.insert(IterMap::value_type(aIter,sal_True));
1726 0 : sal_Int32 nSelectColumnPos = aIter - _rxColumns->get().begin() + 1;
1727 0 : const ::rtl::OUString* pBegin = aSelectColumns.getConstArray();
1728 0 : const ::rtl::OUString* pEnd = pBegin + aSelectColumns.getLength();
1729 0 : for(sal_Int32 i=0;pBegin != pEnd;++pBegin,++i)
1730 : {
1731 0 : if ( aCase(*pBegin, sSelectColumnRealName) )
1732 : {
1733 : // the getXXX methods are 1-based ...
1734 0 : sal_Int32 nTableColumnPos = i + 1;
1735 : // get first table column is the bookmark column ...
1736 0 : _rColMapping[nSelectColumnPos] = nTableColumnPos;
1737 0 : (_rSelectRow->get())[nSelectColumnPos] = (_rRow->get())[nTableColumnPos];
1738 0 : break;
1739 : }
1740 : }
1741 : }
1742 : }
1743 0 : }
1744 0 : }
1745 0 : }
1746 : // -----------------------------------------------------------------------------
1747 0 : void SAL_CALL OResultSet::acquire() throw()
1748 : {
1749 0 : OResultSet_BASE::acquire();
1750 0 : }
1751 : // -----------------------------------------------------------------------------
1752 0 : void SAL_CALL OResultSet::release() throw()
1753 : {
1754 0 : OResultSet_BASE::release();
1755 0 : }
1756 : // -----------------------------------------------------------------------------
1757 0 : Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo( ) throw(RuntimeException)
1758 : {
1759 : //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getPropertySetInfo" );
1760 0 : return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
1761 : }
1762 : // -----------------------------------------------------------------------------
1763 0 : void OResultSet::doTableSpecials(const OSQLTable& _xTable)
1764 : {
1765 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::doTableSpecials" );
1766 0 : Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(_xTable,UNO_QUERY);
1767 0 : if(xTunnel.is())
1768 : {
1769 0 : m_pTable = reinterpret_cast< OFileTable* >( xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()) );
1770 0 : if(m_pTable)
1771 0 : m_pTable->acquire();
1772 0 : }
1773 0 : }
1774 : // -----------------------------------------------------------------------------
1775 0 : void OResultSet::clearInsertRow()
1776 : {
1777 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::clearInsertRow" );
1778 0 : m_aRow->setDeleted(sal_False); // set to false here because this is the new row
1779 0 : OValueRefVector::Vector::iterator aIter = m_aInsertRow->get().begin();
1780 0 : const OValueRefVector::Vector::iterator aEnd = m_aInsertRow->get().end();
1781 0 : for(sal_Int32 nPos = 0;aIter != aEnd;++aIter,++nPos)
1782 : {
1783 0 : ORowSetValueDecoratorRef& rValue = (*aIter);
1784 0 : if ( rValue->isBound() )
1785 : {
1786 0 : (m_aRow->get())[nPos]->setValue( (*aIter)->getValue() );
1787 : }
1788 0 : rValue->setBound(nPos == 0);
1789 0 : rValue->setModified(sal_False);
1790 0 : rValue->setNull();
1791 : }
1792 0 : }
1793 : // -----------------------------------------------------------------------------
1794 0 : void OResultSet::initializeRow(OValueRefRow& _rRow,sal_Int32 _nColumnCount)
1795 : {
1796 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::initializeRow" );
1797 0 : if(!_rRow.is())
1798 : {
1799 0 : _rRow = new OValueRefVector(_nColumnCount);
1800 0 : (_rRow->get())[0]->setBound(sal_True);
1801 0 : ::std::for_each(_rRow->get().begin()+1,_rRow->get().end(),TSetRefBound(sal_False));
1802 : }
1803 0 : }
1804 : // -----------------------------------------------------------------------------
1805 0 : sal_Bool OResultSet::fillIndexValues(const Reference< XColumnsSupplier> &/*_xIndex*/)
1806 : {
1807 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::fillIndexValues" );
1808 0 : return sal_False;
1809 : }
1810 : // -----------------------------------------------------------------------------
1811 0 : sal_Bool OResultSet::move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData)
1812 : {
1813 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::move" );
1814 0 : return Move(_eCursorPosition,_nOffset,_bRetrieveData);
1815 : }
1816 : // -----------------------------------------------------------------------------
1817 0 : sal_Int32 OResultSet::getDriverPos() const
1818 : {
1819 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getDriverPos" );
1820 0 : return (m_aRow->get())[0]->getValue();
1821 : }
1822 : // -----------------------------------------------------------------------------
1823 0 : sal_Bool OResultSet::deletedVisible() const
1824 : {
1825 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::deletedVisible" );
1826 0 : return m_bShowDeleted;
1827 : }
1828 : // -----------------------------------------------------------------------------
1829 0 : sal_Bool OResultSet::isRowDeleted() const
1830 : {
1831 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isRowDeleted" );
1832 0 : return m_aRow->isDeleted();
1833 : }
1834 : // -----------------------------------------------------------------------------
1835 0 : void SAL_CALL OResultSet::disposing( const EventObject& Source ) throw (RuntimeException)
1836 : {
1837 : RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::disposing" );
1838 0 : Reference<XPropertySet> xProp = m_pTable;
1839 0 : if(m_pTable && Source.Source == xProp)
1840 : {
1841 0 : m_pTable->release();
1842 0 : m_pTable = NULL;
1843 0 : }
1844 0 : }
1845 : // -----------------------------------------------------------------------------
1846 :
1847 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|