LibreOffice Module connectivity (master) 1
FResultSet.cxx
Go to the documentation of this file.
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#include <file/FResultSet.hxx>
22#include <sqlbison.hxx>
24#include <com/sun/star/sdbc/DataType.hpp>
25#include <com/sun/star/beans/PropertyAttribute.hpp>
26#include <com/sun/star/container/XIndexAccess.hpp>
32#include <o3tl/safeint.hxx>
33#include <sal/log.hxx>
34#include <iterator>
35#include <com/sun/star/sdbc/ResultSetType.hpp>
36#include <com/sun/star/sdbc/FetchDirection.hpp>
37#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
38#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
39
40#include <algorithm>
42#include <comphelper/types.hxx>
44#include <strings.hrc>
46
47using namespace ::comphelper;
48using namespace connectivity;
49using namespace connectivity::file;
50using namespace ::cppu;
51using namespace dbtools;
52using namespace com::sun::star::uno;
53using namespace com::sun::star::lang;
54using namespace com::sun::star::beans;
55using namespace com::sun::star::sdbc;
56using namespace com::sun::star::sdbcx;
57using namespace com::sun::star::container;
58
59namespace
60{
61 void lcl_throwError(TranslateId pErrorId, const css::uno::Reference< css::uno::XInterface>& _xContext)
62 {
64 const OUString sMessage = aResources.getResourceString(pErrorId);
65 ::dbtools::throwGenericSQLException(sMessage ,_xContext);
66 }
67}
68
69IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.drivers.file.ResultSet","com.sun.star.sdbc.ResultSet");
70
71OResultSet::OResultSet(OStatement_Base* pStmt,OSQLParseTreeIterator& _aSQLIterator) : OResultSet_BASE(m_aMutex)
73 ,m_aSkipDeletedSet(this)
74 ,m_pParseTree(pStmt->getParseTree())
75 ,m_pSQLAnalyzer(nullptr)
76 ,m_aSQLIterator(_aSQLIterator)
77 ,m_nFetchSize(0)
78 ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE)
79 ,m_nFetchDirection(FetchDirection::FORWARD)
80 ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE)
81 ,m_xStatement(*pStmt)
82 ,m_nRowPos(-1)
83 ,m_nFilePos(0)
84 ,m_nLastVisitedPos(-1)
85 ,m_nRowCountResult(-1)
86 ,m_nColumnCount(0)
87 ,m_bWasNull(false)
88 ,m_bInserted(false)
89 ,m_bRowUpdated(false)
90 ,m_bRowInserted(false)
91 ,m_bRowDeleted(false)
92 ,m_bShowDeleted(pStmt->getOwnConnection()->showDeleted())
93 ,m_bIsCount(false)
94{
95 osl_atomic_increment( &m_refCount );
97 m_pParseTree->count() > 2 &&
98 SQL_ISRULE(m_pParseTree->getChild(2),scalar_exp_commalist) &&
99 SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0),derived_column) &&
100 SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0)->getChild(0),general_set_fct) &&
101 m_pParseTree->getChild(2)->getChild(0)->getChild(0)->count() == 4
102 );
103
104 m_nResultSetConcurrency = isCount() ? ResultSetConcurrency::READ_ONLY : ResultSetConcurrency::UPDATABLE;
105 construct();
107 osl_atomic_decrement( &m_refCount );
108}
109
110
112{
113 osl_atomic_increment( &m_refCount );
114 disposing();
115}
116
118{
123}
124
126{
128
129 ::osl::MutexGuard aGuard(m_aMutex);
130 m_xStatement.clear();
131 m_xMetaData.clear();
132 m_pParseTree = nullptr;
133 m_xColNames.clear();
134 m_xColumns = nullptr;
135 m_xColsIdx.clear();
136
137 if ( m_pTable.is() )
138 m_pTable->removeEventListener(this);
139 m_pTable.clear();
140
141 m_pFileSet = nullptr;
142 m_pSortIndex.reset();
143
144 if(m_aInsertRow.is())
145 m_aInsertRow->clear();
146
148}
149
150Any SAL_CALL OResultSet::queryInterface( const Type & rType )
151{
153 return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType);
154}
155
157{
158 ::osl::MutexGuard aGuard( m_aMutex );
159
163
164 return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
165}
166
167
168sal_Int32 SAL_CALL OResultSet::findColumn( const OUString& columnName )
169{
170 ::osl::MutexGuard aGuard( m_aMutex );
171 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
172
173
175 sal_Int32 nLen = xMeta->getColumnCount();
176 sal_Int32 i = 1;
177 for(;i<=nLen;++i)
178 {
179 if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
180 columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
181 return i;
182 }
183
185 assert(false);
186 return 0; // Never reached
187}
188
189const ORowSetValue& OResultSet::getValue(sal_Int32 columnIndex)
190{
191 ::osl::MutexGuard aGuard( m_aMutex );
192 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
193
194 checkIndex(columnIndex );
195
196
197 m_bWasNull = (*m_aSelectRow)[columnIndex]->getValue().isNull();
198 return *(*m_aSelectRow)[columnIndex];
199}
200
201void OResultSet::checkIndex(sal_Int32 columnIndex )
202{
203 if ( columnIndex <= 0
204 || columnIndex >= m_nColumnCount )
206}
207
209{
210 return nullptr;
211}
212
214{
215 return nullptr;
216}
217
218
219sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex )
220{
221 return getValue(columnIndex).getBool();
222}
223
224
225sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex )
226{
227 return getValue(columnIndex).getInt8();
228}
229
230
231Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex )
232{
233 return getValue(columnIndex).getSequence();
234}
235
236
237css::util::Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex )
238{
239 return getValue(columnIndex).getDate();
240}
241
242
243double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex )
244{
245 return getValue(columnIndex).getDouble();
246}
247
248
249float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex )
250{
251 return getValue(columnIndex).getFloat();
252}
253
254
255sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex )
256{
257 return getValue(columnIndex).getInt32();
258}
259
260
261sal_Int32 SAL_CALL OResultSet::getRow( )
262{
263 ::osl::MutexGuard aGuard( m_aMutex );
264 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
265
266 OSL_ENSURE((m_bShowDeleted || !m_aRow->isDeleted()),"getRow called for deleted row");
267
268 return m_aSkipDeletedSet.getMappedPosition((*m_aRow)[0]->getValue().getInt32());
269}
270
271
272sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex )
273{
274 return getValue(columnIndex).getLong();
275}
276
277
279{
280 ::osl::MutexGuard aGuard( m_aMutex );
281 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
282
283
284 if(!m_xMetaData.is())
286 return m_xMetaData;
287}
288
289Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ )
290{
291 return nullptr;
292}
293
294
295Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ )
296{
297 return nullptr;
298}
299
300Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ )
301{
302 return nullptr;
303}
304
305
306Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ )
307{
308 return nullptr;
309}
310
311
312Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< css::container::XNameAccess >& /*typeMap*/ )
313{
314 return getValue(columnIndex).makeAny();
315}
316
317
318sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex )
319{
320 return getValue(columnIndex).getInt16();
321}
322
323OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex )
324{
325 return getValue(columnIndex).getString();
326}
327
328css::util::Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex )
329{
330 return getValue(columnIndex).getTime();
331}
332
333css::util::DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex )
334{
335 return getValue(columnIndex).getDateTime();
336}
337
338
340{
341 ::osl::MutexGuard aGuard( m_aMutex );
342 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
343
344
345 return m_nRowPos == sal_Int32(m_pFileSet->size());
346}
347
349{
350 ::osl::MutexGuard aGuard( m_aMutex );
351 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
352
353
354 return m_nRowPos == 0;
355}
356
358{
359 ::osl::MutexGuard aGuard( m_aMutex );
360 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
361
362
363 return m_nRowPos == sal_Int32(m_pFileSet->size() - 1);
364}
365
367{
368 ::osl::MutexGuard aGuard( m_aMutex );
369 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
370
371
372 if(first())
373 previous();
374}
375
376void SAL_CALL OResultSet::afterLast( )
377{
378 ::osl::MutexGuard aGuard( m_aMutex );
379 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
380
381
382 if(last())
383 next();
384}
385
386
387void SAL_CALL OResultSet::close( )
388{
389 dispose();
390}
391
392
394{
395 ::osl::MutexGuard aGuard( m_aMutex );
396 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
398}
399
400
402{
403 // here I know definitely that I stand on the last record
404 ::osl::MutexGuard aGuard( m_aMutex );
405 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
407}
408
409sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row )
410{
411 ::osl::MutexGuard aGuard( m_aMutex );
412 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
414}
415
416sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row )
417{
418 ::osl::MutexGuard aGuard( m_aMutex );
419 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
421}
422
424{
425 ::osl::MutexGuard aGuard( m_aMutex );
426 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
428}
429
431{
432 ::osl::MutexGuard aGuard( m_aMutex );
433 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
434
435
436 return m_xStatement;
437}
438
439
441{
442 ::osl::MutexGuard aGuard( m_aMutex );
443 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
444
445
446 return m_bRowDeleted;
447}
448
450{ ::osl::MutexGuard aGuard( m_aMutex );
451 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
452
453
454 return m_bRowInserted;
455}
456
458{
459 ::osl::MutexGuard aGuard( m_aMutex );
460 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
461
462
463 return m_bRowUpdated;
464}
465
466
468{
469 ::osl::MutexGuard aGuard( m_aMutex );
470 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
471
472
473 return m_nRowPos == -1;
474}
475
477{
478 ::osl::MutexGuard aGuard( m_aMutex );
479 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
480
482}
483
484
486{
487 ::osl::MutexGuard aGuard( m_aMutex );
488 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
489
490 return m_bWasNull;
491}
492
493
494void SAL_CALL OResultSet::cancel( )
495{
496}
497
499{
500}
501
503{
504 return Any();
505}
506
507void SAL_CALL OResultSet::insertRow( )
508{
509 ::osl::MutexGuard aGuard( m_aMutex );
510 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
511
512
513 if(!m_bInserted || !m_pTable.is())
515
516 // we know that we append new rows at the end
517 // so we have to know where the end is
520 if(m_bRowInserted && m_pFileSet.is())
521 {
522 sal_Int32 nPos = (*m_aInsertRow)[0]->getValue().getInt32();
523 m_pFileSet->push_back(nPos);
524 *(*m_aInsertRow)[0] = sal_Int32(m_pFileSet->size());
526
528 }
529}
530
531void SAL_CALL OResultSet::updateRow( )
532{
533 ::osl::MutexGuard aGuard( m_aMutex );
534 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
535
536 if(!m_pTable.is() || m_pTable->isReadOnly())
537 lcl_throwError(STR_TABLE_READONLY,*this);
538
540 *(*m_aInsertRow)[0] = (*m_aRow)[0]->getValue().getInt32();
541
543}
544
546{
547 ::osl::MutexGuard aGuard( m_aMutex );
548 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
549
550 if(!m_pTable.is() || m_pTable->isReadOnly())
551 lcl_throwError(STR_TABLE_READONLY,*this);
552 if (m_bShowDeleted)
553 lcl_throwError(STR_DELETE_ROW,*this);
554 if(m_aRow->isDeleted())
555 lcl_throwError(STR_ROW_ALREADY_DELETED,*this);
556
557 sal_Int32 nPos = (*m_aRow)[0]->getValue().getInt32();
558 m_bRowDeleted = m_pTable->DeleteRow(*m_xColumns);
559 if(m_bRowDeleted && m_pFileSet.is())
560 {
561 m_aRow->setDeleted(true);
562 // don't touch the m_pFileSet member here
564 }
565}
566
568{
569 ::osl::MutexGuard aGuard( m_aMutex );
570 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
571
572
573 m_bInserted = false;
574 m_bRowUpdated = false;
575 m_bRowInserted = false;
576 m_bRowDeleted = false;
577
578 if(m_aInsertRow.is())
579 {
580 OValueRefVector::iterator aIter = m_aInsertRow->begin()+1;
581 for(;aIter != m_aInsertRow->end();++aIter)
582 {
583 (*aIter)->setBound(false);
584 (*aIter)->setNull();
585 }
586 }
587}
588
589
591{
592 ::osl::MutexGuard aGuard( m_aMutex );
593 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
594
595 if(!m_pTable.is() || m_pTable->isReadOnly())
596 lcl_throwError(STR_TABLE_READONLY,*this);
597
598 m_bInserted = true;
599
600 OValueRefVector::iterator aIter = m_aInsertRow->begin()+1;
601 for(;aIter != m_aInsertRow->end();++aIter)
602 {
603 (*aIter)->setBound(false);
604 (*aIter)->setNull();
605 }
606}
607
608
610{
611}
612
613void OResultSet::updateValue(sal_Int32 columnIndex ,const ORowSetValue& x)
614{
615 ::osl::MutexGuard aGuard( m_aMutex );
616 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
617
618 checkIndex(columnIndex );
619 columnIndex = mapColumn(columnIndex);
620
621 (*m_aInsertRow)[columnIndex]->setBound(true);
622 *(*m_aInsertRow)[columnIndex] = x;
623}
624
625
626void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex )
627{
628 ORowSetValue aEmpty;
629 updateValue(columnIndex,aEmpty);
630}
631
632
633void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x )
634{
635 updateValue(columnIndex, static_cast<bool>(x));
636}
637
638void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x )
639{
640 updateValue(columnIndex,x);
641}
642
643
644void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x )
645{
646 updateValue(columnIndex,x);
647}
648
649void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x )
650{
651 updateValue(columnIndex,x);
652}
653
654void SAL_CALL OResultSet::updateLong( sal_Int32 /*columnIndex*/, sal_Int64 /*x*/ )
655{
656 ::dbtools::throwFeatureNotImplementedSQLException( "XRowUpdate::updateLong", *this );
657}
658
659void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x )
660{
661 updateValue(columnIndex,x);
662}
663
664
665void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x )
666{
667 updateValue(columnIndex,x);
668}
669
670void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const OUString& x )
671{
672 updateValue(columnIndex,x);
673}
674
675void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x )
676{
677 updateValue(columnIndex,x);
678}
679
680void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const css::util::Date& x )
681{
682 updateValue(columnIndex,x);
683}
684
685
686void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const css::util::Time& x )
687{
688 updateValue(columnIndex,x);
689}
690
691
692void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const css::util::DateTime& x )
693{
694 updateValue(columnIndex,x);
695}
696
697
698void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< css::io::XInputStream >& x, sal_Int32 length )
699{
700 ::osl::MutexGuard aGuard( m_aMutex );
701 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
702
703 if(!x.is())
705
707 x->readBytes(aSeq,length);
708 updateValue(columnIndex,aSeq);
709}
710
711void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< css::io::XInputStream >& x, sal_Int32 length )
712{
713 updateBinaryStream(columnIndex,x,length);
714}
715
717{
718 ::osl::MutexGuard aGuard( m_aMutex );
719 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
720}
721
722void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x )
723{
724 if (!::dbtools::implUpdateObject(this, columnIndex, x))
725 throw SQLException();
726}
727
728
729void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ )
730{
731 if (!::dbtools::implUpdateObject(this, columnIndex, x))
732 throw SQLException();
733}
734
735IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
736{
738 describeProperties(aProps);
739 return new ::cppu::OPropertyArrayHelper(aProps);
740}
741
742IPropertyArrayHelper & OResultSet::getInfoHelper()
743{
744 return *getArrayHelper();
745}
746
747
749 sal_Int32 nFirstOffset,
750 bool bEvaluate,
751 bool bRetrieveData)
752{
753 OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::ExecuteRow: Analyzer isn't set!");
754
755 // For further Fetch-Operations this information may possibly be changed ...
756 IResultSetHelper::Movement eCursorPosition = eFirstCursorPosition;
757 sal_Int32 nOffset = nFirstOffset;
758
759 if (!m_pTable.is())
760 return false;
761
762 const OSQLColumns & rTableCols = *(m_pTable->getTableColumns());
763 bool bHasRestriction = m_pSQLAnalyzer->hasRestriction();
764again:
765
766 // protect from reading over the end when somebody is inserting while we are reading
767 // this method works only for dBase at the moment!!!
768 if (eCursorPosition == IResultSetHelper::NEXT && m_nFilePos == m_nLastVisitedPos)
769 {
770 return false;
771 }
772
773 if (!m_pTable.is() || !m_pTable->seekRow(eCursorPosition, nOffset, m_nFilePos))
774 {
775 return false;
776 }
777
778 if (!bEvaluate) // If no evaluation runs, then just fill the results-row
779 {
780 m_pTable->fetchRow(m_aRow,rTableCols, bRetrieveData);
781 }
782 else
783 {
784 m_pTable->fetchRow(m_aEvaluateRow, rTableCols, bRetrieveData || bHasRestriction);
785
786 if ( ( !m_bShowDeleted
787 && m_aEvaluateRow->isDeleted()
788 )
789 || ( bHasRestriction
791 )
792 )
793 { // Evaluate the next record
794 // delete current row in Keyset
795 if (m_pFileSet.is())
796 {
797 OSL_ENSURE(eCursorPosition == IResultSetHelper::NEXT, "Wrong CursorPosition!");
798 eCursorPosition = IResultSetHelper::NEXT;
799 nOffset = 1;
800 }
801 else if (eCursorPosition == IResultSetHelper::FIRST ||
802 eCursorPosition == IResultSetHelper::NEXT ||
803 eCursorPosition == IResultSetHelper::ABSOLUTE1)
804 {
805 eCursorPosition = IResultSetHelper::NEXT;
806 nOffset = 1;
807 }
808 else if (eCursorPosition == IResultSetHelper::LAST ||
809 eCursorPosition == IResultSetHelper::PRIOR)
810 {
811 eCursorPosition = IResultSetHelper::PRIOR;
812 nOffset = 1;
813 }
814 else if (eCursorPosition == IResultSetHelper::RELATIVE1)
815 {
816 eCursorPosition = (nOffset >= 0) ? IResultSetHelper::NEXT : IResultSetHelper::PRIOR;
817 }
818 else
819 {
820 return false;
821 }
822 // Try again ...
823 goto again;
824 }
825 }
826
827 // Evaluate may only be set,
828 // if the Keyset will be constructed further
830 && !isCount()
831 && bEvaluate
832 )
833 {
834 if (m_pSortIndex)
835 {
836 std::unique_ptr<OKeyValue> pKeyValue = GetOrderbyKeyValue( m_aSelectRow );
837 m_pSortIndex->AddKeyValue(std::move(pKeyValue));
838 }
839 else if (m_pFileSet.is())
840 {
841 sal_uInt32 nBookmarkValue = std::abs((*m_aEvaluateRow)[0]->getValue().getInt32());
842 m_pFileSet->push_back(nBookmarkValue);
843 }
844 }
846 {
847 bool bOK = true;
848 if (bEvaluate)
849 {
850 // read the actual result-row
851 bOK = m_pTable->fetchRow(m_aEvaluateRow, *(m_pTable->getTableColumns()), true);
852 }
853
854 if (bOK)
855 {
856 // just give the values to be changed:
858 return false;
859 }
860 }
862 {
863 bool bOK = true;
864 if (bEvaluate)
865 {
866 bOK = m_pTable->fetchRow(m_aEvaluateRow, *(m_pTable->getTableColumns()), true);
867 }
868 if (bOK)
869 {
870 if(!m_pTable->DeleteRow(*m_xColumns))
871 return false;
872 }
873 }
874 return true;
875}
876
877
878bool OResultSet::Move(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, bool bRetrieveData)
879{
880 sal_Int32 nTempPos = m_nRowPos;
881
883 !isCount())
884 {
885 if (!m_pFileSet.is()) //no Index available
886 {
887 // Normal FETCH
888 ExecuteRow(eCursorPosition,nOffset,false,bRetrieveData);
889
890 // now set the bookmark for outside this is the logical pos and not the file pos
891 *(*m_aRow->begin()) = sal_Int32(m_nRowPos + 1);
892 }
893 else
894 {
895 switch(eCursorPosition)
896 {
898 ++m_nRowPos;
899 break;
901 if (m_nRowPos >= 0)
902 --m_nRowPos;
903 break;
905 m_nRowPos = 0;
906 break;
908 m_nRowPos = m_pFileSet->size() - 1;
909 break;
911 m_nRowPos += nOffset;
912 break;
915 if ( m_nRowPos == (nOffset -1) )
916 return true;
917 m_nRowPos = nOffset -1;
918 break;
919 }
920
921 // OffRange?
922 // The FileCursor is outside of the valid range, if:
923 // a.) m_nRowPos < 1
924 // b.) a KeySet exists and m_nRowPos > m_pFileSet->size()
925 if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && o3tl::make_unsigned(m_nRowPos) >= m_pFileSet->size() )) // && m_pFileSet->IsFrozen()
926 {
927 goto Error;
928 }
929 else
930 {
931 if (m_nRowPos < static_cast<sal_Int32>(m_pFileSet->size()))
932 {
933 // Fetch via Index
934 bool bOK = ExecuteRow(IResultSetHelper::BOOKMARK,(*m_pFileSet)[m_nRowPos],false,bRetrieveData);
935 if (!bOK)
936 goto Error;
937
938 // now set the bookmark for outside
939 *(*m_aRow->begin()) = sal_Int32(m_nRowPos + 1);
940 if ( (bRetrieveData || m_pSQLAnalyzer->hasRestriction()) && m_pSQLAnalyzer->hasFunctions() )
941 {
943 }
944 }
945 else // Index must be further constructed
946 {
947 // set first on the last known row
948 if (m_pFileSet->empty())
949 {
951 }
952 else
953 {
954 m_aFileSetIter = m_pFileSet->end()-1;
956 }
957 bool bOK = true;
958 // Determine the number of further Fetches
959 while (bOK && m_nRowPos >= static_cast<sal_Int32>(m_pFileSet->size()))
960 {
961 bOK = ExecuteRow(IResultSetHelper::NEXT,1,true, false);//bRetrieveData);
962 }
963
964 if (bOK)
965 {
966 // read the results again
967 m_pTable->fetchRow(m_aRow, *(m_pTable->getTableColumns()), bRetrieveData);
968
969 // now set the bookmark for outside
970 *(*m_aRow->begin()) = sal_Int32(m_nRowPos + 1);
971
972 if ( (bRetrieveData || m_pSQLAnalyzer->hasRestriction()) && m_pSQLAnalyzer->hasFunctions() )
973 {
975 }
976 }
977 else if (!m_pFileSet->isFrozen()) // no valid record found
978 {
979 m_pFileSet->setFrozen();
980 goto Error;
981 }
982 }
983 }
984 }
985 }
987 {
988 // Fetch the COUNT(*)
989 switch (eCursorPosition)
990 {
992 ++m_nRowPos;
993 break;
995 --m_nRowPos;
996 break;
998 m_nRowPos = 0;
999 break;
1001 m_nRowPos = 0;
1002 break;
1004 m_nRowPos += nOffset;
1005 break;
1008 m_nRowPos = nOffset - 1;
1009 break;
1010 }
1011
1012 if ( m_nRowPos < 0 )
1013 goto Error;
1014 else if (m_nRowPos == 0)
1015 {
1016 // put COUNT(*) in result-row
1017 // (must be the first and only variable in the row)
1018 if (m_aRow->size() >= 2)
1019 {
1020 *(*m_aRow)[1] = m_nRowCountResult;
1021 *(*m_aRow)[0] = sal_Int32(1);
1022 (*m_aRow)[1]->setBound(true);
1023 (*m_aSelectRow)[1] = (*m_aRow)[1];
1024 }
1025 }
1026 else
1027 {
1028 m_nRowPos = 1;
1029 return false;
1030 }
1031 }
1032 else
1033 // Fetch only possible at SELECT!
1034 return false;
1035
1036 return true;
1037
1038Error:
1039 // is the Cursor positioned before the first row
1040 // then the position will be maintained
1041 if (nTempPos == -1)
1042 m_nRowPos = nTempPos;
1043 else
1044 {
1045 switch(eCursorPosition)
1046 {
1049 m_nRowPos = -1;
1050 break;
1055 if (nOffset > 0)
1056 m_nRowPos = m_pFileSet.is() ? static_cast<sal_Int32>(m_pFileSet->size()) : -1;
1057 else if (nOffset < 0)
1058 m_nRowPos = -1;
1059 break;
1061 m_nRowPos = nTempPos; // last Position
1062 }
1063 }
1064 return false;
1065}
1066
1068{
1070 {
1071 // is just one field given for sorting
1072 // and this field is indexed, then the Index will be used
1074 m_pTable->queryInterface(cppu::UnoType<XIndexesSupplier>::get()) >>= xIndexSup;
1075
1076 Reference<XIndexAccess> xIndexes;
1077 if(xIndexSup.is())
1078 {
1079 xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY);
1080 Reference<XPropertySet> xColProp;
1081 if(m_aOrderbyColumnNumber[0] < xIndexes->getCount())
1082 {
1083 xColProp.set(xIndexes->getByIndex(m_aOrderbyColumnNumber[0]),UNO_QUERY);
1084 // iterate through the indexes to find the matching column
1085 const sal_Int32 nCount = xIndexes->getCount();
1086 for(sal_Int32 i=0; i < nCount;++i)
1087 {
1088 Reference<XColumnsSupplier> xIndex(xIndexes->getByIndex(i),UNO_QUERY);
1089 Reference<XNameAccess> xIndexCols = xIndex->getColumns();
1090 if(xIndexCols->hasByName(comphelper::getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)))))
1091 {
1092 m_pFileSet = new OKeySet();
1093
1094 if(fillIndexValues(xIndex))
1095 return;
1096 }
1097 }
1098 }
1099 }
1100 }
1101
1103 size_t i = 0;
1104 for (auto const& elem : m_aOrderbyColumnNumber)
1105 {
1106 OSL_ENSURE(static_cast<sal_Int32>(m_aSelectRow->size()) > elem,"Invalid Index");
1107 switch ((*(m_aSelectRow->begin()+elem))->getValue().getTypeKind())
1108 {
1109 case DataType::CHAR:
1110 case DataType::VARCHAR:
1111 case DataType::LONGVARCHAR:
1112 eKeyType[i] = OKeyType::String;
1113 break;
1114
1115 case DataType::OTHER:
1116 case DataType::TINYINT:
1117 case DataType::SMALLINT:
1118 case DataType::INTEGER:
1119 case DataType::DECIMAL:
1120 case DataType::NUMERIC:
1121 case DataType::REAL:
1122 case DataType::DOUBLE:
1123 case DataType::DATE:
1124 case DataType::TIME:
1125 case DataType::TIMESTAMP:
1126 case DataType::BIT:
1127 eKeyType[i] = OKeyType::Double;
1128 break;
1129
1130 // Other types aren't implemented (so they are always FALSE)
1131 default:
1132 eKeyType[i] = OKeyType::NONE;
1133 SAL_WARN( "connectivity.drivers","OFILECursor::Execute: Data type not implemented");
1134 break;
1135 }
1136 (*m_aSelectRow)[elem]->setBound(true);
1137 ++i;
1138 }
1139
1140 m_pSortIndex.reset(new OSortIndex(std::move(eKeyType), std::vector(m_aOrderbyAscending)));
1141
1142 while ( ExecuteRow( IResultSetHelper::NEXT, 1, false ) )
1143 {
1144 (*m_aSelectRow)[0]->setValue( (*m_aRow)[0]->getValue() );
1147 const sal_Int32 nBookmark = (*m_aRow->begin())->getValue().getInt32();
1148 ExecuteRow( IResultSetHelper::BOOKMARK, nBookmark, true, false );
1149 }
1150
1151 // create sorted Keyset
1152 m_pFileSet = nullptr;
1153 m_pFileSet = m_pSortIndex->CreateKeySet();
1154 m_pSortIndex.reset();
1155 // now access to a sorted set is possible via Index
1156}
1157
1158
1160{
1161 OSL_ENSURE(m_pSQLAnalyzer,"No analyzer set with setSqlAnalyzer!");
1162 if(!m_pTable.is())
1163 {
1164 const OSQLTables& rTabs = m_aSQLIterator.getTables();
1165 if (rTabs.empty() || !rTabs.begin()->second.is())
1166 lcl_throwError(STR_QUERY_TOO_COMPLEX,*this);
1167
1168 if ( rTabs.size() > 1 || m_aSQLIterator.hasErrors() )
1169 lcl_throwError(STR_QUERY_MORE_TABLES,*this);
1170
1171 OSQLTable xTable = rTabs.begin()->second;
1173
1174 m_xColNames = xTable->getColumns();
1175 m_xColsIdx.set(m_xColNames,UNO_QUERY);
1176 doTableSpecials(xTable);
1177 Reference<XComponent> xComp(xTable,UNO_QUERY);
1178 if(xComp.is())
1179 xComp->addEventListener(this);
1180 }
1181
1182 m_pTable->refreshHeader();
1183
1184 sal_Int32 nColumnCount = m_xColsIdx->getCount();
1185
1186 initializeRow(m_aRow,nColumnCount);
1187 initializeRow(m_aEvaluateRow,nColumnCount);
1188 initializeRow(m_aInsertRow,nColumnCount);
1189
1190
1191 m_nResultSetConcurrency = (m_pTable->isReadOnly() || isCount()) ? ResultSetConcurrency::READ_ONLY : ResultSetConcurrency::UPDATABLE;
1192
1193 // create new Index:
1194 m_pFileSet = nullptr;
1195
1196 // position at the beginning
1197 m_nRowPos = -1;
1198 m_nFilePos = 0;
1199 m_nRowCountResult = -1;
1201
1202 m_nLastVisitedPos = m_pTable->getCurrentLastPos();
1203
1205 {
1207 {
1208 if(isCount())
1209 {
1210 if(m_xColumns->size() > 1)
1211 lcl_throwError(STR_QUERY_COMPLEX_COUNT,*this);
1212
1214 // for now simply iterate over all rows and
1215 // do all actions (or just count)
1216 {
1217 bool bOK = true;
1218 while (bOK)
1219 {
1221
1222 if (bOK)
1223 {
1225 }
1226 }
1227
1228 // save result of COUNT(*) in m_nRowCountResult.
1229 // nRowCount (number of Rows in the result) = 1 for this request!
1230 }
1231 }
1232 else
1233 {
1234 bool bDistinct = false;
1235 assert(m_pParseTree != nullptr);
1236 OSQLParseNode *pDistinct = m_pParseTree->getChild(1);
1237
1238 assert(m_aOrderbyColumnNumber.size() ==
1239 m_aOrderbyAscending.size());
1240 if (pDistinct && pDistinct->getTokenID() == SQL_TOKEN_DISTINCT )
1241 {
1242 // To eliminate duplicates we need to sort on all columns.
1243 // This is not a problem because the SQL spec says that the
1244 // order of columns that are not specified in ORDER BY
1245 // clause is undefined, so it doesn't hurt to sort on
1246 // these; pad the vectors to include them.
1247 for (size_t i = 1; // 0: bookmark (see setBoundedColumns)
1248 i < m_aColMapping.size(); ++i)
1249 {
1250 if (std::find(m_aOrderbyColumnNumber.begin(),
1252 sal::static_int_cast<sal_Int32>(i))
1253 == m_aOrderbyColumnNumber.end())
1254 {
1255 m_aOrderbyColumnNumber.push_back(i);
1256 // ASC or DESC doesn't matter
1258 }
1259 }
1260 bDistinct = true;
1261 }
1262
1263 if (IsSorted())
1264 sortRows();
1265
1266 if (!m_pFileSet.is())
1267 {
1268 m_pFileSet = new OKeySet();
1269
1271 // now the Keyset can be filled!
1272 // But be careful: It is assumed, that the FilePositions will be stored as sequence 1..n
1273 {
1274 if ( m_nLastVisitedPos > 0)
1275 m_pFileSet->reserve( m_nLastVisitedPos );
1276 for (sal_Int32 i = 0; i < m_nLastVisitedPos; i++)
1277 m_pFileSet->push_back(i + 1);
1278 }
1279 }
1280 OSL_ENSURE(m_pFileSet.is(),"No KeySet existing! :-(");
1281
1282 if(bDistinct && m_pFileSet.is())
1283 {
1284 OValueRow aSearchRow = new OValueVector(m_aRow->size());
1285 OValueRefVector::iterator aRowIter = m_aRow->begin();
1286 OValueVector::iterator aSearchIter = aSearchRow->begin();
1287 for ( ++aRowIter,++aSearchIter; // the first column is the bookmark column
1288 aRowIter != m_aRow->end();
1289 ++aRowIter,++aSearchIter)
1290 aSearchIter->setBound((*aRowIter)->isBound());
1291
1292 size_t nMaxRow = m_pFileSet->size();
1293
1294 if (nMaxRow)
1295 {
1296 #if OSL_DEBUG_LEVEL > 1
1297 sal_Int32 nFound=0;
1298 #endif
1299 sal_Int32 nPos;
1300 sal_Int32 nKey;
1301
1302 for( size_t j = nMaxRow-1; j > 0; --j)
1303 {
1304 nPos = (*m_pFileSet)[j];
1307 { // cop*y row values
1308 OValueRefVector::iterator copyFrom = m_aSelectRow->begin();
1309 OValueVector::iterator copyTo = aSearchRow->begin();
1310 for ( ++copyFrom,++copyTo; // the first column is the bookmark column
1311 copyFrom != m_aSelectRow->end();
1312 ++copyFrom,++copyTo)
1313 *copyTo = *(*copyFrom);
1314 }
1315
1316 // compare with next row
1317 nKey = (*m_pFileSet)[j-1];
1320 auto rowsMismatchIters = std::mismatch(std::next(m_aSelectRow->begin()), m_aSelectRow->end(),
1321 std::next(aSearchRow->begin()), // the first column is the bookmark column
1322 [](const OValueRefVector::value_type& a, const OValueVector::value_type& b) {
1323 return !a->isBound() || (*a == b); });
1324
1325 if(rowsMismatchIters.first == m_aSelectRow->end())
1326 (*m_pFileSet)[j] = 0; // Rows match -- Mark for deletion by setting key to 0
1327 #if OSL_DEBUG_LEVEL > 1
1328 else
1329 nFound++;
1330 #endif
1331 }
1332
1333 m_pFileSet->erase(std::remove(m_pFileSet->begin(),m_pFileSet->end(),0)
1334 ,m_pFileSet->end());
1335 }
1336 }
1337 }
1338 } break;
1339
1342 // during processing count the number of processed Rows
1344 // for now simply iterate over all rows and
1345 // run the actions (or simply count):
1346 {
1347
1348 bool bOK = true;
1349 while (bOK)
1350 {
1352
1353 if (bOK)
1354 {
1356 }
1357 }
1358
1359 // save result of COUNT(*) in nRowCountResult.
1360 // nRowCount (number of rows in the result-set) = 1 for this request!
1361 }
1362 break;
1365
1366 OSL_ENSURE(m_aAssignValues.is(),"No assign values set!");
1367 if(!m_pTable->InsertRow(*m_aAssignValues, m_xColsIdx))
1368 {
1369 m_nFilePos = 0;
1370 return;
1371 }
1372
1374 break;
1375 default:
1376 SAL_WARN( "connectivity.drivers", "OResultSet::OpenImpl: unsupported statement type!" );
1377 break;
1378 }
1379
1380 // reset FilePos
1381 m_nFilePos = 0;
1382}
1383
1385 const OValueRefRow& _rSelectRow,
1386 const ::rtl::Reference<connectivity::OSQLColumns>& _rxColumns,
1387 const Reference<XIndexAccess>& _xNames,
1388 bool _bSetColumnMapping,
1389 const Reference<XDatabaseMetaData>& _xMetaData,
1390 std::vector<sal_Int32>& _rColMapping)
1391{
1392 ::comphelper::UStringMixEqual aCase(_xMetaData->supportsMixedCaseQuotedIdentifiers());
1393
1394 Reference<XPropertySet> xTableColumn;
1395 OUString sTableColumnName, sSelectColumnRealName;
1396
1400
1401 std::map<OSQLColumns::iterator,bool> aSelectIters;
1402 OValueRefVector::const_iterator aRowIter = _rRow->begin()+1;
1403 for (sal_Int32 i=0; // the first column is the bookmark column
1404 aRowIter != _rRow->end();
1405 ++i, ++aRowIter
1406 )
1407 {
1408 (*aRowIter)->setBound(false);
1409 try
1410 {
1411 // get the table column and its name
1412 _xNames->getByIndex(i) >>= xTableColumn;
1413 OSL_ENSURE(xTableColumn.is(), "OResultSet::setBoundedColumns: invalid table column!");
1414 if (xTableColumn.is())
1415 xTableColumn->getPropertyValue(sName) >>= sTableColumnName;
1416 else
1417 sTableColumnName.clear();
1418
1419 // look if we have such a select column
1420 // TODO: would like to have a O(log n) search here ...
1421 for ( OSQLColumns::iterator aIter = _rxColumns->begin();
1422 aIter != _rxColumns->end();
1423 ++aIter
1424 )
1425 {
1426 if((*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName))
1427 (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName;
1428 else
1429 (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName;
1430
1431 if ( aCase(sTableColumnName, sSelectColumnRealName) && !(*aRowIter)->isBound() && aSelectIters.end() == aSelectIters.find(aIter) )
1432 {
1433 aSelectIters.emplace(aIter,true);
1434 if(_bSetColumnMapping)
1435 {
1436 sal_Int32 nSelectColumnPos = aIter - _rxColumns->begin() + 1;
1437 // the getXXX methods are 1-based ...
1438 sal_Int32 nTableColumnPos = i + 1;
1439 // get first table column is the bookmark column ...
1440 _rColMapping[nSelectColumnPos] = nTableColumnPos;
1441 (*_rSelectRow)[nSelectColumnPos] = *aRowIter;
1442 }
1443
1444 (*aRowIter)->setBound(true);
1445 sal_Int32 nType = DataType::OTHER;
1446 if (xTableColumn.is())
1447 xTableColumn->getPropertyValue(sType) >>= nType;
1448 (*aRowIter)->setTypeKind(nType);
1449
1450 break;
1451 }
1452 }
1453 }
1454 catch (Exception&)
1455 {
1456 TOOLS_WARN_EXCEPTION( "connectivity.drivers","");
1457 }
1458 }
1459 // in this case we got more select columns as columns exist in the table
1460 if ( !(_bSetColumnMapping && aSelectIters.size() != _rColMapping.size()) )
1461 return;
1462
1463 Reference<XNameAccess> xNameAccess(_xNames,UNO_QUERY);
1464 Sequence< OUString > aSelectColumns = xNameAccess->getElementNames();
1465
1466 for ( OSQLColumns::iterator aIter = _rxColumns->begin();
1467 aIter != _rxColumns->end();
1468 ++aIter
1469 )
1470 {
1471 if ( aSelectIters.end() == aSelectIters.find(aIter) )
1472 {
1473 if ( (*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName) )
1474 (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName;
1475 else
1476 (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName;
1477
1478 if ( xNameAccess->hasByName( sSelectColumnRealName ) )
1479 {
1480 aSelectIters.emplace(aIter,true);
1481 sal_Int32 nSelectColumnPos = aIter - _rxColumns->begin() + 1;
1482 const OUString* pBegin = aSelectColumns.getConstArray();
1483 const OUString* pEnd = pBegin + aSelectColumns.getLength();
1484 for(sal_Int32 i=0;pBegin != pEnd;++pBegin,++i)
1485 {
1486 if ( aCase(*pBegin, sSelectColumnRealName) )
1487 {
1488 // the getXXX methods are 1-based ...
1489 sal_Int32 nTableColumnPos = i + 1;
1490 // get first table column is the bookmark column ...
1491 _rColMapping[nSelectColumnPos] = nTableColumnPos;
1492 (*_rSelectRow)[nSelectColumnPos] = (*_rRow)[nTableColumnPos];
1493 break;
1494 }
1495 }
1496 }
1497 }
1498 }
1499}
1500
1501void SAL_CALL OResultSet::acquire() noexcept
1502{
1503 OResultSet_BASE::acquire();
1504}
1505
1506void SAL_CALL OResultSet::release() noexcept
1507{
1508 OResultSet_BASE::release();
1509}
1510
1512{
1513 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
1514}
1515
1517{
1518 m_pTable = dynamic_cast<OFileTable*>(_xTable.get());
1519 assert(m_pTable.is());
1520}
1521
1523{
1524 m_aRow->setDeleted(false); // set to false here because this is the new row
1525 sal_Int32 nPos = 0;
1527 {
1528 if ( rValue->isBound() )
1529 {
1530 (*m_aRow)[nPos]->setValue( rValue->getValue() );
1531 }
1532 rValue->setBound(nPos == 0);
1533 rValue->setModified(false);
1534 rValue->setNull();
1535 ++nPos;
1536 }
1537}
1538
1539void OResultSet::initializeRow(OValueRefRow& _rRow,sal_Int32 _nColumnCount)
1540{
1541 if(!_rRow.is())
1542 {
1543 _rRow = new OValueRefVector(_nColumnCount);
1544 (*_rRow)[0]->setBound(true);
1545 std::for_each(_rRow->begin()+1,_rRow->end(),TSetRefBound(false));
1546 }
1547}
1548
1550{
1551 return false;
1552}
1553
1554bool OResultSet::move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, bool _bRetrieveData)
1555{
1556 return Move(_eCursorPosition,_nOffset,_bRetrieveData);
1557}
1558
1560{
1561 return (*m_aRow)[0]->getValue().getInt32();
1562}
1563
1565{
1566 return m_aRow->isDeleted();
1567}
1568
1569void SAL_CALL OResultSet::disposing( const EventObject& Source )
1570{
1572 if(m_pTable.is() && Source.Source == xProp)
1573 {
1574 m_pTable.clear();
1575 }
1576}
1577
1578
1579/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.drivers.file.ResultSet","com.sun.star.sdbc.ResultSet")
OptionalString sType
::cppu::IPropertyArrayHelper * getArrayHelper()
void describeProperties(css::uno::Sequence< css::beans::Property > &_rProps) const
void registerProperty(const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void *_pPointerToMember, const css::uno::Type &_rMemberType)
void disposing(std::unique_lock< std::mutex > &rGuard)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
The class OKeySet is a refcountable vector which also has a state.
Definition: TSortIndex.hxx:99
::dbtools::OPropertyMap & getPropMap()
Definition: TConnection.cxx:68
css::util::Time getTime() const
Definition: FValue.cxx:1951
sal_Int32 getInt32() const
Definition: FValue.cxx:1377
OUString getString() const
Definition: FValue.cxx:933
css::uno::Any makeAny() const
Definition: FValue.cxx:837
sal_Int8 getInt8() const
Definition: FValue.cxx:1089
float getFloat() const
Definition: FValue.cxx:1669
sal_Int16 getInt16() const
Definition: FValue.cxx:1235
css::util::Date getDate() const
Definition: FValue.cxx:1893
css::util::DateTime getDateTime() const
Definition: FValue.cxx:1995
sal_Int64 getLong() const
Definition: FValue.cxx:1523
double getDouble() const
Definition: FValue.cxx:1745
css::uno::Sequence< sal_Int8 > getSequence() const
Definition: FValue.cxx:1821
sal_uInt32 getTokenID() const
Definition: sqlnode.hxx:350
OSQLParseNode * getChild(sal_uInt32 nPos) const
Definition: sqlnode.hxx:433
const ::rtl::Reference< OSQLColumns > & getSelectColumns() const
const OSQLTables & getTables() const
OSQLStatementType getStatementType() const
void clear()
clear the map and the vector used in this class
void SetDeletedVisible(bool _bDeletedVisible)
sal_Int32 getMappedPosition(sal_Int32 _nBookmark) const
getMappedPosition returns the mapped position of a logical position
void insertNewPosition(sal_Int32 _nPos)
insertNewPosition adds a new position to the map
bool skipDeleted(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, bool _bRetrieveData)
skipDeleted moves the resultset to the position defined by the parameters it guarantees that the row ...
void deletePosition(sal_Int32 _nPos)
deletePosition deletes this position from the map and decrement all following positions
The class OSortIndex can be used to implement a sorted index.
Definition: TSortIndex.hxx:47
std::vector< OKeyType > TKeyTypeVector
Definition: TSortIndex.hxx:50
helper class for accessing resources shared by different libraries in the connectivity module
OUString getResourceString(TranslateId pResId) const
loads a string from the shared resource file
void doTableSpecials(const OSQLTable &_xTable)
virtual void SAL_CALL updateCharacterStream(sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length) override
std::unique_ptr< OKeyValue > GetOrderbyKeyValue(OValueRefRow const &_rRow)
virtual bool isRowDeleted() const override
virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:289
virtual sal_Bool SAL_CALL rowUpdated() override
Definition: FResultSet.cxx:457
virtual sal_Int32 SAL_CALL getInt(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:255
virtual sal_Bool SAL_CALL first() override
Definition: FResultSet.cxx:393
void checkIndex(sal_Int32 columnIndex)
Definition: FResultSet.cxx:201
virtual void SAL_CALL updateTime(sal_Int32 columnIndex, const css::util::Time &x) override
Definition: FResultSet.cxx:686
virtual css::util::Time SAL_CALL getTime(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:328
virtual css::util::DateTime SAL_CALL getTimestamp(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:333
virtual sal_Bool SAL_CALL absolute(sal_Int32 row) override
Definition: FResultSet.cxx:409
virtual void SAL_CALL updateDouble(sal_Int32 columnIndex, double x) override
Definition: FResultSet.cxx:665
virtual float SAL_CALL getFloat(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:249
std::vector< sal_Int32 > m_aColMapping
Definition: FResultSet.hxx:68
virtual void SAL_CALL deleteRow() override
Definition: FResultSet.cxx:545
virtual css::util::Date SAL_CALL getDate(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:237
virtual sal_Bool SAL_CALL relative(sal_Int32 rows) override
Definition: FResultSet.cxx:416
virtual void SAL_CALL clearWarnings() override
Definition: FResultSet.cxx:498
virtual void SAL_CALL updateBytes(sal_Int32 columnIndex, const css::uno::Sequence< sal_Int8 > &x) override
::rtl::Reference< connectivity::OSQLColumns > m_xColumns
Definition: FResultSet.hxx:86
virtual bool move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, bool _bRetrieveData) override
virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:295
css::uno::Reference< css::sdbc::XResultSetMetaData > m_xMetaData
Definition: FResultSet.hxx:99
virtual void SAL_CALL updateNumericObject(sal_Int32 columnIndex, const css::uno::Any &x, sal_Int32 scale) override
virtual void SAL_CALL close() override
Definition: FResultSet.cxx:387
virtual sal_Bool SAL_CALL isLast() override
Definition: FResultSet.cxx:357
virtual sal_Int32 getDriverPos() const override
css::uno::Reference< css::uno::XInterface > m_xStatement
Definition: FResultSet.hxx:98
virtual void SAL_CALL updateString(sal_Int32 columnIndex, const OUString &x) override
Definition: FResultSet.cxx:670
const ORowSetValue & getValue(sal_Int32 columnIndex)
Definition: FResultSet.cxx:189
virtual sal_Bool SAL_CALL isFirst() override
Definition: FResultSet.cxx:348
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
Definition: FResultSet.cxx:735
virtual sal_Int64 SAL_CALL getLong(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:272
virtual void SAL_CALL updateLong(sal_Int32 columnIndex, sal_Int64 x) override
Definition: FResultSet.cxx:654
rtl::Reference< OFileTable > m_pTable
Definition: FResultSet.hxx:87
virtual sal_Bool SAL_CALL next() override
Definition: FResultSet.cxx:476
virtual void SAL_CALL beforeFirst() override
Definition: FResultSet.cxx:366
virtual void SAL_CALL updateByte(sal_Int32 columnIndex, sal_Int8 x) override
Definition: FResultSet.cxx:638
virtual ~OResultSet() override
Definition: FResultSet.cxx:111
virtual sal_Int16 SAL_CALL getShort(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:318
virtual css::uno::Any SAL_CALL getWarnings() override
Definition: FResultSet.cxx:502
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: FResultSet.cxx:156
std::vector< TAscendingOrder > m_aOrderbyAscending
Definition: FResultSet.hxx:71
connectivity::OSQLParseTreeIterator & m_aSQLIterator
Definition: FResultSet.hxx:91
virtual void SAL_CALL updateFloat(sal_Int32 columnIndex, float x) override
Definition: FResultSet.cxx:659
virtual sal_Int8 SAL_CALL getByte(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:225
virtual void SAL_CALL updateBoolean(sal_Int32 columnIndex, sal_Bool x) override
Definition: FResultSet.cxx:633
virtual double SAL_CALL getDouble(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:243
virtual void SAL_CALL updateInt(sal_Int32 columnIndex, sal_Int32 x) override
Definition: FResultSet.cxx:649
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:231
virtual void SAL_CALL moveToInsertRow() override
Definition: FResultSet.cxx:590
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
Definition: FResultSet.cxx:278
virtual sal_Int32 SAL_CALL findColumn(const OUString &columnName) override
Definition: FResultSet.cxx:168
virtual sal_Bool SAL_CALL isAfterLast() override
Definition: FResultSet.cxx:339
virtual void SAL_CALL afterLast() override
Definition: FResultSet.cxx:376
virtual void SAL_CALL release() noexcept override
static void setBoundedColumns(const OValueRefRow &_rRow, const OValueRefRow &_rSelectRow, const ::rtl::Reference< connectivity::OSQLColumns > &_rxColumns, const css::uno::Reference< css::container::XIndexAccess > &_xNames, bool _bSetColumnMapping, const css::uno::Reference< css::sdbc::XDatabaseMetaData > &_xMetaData, std::vector< sal_Int32 > &_rColMapping)
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:213
void updateValue(sal_Int32 columnIndex, const ORowSetValue &x)
Definition: FResultSet.cxx:613
virtual sal_Bool SAL_CALL isBeforeFirst() override
Definition: FResultSet.cxx:467
static void initializeRow(OValueRefRow &_rRow, sal_Int32 _nColumnCount)
virtual void SAL_CALL updateTimestamp(sal_Int32 columnIndex, const css::util::DateTime &x) override
Definition: FResultSet.cxx:692
OKeySet::iterator m_aFileSetIter
Definition: FResultSet.hxx:82
virtual sal_Bool SAL_CALL last() override
Definition: FResultSet.cxx:401
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
Definition: FResultSet.cxx:742
connectivity::OSQLParseNode * m_pParseTree
Definition: FResultSet.hxx:88
virtual void SAL_CALL insertRow() override
Definition: FResultSet.cxx:507
::rtl::Reference< OKeySet > m_pFileSet
Definition: FResultSet.hxx:81
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL updateRow() override
Definition: FResultSet.cxx:531
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
ORefAssignValues m_aAssignValues
Definition: FResultSet.hxx:77
virtual bool fillIndexValues(const css::uno::Reference< css::sdbcx::XColumnsSupplier > &_xIndex)
virtual void SAL_CALL updateShort(sal_Int32 columnIndex, sal_Int16 x) override
Definition: FResultSet.cxx:644
virtual void SAL_CALL refreshRow() override
Definition: FResultSet.cxx:716
virtual void SAL_CALL disposing() override final
Definition: FResultSet.cxx:125
virtual void SAL_CALL updateNull(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:626
bool ExecuteRow(IResultSetHelper::Movement eFirstCursorPosition, sal_Int32 nOffset=1, bool bEvaluate=true, bool bRetrieveData=true)
Definition: FResultSet.cxx:748
virtual sal_Bool SAL_CALL previous() override
Definition: FResultSet.cxx:423
virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:306
virtual OUString SAL_CALL getString(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:323
virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:300
virtual sal_Bool SAL_CALL rowInserted() override
Definition: FResultSet.cxx:449
virtual void SAL_CALL cancel() override
Definition: FResultSet.cxx:494
virtual void SAL_CALL moveToCurrentRow() override
Definition: FResultSet.cxx:609
sal_Int32 mapColumn(sal_Int32 column)
Definition: FResultSet.hxx:286
std::unique_ptr< OSortIndex > m_pSortIndex
Definition: FResultSet.hxx:85
css::uno::Reference< css::container::XNameAccess > m_xColNames
Definition: FResultSet.hxx:100
std::vector< sal_Int32 > m_aOrderbyColumnNumber
Definition: FResultSet.hxx:70
virtual sal_Bool SAL_CALL wasNull() override
Definition: FResultSet.cxx:485
virtual sal_Bool SAL_CALL getBoolean(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:219
css::uno::Reference< css::container::XIndexAccess > m_xColsIdx
Definition: FResultSet.hxx:101
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement() override
Definition: FResultSet.cxx:430
virtual void SAL_CALL cancelRowUpdates() override
Definition: FResultSet.cxx:567
OSkipDeletedSet m_aSkipDeletedSet
Definition: FResultSet.hxx:79
bool Move(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, bool bRetrieveData)
Definition: FResultSet.cxx:878
virtual sal_Bool SAL_CALL rowDeleted() override
Definition: FResultSet.cxx:440
virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream(sal_Int32 columnIndex) override
Definition: FResultSet.cxx:208
virtual void SAL_CALL updateObject(sal_Int32 columnIndex, const css::uno::Any &x) override
virtual sal_Int32 SAL_CALL getRow() override
Definition: FResultSet.cxx:261
virtual void SAL_CALL updateBinaryStream(sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual void SAL_CALL updateDate(sal_Int32 columnIndex, const css::util::Date &x) override
Definition: FResultSet.cxx:680
void setSelectionEvaluationResult(OValueRefRow const &_pRow, const std::vector< sal_Int32 > &_rColumnMapping)
Definition: fanalyzer.cxx:168
mutable::osl::Mutex m_aMutex
const OUString & getNameByIndex(sal_Int32 _nIndex) const
Definition: propertyids.cxx:95
sal_Int32 _nOffset
int nCount
#define TOOLS_WARN_EXCEPTION(area, stream)
ULONG m_refCount
float x
OUString sName
std::mutex m_aMutex
uno_Any a
sal_uInt16 nPos
Sequence< sal_Int8 > aSeq
#define SAL_WARN(area, stream)
@ Exception
OUString getString(const Any &_rAny)
Type
::cppu::WeakComponentImplHelper< css::sdbc::XResultSet, css::sdbc::XRow, css::sdbc::XResultSetMetaDataSupplier, css::util::XCancellable, css::sdbc::XWarningsSupplier, css::sdbc::XResultSetUpdate, css::sdbc::XRowUpdate, css::sdbc::XCloseable, css::sdbc::XColumnLocate, css::lang::XServiceInfo, css::lang::XEventListener > OResultSet_BASE
Definition: FResultSet.hxx:57
std::map< OUString, OSQLTable, comphelper::UStringMixLess > OSQLTables
Definition: CommonTools.hxx:56
css::uno::Reference< css::sdbcx::XColumnsSupplier > OSQLTable
Definition: CommonTools.hxx:54
ODeleteVector< ORowSetValue > OValueVector
Definition: FValue.hxx:457
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
Error
void throwFunctionSequenceException(const Reference< XInterface > &Context, const Any &Next)
void throwInvalidIndexException(const css::uno::Reference< css::uno::XInterface > &Context, const css::uno::Any &Next)
throw an invalid index sqlexception
void throwFeatureNotImplementedSQLException(const OUString &_rFeatureName, const Reference< XInterface > &_rxContext, const Any &_rNextException)
void throwInvalidColumnException(const OUString &_rColumnName, const Reference< XInterface > &_rxContext)
void throwGenericSQLException(const OUString &_rMsg, const css::uno::Reference< css::uno::XInterface > &_rxSource)
throw a generic SQLException, i.e.
bool implUpdateObject(const Reference< XRowUpdate > &_rxUpdatedObject, const sal_Int32 _nColumnIndex, const Any &_rValue)
Definition: dbtools.cxx:1427
int i
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
void dispose()
const char * columnName
Definition: pq_statics.cxx:56
#define PROPERTY_ID_NAME
Definition: propertyids.hxx:50
#define PROPERTY_ID_RESULTSETTYPE
Definition: propertyids.hxx:44
#define PROPERTY_ID_TYPE
Definition: propertyids.hxx:51
#define PROPERTY_ID_RESULTSETCONCURRENCY
Definition: propertyids.hxx:43
#define PROPERTY_ID_FETCHSIZE
Definition: propertyids.hxx:46
#define PROPERTY_ID_REALNAME
Definition: propertyids.hxx:79
#define PROPERTY_ID_FETCHDIRECTION
Definition: propertyids.hxx:45
QPRO_FUNC_TYPE nType
OUString sMessage
#define SQL_ISRULE(pParseNode, eRule)
Definition: sqlnode.hxx:439
TSetBound is a functor to set the bound value with e.q. for_each call.
Definition: FValue.hxx:436
unsigned char sal_Bool
signed char sal_Int8
const SvXMLTokenMapEntry aTypes[]