Search in sources :

Example 71 with TeiidProcessingException

use of org.teiid.core.TeiidProcessingException in project teiid by teiid.

the class ExecDynamicSqlInstruction method process.

/**
 * <p>
 * Processing this instruction executes the ProcessorPlan for the command on
 * the CommandStatement of the update procedure language. Executing this
 * plan does not effect the values of any of the variables defined as part
 * of the update procedure and hence the results of the ProcessPlan
 * execution need not be stored for further processing. The results are
 * removed from the buffer manager immediately after execution. The program
 * counter is incremented after execution of the plan.
 * </p>
 *
 * @throws BlockedException
 *             if this processing the plan throws a currentVarContext
 */
public void process(ProcedurePlan procEnv) throws BlockedException, TeiidComponentException, TeiidProcessingException {
    VariableContext localContext = procEnv.getCurrentVariableContext();
    String query = null;
    try {
        Clob value = (Clob) procEnv.evaluateExpression(dynamicCommand.getSql());
        if (value == null) {
            throw new QueryProcessingException(QueryPlugin.Util.getString(// $NON-NLS-1$
            "ExecDynamicSqlInstruction.0"));
        }
        if (value.length() > MAX_SQL_LENGTH) {
            throw new QueryProcessingException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31204, MAX_SQL_LENGTH));
        }
        query = value.getSubString(1, MAX_SQL_LENGTH);
        LogManager.logTrace(org.teiid.logging.LogConstants.CTX_DQP, // $NON-NLS-1$
        new Object[] { "Executing dynamic sql ", query });
        Command command = QueryParser.getQueryParser().parseCommand(query);
        // special handling for dynamic anon blocks
        if (command instanceof CreateProcedureCommand) {
            if (dynamicCommand.getIntoGroup() != null || returnable) {
                // and the creation of an inline view
                throw new QueryProcessingException(QueryPlugin.Event.TEIID31250, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31250));
            }
            ((CreateProcedureCommand) command).setResultSetColumns(Collections.EMPTY_LIST);
        }
        command.setExternalGroupContexts(dynamicCommand.getExternalGroupContexts());
        command.setTemporaryMetadata(dynamicCommand.getTemporaryMetadata().clone());
        updateContextWithUsingValues(procEnv, localContext);
        TempMetadataStore metadataStore = command.getTemporaryMetadata();
        if (dynamicCommand.getUsing() != null && !dynamicCommand.getUsing().isEmpty()) {
            metadataStore.addTempGroup(Reserved.USING, new LinkedList<ElementSymbol>(dynamicCommand.getUsing().getClauseMap().keySet()));
            GroupSymbol using = new GroupSymbol(Reserved.USING);
            using.setMetadataID(metadataStore.getTempGroupID(Reserved.USING));
            command.addExternalGroupToContext(using);
            metadataStore.addTempGroup(ProcedureReservedWords.DVARS, new LinkedList<ElementSymbol>(dynamicCommand.getUsing().getClauseMap().keySet()));
            using = new GroupSymbol(ProcedureReservedWords.DVARS);
            using.setMetadataID(metadataStore.getTempGroupID(ProcedureReservedWords.DVARS));
            command.addExternalGroupToContext(using);
        }
        QueryResolver.resolveCommand(command, metadata.getDesignTimeMetadata());
        validateDynamicCommand(procEnv, command, value.toString());
        // create a new set of variables including vars
        Map<ElementSymbol, Expression> nameValueMap = createVariableValuesMap(localContext);
        ValidationVisitor visitor = new ValidationVisitor();
        Request.validateWithVisitor(visitor, metadata, command);
        boolean insertInto = false;
        boolean updateCommand = false;
        if (!command.returnsResultSet() && !(command instanceof StoredProcedure)) {
            if (dynamicCommand.isAsClauseSet()) {
                if (dynamicCommand.getProjectedSymbols().size() != 1 || ((Expression) dynamicCommand.getProjectedSymbols().get(0)).getType() != DataTypeManager.DefaultDataClasses.INTEGER) {
                    throw new QueryProcessingException(QueryPlugin.Event.TEIID31157, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31157));
                }
            }
            updateCommand = true;
        } else if (dynamicCommand.getAsColumns() != null && !dynamicCommand.getAsColumns().isEmpty()) {
            // $NON-NLS-1$
            command = QueryRewriter.createInlineViewQuery(new GroupSymbol("X"), command, metadata, dynamicCommand.getAsColumns());
            if (dynamicCommand.getIntoGroup() != null) {
                Insert insert = new Insert(dynamicCommand.getIntoGroup(), dynamicCommand.getAsColumns(), Collections.emptyList());
                insert.setQueryExpression((Query) command);
                command = insert;
                insertInto = true;
            }
        }
        // if this is an update procedure, it could reassign variables
        command = QueryRewriter.rewrite(command, metadata, procEnv.getContext(), command instanceof CreateProcedureCommand ? Collections.EMPTY_MAP : nameValueMap);
        ProcessorPlan commandPlan = QueryOptimizer.optimizePlan(command, metadata, idGenerator, capFinder, AnalysisRecord.createNonRecordingRecord(), procEnv.getContext());
        if (command instanceof CreateProcedureCommand && commandPlan instanceof ProcedurePlan) {
            ((ProcedurePlan) commandPlan).setValidateAccess(procEnv.isValidateAccess());
        }
        CreateCursorResultSetInstruction inst = new CreateCursorResultSetInstruction(null, commandPlan, (insertInto || updateCommand) ? Mode.UPDATE : returnable ? Mode.HOLD : Mode.NOHOLD) {

            @Override
            public void process(ProcedurePlan procEnv) throws BlockedException, TeiidComponentException, TeiidProcessingException {
                boolean done = true;
                try {
                    super.process(procEnv);
                } catch (BlockedException e) {
                    done = false;
                    throw e;
                } finally {
                    if (done) {
                        procEnv.getContext().popCall();
                    }
                }
            }
        };
        dynamicProgram = new Program(false);
        dynamicProgram.addInstruction(inst);
        if (dynamicCommand.getIntoGroup() != null) {
            String groupName = dynamicCommand.getIntoGroup().getName();
            if (!procEnv.getTempTableStore().hasTempTable(groupName, true)) {
                // create the temp table in the parent scope
                Create create = new Create();
                create.setTable(new GroupSymbol(groupName));
                for (ElementSymbol es : (List<ElementSymbol>) dynamicCommand.getAsColumns()) {
                    Column c = new Column();
                    c.setName(es.getShortName());
                    c.setRuntimeType(DataTypeManager.getDataTypeName(es.getType()));
                    create.getColumns().add(c);
                }
                procEnv.getDataManager().registerRequest(procEnv.getContext(), create, TempMetadataAdapter.TEMP_MODEL.getName(), new RegisterRequestParameter());
            }
            // backwards compatibility to support into with a rowcount
            if (updateCommand) {
                Insert insert = new Insert();
                insert.setGroup(new GroupSymbol(groupName));
                for (ElementSymbol es : (List<ElementSymbol>) dynamicCommand.getAsColumns()) {
                    ElementSymbol col = new ElementSymbol(es.getShortName(), insert.getGroup());
                    col.setType(es.getType());
                    insert.addVariable(col);
                }
                insert.addValue(new Constant(procEnv.getCurrentVariableContext().getValue(ProcedurePlan.ROWCOUNT)));
                QueryResolver.resolveCommand(insert, metadata.getDesignTimeMetadata());
                TupleSource ts = procEnv.getDataManager().registerRequest(procEnv.getContext(), insert, TempMetadataAdapter.TEMP_MODEL.getName(), new RegisterRequestParameter());
                ts.nextTuple();
                ts.closeSource();
            }
        }
        // Add group to recursion stack
        if (parentProcCommand.getUpdateType() != Command.TYPE_UNKNOWN) {
            // $NON-NLS-1$
            procEnv.getContext().pushCall(Command.getCommandToken(parentProcCommand.getUpdateType()) + " " + parentProcCommand.getVirtualGroup());
        } else {
            if (parentProcCommand.getVirtualGroup() != null) {
                procEnv.getContext().pushCall(parentProcCommand.getVirtualGroup().toString());
            }
        }
        procEnv.push(dynamicProgram);
    } catch (SQLException e) {
        Object[] params = { dynamicCommand, dynamicCommand.getSql(), e.getMessage() };
        throw new QueryProcessingException(QueryPlugin.Event.TEIID30168, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30168, params));
    } catch (TeiidProcessingException e) {
        Object[] params = { dynamicCommand, query == null ? dynamicCommand.getSql() : query, e.getMessage() };
        throw new QueryProcessingException(QueryPlugin.Event.TEIID30168, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30168, params));
    }
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) ValidationVisitor(org.teiid.query.validator.ValidationVisitor) CreateProcedureCommand(org.teiid.query.sql.proc.CreateProcedureCommand) Query(org.teiid.query.sql.lang.Query) SQLException(java.sql.SQLException) Constant(org.teiid.query.sql.symbol.Constant) Insert(org.teiid.query.sql.lang.Insert) BlockedException(org.teiid.common.buffer.BlockedException) TeiidProcessingException(org.teiid.core.TeiidProcessingException) Column(org.teiid.metadata.Column) Create(org.teiid.query.sql.lang.Create) List(java.util.List) LinkedList(java.util.LinkedList) VariableContext(org.teiid.query.sql.util.VariableContext) RegisterRequestParameter(org.teiid.query.processor.RegisterRequestParameter) StoredProcedure(org.teiid.query.sql.lang.StoredProcedure) CreateProcedureCommand(org.teiid.query.sql.proc.CreateProcedureCommand) Command(org.teiid.query.sql.lang.Command) DynamicCommand(org.teiid.query.sql.lang.DynamicCommand) Expression(org.teiid.query.sql.symbol.Expression) TupleSource(org.teiid.common.buffer.TupleSource) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Clob(java.sql.Clob) ProcessorPlan(org.teiid.query.processor.ProcessorPlan) TempMetadataStore(org.teiid.query.metadata.TempMetadataStore) QueryProcessingException(org.teiid.api.exception.query.QueryProcessingException)

