use of org.apache.ignite.client.proto.query.event.JdbcMetaPrimaryKeysResult in project ignite-3 by apache.
the class JdbcDatabaseMetadata method getPrimaryKeys.
/**
* {@inheritDoc}
*/
@Override
public ResultSet getPrimaryKeys(String catalog, String schema, String tbl) throws SQLException {
conn.ensureNotClosed();
final List<JdbcColumnMeta> meta = asList(new JdbcColumnMeta("TABLE_CAT", String.class), new JdbcColumnMeta("TABLE_SCHEM", String.class), new JdbcColumnMeta("TABLE_NAME", String.class), new JdbcColumnMeta("COLUMN_NAME", String.class), new JdbcColumnMeta("KEY_SEQ", Short.class), new JdbcColumnMeta("PK_NAME", String.class));
if (!isValidCatalog(catalog)) {
return new JdbcResultSet(Collections.emptyList(), meta);
}
JdbcMetaPrimaryKeysResult res = conn.handler().primaryKeysMetaAsync(new JdbcMetaPrimaryKeysRequest(schema, tbl)).join();
if (!res.hasResults()) {
throw IgniteQueryErrorCode.createJdbcSqlException(res.err(), res.status());
}
List<List<Object>> rows = new LinkedList<>();
for (JdbcPrimaryKeyMeta pkMeta : res.meta()) {
rows.addAll(primaryKeyRows(pkMeta));
}
return new JdbcResultSet(rows, meta);
}
Aggregations