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

Wastack btomi96 at gmail.com
Sun Dec 11 10:43:59 UTC 2016


 connectivity/source/drivers/firebird/DatabaseMetaData.cxx  |   13 +++++++++++++
 connectivity/source/drivers/firebird/PreparedStatement.cxx |    5 ++---
 connectivity/source/drivers/firebird/ResultSet.cxx         |    5 +++--
 connectivity/source/drivers/firebird/Util.cxx              |   10 ++++++++++
 4 files changed, 28 insertions(+), 5 deletions(-)

New commits:
commit 1d0f3649ba271a439ab38d35ce02462561cc9caa
Author: Wastack <btomi96 at gmail.com>
Date:   Sun Nov 27 15:08:18 2016 +0100

    tdf#103074 Implement Boolean Type for FB driver
    
    Change-Id: Ibed5435e23730dc901155e79152e9becd3e70566
    Reviewed-on: https://gerrit.libreoffice.org/31262
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Lionel Elie Mamane <lionel at mamane.lu>

diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
index 959b134..1240fae 100644
--- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
@@ -1050,6 +1050,19 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo()
         aRow[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
         aResults.push_back(aRow);
 
+        // SQL_BOOLEAN
+        // TODO FIXME precision
+        aRow[1] = new ORowSetValueDecorator(OUString("BOOLEAN"));
+        aRow[2] = new ORowSetValueDecorator(getColumnTypeFromFBType(SQL_BOOLEAN, 0));
+        aRow[3] = new ORowSetValueDecorator(sal_Int32(1)); // Prevision = max length
+        aRow[6] = new ORowSetValueDecorator(); // Create Params
+        aRow[9] = new ORowSetValueDecorator(
+                sal_Int16(ColumnSearch::BASIC)); // Searchable
+        aRow[12] = new ORowSetValueDecorator(false); // Autoincrement
+        aRow[14] = ODatabaseMetaDataResultSet::get0Value(); // Minimum scale
+        aRow[15] = ODatabaseMetaDataResultSet::get0Value(); // Max scale
+        aResults.push_back(aRow);
+
         // TODO: complete
 //     case SQL_ARRAY:
 //     case SQL_NULL:
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index 7af0976..7af5203 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -355,11 +355,10 @@ void SAL_CALL OPreparedStatement::setNull(sal_Int32 nIndex, sal_Int32 /*nSqlType
     setParameterNull(nIndex);
 }
 
-void SAL_CALL OPreparedStatement::setBoolean(sal_Int32 /*nIndex*/, sal_Bool /*bValue*/)
+void SAL_CALL OPreparedStatement::setBoolean(sal_Int32 nIndex, sal_Bool bValue)
     throw(SQLException, RuntimeException, std::exception)
 {
-    // FIREBIRD3: will need to be implemented.
-    ::dbtools::throwFunctionNotSupportedSQLException("XParameters::setBoolean", *this);
+    setValue< sal_Bool >(nIndex, bValue, SQL_BOOLEAN);
 }
 
 template <typename T>
diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx b/connectivity/source/drivers/firebird/ResultSet.cxx
index e1007af..b09d6cc 100644
--- a/connectivity/source/drivers/firebird/ResultSet.cxx
+++ b/connectivity/source/drivers/firebird/ResultSet.cxx
@@ -481,6 +481,8 @@ ORowSetValue OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_S
             if(nSqlSubType == 1 || nSqlSubType == 2) //numeric or decimal
                 return getString(nColumnIndex);
             return getLong(nColumnIndex);
+        case SQL_BOOLEAN:
+            return getBoolean(nColumnIndex);
         case SQL_BLOB:
         case SQL_NULL:
         case SQL_QUAD:
@@ -643,8 +645,7 @@ sal_Bool SAL_CALL OResultSet::wasNull() throw(SQLException, RuntimeException, st
 sal_Bool SAL_CALL OResultSet::getBoolean(sal_Int32 nColumnIndex)
     throw(SQLException, RuntimeException, std::exception)
 {
-    // Not a native firebird type hence we always have to convert.
-    return safelyRetrieveValue< ORowSetValue >(nColumnIndex);
+    return safelyRetrieveValue< sal_Bool >(nColumnIndex, SQL_BOOLEAN);
 }
 
 sal_Int8 SAL_CALL OResultSet::getByte(sal_Int32 nColumnIndex)
diff --git a/connectivity/source/drivers/firebird/Util.cxx b/connectivity/source/drivers/firebird/Util.cxx
index 1502e60..7d72900 100644
--- a/connectivity/source/drivers/firebird/Util.cxx
+++ b/connectivity/source/drivers/firebird/Util.cxx
@@ -127,6 +127,8 @@ sal_Int32 firebird::getColumnTypeFromFBType(short aType, short aSubType)
         return DataType::SQLNULL;
     case SQL_QUAD:      // Is a "Blob ID" according to the docs
         return 0;       // TODO: verify
+    case SQL_BOOLEAN:
+        return DataType::BOOLEAN;
     default:
         assert(false); // Should never happen
         return 0;
@@ -185,6 +187,8 @@ OUString firebird::getColumnTypeNameFromFBType(short aType, short aSubType)
         return OUString("SQL_NULL");
     case SQL_QUAD:
         return OUString("SQL_QUAD");
+    case SQL_BOOLEAN:
+        return OUString("SQL_BOOLEAN");
     default:
         assert(false); // Should never happen
         return OUString();
@@ -231,6 +235,8 @@ short firebird::getFBTypeFromBlrType(short blrType)
 //         return OUString("SQL_NULL");
     case blr_quad:
         return SQL_QUAD;
+    case blr_bool:
+        return SQL_BOOLEAN;
     default:
         // If this happens we have hit one of the extra types in ibase.h
         // look up blr_* for a list, e.g. blr_domain_name, blr_not_nullable etc.
@@ -286,6 +292,9 @@ void firebird::mallocSQLVAR(XSQLDA* pSqlda)
         case SQL_INT64:
             pVar->sqldata = static_cast<char *>(malloc(sizeof(sal_Int64)));
             break;
+        case SQL_BOOLEAN:
+            pVar->sqldata = static_cast<char *>(malloc(sizeof(sal_Bool)));
+            break;
         case SQL_NULL:
             assert(false); // TODO: implement
             break;
@@ -321,6 +330,7 @@ void firebird::freeSQLVAR(XSQLDA* pSqlda)
         case SQL_INT64:
         case SQL_TYPE_TIME:
         case SQL_TYPE_DATE:
+        case SQL_BOOLEAN:
             if(pVar->sqldata)
             {
                 free(pVar->sqldata);


More information about the Libreoffice-commits mailing list