[Libreoffice-commits] core.git: dbaccess/source

Tamas Bunth tamas.bunth at collabora.co.uk
Wed Mar 7 10:32:15 UTC 2018


 dbaccess/source/filter/hsqldb/createparser.cxx   |   12 +++++++++
 dbaccess/source/filter/hsqldb/hsqlimport.cxx     |   29 ++++++++++++++++++++++-
 dbaccess/source/filter/hsqldb/rowinputbinary.cxx |    2 -
 3 files changed, 41 insertions(+), 2 deletions(-)

New commits:
commit ed031c6ceab99bf3e6b0ea320423d9fa9a734ad5
Author: Tamas Bunth <tamas.bunth at collabora.co.uk>
Date:   Tue Mar 6 21:39:37 2018 +0100

    dbahsql: add BINARY and VARBINARY import
    
    Change-Id: Ibb4d5f8dda16dc7779b7a7b818a8bd2c49cbf283
    Reviewed-on: https://gerrit.libreoffice.org/50844
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tamás Bunth <btomi96 at gmail.com>

diff --git a/dbaccess/source/filter/hsqldb/createparser.cxx b/dbaccess/source/filter/hsqldb/createparser.cxx
index 4df5a097bc64..8e7f12391e0f 100644
--- a/dbaccess/source/filter/hsqldb/createparser.cxx
+++ b/dbaccess/source/filter/hsqldb/createparser.cxx
@@ -157,8 +157,16 @@ sal_Int32 lcl_getDataTypeFromHsql(const OUString& sTypeName)
     assert(false);
     return -1;
 }
+
+void lcl_addDefaultParameters(std::vector<sal_Int32>& aParams, sal_Int32 eType)
+{
+    if (eType == DataType::CHAR || eType == DataType::BINARY || eType == DataType::VARBINARY
+        || eType == DataType::VARCHAR)
+        aParams.push_back(8000); // from SQL standard
 }
 
+} // unnamed namespace
+
 namespace dbahsql
 {
 CreateStmtParser::CreateStmtParser() {}
@@ -195,6 +203,10 @@ void CreateStmtParser::parseColumnPart(const OUString& sColumnPart)
                 aParams.push_back(sParam.toInt32());
             }
         }
+        else
+        {
+            lcl_addDefaultParameters(aParams, lcl_getDataTypeFromHsql(sTypeName));
+        }
 
         ColumnDefinition aColDef(words[0], lcl_getDataTypeFromHsql(sTypeName), aParams,
                                  lcl_isPrimaryKey(sColumn), lcl_getAutoIncrementDefault(sColumn),
diff --git a/dbaccess/source/filter/hsqldb/hsqlimport.cxx b/dbaccess/source/filter/hsqldb/hsqlimport.cxx
index c1f4cddd113c..03d25f79ed03 100644
--- a/dbaccess/source/filter/hsqldb/hsqlimport.cxx
+++ b/dbaccess/source/filter/hsqldb/hsqlimport.cxx
@@ -122,28 +122,55 @@ void lcl_setParams(const RowVector& row, Reference<XParameters>& xParam,
             }
             break;
             case DataType::BIGINT:
-                break;
+            {
+                sal_Int64 nVal;
+                if (row.at(i) >>= nVal)
+                {
+                    xParam->setLong(i + 1, nVal);
+                }
+            }
+            break;
             case DataType::REAL:
             case DataType::FLOAT:
             case DataType::DOUBLE:
+            {
+                double nVal;
+                if (row.at(i) >>= nVal)
+                {
+                    xParam->setDouble(i + 1, nVal);
+                }
                 break;
+            }
             case DataType::NUMERIC:
             case DataType::DECIMAL:
+                // TODO
                 break;
             case DataType::DATE:
+                // TODO
                 break;
             case DataType::TIME:
+                // TODO
                 break;
             case DataType::TIMESTAMP:
+                // TODO
                 break;
             case DataType::BOOLEAN:
+                // TODO
                 break;
             case DataType::OTHER:
+                // TODO
                 break;
             case DataType::BINARY:
             case DataType::VARBINARY:
             case DataType::LONGVARBINARY:
+            {
+                Sequence<sal_Int8> nVal;
+                if (row.at(i) >>= nVal)
+                {
+                    xParam->setBytes(i + 1, nVal);
+                }
                 break;
+            }
             default:
                 throw WrongFormatException();
         }
diff --git a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
index 37cfa918fef5..a0f52b0601a1 100644
--- a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
+++ b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
@@ -227,7 +227,7 @@ std::vector<Any> HsqlRowInputStream::readOneRow(const ColumnTypeVector& nColType
                 sal_Int32 nSize = 0;
                 m_pStream->ReadInt32(nSize);
 
-                Sequence<sal_uInt8> aBytes(nSize);
+                Sequence<sal_Int8> aBytes(nSize);
                 m_pStream->ReadBytes(aBytes.getArray(), nSize);
                 aData.push_back(makeAny(aBytes));
             }


More information about the Libreoffice-commits mailing list