From c729e75129ed5de9b8e8044a9fe071ade621dc93 Mon Sep 17 00:00:00 2001 From: "Andrzej J.R. Hunt" Date: Mon, 22 Jul 2013 09:30:30 +0200 Subject: Add conversion of blr types to firebird SQL_ types. Internally firebird uses blr_* types -- we encounter these values e.g. when retrieving column metadata within RDB$FIELD_TYPE. These can be converted to the firebird SQL_* types for use within the rest of the driver as appropriate. Change-Id: If9a9bc3c58d99a2f61f52faef6316e2d3451af1a --- connectivity/source/drivers/firebird/Util.cxx | 51 +++++++++++++++++++++++++-- connectivity/source/drivers/firebird/Util.hxx | 12 +++++-- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/connectivity/source/drivers/firebird/Util.cxx b/connectivity/source/drivers/firebird/Util.cxx index 5fd08e3e9408..c41dde26c1b4 100644 --- a/connectivity/source/drivers/firebird/Util.cxx +++ b/connectivity/source/drivers/firebird/Util.cxx @@ -17,7 +17,7 @@ using namespace ::rtl; using namespace ::com::sun::star::sdbc; -sal_Int32 firebird::getColumnTypeFromFBType(int aType) +sal_Int32 firebird::getColumnTypeFromFBType(short aType) { aType &= ~1; // Remove last bit -- it is used to denote whether column // can store Null, not needed for type determination @@ -59,7 +59,7 @@ sal_Int32 firebird::getColumnTypeFromFBType(int aType) } } -OUString firebird::getColumnTypeNameFromFBType(int aType) +OUString firebird::getColumnTypeNameFromFBType(short aType) { aType &= ~1; // Remove last bit -- it is used to denote whether column // can store Null, not needed for type determination @@ -101,4 +101,51 @@ OUString firebird::getColumnTypeNameFromFBType(int aType) } } +short getFBTypeFromBlrType(short blrType) +{ + switch (blrType) + { + case blr_text: + return SQL_TEXT; + case blr_text2: + assert(false); + return 0; // No idea if this should be supported + case blr_varying: + return SQL_VARYING; + case blr_varying2: + assert(false); + return 0; // No idea if this should be supported + case blr_short: + return SQL_SHORT; + case blr_long: + return SQL_LONG; + case blr_float: + return SQL_FLOAT; + case blr_double: + return SQL_DOUBLE; + case blr_d_float: + return SQL_D_FLOAT; + case blr_timestamp: + return SQL_TIMESTAMP; + case blr_blob: + return SQL_BLOB; +// case blr_SQL_ARRAY: +// return OUString("SQL_ARRAY"); + case blr_sql_time: + return SQL_TYPE_TIME; + case blr_sql_date: + return SQL_TYPE_DATE; + case blr_int64: + return SQL_INT64; +// case SQL_NULL: +// return OUString("SQL_NULL"); + case blr_quad: + return SQL_QUAD; + 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. + assert(false); + return 0; + } +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/connectivity/source/drivers/firebird/Util.hxx b/connectivity/source/drivers/firebird/Util.hxx index 532403103ca0..0d68099b78df 100644 --- a/connectivity/source/drivers/firebird/Util.hxx +++ b/connectivity/source/drivers/firebird/Util.hxx @@ -18,8 +18,16 @@ namespace connectivity { namespace firebird { - sal_Int32 getColumnTypeFromFBType(int aType); - ::rtl::OUString getColumnTypeNameFromFBType(int aType); + sal_Int32 getColumnTypeFromFBType(short aType); + ::rtl::OUString getColumnTypeNameFromFBType(short aType); + + /** + * Internally (i.e. in RDB$FIELD_TYPE) firebird stores the data type + * for a column as defined in blr_*, however in the firebird + * api the SQL_* types are used, hence we need to be able to convert + * between the two when retrieving column metadata. + */ + short getFBTypeFromBlrType(short blrType); } } #endif //CONNECTIVITY_FIREBIRD_UTIL_HXX -- cgit