Example 72 with TeiidProcessingException

use of org.teiid.core.TeiidProcessingException in project teiid by teiid.

the class ProcedurePlan method processProcedure.

/**
 * <p>Process the procedure, using the stack of Programs supplied by the
 * ProcessorEnvironment.  With each pass through the loop, the
 * current Program is gotten off the top of the stack, and the
 * current instruction is gotten from that program; each call
 * to an instruction's process method may alter the Program
 * Stack and/or the current instruction pointer of a Program,
 * so it's important that this method's loop refer to the
 * call stack of the ProcessorEnvironment each time, and not
 * cache things in local variables.  If the current Program's
 * current instruction is null, then it's time to pop that
 * Program off the stack.</p>
 *
 * @return List a single tuple containing one Integer: the update
 * count resulting from the procedure execution.
 */
private TupleSource processProcedure() throws TeiidComponentException, TeiidProcessingException, BlockedException {
    // execute plan
    ProgramInstruction inst = null;
    while (!this.programs.empty()) {
        Program program = peek();
        inst = program.getCurrentInstruction();
        if (inst == null) {
            // $NON-NLS-1$
            LogManager.logTrace(org.teiid.logging.LogConstants.CTX_DQP, "Finished program", program);
            // look ahead to see if we need to process in place
            VariableContext vc = this.cursorStates.getParentContext();
            CursorState last = (CursorState) this.cursorStates.getValue(null);
            if (last != null) {
                if (last.resultsBuffer == null && (last.usesLocalTemp || !txnTupleSources.isEmpty())) {
                    last.resultsBuffer = bufferMgr.createTupleBuffer(last.processor.getOutputElements(), getContext().getConnectionId(), TupleSourceType.PROCESSOR);
                    last.returning = true;
                }
                if (last.returning) {
                    while (last.ts.hasNext()) {
                        List<?> tuple = last.ts.nextTuple();
                        last.resultsBuffer.addTuple(tuple);
                    }
                    last.resultsBuffer.close();
                    last.ts = last.resultsBuffer.createIndexedTupleSource(true);
                    last.returning = false;
                }
            }
            this.pop(true);
            continue;
        }
        try {
            getContext().setCurrentTimestamp(System.currentTimeMillis());
            if (inst instanceof RepeatedInstruction) {
                // $NON-NLS-1$
                LogManager.logTrace(org.teiid.logging.LogConstants.CTX_DQP, "Executing repeated instruction", inst);
                RepeatedInstruction loop = (RepeatedInstruction) inst;
                if (loop.testCondition(this)) {
                    // $NON-NLS-1$
                    LogManager.logTrace(org.teiid.logging.LogConstants.CTX_DQP, "Passed condition, executing program " + loop.getNestedProgram());
                    inst.process(this);
                    this.push(loop.getNestedProgram());
                    continue;
                }
                // $NON-NLS-1$
                LogManager.logTrace(org.teiid.logging.LogConstants.CTX_DQP, "Exiting repeated instruction", inst);
                loop.postInstruction(this);
            } else {
                // $NON-NLS-1$
                LogManager.logTrace(org.teiid.logging.LogConstants.CTX_DQP, "Executing instruction", inst);
                inst.process(this);
                this.evaluator.close();
            }
        } catch (TeiidComponentException e) {
            throw e;
        } catch (Exception e) {
            // processing or teiidsqlexception
            boolean atomic = program.isAtomic();
            while (program.getExceptionGroup() == null) {
                this.pop(false);
                if (this.programs.empty()) {
                    // reached the top without a handler, so throw
                    if (e instanceof TeiidProcessingException) {
                        throw (TeiidProcessingException) e;
                    }
                    throw new ProcedureErrorInstructionException(QueryPlugin.Event.TEIID30167, e);
                }
                program = peek();
                atomic |= program.isAtomic();
            }
            try {
                // allow the current program to go out of scope
                this.pop(false);
                if (atomic) {
                    TransactionContext tc = this.getContext().getTransactionContext();
                    if (tc != null && tc.getTransactionType() != Scope.NONE) {
                        // a non-completing atomic block under a higher level transaction
                        // this will not work correctly until we support
                        // checkpoints/subtransactions
                        tc.getTransaction().setRollbackOnly();
                        getContext().addWarning(TeiidSQLException.create(e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31266)));
                    }
                }
            } catch (IllegalStateException | SystemException | TeiidComponentException e1) {
                // $NON-NLS-1$
                LogManager.logDetail(LogConstants.CTX_DQP, "Caught exception while rolling back transaction", e1);
            } catch (Throwable e1) {
                LogManager.logWarning(LogConstants.CTX_DQP, e1);
            }
            if (e instanceof RuntimeException) {
                LogManager.logWarning(LogConstants.CTX_DQP, e);
            } else {
                // $NON-NLS-1$
                LogManager.logDetail(LogConstants.CTX_DQP, "Caught exception in exception hanlding block", e);
            }
            if (program.getExceptionProgram() == null) {
                continue;
            }
            Program exceptionProgram = program.getExceptionProgram();
            this.push(exceptionProgram);
            TeiidSQLException tse = TeiidSQLException.create(e);
            GroupSymbol gs = new GroupSymbol(program.getExceptionGroup());
            this.currentVarContext.setValue(exceptionSymbol(gs, 0), tse.getSQLState());
            this.currentVarContext.setValue(exceptionSymbol(gs, 1), tse.getErrorCode());
            this.currentVarContext.setValue(exceptionSymbol(gs, 2), tse.getTeiidCode());
            this.currentVarContext.setValue(exceptionSymbol(gs, 3), tse);
            this.currentVarContext.setValue(exceptionSymbol(gs, 4), tse.getCause());
            continue;
        }
        program.incrementProgramCounter();
    }
    CursorState last = (CursorState) this.cursorStates.getValue(null);
    if (last == null) {
        return CollectionTupleSource.createNullTupleSource();
    }
    return last.ts;
}
Also used : TeiidSQLException(org.teiid.jdbc.TeiidSQLException) ProcedureErrorInstructionException(org.teiid.client.ProcedureErrorInstructionException) VariableContext(org.teiid.query.sql.util.VariableContext) TeiidComponentException(org.teiid.core.TeiidComponentException) QueryMetadataException(org.teiid.api.exception.query.QueryMetadataException) TeiidProcessingException(org.teiid.core.TeiidProcessingException) ProcedureErrorInstructionException(org.teiid.client.ProcedureErrorInstructionException) TeiidSQLException(org.teiid.jdbc.TeiidSQLException) BlockedException(org.teiid.common.buffer.BlockedException) XATransactionException(org.teiid.client.xa.XATransactionException) QueryValidatorException(org.teiid.api.exception.query.QueryValidatorException) SystemException(javax.transaction.SystemException) TeiidProcessingException(org.teiid.core.TeiidProcessingException) TransactionContext(org.teiid.dqp.service.TransactionContext) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) TeiidComponentException(org.teiid.core.TeiidComponentException)

