当前位置: 首页>>代码示例>>Java>>正文


Java SQLLexer类代码示例

本文整理汇总了Java中org.voltdb.parser.SQLLexer的典型用法代码示例。如果您正苦于以下问题:Java SQLLexer类的具体用法?Java SQLLexer怎么用?Java SQLLexer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SQLLexer类属于org.voltdb.parser包,在下文中一共展示了SQLLexer类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dispatchAdHocCommon

import org.voltdb.parser.SQLLexer; //导入依赖的package包/类
private final void dispatchAdHocCommon(StoredProcedureInvocation task,
        ClientInputHandler handler, Connection ccxn, ExplainMode explainMode,
        String sql, Object[] userParams, Object[] userPartitionKey, AuthSystem.AuthUser user) {
    List<String> sqlStatements = SQLLexer.splitStatements(sql);
    String[] stmtsArray = sqlStatements.toArray(new String[sqlStatements.size()]);

    AdHocPlannerWork ahpw = new AdHocPlannerWork(
            m_siteId,
            task.clientHandle, handler.connectionId(),
            handler.isAdmin(), ccxn,
            sql, stmtsArray, userParams, null, explainMode,
            userPartitionKey == null, userPartitionKey,
            task.procName, task.type, task.originalTxnId, task.originalUniqueId,
            VoltDB.instance().getReplicationRole() == ReplicationRole.REPLICA,
            VoltDB.instance().getCatalogContext().cluster.getUseddlschema(),
            m_adhocCompletionHandler, user);
    LocalObjectMessage work = new LocalObjectMessage( ahpw );

    m_mailbox.send(m_plannerSiteId, work);
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:21,代码来源:ClientInterface.java

示例2: parseSQL

import org.voltdb.parser.SQLLexer; //导入依赖的package包/类
public static VoltSQL parseSQL(String queryIn) throws SQLException
{
    if (queryIn == null || queryIn.length() == 0) {
        throw SQLError.get(SQLError.ILLEGAL_STATEMENT);
    }

    String query = queryIn.trim();
    if (query.length() == 0) {
        throw SQLError.get(SQLError.ILLEGAL_STATEMENT);
    }

    // Assume the type is an update.  We'll look for SELECT explicitly.
    // We need to know the type to validate the exec() statements.  Either it is a query or DDL/update.
    byte type = TYPE_UPDATE;
    if (SQLLexer.isSelect(query)) {
        type = TYPE_SELECT;
    }

    // Make sure there's a ';' terminator;
    if (!query.endsWith(";")) {
        query += ";";
    }
    // Count substitution parameters.
    int parameterCount = 0;
    if(query.indexOf("?") > -1)
    {
        String[] queryParts = (query + ";").split("\\?");
        parameterCount = queryParts.length-1;
    }

    return new VoltSQL(new String[] {query}, parameterCount, type);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:33,代码来源:JDBC4Statement.java

示例3: readingState

import org.voltdb.parser.SQLLexer; //导入依赖的package包/类
private int readingState(char[] nchar, DDLStatement retval) {
    if (nchar[0] == '-') {
        // remember that a possible '--' is being examined
        return kStateReadingCommentDelim;
    }
    else if (nchar[0] == '\n') {
        // normalize newlines to spaces
        m_currLineNo += 1;
        retval.statement += " ";
    }
    else if (nchar[0] == '\r') {
        // ignore carriage returns
    }
    else if (nchar[0] == ';') {
        // end of the statement
        retval.statement += nchar[0];
        return kStateCompleteStatement;
    }
    else if (nchar[0] == '\'') {
        retval.statement += nchar[0];
        return kStateReadingStringLiteral;
    }
    else if (SQLLexer.isBlockDelimiter(nchar[0])) {
        // we may be examining ### code block delimiters
        retval.statement += nchar[0];
        return kStateReadingCodeBlockDelim;
    }
    else {
        // accumulate and continue
        retval.statement += nchar[0];
    }

    return kStateReading;
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:35,代码来源:DDLCompiler.java

示例4: readingCodeBlockStateDelim

import org.voltdb.parser.SQLLexer; //导入依赖的package包/类
private int readingCodeBlockStateDelim(char [] nchar, DDLStatement retval) {
    retval.statement += nchar[0];
    if (SQLLexer.isBlockDelimiter(nchar[0])) {
        return kStateReadingCodeBlockNextDelim;
    } else {
        return readingState(nchar, retval);
    }
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:9,代码来源:DDLCompiler.java

示例5: readingEndCodeBlockStateDelim

import org.voltdb.parser.SQLLexer; //导入依赖的package包/类
private int readingEndCodeBlockStateDelim(char [] nchar, DDLStatement retval) {
    retval.statement += nchar[0];
    if (SQLLexer.isBlockDelimiter(nchar[0])) {
        return kStateReadingEndCodeBlockNextDelim;
    } else {
        return kStateReadingCodeBlock;
    }
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:9,代码来源:DDLCompiler.java

示例6: readingCodeBlockStateNextDelim

import org.voltdb.parser.SQLLexer; //导入依赖的package包/类
private int readingCodeBlockStateNextDelim(char [] nchar, DDLStatement retval) {
    if (SQLLexer.isBlockDelimiter(nchar[0])) {
        retval.statement += nchar[0];
        return kStateReadingCodeBlock;
    }
    return readingState(nchar, retval);
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:8,代码来源:DDLCompiler.java

示例7: readingEndCodeBlockStateNextDelim

import org.voltdb.parser.SQLLexer; //导入依赖的package包/类
private int readingEndCodeBlockStateNextDelim(char [] nchar, DDLStatement retval) {
    retval.statement += nchar[0];
    if (SQLLexer.isBlockDelimiter(nchar[0])) {
        return kStateReading;
    }
    return kStateReadingCodeBlock;
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:8,代码来源:DDLCompiler.java

示例8: readingCodeBlock

import org.voltdb.parser.SQLLexer; //导入依赖的package包/类
private int readingCodeBlock(char [] nchar, DDLStatement retval) {
    // all characters in the literal are accumulated. keep track of
    // newlines for error messages.
    retval.statement += nchar[0];
    if (SQLLexer.isBlockDelimiter(nchar[0])) {
        return kStateReadingEndCodeBlockDelim;
    }

    if (nchar[0] == '\n') {
        m_currLineNo += 1;
    }
    return kStateReadingCodeBlock;
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:14,代码来源:DDLCompiler.java

示例9: testIsPermitted

import org.voltdb.parser.SQLLexer; //导入依赖的package包/类
@Test
public void testIsPermitted()
{
    assertTrue(SQLLexer.isPermitted("create table PANTS (ID int, RENAME varchar(50));"));
    assertTrue(SQLLexer.isPermitted("create table PANTS (\n ID int,\n RENAME varchar(50)\n);"));
    assertTrue(SQLLexer.isPermitted("create view PANTS (ID int, RENAME varchar(50));"));
    assertTrue(SQLLexer.isPermitted("create index PANTS (ID int, RENAME varchar(50));"));
    assertFalse(SQLLexer.isPermitted("create tabel PANTS (ID int, RENAME varchar(50));"));
    assertFalse(SQLLexer.isPermitted("craete table PANTS (ID int, RENAME varchar(50));"));
    assertTrue(SQLLexer.isPermitted("create role pants with pockets;"));
    assertTrue(SQLLexer.isPermitted("create role\n pants\n with cuffs;\n"));

    assertTrue(SQLLexer.isPermitted("drop table pants;"));
    assertTrue(SQLLexer.isPermitted("drop view pants;"));
    assertTrue(SQLLexer.isPermitted("drop index pants;"));
    assertFalse(SQLLexer.isPermitted("dorp table pants;"));
    assertFalse(SQLLexer.isPermitted("drop tabel pants;"));

    assertTrue(SQLLexer.isPermitted("alter table pants add column blargy blarg;"));
    assertTrue(SQLLexer.isPermitted("alter table pants add constraint blargy blarg;"));
    assertTrue(SQLLexer.isPermitted("alter index pants"));
    assertFalse(SQLLexer.isPermitted("alter table pants rename to shorts;"));
    assertFalse(SQLLexer.isPermitted("alter index pants rename to shorts;"));
    assertFalse(SQLLexer.isPermitted("alter table pants alter column rename to shorts;"));
    assertFalse(SQLLexer.isPermitted("altre table pants blargy blarg;"));
    assertFalse(SQLLexer.isPermitted("alter tabel pants blargy blarg;"));
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:28,代码来源:TestSQLLexer.java

示例10: checkSplitter

import org.voltdb.parser.SQLLexer; //导入依赖的package包/类
private void checkSplitter(final String strIn, final String... strsCmp) {
    final List<String> strsOut = SQLLexer.splitStatements(strIn);
    assertEquals(strsCmp.length, strsOut.size());
    for (int i = 0; i < strsCmp.length; ++i) {
        assertEquals(strsCmp[i], strsOut.get(i));
    }
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:8,代码来源:TestSplitSQLStatements.java

示例11: dispatchExplainProcedure

import org.voltdb.parser.SQLLexer; //导入依赖的package包/类
ClientResponseImpl dispatchExplainProcedure(StoredProcedureInvocation task, ClientInputHandler handler, Connection ccxn, AuthUser user) {
    ParameterSet params = task.getParams();
    /*
     * TODO: We don't actually support multiple proc names in an ExplainProc call,
     * so I THINK that the string is always a single procname symbol and all this
     * splitting and iterating is a no-op.
     */
    //String procs = (String) params.toArray()[0];
    List<String> procNames = SQLLexer.splitStatements( (String)params.toArray()[0]);
    int size = procNames.size();
    VoltTable[] vt = new VoltTable[ size ];
    for( int i=0; i<size; i++ ) {
        String procName = procNames.get(i);

        // look in the catalog
        Procedure proc = m_catalogContext.get().procedures.get(procName);
        if (proc == null) {
            // check default procs and send them off to be explained using the regular
            // adhoc explain process
            proc = m_catalogContext.get().m_defaultProcs.checkForDefaultProcedure(procName);
            if (proc != null) {
                String sql = m_catalogContext.get().m_defaultProcs.sqlForDefaultProc(proc);
                dispatchAdHocCommon(task, handler, ccxn, ExplainMode.EXPLAIN_DEFAULT_PROC, sql, new Object[0], null, user);
                return null;
            }

            ClientResponseImpl errorResponse =
                    new ClientResponseImpl(
                            ClientResponseImpl.UNEXPECTED_FAILURE,
                            new VoltTable[0], "Procedure "+procName+" not in catalog",
                            task.clientHandle);
            return errorResponse;
        }

        vt[i] = new VoltTable(new VoltTable.ColumnInfo( "SQL_STATEMENT", VoltType.STRING),
                              new VoltTable.ColumnInfo( "EXECUTION_PLAN", VoltType.STRING));

        for( Statement stmt : proc.getStatements() ) {
            vt[i].addRow( stmt.getSqltext(), Encoder.hexDecodeToString( stmt.getExplainplan() ) );
        }
    }

    ClientResponseImpl response =
            new ClientResponseImpl(
                    ClientResponseImpl.SUCCESS,
                    ClientResponse.UNINITIALIZED_APP_STATUS_CODE,
                    null,
                    vt,
                    null);
    response.setClientHandle( task.clientHandle );
    ByteBuffer buf = ByteBuffer.allocate(response.getSerializedSize() + 4);
    buf.putInt(buf.capacity() - 4);
    response.flattenToBuffer(buf);
    buf.flip();
    ccxn.writeStream().enqueue(buf);
    return null;
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:58,代码来源:ClientInterface.java

示例12: checkDDL

import org.voltdb.parser.SQLLexer; //导入依赖的package包/类
private void checkDDL(final String strIn, final String expectString)
{
    String result = SQLLexer.extractDDLToken(strIn);
    assertEquals(expectString, result);
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:6,代码来源:TestSQLLexer.java


注:本文中的org.voltdb.parser.SQLLexer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。