summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorWastack <btomi96@gmail.com>2016-11-27 15:08:18 +0100
committerLionel Elie Mamane <lionel@mamane.lu>2016-12-11 10:43:22 +0000
commit1d0f3649ba271a439ab38d35ce02462561cc9caa (patch)
tree8fcc82e030bba4ff29783cf6f22149deb98e4986 /connectivity
parentea61a62323fe398d682da5bbf5b0d9e17d442212 (diff)
tdf#103074 Implement Boolean Type for FB driver
Change-Id: Ibed5435e23730dc901155e79152e9becd3e70566 Reviewed-on: https://gerrit.libreoffice.org/31262 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Lionel Elie Mamane <lionel@mamane.lu>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/firebird/DatabaseMetaData.cxx13
-rw-r--r--connectivity/source/drivers/firebird/PreparedStatement.cxx5
-rw-r--r--connectivity/source/drivers/firebird/ResultSet.cxx5
-rw-r--r--connectivity/source/drivers/firebird/Util.cxx10
4 files changed, 28 insertions, 5 deletions
diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
index 959b134a0505..1240fae101a8 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 7af0976b4962..7af52032cc4c 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 e1007afb7a71..b09d6cce5080 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 1502e60c5286..7d72900a4788 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);