Search in sources :

Example 1 with HSQLInterface

use of org.hsqldb_voltpatches.HSQLInterface in project voltdb by VoltDB.

the class TestDDLCompiler method testTooManyColumnTable.

//
// Note, this should succeed as HSQL doesn't have a hard limit
// on the number of columns. The test in TestVoltCompiler will
// fail on 1025 columns.
// @throws HSQLParseException
//
public void testTooManyColumnTable() throws IOException, HSQLParseException {
    String schemaPath = "";
    URL url = TestVoltCompiler.class.getResource("toowidetable-ddl.sql");
    schemaPath = URLDecoder.decode(url.getPath(), "UTF-8");
    FileReader fr = new FileReader(new File(schemaPath));
    BufferedReader br = new BufferedReader(fr);
    String ddl1 = "";
    String line;
    while ((line = br.readLine()) != null) {
        ddl1 += line + "\n";
    }
    br.close();
    HSQLInterface hsql = HSQLInterface.loadHsqldb();
    hsql.runDDLCommand(ddl1);
    VoltXMLElement xml = hsql.getXMLFromCatalog();
    System.out.println(xml);
    assertTrue(xml != null);
}
Also used : HSQLInterface(org.hsqldb_voltpatches.HSQLInterface) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) VoltXMLElement(org.hsqldb_voltpatches.VoltXMLElement) File(java.io.File) URL(java.net.URL)

Example 2 with HSQLInterface

use of org.hsqldb_voltpatches.HSQLInterface in project voltdb by VoltDB.

the class TestDDLCompiler method testSimpleDDLCompiler.

public void testSimpleDDLCompiler() throws HSQLParseException {
    String ddl1 = "CREATE TABLE warehouse ( " + "w_id integer default '0' NOT NULL, " + "w_name varchar(16) default NULL, " + "w_street_1 varchar(32) default NULL, " + "w_street_2 varchar(32) default NULL, " + "w_city varchar(32) default NULL, " + "w_state varchar(2) default NULL, " + "w_zip varchar(9) default NULL, " + "w_tax float default NULL, " + "PRIMARY KEY  (w_id) " + ");";
    HSQLInterface hsql = HSQLInterface.loadHsqldb();
    hsql.runDDLCommand(ddl1);
    VoltXMLElement xml = hsql.getXMLFromCatalog();
    System.out.println(xml);
    assertTrue(xml != null);
}
Also used : HSQLInterface(org.hsqldb_voltpatches.HSQLInterface) VoltXMLElement(org.hsqldb_voltpatches.VoltXMLElement)

Example 3 with HSQLInterface

use of org.hsqldb_voltpatches.HSQLInterface in project voltdb by VoltDB.

the class VoltCompiler method compileDatabaseNode.

/**
     * Load a ddl file with full support for VoltDB extensions (partitioning, procedures,
     * export), AND full support for input via a project xml file's "database" node.
     * @param database catalog-related info parsed from a project file
     * @param ddlReaderList Reader objects for ddl files.
     * @param jarOutput The in-memory jar to populate or null if the caller doesn't provide one.
     * @throws VoltCompilerException
     */
private void compileDatabaseNode(VoltCompilerReader cannonicalDDLIfAny, Database previousDBIfAny, final List<VoltCompilerReader> ddlReaderList, final InMemoryJarfile jarOutput) throws VoltCompilerException {
    final ArrayList<Class<?>> classDependencies = new ArrayList<>();
    final VoltDDLElementTracker voltDdlTracker = new VoltDDLElementTracker(this);
    Database db = initCatalogDatabase(m_catalog);
    // shutdown and make a new hsqldb
    HSQLInterface hsql = HSQLInterface.loadHsqldb();
    compileDatabase(db, hsql, voltDdlTracker, cannonicalDDLIfAny, previousDBIfAny, ddlReaderList, classDependencies, DdlProceduresToLoad.ALL_DDL_PROCEDURES, jarOutput);
}
Also used : HSQLInterface(org.hsqldb_voltpatches.HSQLInterface) ArrayList(java.util.ArrayList) Database(org.voltdb.catalog.Database)

Example 4 with HSQLInterface

use of org.hsqldb_voltpatches.HSQLInterface in project voltdb by VoltDB.

the class TestDeterminism method testDeterminismReadOnlyNoWarning.

/*
     * A test that runs some read-only non-deterministic DDLs, check that the output does not contain
     * any ND warnings
     */
public void testDeterminismReadOnlyNoWarning() throws Exception {
    // Should the members be reused here?
    HSQLInterface hsql = HSQLInterface.loadHsqldb();
    VoltCompiler compiler = new VoltCompiler(false);
    VoltCompiler.DdlProceduresToLoad all_procs = DdlProceduresToLoad.NO_DDL_PROCEDURES;
    URL path = TestDeterminism.class.getResource("testplans-determinism-read-only.sql");
    String pathStr = URLDecoder.decode(path.getPath(), "UTF-8");
    compiler.loadSchema(hsql, all_procs, pathStr);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    compiler.summarizeSuccess(new PrintStream(outputStream), null, "");
    System.out.println(outputStream.toString());
    // There is no warnings generated for read-only ND queries
    String msg = outputStream.toString();
    assertFalse(stringContains(msg, "ND"));
    assertFalse(stringContains(msg, "WARN"));
    assertTrue(stringContains(msg, "Successfully created"));
    assertTrue(stringContains(msg, "Catalog contains"));
    outputStream.close();
}
Also used : PrintStream(java.io.PrintStream) VoltCompiler(org.voltdb.compiler.VoltCompiler) HSQLInterface(org.hsqldb_voltpatches.HSQLInterface) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DdlProceduresToLoad(org.voltdb.compiler.VoltCompiler.DdlProceduresToLoad) URL(java.net.URL)

Example 5 with HSQLInterface

use of org.hsqldb_voltpatches.HSQLInterface in project voltdb by VoltDB.

the class TestDDLCompiler method testCharIsNotAllowed.

public void testCharIsNotAllowed() {
    String ddl1 = "CREATE TABLE warehouse ( " + "w_street_1 char(32) default NULL, " + ");";
    HSQLInterface hsql = HSQLInterface.loadHsqldb();
    try {
        hsql.runDDLCommand(ddl1);
    } catch (HSQLParseException e) {
        assertTrue(true);
        return;
    }
    fail();
}
Also used : HSQLInterface(org.hsqldb_voltpatches.HSQLInterface) HSQLParseException(org.hsqldb_voltpatches.HSQLInterface.HSQLParseException)

Aggregations

HSQLInterface (org.hsqldb_voltpatches.HSQLInterface)7 VoltXMLElement (org.hsqldb_voltpatches.VoltXMLElement)4 URL (java.net.URL)2 BufferedReader (java.io.BufferedReader)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileReader (java.io.FileReader)1 PrintStream (java.io.PrintStream)1 ArrayList (java.util.ArrayList)1 HSQLParseException (org.hsqldb_voltpatches.HSQLInterface.HSQLParseException)1 Database (org.voltdb.catalog.Database)1 VoltCompiler (org.voltdb.compiler.VoltCompiler)1 DdlProceduresToLoad (org.voltdb.compiler.VoltCompiler.DdlProceduresToLoad)1