use of com.questdb.std.FilesFacade in project questdb by bluestreak01.
the class Engine method rename0.
private void rename0(CharSequence tableName, CharSequence to) {
final FilesFacade ff = configuration.getFilesFacade();
final CharSequence root = configuration.getRoot();
if (TableUtils.exists(ff, path, root, tableName) != TableUtils.TABLE_EXISTS) {
LOG.error().$('\'').utf8(tableName).$("' does not exist. Rename failed.").$();
throw CairoException.instance(0).put("Rename failed. Table '").put(tableName).put("' does not exist");
}
path.of(root).concat(tableName).$();
other.of(root).concat(to).$();
if (ff.exists(other)) {
LOG.error().$("rename target exists [from='").$(tableName).$("', to='").$(other).$("']").$();
throw CairoException.instance(0).put("Rename target exists");
}
if (!ff.rename(path, other)) {
int error = ff.errno();
LOG.error().$("rename failed [from='").$(path).$("', to='").$(other).$("', error=").$(error).$(']').$();
throw CairoException.instance(error).put("Rename failed");
}
}
use of com.questdb.std.FilesFacade in project questdb by bluestreak01.
the class SqlLexerOptimiserTest method testTableNameCannotOpen.
@Test
public void testTableNameCannotOpen() {
final FilesFacade ff = new FilesFacadeImpl() {
@Override
public long openRO(LPSZ name) {
if (Chars.endsWith(name, TableUtils.META_FILE_NAME)) {
return -1;
}
return super.openRO(name);
}
};
CairoConfiguration configuration = new DefaultCairoConfiguration(root) {
@Override
public FilesFacade getFilesFacade() {
return ff;
}
};
CairoEngine engine = new Engine(configuration);
SqlLexerOptimiser lexer = new SqlLexerOptimiser(engine, configuration);
assertSyntaxError(lexer, engine, "select * from tab", 14, "Cannot open file", modelOf("tab").col("x", ColumnType.INT));
}
use of com.questdb.std.FilesFacade in project questdb by bluestreak01.
the class TableReadFailTest method testTxnFileCannotOpenConstructor.
@Test
public void testTxnFileCannotOpenConstructor() throws Exception {
FilesFacade ff = new FilesFacadeImpl() {
@Override
public long openRO(LPSZ name) {
if (Chars.endsWith(name, TableUtils.TXN_FILE_NAME)) {
return -1;
}
return super.openRO(name);
}
};
assertConstructorFail(ff);
}
use of com.questdb.std.FilesFacade in project questdb by bluestreak01.
the class TableReadFailTest method testTxnFileMissingConstructor.
@Test
public void testTxnFileMissingConstructor() throws Exception {
FilesFacade ff = new FilesFacadeImpl() {
@Override
public boolean exists(LPSZ path) {
return !Chars.endsWith(path, TableUtils.TXN_FILE_NAME) && super.exists(path);
}
};
assertConstructorFail(ff);
}
use of com.questdb.std.FilesFacade in project questdb by bluestreak01.
the class TableReadFailTest method testTodoPresentConstructor.
@Test
public void testTodoPresentConstructor() throws Exception {
FilesFacade ff = new FilesFacadeImpl() {
@Override
public boolean exists(LPSZ path) {
return Chars.endsWith(path, TableUtils.TODO_FILE_NAME) || super.exists(path);
}
};
assertConstructorFail(ff);
}
Aggregations