Search in sources :

Example 1 with FilesFacade

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");
    }
}
Also used : FilesFacade(com.questdb.std.FilesFacade)

Example 2 with FilesFacade

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));
}
Also used : FilesFacade(com.questdb.std.FilesFacade) LPSZ(com.questdb.std.str.LPSZ) FilesFacadeImpl(com.questdb.std.FilesFacadeImpl) CairoEngine(com.questdb.cairo.sql.CairoEngine) CairoEngine(com.questdb.cairo.sql.CairoEngine) Test(org.junit.Test)

Example 3 with FilesFacade

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);
}
Also used : FilesFacade(com.questdb.std.FilesFacade) LPSZ(com.questdb.std.str.LPSZ) FilesFacadeImpl(com.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 4 with FilesFacade

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);
}
Also used : FilesFacade(com.questdb.std.FilesFacade) LPSZ(com.questdb.std.str.LPSZ) FilesFacadeImpl(com.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Example 5 with FilesFacade

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);
}
Also used : FilesFacade(com.questdb.std.FilesFacade) LPSZ(com.questdb.std.str.LPSZ) FilesFacadeImpl(com.questdb.std.FilesFacadeImpl) Test(org.junit.Test)

Aggregations

FilesFacade (com.questdb.std.FilesFacade)8 FilesFacadeImpl (com.questdb.std.FilesFacadeImpl)6 LPSZ (com.questdb.std.str.LPSZ)6 Test (org.junit.Test)6 CairoEngine (com.questdb.cairo.sql.CairoEngine)1 Path (com.questdb.std.str.Path)1