diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-08-29 11:21:08 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-08-29 11:21:08 +0000 |
commit | b3b894be722f9aad6d8a05bc2455ba9af490f9e2 (patch) | |
tree | 14ef9ab83c4f8af4f45fff5493d569a20f4ba15d /connectivity/source/drivers/file | |
parent | 8cf6106c855901bd2ec6a959ad6e93f3686ec143 (diff) |
#84578# fixes for resultset
Diffstat (limited to 'connectivity/source/drivers/file')
-rw-r--r-- | connectivity/source/drivers/file/FDatabaseMetaData.cxx | 16 | ||||
-rw-r--r-- | connectivity/source/drivers/file/FNoException.cxx | 268 | ||||
-rw-r--r-- | connectivity/source/drivers/file/FResultSet.cxx | 116 | ||||
-rw-r--r-- | connectivity/source/drivers/file/FStatement.cxx | 29 |
4 files changed, 82 insertions, 347 deletions
diff --git a/connectivity/source/drivers/file/FDatabaseMetaData.cxx b/connectivity/source/drivers/file/FDatabaseMetaData.cxx index 598a9180e87a..959bbe0221ae 100644 --- a/connectivity/source/drivers/file/FDatabaseMetaData.cxx +++ b/connectivity/source/drivers/file/FDatabaseMetaData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FDatabaseMetaData.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:08:38 $ + * last change: $Author: oj $ $Date: 2001-08-29 12:15:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -245,7 +245,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( sal_Unicode nChar = aName.toChar(); if(match(tableNamePattern,aName.getStr(),'\0') && (nChar < '0' || nChar > '9')) { - aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(aName)); + aRow.push_back(new ORowSetValueDecorator(aName)); bNewRow = sal_True; } } @@ -260,7 +260,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( sal_Unicode nChar = aURL.getBase().GetChar(0); if(match(tableNamePattern,aURL.getBase().GetBuffer(),'\0') && (nChar < '0' || nChar > '9')) { - aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString(aURL.getBase()))); + aRow.push_back(new ORowSetValueDecorator(::rtl::OUString(aURL.getBase()))); bNewRow = sal_True; } break; @@ -274,7 +274,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( } if(bNewRow) { - aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(aTable)); + aRow.push_back(new ORowSetValueDecorator(aTable)); aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRows.push_back(aRow); @@ -446,9 +446,9 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( { static ODatabaseMetaDataResultSet::ORow aRow(8); - aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(*pBegin); + aRow[2] = new ORowSetValueDecorator(*pBegin); aRow[6] = ODatabaseMetaDataResultSet::getSelectValue(); - aRow[7] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO")); + aRow[7] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO")); aRows.push_back(aRow); Reference< XPropertySet> xTable; @@ -701,7 +701,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLE { ODatabaseMetaDataResultSet::ORow aRow; aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); - aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("TABLE"))); + aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TABLE"))); aRows.push_back(aRow); } pResult->setRows(aRows); diff --git a/connectivity/source/drivers/file/FNoException.cxx b/connectivity/source/drivers/file/FNoException.cxx index 0117eb0c238b..843ce25f54c1 100644 --- a/connectivity/source/drivers/file/FNoException.cxx +++ b/connectivity/source/drivers/file/FNoException.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FNoException.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:08:38 $ + * last change: $Author: oj $ $Date: 2001-08-29 12:15:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -79,6 +79,9 @@ #ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> #endif +#ifndef CONNECTIVITY_TKEYVALUE_HXX +#include "TKeyValue.hxx" +#endif using namespace connectivity; using namespace connectivity::file; @@ -157,265 +160,16 @@ void OPreparedStatement::scanParameter(OSQLParseNode* pParseNode,::std::vector< scanParameter(pParseNode->getChild(i),_rParaNodes); } // ----------------------------------------------------------------------------- -//------------------------------------------------------------------ -int -#if defined(WIN) || defined(WNT) -__cdecl -#endif -#if defined(ICC) && defined(OS2) -_Optlink -#endif -connectivity::file::OFILEKeyCompare(const void * elem1, const void * elem2) -{ - const OFILESortIndex * pIndex = OFILESortIndex::pCurrentIndex; - const OFILEKeyValue * pKeyValue1 = (OFILEKeyValue *) * (OFILEKeyValue **) elem1; - const OFILEKeyValue * pKeyValue2 = (OFILEKeyValue *) * (OFILEKeyValue **) elem2; - - // Ueber die (max.) drei ORDER BY-Columns iterieren. Abbruch des Vergleiches, wenn Ungleichheit erkannt - // oder alle Columns gleich. - for (UINT16 i = 0; i < SQL_ORDERBYKEYS && pIndex->eKeyType[i] != SQL_ORDERBYKEY_NONE; i++) - { - const int nGreater = (pIndex->m_aAscending[i]) ? 1 : -1; - const int nLess = - nGreater; - - // Vergleich (je nach Datentyp): - switch (pIndex->eKeyType[i]) - { - case SQL_ORDERBYKEY_STRING: - { - INT32 nRes = pKeyValue1->GetKeyString(i)->compareTo(*pKeyValue2->GetKeyString(i)); - if (nRes < 0) - return nLess; - else if (nRes > 0) - return nGreater; - } - break; - case SQL_ORDERBYKEY_DOUBLE: - { - double d1 = pKeyValue1->GetKeyDouble(i); - double d2 = pKeyValue2->GetKeyDouble(i); - - if (d1 < d2) - return nLess; - else if (d1 > d2) - return nGreater; - } - break; - } - } - - // Wenn wir bis hierher gekommen sind, waren alle Werte gleich: - return 0; -} -// ----------------------------------------------------------------------------- -//------------------------------------------------------------------ -OKeySet* OFILESortIndex::CreateKeySet() -{ - - OSL_ENSURE(! bFrozen,"OFILESortIndex::Freeze: already frozen!"); - - // Kritischer Bereich: Hinterlegung von this in statischer Variable. - // Zugriff auf diese Variable von der OFILECompare-Funktion aus. - // Da dies NUR waehrend der Ausfuehrung der qsort-Funktion stattfindet, - // ist dies aber unkritisch: unter Windows 3.x ist diese Ausfuehrung - // UNUNTERBRECHBAR; unter NT, OS/2, Unix, ... hat jede DLL ihr - // eigenes Datensegment. - pCurrentIndex = this; - eCurrentCharSet = eCharSet; - - // Sortierung: - if (eKeyType[0] != SQL_ORDERBYKEY_NONE) - // Sortierung, wenn mindestens nach dem ersten Key sortiert werden soll: - qsort(ppKeyValueArray,nCount,sizeof(void *),&OFILEKeyCompare); - - - // Ende des kritischen Bereiches - pCurrentIndex = NULL; - - - OKeySet* pKeySet = new OKeySet(nCount); - OKeySet::iterator aIter = pKeySet->begin(); - for (INT32 i = 0; i < nCount; i++,++aIter) - { - OFILEKeyValuePtr pKeyValue = ppKeyValueArray[i]; - - OSL_ENSURE(pKeyValue != NULL,"OFILESortIndex::Freeze: pKeyValue == NULL"); - (*aIter) = pKeyValue->GetValue(); // Wert holen ... - - // Strings in KeyValue freigeben! - for (int j = 0; j < SQL_ORDERBYKEYS; j++) - { - if (eKeyType[j] == SQL_ORDERBYKEY_STRING) - delete pKeyValue->GetKeyString(j); - } - delete pKeyValue; - } - bFrozen = TRUE; - pKeySet->setFrozen(); - return pKeySet; -} -// ----------------------------------------------------------------------------- -OFILESortIndex * OFILESortIndex::pCurrentIndex; -CharSet OFILESortIndex::eCurrentCharSet; -//------------------------------------------------------------------ -OFILESortIndex::OFILESortIndex(const OKeyType eKeyType2[], // Genau 3 Eintraege! - const ::std::vector<sal_Int16>& _aAscending, // Genau 3 Eintraege! - INT32 nMaxNumberOfRows, rtl_TextEncoding eSet) // Obere Schranke fuer die Anzahl indizierbarer Zeilen - : nMaxCount(nMaxNumberOfRows), - nCount(0), - bFrozen(FALSE), - eCharSet(eSet), - m_aAscending(_aAscending) -{ - for (int j = 0; j < SQL_ORDERBYKEYS; j++) - { - eKeyType[j] = eKeyType2[j]; - } - -#if defined MAX_KEYSET_SIZE - // Zur Sicherheit Maximalgroesse nochmal pruefen: - if (nMaxCount > MAX_KEYSET_SIZE) - { - DBG_WARNING("OFILESortIndex::OFILESortIndex: nMaxNumberOfRows zur Zeit auf <16K beschraenkt!"); - nMaxCount = MAX_KEYSET_SIZE; - } -#endif - if (nMaxCount <= 0) - nMaxCount = USHORT(-1); - - ppKeyValueArray = new OFILEKeyValuePtr[nMaxCount]; - - for (INT32 i = 0; i < nMaxCount; i++) - ppKeyValueArray[i] = NULL; -} - -//------------------------------------------------------------------ -OFILESortIndex::~OFILESortIndex() -{ - __DELETE(nMaxCount) ppKeyValueArray; -} - - -//------------------------------------------------------------------ -BOOL OFILESortIndex::AddKeyValue(OFILEKeyValue * pKeyValue) -{ - if (nCount < nMaxCount) - { - if (bFrozen) // wenn der Index schon eingefroren - // dann wird der Key einfach ans Ende gehaengt - { - OSL_ENSURE(pKeyValue != NULL,"OFILESortIndex::Freeze: pKeyValue == NULL"); - INT32 nValue = pKeyValue->GetValue(); // Wert holen ... - - // Strings in KeyValue freigeben! - for (int j = 0; j < SQL_ORDERBYKEYS; j++) - { - if (eKeyType[j] == SQL_ORDERBYKEY_STRING) - delete pKeyValue->GetKeyString(j); - } - delete pKeyValue; - ppKeyValueArray[nCount++] = (OFILEKeyValuePtr) nValue; - } - else - ppKeyValueArray[nCount++] = pKeyValue; - return TRUE; - } - else - return FALSE; -} - - -//------------------------------------------------------------------ -void OFILESortIndex::Freeze() -{ - OSL_ENSURE(! bFrozen,"OFILESortIndex::Freeze: already frozen!"); - - // Kritischer Bereich: Hinterlegung von this in statischer Variable. - // Zugriff auf diese Variable von der OFILECompare-Funktion aus. - // Da dies NUR waehrend der Ausfuehrung der qsort-Funktion stattfindet, - // ist dies aber unkritisch: unter Windows 3.x ist diese Ausfuehrung - // UNUNTERBRECHBAR; unter NT, OS/2, Unix, ... hat jede DLL ihr - // eigenes Datensegment. - pCurrentIndex = this; - eCurrentCharSet = eCharSet; - - // Sortierung: - if (eKeyType[0] != SQL_ORDERBYKEY_NONE) - // Sortierung, wenn mindestens nach dem ersten Key sortiert werden soll: - qsort(ppKeyValueArray,nCount,sizeof(void *),&OFILEKeyCompare); - - - // Ende des kritischen Bereiches - pCurrentIndex = NULL; - - // Wert auslesen, KeyValue loeschen und in den void * den Value - // reinschreiben (uebler Trick mit Typecast!) - for (INT32 i = 0; i < nCount; i++) - { - OFILEKeyValuePtr pKeyValue = ppKeyValueArray[i]; - - OSL_ENSURE(pKeyValue != NULL,"OFILESortIndex::Freeze: pKeyValue == NULL"); - INT32 nValue = pKeyValue->GetValue(); // Wert holen ... - - // Strings in KeyValue freigeben! - for (int j = 0; j < SQL_ORDERBYKEYS; j++) - { - if (eKeyType[j] == SQL_ORDERBYKEY_STRING) - delete pKeyValue->GetKeyString(j); - } - delete pKeyValue; - ppKeyValueArray[i] = (OFILEKeyValuePtr) nValue; - } - - bFrozen = TRUE; -} - -//------------------------------------------------------------------ -INT32 OFILESortIndex::GetValue(INT32 nPos) const -{ - OSL_ENSURE(nPos > 0,"OFILESortIndex::GetValue: nPos == 0"); - OSL_ENSURE(nPos <= nCount,"OFILESortIndex::GetValue: Zugriff ausserhalb der Array-Grenzen"); - -// OSL_ENSURE(ppKeyValueArray[nPos-1] != NULL,"OFILESortIndex::GetValue: interner Fehler: kein KeyValue an dieser Stelle"); -// return ppKeyValueArray[nPos-1]->GetValue(); - - if (!bFrozen) - { - if (eKeyType[0] == SQL_ORDERBYKEY_NONE) // wenn keine Sortierung vorliegt - // darf auf die Values schon vorher zugegriffen werden - return ppKeyValueArray[nPos-1]->GetValue(); - else - { - OSL_ASSERT("OFILESortIndex::GetValue: Invalid use of index!"); - return 0; - } - } - else - return (INT32) ppKeyValueArray[nPos-1]; // Trick: nach Freeze sind hier nur noch Values, keine KeyValue-Strukturen mehr! - -} -// ----------------------------------------------------------------------------- -OFILEKeyValue* OResultSet::GetOrderbyKeyValue(OValueRow _rRow) +OKeyValue* OResultSet::GetOrderbyKeyValue(OValueRow _rRow) { UINT32 nBookmarkValue = Abs((sal_Int32)(*_rRow)[0]); - OFILEKeyValue* pKeyValue = new OFILEKeyValue((UINT32)nBookmarkValue); - for (int i = 0; i < m_aOrderbyColumnNumber.size(); ++i) - { - if (m_aOrderbyColumnNumber[i] == SQL_COLUMN_NOTFOUND) break; + OKeyValue* pKeyValue = new OKeyValue((UINT32)nBookmarkValue); + + ::std::vector<sal_Int32>::iterator aIter = m_aOrderbyColumnNumber.begin(); + for (;aIter != m_aOrderbyColumnNumber.end(); ++aIter) + pKeyValue->pushKey(new ORowSetValueDecorator((*_rRow)[*aIter])); - ORowSetValue xKey = (*_rRow)[m_aOrderbyColumnNumber[i]]; - switch (xKey.getTypeKind()) - { - case ::com::sun::star::sdbc::DataType::VARCHAR: - case ::com::sun::star::sdbc::DataType::CHAR: - pKeyValue->SetKey(i,(rtl::OUString)xKey); - break; - default: - pKeyValue->SetKey(i,(double)xKey); - break; - } - } return pKeyValue; } // ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx index 2f97ec17c29d..f403d8b55267 100644 --- a/connectivity/source/drivers/file/FResultSet.cxx +++ b/connectivity/source/drivers/file/FResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FResultSet.cxx,v $ * - * $Revision: 1.72 $ + * $Revision: 1.73 $ * - * last change: $Author: oj $ $Date: 2001-08-27 09:13:35 $ + * last change: $Author: oj $ $Date: 2001-08-29 12:15:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -238,7 +238,7 @@ void OResultSet::disposing(void) // ----------------------------------------------------------------------------- void OResultSet::clear() { - DELETEZ(m_pFileSet); + m_pFileSet = NULL; DELETEZ(m_pSortIndex); if(m_aInsertRow.isValid()) @@ -662,7 +662,7 @@ void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException) // so we have to know where the end is SkipDeleted(OFileTable::FILE_LAST,1,sal_False); m_bRowInserted = m_pTable->InsertRow(m_aInsertRow.getBody(), TRUE,Reference<XIndexAccess>(m_xColNames,UNO_QUERY)); - if(m_bRowInserted && m_pFileSet) + if(m_bRowInserted && m_pFileSet.isValid()) { sal_Int32 nPos = (*m_aInsertRow)[0]; m_pFileSet->push_back(nPos); @@ -701,7 +701,7 @@ void SAL_CALL OResultSet::deleteRow() throw(SQLException, RuntimeException) sal_Int32 nPos = (sal_Int32)(*m_aRow)[0]; m_bRowDeleted = m_pTable->DeleteRow(m_xColumns.getBody()); - if(m_bRowDeleted && m_pFileSet) + if(m_bRowDeleted && m_pFileSet.isValid()) { m_aRow->setDeleted(sal_True); // don't touch the m_pFileSet member here @@ -957,7 +957,7 @@ again: return sal_False; } } - else if (m_pFileSet) + else if (m_pFileSet.isValid()) { OSL_ENSURE(//!m_pFileSet->IsFrozen() && eCursorPosition == OFileTable::FILE_NEXT, "Falsche CursorPosition!"); @@ -993,17 +993,17 @@ again: // Evaluate darf nur gesetzt sein, // wenn der Keyset weiter aufgebaut werden soll if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT && !isCount() && - (m_pFileSet || m_pSortIndex) && bEvaluate) + (m_pFileSet.isValid() || m_pSortIndex) && bEvaluate) { if (m_pSortIndex) { - OFILEKeyValue* pKeyValue = GetOrderbyKeyValue(m_aEvaluateRow); + OKeyValue* pKeyValue = GetOrderbyKeyValue(m_aEvaluateRow); if (!m_pSortIndex->AddKeyValue(pKeyValue)) { // Ueberwachung auf Ueberschreitung der Index-Kapazitaet: } } - else if (m_pFileSet) + else if (m_pFileSet.isValid()) { // OSL_ENSURE(!m_pFileSet->IsFrozen() , "Falsche CursorPosition!"); sal_uInt32 nBookmarkValue = Abs((sal_Int32)(*m_aEvaluateRow)[0]); @@ -1055,7 +1055,7 @@ BOOL OResultSet::Move(OFileTable::FilePosition eCursorPosition, INT32 nOffset, B if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT && !isCount()) { - if (m_pFileSet == NULL) // kein Index verfuegbar + if (!m_pFileSet.isValid()) // kein Index verfuegbar { // Normales FETCH ExecuteRow(eCursorPosition,nOffset,TRUE,FALSE,bRetrieveData); @@ -1232,7 +1232,7 @@ Error: case OFileTable::FILE_ABSOLUTE: case OFileTable::FILE_RELATIVE: if (nOffset > 0) - m_nRowPos = (m_pFileSet) ? m_pFileSet->size() : -1; + m_nRowPos = (m_pFileSet.isValid()) ? m_pFileSet->size() : -1; else if (nOffset < 0) m_nRowPos = -1; break; @@ -1481,7 +1481,7 @@ BOOL OResultSet::OpenImpl() // } // Neuen Index aufbauen: - DELETEZ(m_pFileSet); + m_pFileSet = NULL; // DELETEZ(m_pEvaluationKeySet); // Row zur Auswertung binden, wenn Preprocessing erfolg, dann bereits ein Keyset @@ -1552,64 +1552,56 @@ BOOL OResultSet::OpenImpl() { if(!IsSorted()) { - m_aOrderbyColumnNumber[0] = m_aColMapping[1]; - m_aOrderbyAscending[0] = 0; + m_aOrderbyColumnNumber.push_back(m_aColMapping[1]); + m_aOrderbyAscending.push_back(SQL_DESC); } else bWasSorted = TRUE; bDistinct = TRUE; } - // Ohne Restriction und Sortierung RowCount bekannt. - // if (!HasRestriction() && !IsSorted() && bShowDeleted) - // SetRowCount(MaxRowCount()); - OSL_ENSURE(m_aOrderbyColumnNumber.size() == SQL_ORDERBYKEYS,"Maximale Anzahl der ORDER BY Columns muss derzeit genau 3 sein!"); - OKeyType eKeyType[SQL_ORDERBYKEYS]; + OSortIndex::TKeyTypeVector eKeyType(m_aOrderbyColumnNumber.size()); OValueVector::iterator aRowIter = m_aRow->begin()+1; - for (int i = 0; i < SQL_ORDERBYKEYS; i++) + ::std::vector<sal_Int32>::iterator aOrderByIter = m_aOrderbyColumnNumber.begin(); + for (::std::vector<sal_Int16>::size_type i=0;aOrderByIter != m_aOrderbyColumnNumber.end(); ++aOrderByIter,++i) { - if (m_aOrderbyColumnNumber[i] == SQL_COLUMN_NOTFOUND) - eKeyType[i] = SQL_ORDERBYKEY_NONE; - else + OSL_ENSURE((sal_Int32)m_aRow->size() > *aOrderByIter,"Invalid Index"); + switch ((m_aRow->begin()+*aOrderByIter)->getTypeKind()) { - OSL_ENSURE((sal_Int32)m_aRow->size() > m_aOrderbyColumnNumber[i],"Invalid Index"); - switch ((m_aRow->begin()+m_aOrderbyColumnNumber[i])->getTypeKind()) - { - case DataType::CHAR: - case DataType::VARCHAR: - eKeyType[i] = SQL_ORDERBYKEY_STRING; - break; - - case DataType::OTHER: - case DataType::TINYINT: - case DataType::SMALLINT: - case DataType::INTEGER: - case DataType::DECIMAL: - case DataType::NUMERIC: - case DataType::REAL: - case DataType::DOUBLE: - case DataType::DATE: - case DataType::TIME: - case DataType::TIMESTAMP: - case DataType::BIT: - eKeyType[i] = SQL_ORDERBYKEY_DOUBLE; - break; - - // Andere Typen sind nicht implementiert (und damit immer FALSE) - default: - eKeyType[i] = SQL_ORDERBYKEY_NONE; - OSL_ASSERT("OFILECursor::Execute: Datentyp nicht implementiert"); - break; - } - (*m_aEvaluateRow)[m_aOrderbyColumnNumber[i]].setBound(sal_True); + case DataType::CHAR: + case DataType::VARCHAR: + eKeyType[i] = SQL_ORDERBYKEY_STRING; + break; + + case DataType::OTHER: + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::INTEGER: + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::REAL: + case DataType::DOUBLE: + case DataType::DATE: + case DataType::TIME: + case DataType::TIMESTAMP: + case DataType::BIT: + eKeyType[i] = SQL_ORDERBYKEY_DOUBLE; + break; + + // Andere Typen sind nicht implementiert (und damit immer FALSE) + default: + eKeyType[i] = SQL_ORDERBYKEY_NONE; + OSL_ASSERT("OFILECursor::Execute: Datentyp nicht implementiert"); + break; } + (*m_aEvaluateRow)[*aOrderByIter].setBound(sal_True); } // Nur wenn Sortierung gewuenscht, ueber alle Datensaetze iterieren und // dabei den "Key", nach dem sortiert werden soll, in den Index eintragen: if (IsSorted()) { - if (!m_pSQLAnalyzer->hasRestriction() && m_aOrderbyColumnNumber[1] == SQL_COLUMN_NOTFOUND) + if (!m_pSQLAnalyzer->hasRestriction() && m_aOrderbyColumnNumber.size() == 1) { // Ist nur ein Feld fuer die Sortierung angegeben // Und diese Feld ist indiziert, dann den Index ausnutzen @@ -1642,9 +1634,7 @@ BOOL OResultSet::OpenImpl() } } - m_pSortIndex = new OFILESortIndex(eKeyType, - m_aOrderbyAscending, - nMaxRowCount,m_nTextEncoding); + m_pSortIndex = new OSortIndex(eKeyType,m_aOrderbyAscending); sal_Bool bOK = sal_True; if (m_pEvaluationKeySet) @@ -1668,8 +1658,7 @@ BOOL OResultSet::OpenImpl() // Sortiertes Keyset erzeugen // DELETEZ(m_pEvaluationKeySet); m_pEvaluationKeySet = NULL; - if(m_pFileSet) - delete m_pFileSet; + m_pFileSet = NULL; m_pFileSet = m_pSortIndex->CreateKeySet(); // if(!bDistinct) // SetRowCount(pFileSet->count()); @@ -1677,7 +1666,7 @@ BOOL OResultSet::OpenImpl() // Nun kann ueber den Index sortiert zugegriffen werden. } - if (!m_pFileSet) + if (!m_pFileSet.isValid()) { m_pFileSet = new OKeySet(); @@ -1692,8 +1681,8 @@ BOOL OResultSet::OpenImpl() m_pFileSet->push_back(i + 1); } } - OSL_ENSURE(m_pFileSet,"Kein KeySet vorhanden! :-("); - DISTINCT: if(bDistinct && m_pFileSet) // sicher ist sicher + OSL_ENSURE(m_pFileSet.isValid(),"Kein KeySet vorhanden! :-("); + DISTINCT: if(bDistinct && m_pFileSet.isValid()) // sicher ist sicher { OValueRow aSearchRow = new OValueVector(m_aRow->size()); OValueVector::iterator aRowIter = m_aRow->begin(); @@ -1762,7 +1751,8 @@ BOOL OResultSet::OpenImpl() if (!bWasSorted) { - m_aOrderbyColumnNumber[0] = SQL_COLUMN_NOTFOUND; + m_aOrderbyColumnNumber.clear(); + m_aOrderbyAscending.clear(); sort(m_pFileSet->begin(),m_pFileSet->end()); } } diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx index 4b9e536c53b9..1c9bd36db25b 100644 --- a/connectivity/source/drivers/file/FStatement.cxx +++ b/connectivity/source/drivers/file/FStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FStatement.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:08:38 $ + * last change: $Author: oj $ $Date: 2001-08-29 12:15:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -134,8 +134,6 @@ OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE( ,m_nFetchDirection(FetchDirection::FORWARD) ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE) ,m_pSQLAnalyzer(NULL) - ,m_aOrderbyColumnNumber(SQL_ORDERBYKEYS,SQL_COLUMN_NOTFOUND) - ,m_aOrderbyAscending(SQL_ORDERBYKEYS,1) ,m_xDBMetaData(_pConnection->getMetaData()) ,m_pTable(NULL) { @@ -144,13 +142,13 @@ OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE( sal_Int32 nAttrib = 0; registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME), PROPERTY_ID_CURSORNAME, nAttrib,&m_aCursorName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); - registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXFIELDSIZE), PROPERTY_ID_MAXFIELDSIZE, nAttrib,&m_nMaxFieldSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXFIELDSIZE), PROPERTY_ID_MAXFIELDSIZE, nAttrib,&m_nMaxFieldSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXROWS), PROPERTY_ID_MAXROWS, nAttrib,&m_nMaxRows, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); - registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_QUERYTIMEOUT), PROPERTY_ID_QUERYTIMEOUT, nAttrib,&m_nQueryTimeOut, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_QUERYTIMEOUT), PROPERTY_ID_QUERYTIMEOUT, nAttrib,&m_nQueryTimeOut, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), PROPERTY_ID_FETCHSIZE, nAttrib,&m_nFetchSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), PROPERTY_ID_RESULTSETTYPE, nAttrib,&m_nResultSetType, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), PROPERTY_ID_FETCHDIRECTION, nAttrib,&m_nFetchDirection, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); - registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ESCAPEPROCESSING), PROPERTY_ID_ESCAPEPROCESSING, nAttrib,&m_bEscapeProcessing,::getCppuBooleanType()); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ESCAPEPROCESSING),PROPERTY_ID_ESCAPEPROCESSING, nAttrib,&m_bEscapeProcessing,::getCppuBooleanType()); registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY, nAttrib,&m_nResultSetConcurrency, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL))); } @@ -423,20 +421,14 @@ void OStatement_Base::anylizeSQL() throw SQLException(); } OSQLParseNode * pAscendingDescending = pOrderingSpec->getChild(1); - setOrderbyColumn((UINT16)m,pColumnRef,pAscendingDescending); + setOrderbyColumn(pColumnRef,pAscendingDescending); } } } //------------------------------------------------------------------ -void OStatement_Base::setOrderbyColumn(UINT16 nOrderbyColumnNo, - OSQLParseNode* pColumnRef, - OSQLParseNode* pAscendingDescending) +void OStatement_Base::setOrderbyColumn( OSQLParseNode* pColumnRef, + OSQLParseNode* pAscendingDescending) { - if (nOrderbyColumnNo >= m_aOrderbyColumnNumber.size()) - { - throw SQLException(); - } - ::rtl::OUString aColumnName; if (pColumnRef->count() == 1) aColumnName = pColumnRef->getChild(0)->getTokenValue(); @@ -464,11 +456,10 @@ void OStatement_Base::setOrderbyColumn(UINT16 nOrderbyColumnNo, return; // Alles geprueft und wir haben den Namen der Column. // Die wievielte Column ist das? - m_aOrderbyColumnNumber[nOrderbyColumnNo] = xColLocate->findColumn(aColumnName); + m_aOrderbyColumnNumber.push_back(xColLocate->findColumn(aColumnName)); // Ascending or Descending? - m_aOrderbyAscending[nOrderbyColumnNo] = (SQL_ISTOKEN(pAscendingDescending,DESC)) ? - FALSE : TRUE; + m_aOrderbyAscending.push_back((SQL_ISTOKEN(pAscendingDescending,DESC)) ? SQL_DESC : SQL_ASC); } // ----------------------------------------------------------------------------- |