use of io.questdb.cairo.pool.ex.EntryLockedException in project questdb by bluestreak01.
the class SqlOptimiser method openReaderAndEnumerateColumns.
private void openReaderAndEnumerateColumns(SqlExecutionContext executionContext, QueryModel model) throws SqlException {
final ExpressionNode tableNameNode = model.getTableName();
// table name must not contain quotes by now
final CharSequence tableName = tableNameNode.token;
final int tableNamePosition = tableNameNode.position;
int lo = 0;
int hi = tableName.length();
if (Chars.startsWith(tableName, QueryModel.NO_ROWID_MARKER)) {
lo += QueryModel.NO_ROWID_MARKER.length();
}
if (lo == hi) {
throw SqlException.$(tableNamePosition, "come on, where is table name?");
}
int status = engine.getStatus(executionContext.getCairoSecurityContext(), path, tableName, lo, hi);
if (status == TableUtils.TABLE_DOES_NOT_EXIST) {
try {
model.getTableName().type = ExpressionNode.FUNCTION;
parseFunctionAndEnumerateColumns(model, executionContext);
return;
} catch (SqlException e) {
throw SqlException.$(tableNamePosition, "" + "table does not exist [name=").put(tableName).put(']');
}
}
if (status == TableUtils.TABLE_RESERVED) {
throw SqlException.$(tableNamePosition, "table directory is of unknown format");
}
try (TableReader r = engine.getReader(executionContext.getCairoSecurityContext(), tableLookupSequence.of(tableName, lo, hi - lo), TableUtils.ANY_TABLE_ID, TableUtils.ANY_TABLE_VERSION)) {
model.setTableVersion(r.getVersion());
model.setTableId(r.getMetadata().getId());
copyColumnsFromMetadata(model, r.getMetadata(), false);
} catch (EntryLockedException e) {
throw SqlException.position(tableNamePosition).put("table is locked: ").put(tableLookupSequence);
} catch (CairoException e) {
throw SqlException.position(tableNamePosition).put(e);
}
}
Aggregations