summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamas Bunth <tamas.bunth@collabora.co.uk>2018-04-26 13:29:16 +0200
committerTamás Bunth <btomi96@gmail.com>2018-05-02 19:02:55 +0200
commit04e564b8179cdfafc0f33233daae126e39f46e47 (patch)
treea06477919aee91ee8f0603730494cd55639a7652
parentbe3ef7b0e5e51c1d97309ce3b6d5cac1fbd025d0 (diff)
tdf#116980 tdf#116986 Fix data migration in..
.. databases with relations. There might be several nodes written in data file before the actual row, each representing an index. We have to skip these. Change-Id: I1556a8212b509c6cb63cb98fa0e9b7b8d3483004 Reviewed-on: https://gerrit.libreoffice.org/53507 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tamás Bunth <btomi96@gmail.com>
-rw-r--r--dbaccess/source/filter/hsqldb/hsqlbinarynode.cxx6
-rw-r--r--dbaccess/source/filter/hsqldb/hsqlbinarynode.hxx3
-rw-r--r--dbaccess/source/filter/hsqldb/hsqlimport.cxx16
-rw-r--r--dbaccess/source/filter/hsqldb/hsqlimport.hxx3
4 files changed, 17 insertions, 11 deletions
diff --git a/dbaccess/source/filter/hsqldb/hsqlbinarynode.cxx b/dbaccess/source/filter/hsqldb/hsqlbinarynode.cxx
index c7e07ec90b83..89371c735c44 100644
--- a/dbaccess/source/filter/hsqldb/hsqlbinarynode.cxx
+++ b/dbaccess/source/filter/hsqldb/hsqlbinarynode.cxx
@@ -48,9 +48,11 @@ void HsqlBinaryNode::readChildren(HsqlRowInputStream const& input)
}
std::vector<css::uno::Any> HsqlBinaryNode::readRow(HsqlRowInputStream& input,
- const ColumnTypeVector& aColTypes)
+ const ColumnTypeVector& aColTypes,
+ sal_Int32 nIndexCount)
{
- input.seek(m_nPos + 20); // go to data
+ // skip first 4 bytes (size), and index nodes, 16 bytes each
+ input.seek(m_nPos + 4 + nIndexCount * 16);
return input.readOneRow(aColTypes);
}
diff --git a/dbaccess/source/filter/hsqldb/hsqlbinarynode.hxx b/dbaccess/source/filter/hsqldb/hsqlbinarynode.hxx
index 0f9271b8eef1..e03a88a72de8 100644
--- a/dbaccess/source/filter/hsqldb/hsqlbinarynode.hxx
+++ b/dbaccess/source/filter/hsqldb/hsqlbinarynode.hxx
@@ -57,7 +57,8 @@ public:
* @param rInput input stream where the row should be read from.
*/
std::vector<css::uno::Any> readRow(HsqlRowInputStream& rInput,
- const std::vector<ColumnDefinition>& aColTypes);
+ const std::vector<ColumnDefinition>& aColTypes,
+ sal_Int32 nIndexCount);
};
}
diff --git a/dbaccess/source/filter/hsqldb/hsqlimport.cxx b/dbaccess/source/filter/hsqldb/hsqlimport.cxx
index 409ad54447d1..707e34eaaa6c 100644
--- a/dbaccess/source/filter/hsqldb/hsqlimport.cxx
+++ b/dbaccess/source/filter/hsqldb/hsqlimport.cxx
@@ -229,23 +229,24 @@ void HsqlImporter::insertRow(const RowVector& xRows, const OUString& sTableName,
}
void HsqlImporter::processTree(HsqlBinaryNode& rNode, HsqlRowInputStream& rStream,
- const ColumnTypeVector& rColTypes, const OUString& sTableName)
+ const ColumnTypeVector& rColTypes, const OUString& sTableName,
+ sal_Int32 nIndexCount)
{
rNode.readChildren(rStream);
sal_Int32 nNext = rNode.getLeft();
if (nNext > 0)
{
HsqlBinaryNode aLeft{ nNext };
- processTree(aLeft, rStream, rColTypes, sTableName);
+ processTree(aLeft, rStream, rColTypes, sTableName, nIndexCount);
}
- std::vector<Any> row = rNode.readRow(rStream, rColTypes);
+ std::vector<Any> row = rNode.readRow(rStream, rColTypes, nIndexCount);
insertRow(row, sTableName, rColTypes);
nNext = rNode.getRight();
if (nNext > 0)
{
HsqlBinaryNode aRight{ nNext };
- processTree(aRight, rStream, rColTypes, sTableName);
+ processTree(aRight, rStream, rColTypes, sTableName, nIndexCount);
}
}
@@ -278,11 +279,12 @@ void HsqlImporter::parseTableRows(const IndexVector& rIndexes,
Reference<XInputStream> xInput = xStream->getInputStream();
rowInput.setInputStream(xInput);
- for (const auto& rIndex : rIndexes)
+ if (rIndexes.size() > 0)
{
- HsqlBinaryNode aNode{ rIndex };
- processTree(aNode, rowInput, rColTypes, sTableName);
+ HsqlBinaryNode aPrimaryNode{ rIndexes.at(0) };
+ processTree(aPrimaryNode, rowInput, rColTypes, sTableName, rIndexes.size());
}
+
xInput->closeInput();
}
diff --git a/dbaccess/source/filter/hsqldb/hsqlimport.hxx b/dbaccess/source/filter/hsqldb/hsqlimport.hxx
index 1df9ddbc3a10..12d0489cb852 100644
--- a/dbaccess/source/filter/hsqldb/hsqlimport.hxx
+++ b/dbaccess/source/filter/hsqldb/hsqlimport.hxx
@@ -29,7 +29,8 @@ protected:
void insertRow(const std::vector<css::uno::Any>& xRows, const OUString& sTable,
const std::vector<ColumnDefinition>& rColTypes);
void processTree(HsqlBinaryNode& rNode, HsqlRowInputStream& rStream,
- const std::vector<ColumnDefinition>& rColTypes, const OUString& sTableName);
+ const std::vector<ColumnDefinition>& rColTypes, const OUString& sTableName,
+ sal_Int32 nIndexCount);
void parseTableRows(const std::vector<sal_Int32>& rIndexes,
const std::vector<ColumnDefinition>& rColTypes, const OUString& sTableName);