Package com.foundationdb.server.error

Examples of com.foundationdb.server.error.ExternalRowReaderException


                        if (fieldMatches(into)) {
                            clearField();
                            state = State.INSERT_TABLE;
                        }
                        else {
                            throw new ExternalRowReaderException("Unrecognized statement INSERT " + decodeField());
                        }
                    }
                    else if (state == State.INSERT_VALUES) {
                        if (fieldMatches(values)) {
                            clearField();
                            state = State.NEXT_ROW_CTOR;
                        }
                        else {
                            throw new ExternalRowReaderException("Unrecognized statement INSERT INTO " + decodeField());
                        }
                    }
                    else if (fieldMatches(lock) || fieldMatches(unlock)) {
                        clearField();
                        state = State.IGNORED_STATEMENT;
                    }
                    else if (fieldMatches(insert)) {
                        clearField();
                        state = State.INSERT;
                    }
                    else {
                        throw new ExternalRowReaderException("Unrecognized statement " + decodeField());
                    }
                }
                break;
            case IGNORED_STATEMENT:
                if (b < 0) {
                    throw eofInTheMiddleOf("a statement");
                }
                else if (b == ';') {
                    state = State.STATEMENT_START;
                }
                else if (b == '`') {
                    state = State.IGNORED_BACKQUOTE;
                }
                break;
            case IGNORED_BACKQUOTE:
                if (b < 0) {
                    throw eofInTheMiddleOf("a statement");
                }
                else if (b == '`') {
                    state = State.IGNORED_STATEMENT;
                }
                else if (b == '\\') {
                    b = read();
                }
                break;
            case INSERT_TABLE:
                if (b < 0) {
                    throw eofInTheMiddleOf("a statement");
                }
                else if (b == '`') {
                    addToField(b);
                    state = State.TABLE_BACKQUOTE;
                }
                else if ((b == '.') ||
                         ((b >= 'A') && (b <= 'Z')) ||
                         ((b >= 'a') && (b <= 'z')) ||
                         ((b >= '0') && (b <= '9')) ||
                         (b == '_')) {
                    // Unquoted or qualified table name.
                    addToField(b);
                }
                else {
                    if (b != ' ') unread(b);
                    if (tableName == null) {
                        tableName = copyField();
                        if (logger.isTraceEnabled()) {
                            logger.trace("Original target table: {}", decodeField());
                        }
                    }
                    else if (!fieldMatches(tableName)) {
                        throw new ExternalRowReaderException("INSERT INTO changed from " +
                                                             decode(tableName) +
                                                             " to " + decodeField() +
                                                             ". Does file contain multiple tables?");
                    }
                    clearField();
                    state = State.INSERT_VALUES;
                }
                break;
            case TABLE_BACKQUOTE:
                if (b < 0) {
                    throw eofInTheMiddleOf("table name");
                }
                else if (b == '`') {
                    addToField(b);
                    state = State.INSERT_TABLE;
                }
                else if (b == '\\') {
                    addToField(b);
                    b = read();
                    if (b >= 0)
                        addToField(b);
                }
                else {
                    addToField(b);
                }
                break;
            case NEXT_ROW_CTOR:
                if (b < 0) {
                    throw eofInTheMiddleOf("a statement");
                }
                else if (b == '(') {
                    newRow();
                    state = State.NEXT_FIELD;
                }
                else {
                    throw unexpectedToken(b);
                }
                break;
            case AFTER_ROW_CTOR:
                if (b < 0) {
                    throw eofInTheMiddleOf("a statement");
                }
                else if (b == ';') {
                    state = State.STATEMENT_START;
                }
                else if (b == ',') {
                    state = State.NEXT_ROW_CTOR;
                }
                else {
                    throw unexpectedToken(b);
                }
                break;
            case NEXT_FIELD:
                if (b < 0) {
                    throw eofInTheMiddleOf("a statement");
                }
                else if (b == ')') {
                    state = State.AFTER_ROW_CTOR;
                    return finishRow();
                }
                else if (b == '\'') {
                    state = State.QUOTED_FIELD;
                }
                else if (b == ',') {
                    addField(false);
                }
                else if ((b == ' ') || (b == '\r') || (b == '\n')) {
                }
                else {
                    addToField(b);
                    state = State.UNQUOTED_FIELD;
                }
                break;
            case UNQUOTED_FIELD:
                if (b < 0) {
                    throw eofInTheMiddleOf("a statement");
                }
                else if (b == ',') {
                    addField(false);
                    state = State.NEXT_FIELD;
                }
                else if (b == ')') {
                    addField(false);
                    state = State.AFTER_ROW_CTOR;
                    return finishRow();
                }
                else if (b == '\'') {
                    throw new ExternalRowReaderException("Quote in the middle of a value");
                }
                else {
                    addToField(b);
                }
                break;
View Full Code Here


    protected ExternalRowReaderException unexpectedToken(int... bytes) {
        byte[] ba = new byte[bytes.length];
        for (int i = 0; i < ba.length; i++) {
            ba[i] = (byte)bytes[i];
        }
        return new ExternalRowReaderException("Unexpected token " + decode(ba));
    }
View Full Code Here

        }
        return new ExternalRowReaderException("Unexpected token " + decode(ba));
    }

    protected ExternalRowReaderException eofInTheMiddleOf(String what) {
        return new ExternalRowReaderException("EOF in the middle of " + what);
    }
View Full Code Here

                else if (b == delim) {
                    addField(false);
                    state = State.FIELD_START;
                }
                else if (b == quote) {
                    throw new ExternalRowReaderException("QUOTE in the middle of a field");
                }
                else {
                    addToField(b);
                }
                break;
            case IN_QUOTE:
                if (b < 0)
                    throw new ExternalRowReaderException("EOF inside QUOTE");
                else if (b == quote) {
                    if (escape == quote) {
                        // Must be doubled; peek next character.
                        b = read();
                        if (b == quote) {
                            addToField(b);
                            continue;
                        }
                        else {
                            unread(b);
                        }
                    }
                    state = State.AFTER_QUOTE;
                }
                else if (b == escape) {
                    // Non-doubling escape.
                    b = read();
                    if (b < 0) throw new ExternalRowReaderException("EOF after ESCAPE");
                    addToField(b);
                }
                else {
                    addToField(b);
                }
                break;
            case AFTER_QUOTE:
                if ((b < 0) || (b == cr) || (b == nl)) {
                    addField(true);
                    return finishRow();
                }
                else if (b == delim) {
                    addField(true);
                    state = State.FIELD_START;
                }
                else {
                    throw new ExternalRowReaderException("junk after quoted field");
                }
                break;
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.foundationdb.server.error.ExternalRowReaderException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.