diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-10-01 10:24:29 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-10-01 10:24:29 +0000 |
commit | b75c8e2d989a250403c079d88b779119d87deba1 (patch) | |
tree | 8f68dcf33b48e8cd8fa8e79e4c8d03c2c7244743 /connectivity/source | |
parent | 28470b188ccd9e1ebfdc15cf08fed727fe7d8bbc (diff) |
#92613# unbound evaluationrow fixed
Diffstat (limited to 'connectivity/source')
-rw-r--r-- | connectivity/source/commontools/FValue.cxx | 86 | ||||
-rw-r--r-- | connectivity/source/commontools/dbconversion.cxx | 55 | ||||
-rw-r--r-- | connectivity/source/drivers/file/FPreparedStatement.cxx | 23 | ||||
-rw-r--r-- | connectivity/source/drivers/file/FStatement.cxx | 25 | ||||
-rw-r--r-- | connectivity/source/drivers/file/fanalyzer.cxx | 6 | ||||
-rw-r--r-- | connectivity/source/inc/file/FPreparedStatement.hxx | 6 | ||||
-rw-r--r-- | connectivity/source/inc/file/FStatement.hxx | 7 | ||||
-rw-r--r-- | connectivity/source/parse/sqlnode.cxx | 36 |
8 files changed, 164 insertions, 80 deletions
diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index b117bae824eb..7f56d543c1bf 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FValue.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: oj $ $Date: 2001-09-20 12:51:56 $ + * last change: $Author: oj $ $Date: 2001-10-01 11:24:28 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,6 +75,7 @@ #endif using namespace connectivity; +using namespace dbtools; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; @@ -1288,35 +1289,86 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const // ----------------------------------------------------------------------------- ::com::sun::star::util::Date ORowSetValue::getDate() const { - switch(m_eTypeKind) + ::com::sun::star::util::Date aValue; + if(!m_bNull) { - case DataType::DATE: - if(!m_bNull) - return *(::com::sun::star::util::Date*)m_aValue.m_pValue; + switch(m_eTypeKind) + { + case DataType::CHAR: + case DataType::VARCHAR: + aValue = DBTypeConversion::toDate(getString()); + break; + case DataType::DECIMAL: + case DataType::NUMERIC: + aValue = DBTypeConversion::toDate((double)*this); + break; + case DataType::FLOAT: + case DataType::DOUBLE: + case DataType::REAL: + aValue = DBTypeConversion::toDate((double)*this); + break; + + case DataType::DATE: + aValue = *(::com::sun::star::util::Date*)m_aValue.m_pValue; + } } - return ::com::sun::star::util::Date(); + return aValue; } // ----------------------------------------------------------------------------- ::com::sun::star::util::Time ORowSetValue::getTime() const { - switch(m_eTypeKind) + ::com::sun::star::util::Time aValue; + if(!m_bNull) { - case DataType::TIME: - if(!m_bNull) - return *(::com::sun::star::util::Time*)m_aValue.m_pValue; + switch(m_eTypeKind) + { + case DataType::CHAR: + case DataType::VARCHAR: + aValue = DBTypeConversion::toTime(getString()); + break; + case DataType::DECIMAL: + case DataType::NUMERIC: + aValue = DBTypeConversion::toTime((double)*this); + break; + case DataType::FLOAT: + case DataType::DOUBLE: + case DataType::REAL: + aValue = DBTypeConversion::toTime((double)*this); + break; + + case DataType::TIME: + aValue = *(::com::sun::star::util::Time*)m_aValue.m_pValue; + } } - return ::com::sun::star::util::Time(); + return aValue; } // ----------------------------------------------------------------------------- ::com::sun::star::util::DateTime ORowSetValue::getDateTime() const { - switch(m_eTypeKind) + ::com::sun::star::util::DateTime aValue; + if(!m_bNull) { - case DataType::TIMESTAMP: - if(!m_bNull) - return *(::com::sun::star::util::DateTime*)m_aValue.m_pValue; + switch(m_eTypeKind) + { + case DataType::CHAR: + case DataType::VARCHAR: + aValue = DBTypeConversion::toDateTime(getString()); + break; + case DataType::DECIMAL: + case DataType::NUMERIC: + aValue = DBTypeConversion::toDateTime((double)*this); + break; + case DataType::FLOAT: + case DataType::DOUBLE: + case DataType::REAL: + aValue = DBTypeConversion::toDateTime((double)*this); + break; + case DataType::TIMESTAMP: + aValue = *(::com::sun::star::util::DateTime*)m_aValue.m_pValue; + break; + } } - return ::com::sun::star::util::DateTime(); + return aValue; } // ----------------------------------------------------------------------------- diff --git a/connectivity/source/commontools/dbconversion.cxx b/connectivity/source/commontools/dbconversion.cxx index dc883df9d6dd..14e8cd4bee63 100644 --- a/connectivity/source/commontools/dbconversion.cxx +++ b/connectivity/source/commontools/dbconversion.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dbconversion.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: oj $ $Date: 2001-08-06 06:21:03 $ + * last change: $Author: oj $ $Date: 2001-10-01 11:24:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -446,6 +446,54 @@ DateTime DBTypeConversion::toDateTime(double dVal, const Date& _rNullDate) return xRet; } //------------------------------------------------------------------------------ +Date DBTypeConversion::toDate(const ::rtl::OUString& _sSQLString) +{ + // get the token out of a string + static sal_Unicode sDateSep = '-'; + + sal_Int32 nIndex = 0; + sal_uInt16 nYear = 0, + nMonth = 0, + nDay = 0; + nYear = (sal_uInt16)_sSQLString.getToken(0,sDateSep,nIndex).toInt32(); + if(nIndex != -1) + { + nMonth = (sal_uInt16)_sSQLString.getToken(0,sDateSep,nIndex).toInt32(); + if(nIndex != -1) + nDay = (sal_uInt16)_sSQLString.getToken(0,sDateSep,nIndex).toInt32(); + } + + return Date(nDay,nMonth,nYear); +} + +//----------------------------------------------------------------------------- +DateTime DBTypeConversion::toDateTime(const ::rtl::OUString& _sSQLString) +{ + Date aDate = toDate(_sSQLString); + Time aTime = toTime(_sSQLString); + + return DateTime(0,aTime.Seconds,aTime.Minutes,aTime.Hours,aDate.Day,aDate.Month,aDate.Year); +} + +//----------------------------------------------------------------------------- +Time DBTypeConversion::toTime(const ::rtl::OUString& _sSQLString) +{ + static sal_Unicode sTimeSep = ':'; + + sal_Int32 nIndex = 0; + sal_uInt16 nHour = 0, + nMinute = 0, + nSecond = 0; + nHour = (sal_uInt16)_sSQLString.getToken(0,sTimeSep,nIndex).toInt32(); + if(nIndex != -1) + { + nMinute = (sal_uInt16)_sSQLString.getToken(0,sTimeSep,nIndex).toInt32(); + if(nIndex != -1) + nSecond = (sal_uInt16)_sSQLString.getToken(0,sTimeSep,nIndex).toInt32(); + } + return Time(0,nHour,nMinute,nSecond); +} +// ----------------------------------------------------------------------------- //......................................................................... @@ -456,6 +504,9 @@ DateTime DBTypeConversion::toDateTime(double dVal, const Date& _rNullDate) /************************************************************************* * history: * $Log: not supported by cvs2svn $ + * Revision 1.16 2001/08/06 06:21:03 oj + * #89430# overflow corrected + * * Revision 1.15 2001/05/25 13:09:29 oj * #86839# flush scanner buffer * diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx index 633eeb1a6e19..a471d777086f 100644 --- a/connectivity/source/drivers/file/FPreparedStatement.cxx +++ b/connectivity/source/drivers/file/FPreparedStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FPreparedStatement.cxx,v $ * - * $Revision: 1.23 $ + * $Revision: 1.24 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:08:38 $ + * last change: $Author: oj $ $Date: 2001-10-01 11:24:25 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -118,7 +118,6 @@ IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbc.driver.file.Prepare OPreparedStatement::OPreparedStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection ) ,m_pResultSet(NULL) - ,m_pEvaluationKeySet(NULL) { } // ------------------------------------------------------------------------- @@ -138,12 +137,7 @@ void OPreparedStatement::disposing() m_aParameterRow->clear(); m_aParameterRow = NULL; } - if(m_aEvaluateRow.isValid()) - { - m_aEvaluateRow->clear(); - m_aEvaluateRow = NULL; - } - delete m_pEvaluationKeySet; + m_xParamColumns = NULL; } // ------------------------------------------------------------------------- @@ -156,11 +150,6 @@ void OPreparedStatement::construct(const ::rtl::OUString& sql) throw(SQLExcepti m_xParamColumns = new OSQLColumns(); Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY); - // set the binding of the resultrow - m_aEvaluateRow = new OValueVector(xNames->getCount()); - - (*m_aEvaluateRow)[0].setBound(sal_True); - ::std::for_each(m_aEvaluateRow->begin()+1,m_aEvaluateRow->end(),TSetBound(sal_False)); // describe all parameters need for the resultset describeParameter(); @@ -856,10 +845,10 @@ void OPreparedStatement::describeParameter() void OPreparedStatement::initializeResultSet(OResultSet* _pResult) { OStatement_Base::initializeResultSet(_pResult); + m_pResultSet->setParameterColumns(m_xParamColumns); m_pResultSet->setParameterRow(m_aParameterRow); m_pResultSet->setAssignValues(m_aAssignValues); - m_pResultSet->setEvaluationRow(m_aEvaluateRow); // Parameter substituieren (AssignValues und Kriterien): if (!m_xParamColumns->empty()) @@ -887,8 +876,8 @@ void OPreparedStatement::initializeResultSet(OResultSet* _pResult) } } - m_pEvaluationKeySet = m_pSQLAnalyzer->bindResultRow(m_aEvaluateRow); // Werte im Code des Compilers setzen - m_pResultSet->setEvaluationKeySet(m_pEvaluationKeySet); +// m_pEvaluationKeySet = m_pSQLAnalyzer->bindResultRow(m_aEvaluateRow); // Werte im Code des Compilers setzen +// m_pResultSet->setEvaluationKeySet(m_pEvaluationKeySet); } // ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx index 1c9bd36db25b..775a75c3eb01 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.21 $ + * $Revision: 1.22 $ * - * last change: $Author: oj $ $Date: 2001-08-29 12:15:31 $ + * last change: $Author: oj $ $Date: 2001-10-01 11:24:25 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -136,6 +136,7 @@ OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE( ,m_pSQLAnalyzer(NULL) ,m_xDBMetaData(_pConnection->getMetaData()) ,m_pTable(NULL) + ,m_pEvaluationKeySet(NULL) { m_pConnection->acquire(); @@ -195,6 +196,7 @@ void OStatement_BASE2::disposing() if (m_pConnection) m_pConnection->release(); + dispose_ChildImpl(); OStatement_Base::disposing(); } @@ -378,6 +380,12 @@ void SAL_CALL OStatement::release() throw(::com::sun::star::uno::RuntimeExceptio // ----------------------------------------------------------------------------- void SAL_CALL OStatement_Base::disposing(void) { + if(m_aEvaluateRow.isValid()) + { + m_aEvaluateRow->clear(); + m_aEvaluateRow = NULL; + } + delete m_pEvaluationKeySet; OStatement_BASE::disposing(); } // ----------------------------------------------------------------------------- @@ -492,7 +500,14 @@ void OStatement_Base::construct(const ::rtl::OUString& sql) throw(SQLException, m_aRow = new OValueVector(xNames->getCount()); (*m_aRow)[0].setBound(sal_True); ::std::for_each(m_aRow->begin()+1,m_aRow->end(),TSetBound(sal_False)); - // create teh column mapping + + // set the binding of the resultrow + m_aEvaluateRow = new OValueVector(xNames->getCount()); + + (*m_aEvaluateRow)[0].setBound(sal_True); + ::std::for_each(m_aEvaluateRow->begin()+1,m_aEvaluateRow->end(),TSetBound(sal_False)); + + // create the column mapping createColumnMapping(); m_pSQLAnalyzer = createAnalyzer(); @@ -528,8 +543,10 @@ void OStatement_Base::initializeResultSet(OResultSet* _pResult) _pResult->setOrderByAscending(m_aOrderbyAscending); _pResult->setBindingRow(m_aRow); _pResult->setColumnMapping(m_aColMapping); - // _pResult->setTable(m_pTable); + _pResult->setEvaluationRow(m_aEvaluateRow); + m_pEvaluationKeySet = m_pSQLAnalyzer->bindResultRow(m_aEvaluateRow); // Werte im Code des Compilers setzen + _pResult->setEvaluationKeySet(m_pEvaluationKeySet); } } } diff --git a/connectivity/source/drivers/file/fanalyzer.cxx b/connectivity/source/drivers/file/fanalyzer.cxx index 6abc44b3d1a1..86befa00e8fc 100644 --- a/connectivity/source/drivers/file/fanalyzer.cxx +++ b/connectivity/source/drivers/file/fanalyzer.cxx @@ -2,9 +2,9 @@ * * $RCSfile: fanalyzer.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:08:38 $ + * last change: $Author: oj $ $Date: 2001-10-01 11:24:25 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -200,7 +200,7 @@ void OSQLAnalyzer::start(OSQLParseNode* pSQLParseNode) } // Keyset erzeugen mit kleinster Liste - if(aEvaluateSetList.size()) + if(!aEvaluateSetList.empty()) { // welche Liste hat den kleinsten count ? OEvaluateSetList::iterator i = aEvaluateSetList.begin(); diff --git a/connectivity/source/inc/file/FPreparedStatement.hxx b/connectivity/source/inc/file/FPreparedStatement.hxx index 448a5db96c59..ecb115bae27f 100644 --- a/connectivity/source/inc/file/FPreparedStatement.hxx +++ b/connectivity/source/inc/file/FPreparedStatement.hxx @@ -2,9 +2,9 @@ * * $RCSfile: FPreparedStatement.hxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:00:38 $ + * last change: $Author: oj $ $Date: 2001-10-01 11:24:24 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -104,7 +104,6 @@ namespace connectivity //==================================================================== ::std::vector<sal_Int32> m_aParameterIndexes; // maps the parameter index to column index ::rtl::OUString m_aSql; - OValueRow m_aEvaluateRow; // contains all values of a row OValueRow m_aParameterRow; ORefAssignValues m_aAssignValues; // needed for insert,update and parameters // to compare with the restrictions @@ -112,7 +111,6 @@ namespace connectivity ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; OResultSet* m_pResultSet; - TIntVector* m_pEvaluationKeySet; ::vos::ORef<connectivity::OSQLColumns> m_xParamColumns; // the parameter columns // factory method for resultset's diff --git a/connectivity/source/inc/file/FStatement.hxx b/connectivity/source/inc/file/FStatement.hxx index 2e670fa1ba4e..41cb495d30ab 100644 --- a/connectivity/source/inc/file/FStatement.hxx +++ b/connectivity/source/inc/file/FStatement.hxx @@ -2,9 +2,9 @@ * * $RCSfile: FStatement.hxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: oj $ $Date: 2001-08-29 12:14:43 $ + * last change: $Author: oj $ $Date: 2001-10-01 11:24:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -154,8 +154,11 @@ namespace connectivity connectivity::OSQLParseNode* m_pParseTree; OSQLAnalyzer* m_pSQLAnalyzer; //the sql analyzer used by the resultset + ::std::vector<sal_Int32>* m_pEvaluationKeySet; + OFileTable* m_pTable; // the current table OValueRow m_aRow; + OValueRow m_aEvaluateRow; // contains all values of a row ::rtl::OUString m_aCursorName; diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 784d03a6e017..5f4578bc0b2a 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sqlnode.cxx,v $ * - * $Revision: 1.23 $ + * $Revision: 1.24 $ * - * last change: $Author: oj $ $Date: 2001-09-27 09:47:41 $ + * last change: $Author: oj $ $Date: 2001-10-01 11:24:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -176,15 +176,7 @@ OSQLParseNode::SQLParseNodeParameter::SQLParseNodeParameter(const ::rtl::OUStrin //----------------------------------------------------------------------------- ::rtl::OUString OSQLParseNode::convertDateString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const { - // get the token out of a string - static sal_Unicode sDateSep = '-'; - - sal_Int32 nIndex = 0; - sal_uInt16 nYear = (sal_uInt16)rString.getToken(0,sDateSep,nIndex).toInt32(); - sal_uInt16 nMonth = (sal_uInt16)rString.getToken(0,sDateSep,nIndex).toInt32(); - sal_uInt16 nDay = (sal_uInt16)rString.getToken(0,sDateSep,nIndex).toInt32(); - - Date aDate(nDay,nMonth,nYear); + Date aDate = DBTypeConversion::toDate(rString); Reference< XNumberFormatsSupplier > xSupplier(rParam.xFormatter->getNumberFormatsSupplier()); Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY); @@ -196,18 +188,7 @@ OSQLParseNode::SQLParseNodeParameter::SQLParseNodeParameter(const ::rtl::OUStrin //----------------------------------------------------------------------------- ::rtl::OUString OSQLParseNode::convertDateTimeString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const { - static sal_Unicode sDateSep = '-'; - static sal_Unicode sTimeSep = ':'; - - sal_Int32 nIndex = 0; - sal_uInt16 nYear = (sal_uInt16)rString.getToken(0,sDateSep,nIndex).toInt32(); - sal_uInt16 nMonth = (sal_uInt16)rString.getToken(0,sDateSep,nIndex).toInt32(); - sal_uInt16 nDay = (sal_uInt16)rString.getToken(0,sDateSep,nIndex).toInt32(); - sal_uInt16 nHour = (sal_uInt16)rString.getToken(0,sTimeSep,nIndex).toInt32(); - sal_uInt16 nMinute = (sal_uInt16)rString.getToken(0,sTimeSep,nIndex).toInt32(); - sal_uInt16 nSecond = (sal_uInt16)rString.getToken(0,sTimeSep,nIndex).toInt32(); - - DateTime aDate(0,nSecond,nMinute,nHour,nDay,nMonth,nYear); + DateTime aDate = DBTypeConversion::toDateTime(rString); Reference< XNumberFormatsSupplier > xSupplier(rParam.xFormatter->getNumberFormatsSupplier()); Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY); @@ -219,14 +200,7 @@ OSQLParseNode::SQLParseNodeParameter::SQLParseNodeParameter(const ::rtl::OUStrin //----------------------------------------------------------------------------- ::rtl::OUString OSQLParseNode::convertTimeString(const SQLParseNodeParameter& rParam, const ::rtl::OUString& rString) const { - static sal_Unicode sTimeSep = ':'; - - sal_Int32 nIndex = 0; - sal_uInt16 nHour = (sal_uInt16)rString.getToken(0,sTimeSep,nIndex).toInt32(); - sal_uInt16 nMinute = (sal_uInt16)rString.getToken(0,sTimeSep,nIndex).toInt32(); - sal_uInt16 nSecond = (sal_uInt16)rString.getToken(0,sTimeSep,nIndex).toInt32(); - - Time aTime(0,nHour,nMinute,nSecond); + Time aTime = DBTypeConversion::toTime(rString); Reference< XNumberFormatsSupplier > xSupplier(rParam.xFormatter->getNumberFormatsSupplier()); Reference< XNumberFormatTypes > xTypes(xSupplier->getNumberFormats(), UNO_QUERY); |