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>
This commit is contained in:
Wastack 2016-11-27 15:08:18 +01:00 committed by Lionel Elie Mamane
parent ea61a62323
commit 1d0f3649ba
4 changed files with 28 additions and 5 deletions

View File

@ -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:

View File

@ -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>

View File

@ -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)

View File

@ -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);