use of com.questdb.cairo.CairoException in project questdb by bluestreak01.
the class QueryModel method getTableMetadata.
public RecordMetadata getTableMetadata(CairoEngine engine, FlyweightCharSequence charSequence) throws ParserException {
// table name must not contain quotes by now
ExprNode readerNode = getTableName();
int lo = 0;
int hi = readerNode.token.length();
if (Chars.startsWith(readerNode.token, NO_ROWID_MARKER)) {
lo += NO_ROWID_MARKER.length();
}
if (lo == hi) {
throw ParserException.$(readerNode.position, "come on, where is table name?");
}
int status = engine.getStatus(readerNode.token, lo, hi);
if (status == TableUtils.TABLE_DOES_NOT_EXIST) {
throw ParserException.$(readerNode.position, "table does not exist");
}
if (status == TableUtils.TABLE_RESERVED) {
throw ParserException.$(readerNode.position, "table directory is of unknown format");
}
try (TableReader r = engine.getReader(charSequence.of(readerNode.token, lo, hi - lo))) {
return r.getMetadata();
} catch (EntryLockedException e) {
throw ParserException.position(readerNode.position).put("table is locked: ").put(charSequence);
} catch (CairoException e) {
throw ParserException.position(readerNode.position).put(e);
}
}
Aggregations