diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2021-11-18 13:07:41 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2021-11-20 14:21:44 +0100 |
commit | 2d445f90dbecf8d2240474dcb06084868ceb921a (patch) | |
tree | 60bd46ea2a31b83fdd306b8658c215d3c8da6995 /connectivity | |
parent | 653c5d2ca1cc777d3556348b65ded0eaae95a414 (diff) |
tdf#145714: teach "mediumblob" to Mysql/MariaDB part in LO
also teach about:
TINYBLOB + LONGBLOB + TINYTEXT + MEDIUMTEXT + YEAR + BIT
Taking a look at libmariadb, I see in libmariadb/mariadb_stmt.c:
535 case MYSQL_TYPE_SHORT:
536 case MYSQL_TYPE_YEAR:
537 int2store(*p, (*(short *)buf));
538 (*p) += 2;
539 break;
1208 case MYSQL_TYPE_SHORT:
1209 case MYSQL_TYPE_YEAR:
1210 stmt->params[i].buffer_length= 2;
1211 break;
1313 case MYSQL_TYPE_SHORT:
1314 case MYSQL_TYPE_YEAR:
1315 *stmt->bind[i].length= stmt->bind[i].length_value= 2;
1316 break;
Change-Id: Id72056429d5d2f2741063ee28b2d2e3c75e378a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125472
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'connectivity')
3 files changed, 36 insertions, 7 deletions
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_general.cxx b/connectivity/source/drivers/mysqlc/mysqlc_general.cxx index e4b9040b8a1e..35ecfee84750 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_general.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_general.cxx @@ -43,6 +43,7 @@ void allocateSqlVar(void** mem, enum_field_types eType, unsigned nSize) *mem = malloc(sizeof(sal_Int32)); break; case MYSQL_TYPE_SHORT: + case MYSQL_TYPE_YEAR: *mem = malloc(sizeof(sal_Int16)); break; case MYSQL_TYPE_BIT: @@ -62,7 +63,6 @@ void allocateSqlVar(void** mem, enum_field_types eType, unsigned nSize) case MYSQL_TYPE_TIME: case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_TIMESTAMP: - case MYSQL_TYPE_YEAR: // FIXME below case MYSQL_TYPE_NEWDATE: case MYSQL_TYPE_ENUM: case MYSQL_TYPE_SET: @@ -131,6 +131,7 @@ sal_Int32 mysqlToOOOType(int eType, int charsetnr) noexcept return css::sdbc::DataType::TINYINT; case MYSQL_TYPE_SHORT: + case MYSQL_TYPE_YEAR: return css::sdbc::DataType::SMALLINT; case MYSQL_TYPE_INT24: @@ -193,10 +194,8 @@ sal_Int32 mysqlStrToOOOType(const OUString& sType) // TODO other types. if (sType.equalsIgnoreAsciiCase("tiny") || sType.equalsIgnoreAsciiCase("tinyint")) return css::sdbc::DataType::TINYINT; - if (sType.equalsIgnoreAsciiCase("smallint")) + if (sType.equalsIgnoreAsciiCase("smallint") || sType.equalsIgnoreAsciiCase("year")) return css::sdbc::DataType::SMALLINT; - if (sType.equalsIgnoreAsciiCase("longtext")) - return css::sdbc::DataType::LONGVARCHAR; if (sType.equalsIgnoreAsciiCase("int") || sType.equalsIgnoreAsciiCase("mediumint")) return css::sdbc::DataType::INTEGER; if (sType.equalsIgnoreAsciiCase("varchar") || sType.equalsIgnoreAsciiCase("set") @@ -204,13 +203,18 @@ sal_Int32 mysqlStrToOOOType(const OUString& sType) return css::sdbc::DataType::VARCHAR; if (sType.equalsIgnoreAsciiCase("bigint")) return css::sdbc::DataType::BIGINT; - if (sType.equalsIgnoreAsciiCase("blob") || sType.equalsIgnoreAsciiCase("longblob")) + if (sType.equalsIgnoreAsciiCase("blob") || sType.equalsIgnoreAsciiCase("longblob") + || sType.equalsIgnoreAsciiCase("tinyblob") || sType.equalsIgnoreAsciiCase("mediumblob")) return css::sdbc::DataType::BLOB; if (sType.equalsIgnoreAsciiCase("varbinary")) return css::sdbc::DataType::VARBINARY; if (sType.equalsIgnoreAsciiCase("char")) return css::sdbc::DataType::CHAR; + if (sType.equalsIgnoreAsciiCase("tinytext")) + return css::sdbc::DataType::VARCHAR; if (sType.equalsIgnoreAsciiCase("text")) + return css::sdbc::DataType::LONGVARCHAR; + if (sType.equalsIgnoreAsciiCase("mediumtext") || sType.equalsIgnoreAsciiCase("longtext")) return css::sdbc::DataType::CLOB; if (sType.equalsIgnoreAsciiCase("binary")) return css::sdbc::DataType::BINARY; diff --git a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx index 22f5499ea9a2..7c88cd1a347c 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx @@ -57,9 +57,12 @@ std::type_index getTypeFromMysqlType(enum_field_types type) { switch (type) { + case MYSQL_TYPE_BIT: + return std::type_index(typeid(bool)); case MYSQL_TYPE_TINY: return std::type_index(typeid(sal_Int8)); case MYSQL_TYPE_SHORT: + case MYSQL_TYPE_YEAR: return std::type_index(typeid(sal_Int16)); case MYSQL_TYPE_LONG: case MYSQL_TYPE_INT24: @@ -83,8 +86,6 @@ std::type_index getTypeFromMysqlType(enum_field_types type) case MYSQL_TYPE_NEWDECIMAL: return std::type_index(typeid(OUString)); case MYSQL_TYPE_BLOB: - case MYSQL_TYPE_YEAR: - case MYSQL_TYPE_BIT: case MYSQL_TYPE_SET: case MYSQL_TYPE_ENUM: case MYSQL_TYPE_GEOMETRY: @@ -318,10 +319,13 @@ ORowSetValue OPreparedResultSet::getRowSetValue(sal_Int32 nColumnIndex) case MYSQL_TYPE_TINY: return getByte(nColumnIndex); case MYSQL_TYPE_SHORT: + case MYSQL_TYPE_YEAR: return getShort(nColumnIndex); case MYSQL_TYPE_LONG: case MYSQL_TYPE_INT24: return getInt(nColumnIndex); + case MYSQL_TYPE_BIT: + return ORowSetValue(bool(getBoolean(nColumnIndex))); case MYSQL_TYPE_LONGLONG: return getLong(nColumnIndex); case MYSQL_TYPE_FLOAT: diff --git a/connectivity/source/drivers/mysqlc/mysqlc_types.cxx b/connectivity/source/drivers/mysqlc/mysqlc_types.cxx index 219e0d553d41..ca473cebd84f 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_types.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_types.cxx @@ -673,6 +673,27 @@ TypeInfoDef const mysqlc_types[] = { }, // ----------- MySQL-Type: TIMESTAMP SDBC-Type: TIMESTAMP ---------- + + // ----------- MySQL-Type: YEAR SDBC-Type: INTEGER ---------- + { + "YEAR", // Typename + com::sun::star::sdbc::DataType::SMALLINT, // sdbc-type + 10, // Precision + "", // Literal prefix + "", // Literal suffix + "[(M)] [UNSIGNED] [ZEROFILL]", // Create params + com::sun::star::sdbc::ColumnValue::NULLABLE, // nullable + false, // case sensitive + com::sun::star::sdbc::ColumnSearch::FULL, // searchable + true, // unsignable + false, // fixed_prec_scale + true, // auto_increment + "YEAR", // local type name + 0, // minimum scale + 0 // maximum scale + }, + + // ----------- MySQL-Type: YEAR SDBC-Type: INTEGER ---------- { nullptr, 0, 0, nullptr, nullptr, nullptr, 0, false, 0, false, false, false, nullptr, 0, 0 } }; |