Execution execution)
{
StringBuilder buf = new StringBuilder("select count(*) from ");
dialect.quoteIdentifier(buf, catalog, schema, table);
final String sql = buf.toString();
SqlStatement stmt =
RolapUtil.executeQuery(
dataSource,
sql,
new Locus(
execution,
"SqlStatisticsProvider.getTableCardinality",
"Reading row count from table "
+ Arrays.asList(catalog, schema, table)));
try {
ResultSet resultSet = stmt.getResultSet();
if (resultSet.next()) {
++stmt.rowCount;
return resultSet.getInt(1);
}
return -1; // huh?
} catch (SQLException e) {
throw stmt.handle(e);
} finally {
stmt.close();
}
}