Example 73 with TeiidProcessingException

use of org.teiid.core.TeiidProcessingException in project teiid by teiid.

the class XMLTableNode method nextBatchDirect.

@Override
protected synchronized TupleBatch nextBatchDirect() throws BlockedException, TeiidComponentException, TeiidProcessingException {
    evaluate(false);
    if (streaming) {
        while (state == State.BUILDING) {
            try {
                this.wait();
            } catch (InterruptedException e) {
                throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30169, e);
            }
        }
        unwrapException(asynchException);
        TupleBatch batch = this.buffer.getBatch(outputRow);
        outputRow = batch.getEndRow() + 1;
        if (state != State.DONE && !batch.getTerminationFlag()) {
            state = hasNextBatch() ? State.AVAILABLE : State.BUILDING;
        }
        return batch;
    }
    while (!isBatchFull() && !isLastBatch()) {
        if (item == null) {
            try {
                item = result.iter.next();
            } catch (XPathException e) {
                throw new TeiidProcessingException(QueryPlugin.Event.TEIID30170, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30170, e.getMessage()));
            }
            rowCount++;
            if (item == null) {
                terminateBatches();
                break;
            }
        }
        addBatchRow(processRow());
        if (rowCount == rowLimit) {
            terminateBatches();
            break;
        }
    }
    return pullBatch();
}
Also used : XPathException(net.sf.saxon.trans.XPathException) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) TupleBatch(org.teiid.common.buffer.TupleBatch) TeiidProcessingException(org.teiid.core.TeiidProcessingException)

