23#include <com/sun/star/sdbc/XRow.hpp>
24#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
32OResultSetMetaData::OResultSetMetaData(
OConnection& rConn, MYSQL_RES* pResult)
33 : m_rConnection(rConn)
35 MYSQL_FIELD* fields = mysql_fetch_field(pResult);
36 unsigned nFieldCount = mysql_num_fields(pResult);
37 for (
unsigned i = 0;
i < nFieldCount; ++
i)
42 = OUString{ fields[
i].name,
static_cast<sal_Int32
>(fields[
i].name_length),
44 fieldInfo.
length =
static_cast<sal_Int32
>(fields[
i].length);
49 fieldInfo.
flags = fields[
i].flags;
51 = OUString{ fields[
i].db,
static_cast<sal_Int32
>(fields[
i].db_length),
54 = OUString{ fields[
i].table,
static_cast<sal_Int32
>(fields[
i].table_length),
57 = OUString{ fields[
i].catalog,
static_cast<sal_Int32
>(fields[
i].catalog_length),
59 fieldInfo.
decimals =
static_cast<sal_Int32
>(fields[
i].decimals);
60 fieldInfo.
max_length =
static_cast<sal_Int32
>(fields[
i].max_length);
62 m_fields.push_back(std::move(fieldInfo));
69 return m_fields.at(column - 1).length;
85 =
"SHOW COLLATION WHERE Id =" + OUString::number(
m_fields.at(column - 1).charsetNumber);
88 Reference<XResultSet> rs = stmt->executeQuery(
sql);
89 Reference<XRow> xRow(rs, UNO_QUERY_THROW);
94 OUString sColName = xRow->getString(1);
96 return !sColName.isEmpty() && !sColName.endsWith(
"_ci");
102 return m_fields.at(column - 1).schemaName;
108 return m_fields.at(column - 1).columnName;
114 return m_fields.at(column - 1).tableName;
120 return m_fields.at(column - 1).catalogName;
149 return (
m_fields.at(column - 1).flags & AUTO_INCREMENT_FLAG) != 0;
155 return !(
m_fields.at(column - 1).flags & UNSIGNED_FLAG);
161 return m_fields.at(column - 1).max_length -
m_fields.at(column - 1).decimals;
167 return m_fields.at(column - 1).decimals;
173 return (
m_fields.at(column - 1).flags & NOT_NULL_FLAG) ? 0 : 1;
185 return m_fields.at(column - 1).schemaName.isEmpty();
205 OUString str =
"Column index out of range (expected 1 to "
206 + OUString::number(sal_Int32(nColCount)) +
", got "
207 + OUString::number(columnIndex) +
".";
208 throw SQLException(str, *
this, OUString(), 1,
Any());
rtl_TextEncoding getConnectionEncoding() const
css::uno::Reference< css::sdbc::XStatement > SAL_CALL createStatement() override
sal_Int32 mysqlToOOOType(int eType, int charsetnr) noexcept
OUString mysqlTypeToStr(unsigned type, unsigned flags)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
enum_field_types mysql_type