summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorMathias Bauer <mba@openoffice.org>2009-12-05 19:29:07 +0100
committerMathias Bauer <mba@openoffice.org>2009-12-05 19:29:07 +0100
commit8d669bc21b9d1976842ba8252d2f0fb953160bdd (patch)
tree63e5a53c8ff9c4cdff33070e177eda653922f28a /connectivity
parentf232b25c1eceb8e1c32cfd917d666b3a16b14405 (diff)
parent875ac20478f16e5107acb222c0b851b99d2e0f27 (diff)
merge to m67
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/inc/connectivity/FValue.hxx12
-rw-r--r--connectivity/source/commontools/FValue.cxx154
-rw-r--r--connectivity/source/drivers/file/quotedstring.cxx2
-rw-r--r--connectivity/source/drivers/hsqldb/HDriver.cxx47
-rw-r--r--connectivity/source/drivers/hsqldb/makefile.mk1
-rw-r--r--connectivity/source/inc/resource/hsqldb_res.hrc1
-rw-r--r--connectivity/source/parse/sqlnode.cxx14
-rw-r--r--connectivity/source/resource/conn_shared_res.src5
8 files changed, 206 insertions, 30 deletions
diff --git a/connectivity/inc/connectivity/FValue.hxx b/connectivity/inc/connectivity/FValue.hxx
index 4196e8d843d9..22a169f4025d 100644
--- a/connectivity/inc/connectivity/FValue.hxx
+++ b/connectivity/inc/connectivity/FValue.hxx
@@ -44,9 +44,15 @@
#include <com/sun/star/util/Time.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
namespace connectivity
{
+ namespace detail
+ {
+ class IValueSource;
+ }
+
class OOO_DLLPUBLIC_DBTOOLS ORowSetValue
{
union
@@ -361,6 +367,12 @@ namespace connectivity
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow>& _xRow);
void fill(const ::com::sun::star::uno::Any& _rValue);
+
+ void fill( const sal_Int32 _nType,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxColumn );
+
+ private:
+ void impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const detail::IValueSource& _rValueSource );
};
/// ORowSetValueDecorator decorates a ORowSetValue so the value is "refcounted"
diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx
index cd09efa227fe..f7943fc4cf45 100644
--- a/connectivity/source/commontools/FValue.cxx
+++ b/connectivity/source/commontools/FValue.cxx
@@ -40,13 +40,16 @@
#include <rtl/ustrbuf.hxx>
#include <rtl/logfile.hxx>
-using namespace connectivity;
-using namespace dbtools;
+using namespace ::dbtools;
using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::util;
using namespace ::com::sun::star::io;
+namespace connectivity
+{
+
namespace {
static sal_Bool isStorageCompatible(sal_Int32 _eType1, sal_Int32 _eType2)
{
@@ -1809,6 +1812,107 @@ void ORowSetValue::setSigned(sal_Bool _bMod)
}
}
}
+
+// -----------------------------------------------------------------------------
+namespace detail
+{
+ class SAL_NO_VTABLE IValueSource
+ {
+ public:
+ virtual ::rtl::OUString getString() const = 0;
+ virtual sal_Bool getBoolean() const = 0;
+ virtual sal_Int8 getByte() const = 0;
+ virtual sal_Int16 getShort() const = 0;
+ virtual sal_Int32 getInt() const = 0;
+ virtual sal_Int64 getLong() const = 0;
+ virtual float getFloat() const = 0;
+ virtual double getDouble() const = 0;
+ virtual Date getDate() const = 0;
+ virtual Time getTime() const = 0;
+ virtual DateTime getTimestamp() const = 0;
+ virtual Sequence< sal_Int8 > getBytes() const = 0;
+ virtual Reference< XInputStream > getBinaryStream() const = 0;
+ virtual Reference< XInputStream > getCharacterStream() const = 0;
+ virtual sal_Bool wasNull() const = 0;
+
+ virtual ~IValueSource() { }
+ };
+
+ class RowValue : public IValueSource
+ {
+ public:
+ RowValue( const Reference< XRow >& _xRow, const sal_Int32 _nPos )
+ :m_xRow( _xRow )
+ ,m_nPos( _nPos )
+ {
+ }
+
+ // IValueSource
+ virtual ::rtl::OUString getString() const { return m_xRow->getString( m_nPos ); };
+ virtual sal_Bool getBoolean() const { return m_xRow->getBoolean( m_nPos ); };
+ virtual sal_Int8 getByte() const { return m_xRow->getByte( m_nPos ); };
+ virtual sal_Int16 getShort() const { return m_xRow->getShort( m_nPos ); }
+ virtual sal_Int32 getInt() const { return m_xRow->getInt( m_nPos ); }
+ virtual sal_Int64 getLong() const { return m_xRow->getLong( m_nPos ); }
+ virtual float getFloat() const { return m_xRow->getFloat( m_nPos ); };
+ virtual double getDouble() const { return m_xRow->getDouble( m_nPos ); };
+ virtual Date getDate() const { return m_xRow->getDate( m_nPos ); };
+ virtual Time getTime() const { return m_xRow->getTime( m_nPos ); };
+ virtual DateTime getTimestamp() const { return m_xRow->getTimestamp( m_nPos ); };
+ virtual Sequence< sal_Int8 > getBytes() const { return m_xRow->getBytes( m_nPos ); };
+ virtual Reference< XInputStream > getBinaryStream() const { return m_xRow->getBinaryStream( m_nPos ); };
+ virtual Reference< XInputStream > getCharacterStream() const { return m_xRow->getCharacterStream( m_nPos ); };
+ virtual sal_Bool wasNull() const { return m_xRow->wasNull( ); };
+
+ private:
+ const Reference< XRow > m_xRow;
+ const sal_Int32 m_nPos;
+ };
+
+ class ColumnValue : public IValueSource
+ {
+ public:
+ ColumnValue( const Reference< XColumn >& _rxColumn )
+ :m_xColumn( _rxColumn )
+ {
+ }
+
+ // IValueSource
+ virtual ::rtl::OUString getString() const { return m_xColumn->getString(); };
+ virtual sal_Bool getBoolean() const { return m_xColumn->getBoolean(); };
+ virtual sal_Int8 getByte() const { return m_xColumn->getByte(); };
+ virtual sal_Int16 getShort() const { return m_xColumn->getShort(); }
+ virtual sal_Int32 getInt() const { return m_xColumn->getInt(); }
+ virtual sal_Int64 getLong() const { return m_xColumn->getLong(); }
+ virtual float getFloat() const { return m_xColumn->getFloat(); };
+ virtual double getDouble() const { return m_xColumn->getDouble(); };
+ virtual Date getDate() const { return m_xColumn->getDate(); };
+ virtual Time getTime() const { return m_xColumn->getTime(); };
+ virtual DateTime getTimestamp() const { return m_xColumn->getTimestamp(); };
+ virtual Sequence< sal_Int8 > getBytes() const { return m_xColumn->getBytes(); };
+ virtual Reference< XInputStream > getBinaryStream() const { return m_xColumn->getBinaryStream(); };
+ virtual Reference< XInputStream > getCharacterStream() const { return m_xColumn->getCharacterStream(); };
+ virtual sal_Bool wasNull() const { return m_xColumn->wasNull( ); };
+
+ private:
+ const Reference< XColumn > m_xColumn;
+ };
+}
+
+// -----------------------------------------------------------------------------
+void ORowSetValue::fill( const sal_Int32 _nType, const Reference< XColumn >& _rxColumn )
+{
+ detail::ColumnValue aColumnValue( _rxColumn );
+ impl_fill( _nType, sal_True, aColumnValue );
+}
+
+// -----------------------------------------------------------------------------
+void ORowSetValue::fill( sal_Int32 _nPos, sal_Int32 _nType, sal_Bool _bNullable, const Reference< XRow>& _xRow )
+{
+ detail::RowValue aRowValue( _xRow, _nPos );
+ impl_fill( _nType, _bNullable, aRowValue );
+}
+
// -----------------------------------------------------------------------------
void ORowSetValue::fill(sal_Int32 _nPos,
sal_Int32 _nType,
@@ -1819,10 +1923,8 @@ void ORowSetValue::fill(sal_Int32 _nPos,
}
// -----------------------------------------------------------------------------
-void ORowSetValue::fill(sal_Int32 _nPos,
- sal_Int32 _nType,
- sal_Bool _bNullable,
- const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow>& _xRow)
+void ORowSetValue::impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const detail::IValueSource& _rValueSource )
+
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill (2)" );
sal_Bool bReadData = sal_True;
@@ -1833,63 +1935,63 @@ void ORowSetValue::fill(sal_Int32 _nPos,
case DataType::DECIMAL:
case DataType::NUMERIC:
case DataType::LONGVARCHAR:
- (*this) = _xRow->getString(_nPos);
+ (*this) = _rValueSource.getString();
break;
case DataType::BIGINT:
if ( isSigned() )
- (*this) = _xRow->getLong(_nPos);
+ (*this) = _rValueSource.getLong();
else
- (*this) = _xRow->getString(_nPos);
+ (*this) = _rValueSource.getString();
break;
case DataType::FLOAT:
- (*this) = _xRow->getFloat(_nPos);
+ (*this) = _rValueSource.getFloat();
break;
case DataType::DOUBLE:
case DataType::REAL:
- (*this) = _xRow->getDouble(_nPos);
+ (*this) = _rValueSource.getDouble();
break;
case DataType::DATE:
- (*this) = _xRow->getDate(_nPos);
+ (*this) = _rValueSource.getDate();
break;
case DataType::TIME:
- (*this) = _xRow->getTime(_nPos);
+ (*this) = _rValueSource.getTime();
break;
case DataType::TIMESTAMP:
- (*this) = _xRow->getTimestamp(_nPos);
+ (*this) = _rValueSource.getTimestamp();
break;
case DataType::BINARY:
case DataType::VARBINARY:
case DataType::LONGVARBINARY:
- (*this) = _xRow->getBytes(_nPos);
+ (*this) = _rValueSource.getBytes();
break;
case DataType::BIT:
case DataType::BOOLEAN:
- (*this) = _xRow->getBoolean(_nPos);
+ (*this) = _rValueSource.getBoolean();
break;
case DataType::TINYINT:
if ( isSigned() )
- (*this) = _xRow->getByte(_nPos);
+ (*this) = _rValueSource.getByte();
else
- (*this) = _xRow->getShort(_nPos);
+ (*this) = _rValueSource.getShort();
break;
case DataType::SMALLINT:
if ( isSigned() )
- (*this) = _xRow->getShort(_nPos);
+ (*this) = _rValueSource.getShort();
else
- (*this) = _xRow->getInt(_nPos);
+ (*this) = _rValueSource.getInt();
break;
case DataType::INTEGER:
if ( isSigned() )
- (*this) = _xRow->getInt(_nPos);
+ (*this) = _rValueSource.getInt();
else
- (*this) = _xRow->getLong(_nPos);
+ (*this) = _rValueSource.getLong();
break;
case DataType::CLOB:
- (*this) = ::com::sun::star::uno::makeAny(_xRow->getCharacterStream(_nPos));
+ (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getCharacterStream());
setTypeKind(DataType::CLOB);
break;
case DataType::BLOB:
- (*this) = ::com::sun::star::uno::makeAny(_xRow->getBinaryStream(_nPos));
+ (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getBinaryStream());
setTypeKind(DataType::BLOB);
break;
default:
@@ -1897,7 +1999,7 @@ void ORowSetValue::fill(sal_Int32 _nPos,
bReadData = false;
break;
}
- if ( bReadData && _bNullable && _xRow->wasNull() )
+ if ( bReadData && _bNullable && _rValueSource.wasNull() )
setNull();
setTypeKind(_nType);
}
@@ -2043,3 +2145,5 @@ void ORowSetValue::fill(const Any& _rValue)
break;
}
}
+
+} // namespace connectivity
diff --git a/connectivity/source/drivers/file/quotedstring.cxx b/connectivity/source/drivers/file/quotedstring.cxx
index abd2d3b51e44..765c42eeeae2 100644
--- a/connectivity/source/drivers/file/quotedstring.cxx
+++ b/connectivity/source/drivers/file/quotedstring.cxx
@@ -152,7 +152,6 @@ namespace connectivity
// Vorzeitiger Abbruch der Schleife moeglich, denn
// wir haben, was wir wollten.
nStartPos = i+1;
- *pData = 0;
break;
}
else
@@ -161,6 +160,7 @@ namespace connectivity
}
}
} // for( xub_StrLen i = nStartPos; i < nLen; ++i )
+ *pData = 0;
_rStr.ReleaseBufferAccess(xub_StrLen(pData - pStart));
}
}
diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx
index 1e80a96cf682..7e97d27e1d86 100644
--- a/connectivity/source/drivers/hsqldb/HDriver.cxx
+++ b/connectivity/source/drivers/hsqldb/HDriver.cxx
@@ -55,6 +55,7 @@
#include <connectivity/dbexception.hxx>
#include <comphelper/namedvaluecollection.hxx>
#include <unotools/confignode.hxx>
+#include <unotools/ucbstreamhelper.hxx>
#include "resource/hsqldb_res.hrc"
#include "resource/sharedresources.hxx"
@@ -70,6 +71,8 @@ namespace connectivity
using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::embed;
+ using namespace ::com::sun::star::io;
+ using namespace ::com::sun::star::task;
using namespace ::com::sun::star::reflection;
namespace hsqldb
@@ -260,6 +263,50 @@ namespace connectivity
);
aProperties.put( "SystemProperties", Sequence< NamedValue >( &aPermittedClasses, 1 ) );
+ const ::rtl::OUString sProperties( RTL_CONSTASCII_USTRINGPARAM( "properties" ) );
+ ::rtl::OUString sMessage;
+ try
+ {
+ if ( !bIsNewDatabase && xStorage->isStreamElement(sProperties) )
+ {
+ Reference<XStream > xStream = xStorage->openStreamElement(sProperties,ElementModes::READ);
+ if ( xStream.is() )
+ {
+ ::std::auto_ptr<SvStream> pStream( ::utl::UcbStreamHelper::CreateStream(xStream) );
+ if ( pStream.get() )
+ {
+ ByteString sLine;
+ while ( pStream->ReadLine(sLine) )
+ {
+ if ( sLine.Equals("version=",0,sizeof("version=")-1) )
+ {
+ sLine = sLine.GetToken(1,'=');
+ const sal_Int32 nMajor = sLine.GetToken(0,'.').ToInt32();
+ const sal_Int32 nMinor = sLine.GetToken(1,'.').ToInt32();
+ const sal_Int32 nMicro = sLine.GetToken(2,'.').ToInt32();
+ if ( nMajor > 1
+ || ( nMajor == 1 && nMinor > 8 )
+ || ( nMajor == 1 && nMinor == 8 && nMicro > 0 ) )
+ {
+ ::connectivity::SharedResources aResources;
+ sMessage = aResources.getResourceString(STR_ERROR_NEW_VERSION);
+ }
+ break;
+ }
+ }
+ }
+ } // if ( xStream.is() )
+ ::comphelper::disposeComponent(xStream);
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ if ( sMessage.getLength() )
+ {
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ }
+
// readonly?
Reference<XPropertySet> xProp(xStorage,UNO_QUERY);
if ( xProp.is() )
diff --git a/connectivity/source/drivers/hsqldb/makefile.mk b/connectivity/source/drivers/hsqldb/makefile.mk
index 9ed5acb17d4c..c61e4b297ba4 100644
--- a/connectivity/source/drivers/hsqldb/makefile.mk
+++ b/connectivity/source/drivers/hsqldb/makefile.mk
@@ -102,6 +102,7 @@ SHL1STDLIBS=\
$(DBTOOLSLIB) \
$(JVMFWKLIB) \
$(COMPHELPERLIB) \
+ $(TOOLSLIB) \
$(UNOTOOLSLIB)
diff --git a/connectivity/source/inc/resource/hsqldb_res.hrc b/connectivity/source/inc/resource/hsqldb_res.hrc
index 3b7b9ef15c0a..b9066488d425 100644
--- a/connectivity/source/inc/resource/hsqldb_res.hrc
+++ b/connectivity/source/inc/resource/hsqldb_res.hrc
@@ -44,6 +44,7 @@
#define STR_NO_TABLE_EDITOR_DIALOG ( STR_HSQLDB_BASE + 3 )
#define STR_NO_TABLENAME ( STR_HSQLDB_BASE + 4 )
#define STR_NO_DOCUMENTUI ( STR_HSQLDB_BASE + 5 )
+#define STR_ERROR_NEW_VERSION ( STR_HSQLDB_BASE + 6 )
#endif // CONNECTIVITY_RESOURCE_HSQLDB_HRC
diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index a1fd44014314..8d869c2dea0a 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -2074,18 +2074,18 @@ void OSQLParseNode::absorptions(OSQLParseNode*& pSearchCondition)
if ( SQL_ISRULE(p2ndSearch,boolean_primary) )
p2ndSearch = p2ndSearch->getChild(1);
- if ( *p2ndSearch->getChild(0) == *pSearchCondition->getChild(2-nPos) )
+ if ( *p2ndSearch->getChild(0) == *pSearchCondition->getChild(2-nPos) ) // a and ( a or b) -> a or b
{
pNewNode = pSearchCondition->removeAt((sal_uInt32)0);
replaceAndReset(pSearchCondition,pNewNode);
}
- else if ( *p2ndSearch->getChild(2) == *pSearchCondition->getChild(2-nPos) )
+ else if ( *p2ndSearch->getChild(2) == *pSearchCondition->getChild(2-nPos) ) // a and ( b or a) -> a or b
{
pNewNode = pSearchCondition->removeAt((sal_uInt32)2);
replaceAndReset(pSearchCondition,pNewNode);
}
- else if ( p2ndSearch->getByRule(OSQLParseNode::boolean_term) )
+ else if ( p2ndSearch->getByRule(OSQLParseNode::search_condition) )
{
// a and ( b or c ) -> ( a and b ) or ( a and c )
// ( b or c ) and a -> ( a and b ) or ( a and c )
@@ -2096,7 +2096,13 @@ void OSQLParseNode::absorptions(OSQLParseNode*& pSearchCondition)
OSQLParseNode* p1stAnd = MakeANDNode(pA,pB);
OSQLParseNode* p2ndAnd = MakeANDNode(new OSQLParseNode(*pA),pC);
pNewNode = MakeORNode(p1stAnd,p2ndAnd);
- replaceAndReset(pSearchCondition,pNewNode);
+ OSQLParseNode* pNode = new OSQLParseNode(::rtl::OUString(),SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::boolean_primary));
+ pNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii("("),SQL_NODE_PUNCTUATION));
+ pNode->append(pNewNode);
+ pNode->append(new OSQLParseNode(::rtl::OUString::createFromAscii(")"),SQL_NODE_PUNCTUATION));
+ OSQLParseNode::eraseBraces(p1stAnd);
+ OSQLParseNode::eraseBraces(p2ndAnd);
+ replaceAndReset(pSearchCondition,pNode);
}
}
// a or a and b || a or b and a
diff --git a/connectivity/source/resource/conn_shared_res.src b/connectivity/source/resource/conn_shared_res.src
index d143dad1ba0f..48ab06f0f635 100644
--- a/connectivity/source/resource/conn_shared_res.src
+++ b/connectivity/source/resource/conn_shared_res.src
@@ -645,3 +645,8 @@ String STR_NO_DOCUMENTUI
{
Text [ en-US ] = "The provided DocumentUI is not allowed to be NULL.";
};
+String STR_ERROR_NEW_VERSION
+{
+ Text = "The connection could not be established. The database was created by a newer version of %PRODUCTNAME.";
+};
+