Example 74 with TeiidProcessingException

use of org.teiid.core.TeiidProcessingException in project teiid by teiid.

the class XMLTableNode method processRow.

private List<?> processRow() throws ExpressionEvaluationException, BlockedException, TeiidComponentException, TeiidProcessingException {
    List<Object> tuple = new ArrayList<Object>(projectedColumns.size());
    for (XMLColumn proColumn : projectedColumns) {
        if (proColumn.isOrdinal()) {
            if (rowCount > Integer.MAX_VALUE) {
                throw new TeiidRuntimeException(new TeiidProcessingException(QueryPlugin.Event.TEIID31174, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31174)));
            }
            tuple.add((int) rowCount);
        } else {
            try {
                XPathExpression path = proColumn.getPathExpression();
                XPathDynamicContext dynamicContext = path.createDynamicContext(item);
                final SequenceIterator pathIter = path.iterate(dynamicContext);
                Item colItem = pathIter.next();
                if (colItem == null) {
                    if (proColumn.getDefaultExpression() != null) {
                        tuple.add(getEvaluator(Collections.emptyMap()).evaluate(proColumn.getDefaultExpression(), null));
                    } else {
                        tuple.add(null);
                    }
                    continue;
                }
                if (proColumn.getSymbol().getType() == DataTypeManager.DefaultDataClasses.XML) {
                    SequenceIterator pushBack = new PushBackSequenceIterator(pathIter, colItem);
                    XMLType value = table.getXQueryExpression().createXMLType(pushBack, this.getBufferManager(), false, getContext());
                    tuple.add(value);
                    continue;
                }
                if (proColumn.getSymbol().getType().isArray()) {
                    ArrayList<Object> vals = new ArrayList<Object>();
                    vals.add(getValue(proColumn.getSymbol().getType().getComponentType(), colItem, this.table.getXQueryExpression().getConfig(), getContext()));
                    Item next = null;
                    while ((next = pathIter.next()) != null) {
                        vals.add(getValue(proColumn.getSymbol().getType().getComponentType(), next, this.table.getXQueryExpression().getConfig(), getContext()));
                    }
                    Object value = new ArrayImpl(vals.toArray((Object[]) Array.newInstance(proColumn.getSymbol().getType().getComponentType(), vals.size())));
                    tuple.add(value);
                    continue;
                } else if (pathIter.next() != null) {
                    throw new TeiidProcessingException(QueryPlugin.Event.TEIID30171, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30171, proColumn.getName()));
                }
                Object value = getValue(proColumn.getSymbol().getType(), colItem, this.table.getXQueryExpression().getConfig(), getContext());
                tuple.add(value);
            } catch (XPathException e) {
                throw new TeiidProcessingException(QueryPlugin.Event.TEIID30172, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30172, proColumn.getName()));
            }
        }
    }
    item = null;
    return tuple;
}
Also used : XPathExpression(net.sf.saxon.sxpath.XPathExpression) XPathException(net.sf.saxon.trans.XPathException) ArrayImpl(org.teiid.core.types.ArrayImpl) ArrayList(java.util.ArrayList) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) TeiidProcessingException(org.teiid.core.TeiidProcessingException) XMLColumn(org.teiid.query.sql.lang.XMLTable.XMLColumn) Item(net.sf.saxon.om.Item) XMLType(org.teiid.core.types.XMLType) PushBackSequenceIterator(org.teiid.query.xquery.saxon.PushBackSequenceIterator) SequenceIterator(net.sf.saxon.om.SequenceIterator) LanguageObject(org.teiid.query.sql.LanguageObject) PushBackSequenceIterator(org.teiid.query.xquery.saxon.PushBackSequenceIterator) XPathDynamicContext(net.sf.saxon.sxpath.XPathDynamicContext)

Example 75 with TeiidProcessingException

use of org.teiid.core.TeiidProcessingException in project teiid by teiid.

the class TextTableNode method parseDelimitedLine.

private List<String> parseDelimitedLine(StringBuilder line) throws TeiidProcessingException {
    ArrayList<String> result = new ArrayList<String>();
    StringBuilder builder = new StringBuilder();
    boolean escaped = false;
    boolean wasQualified = false;
    boolean qualified = false;
    while (true) {
        if (line == null) {
            if (escaped) {
                // allow for escaped new lines
                if (cr) {
                    builder.append('\r');
                }
                builder.append(newLine);
                escaped = false;
                line = readLine(lineWidth, false);
                continue;
            }
            if (!qualified) {
                // close the last entry
                addValue(result, wasQualified || noTrim, builder.toString());
                return result;
            }
            line = readLine(lineWidth, false);
            if (line == null) {
                throw new TeiidProcessingException(QueryPlugin.Event.TEIID30182, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30182, systemId));
            }
        }
        for (int i = 0; i < line.length(); i++) {
            char chr = line.charAt(i);
            if (chr == delimiter) {
                if (escaped || qualified) {
                    builder.append(chr);
                    escaped = false;
                } else {
                    addValue(result, wasQualified || noTrim, builder.toString());
                    wasQualified = false;
                    // next entry
                    builder = new StringBuilder();
                }
            } else if (chr == quote) {
                if (noQuote) {
                    // it's the escape char
                    if (escaped) {
                        builder.append(quote);
                    }
                    escaped = !escaped;
                } else {
                    if (qualified) {
                        qualified = false;
                    } else {
                        if (wasQualified) {
                            qualified = true;
                            builder.append(chr);
                        } else {
                            if (builder.toString().trim().length() != 0) {
                                throw new TeiidProcessingException(QueryPlugin.Event.TEIID30183, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30183, textLine, systemId));
                            }
                            qualified = true;
                            // start the entry over
                            builder = new StringBuilder();
                            wasQualified = true;
                        }
                    }
                }
            } else {
                if (escaped) {
                    // don't understand other escape sequences yet
                    throw new TeiidProcessingException(QueryPlugin.Event.TEIID30184, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30184, chr, textLine, systemId));
                }
                if (wasQualified && !qualified) {
                    if (!Character.isWhitespace(chr)) {
                        throw new TeiidProcessingException(QueryPlugin.Event.TEIID30183, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30183, textLine, systemId));
                    }
                // else just ignore
                } else {
                    builder.append(chr);
                }
            }
        }
        line = null;
    }
}
Also used : ArrayList(java.util.ArrayList) TeiidProcessingException(org.teiid.core.TeiidProcessingException)

Aggregations

TeiidProcessingException (org.teiid.core.TeiidProcessingException)92 TeiidComponentException (org.teiid.core.TeiidComponentException)30 IOException (java.io.IOException)17 ArrayList (java.util.ArrayList)17 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)17 SQLException (java.sql.SQLException)16 BlockedException (org.teiid.common.buffer.BlockedException)16 Test (org.junit.Test)14 CommandContext (org.teiid.query.util.CommandContext)14 LanguageObject (org.teiid.query.sql.LanguageObject)13 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)13 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)12 List (java.util.List)11 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)10 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)10 QueryPlannerException (org.teiid.api.exception.query.QueryPlannerException)9 TupleSource (org.teiid.common.buffer.TupleSource)9 TupleBatch (org.teiid.common.buffer.TupleBatch)8 CollectionTupleSource (org.teiid.query.processor.CollectionTupleSource)7 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)6