final public RaiseStatement errorStatement(ParseInfo info) throws ParseException { Expression errMsg = null; jj_consume_token(ERROR); errMsg = expression(info); ExceptionExpression ee = new ExceptionExpression(); ee.setMessage(errMsg); {if (true) return new RaiseStatement(ee);} throw new Error("Missing return statement in function"); }
@Override public void visit(ExceptionExpression exceptionExpression) { if (exceptionExpression.getMessage() != null) { exceptionExpression.setMessage(replaceExpression(exceptionExpression.getMessage())); } if (exceptionExpression.getSqlState() != null) { exceptionExpression.setSqlState(replaceExpression(exceptionExpression.getSqlState())); } if (exceptionExpression.getErrorCode() != null) { exceptionExpression.setErrorCode(replaceExpression(exceptionExpression.getErrorCode())); } if (exceptionExpression.getParent() != null) { exceptionExpression.setParent(replaceExpression(exceptionExpression.getParent())); } }
private Object evaluate(List<?> tuple, ExceptionExpression ee) throws ExpressionEvaluationException, BlockedException, TeiidComponentException { String msg = (String) internalEvaluate(ee.getMessage(), tuple); String sqlState = ee.getDefaultSQLState(); if (ee.getSqlState() != null) { sqlState = (String) internalEvaluate(ee.getSqlState(), tuple); } Integer errorCode = null; if (ee.getErrorCode() != null) { errorCode = (Integer) internalEvaluate(ee.getErrorCode(), tuple); } Exception parent = null; if (ee.getParent() != null) { parent = (Exception) internalEvaluate(ee.getParent(), tuple); } Exception result = new TeiidSQLException(parent, msg, sqlState, errorCode!=null?errorCode:0); result.setStackTrace(SourceWarning.EMPTY_STACK_TRACE); return result; }
ExceptionExpression ee = new ExceptionExpression(); ee.setMessage(err); ee.setSqlState(sqlState); ee.setErrorCode(errCode); ee.setParent(parent); {if (true) return ee;} throw new Error("Missing return statement in function");
@Override public ExceptionExpression clone() { ExceptionExpression clone = new ExceptionExpression(); if (this.message != null) { clone.message = (Expression) this.message.clone(); } if (this.sqlState != null) { clone.sqlState = (Expression) this.sqlState.clone(); } if (this.errorCode != null) { clone.errorCode = (Expression) this.errorCode.clone(); } if (this.parent != null) { clone.parent = (Expression) this.parent.clone(); } return clone; }
ExceptionExpression ee = new ExceptionExpression(); ee.setMessage(err); ee.setSqlState(sqlState); ee.setErrorCode(errCode); ee.setParent(parent); {if (true) return ee;} throw new Error("Missing return statement in function");
@Override public ExceptionExpression clone() { ExceptionExpression clone = new ExceptionExpression(); if (this.message != null) { clone.message = (Expression) this.message.clone(); } if (this.sqlState != null) { clone.sqlState = (Expression) this.sqlState.clone(); } if (this.errorCode != null) { clone.errorCode = (Expression) this.errorCode.clone(); } if (this.parent != null) { clone.parent = (Expression) this.parent.clone(); } return clone; }
@Override public void visit(ExceptionExpression exceptionExpression) { if (exceptionExpression.getMessage() != null) { exceptionExpression.setMessage(replaceExpression(exceptionExpression.getMessage())); } if (exceptionExpression.getSqlState() != null) { exceptionExpression.setSqlState(replaceExpression(exceptionExpression.getSqlState())); } if (exceptionExpression.getErrorCode() != null) { exceptionExpression.setErrorCode(replaceExpression(exceptionExpression.getErrorCode())); } if (exceptionExpression.getParent() != null) { exceptionExpression.setParent(replaceExpression(exceptionExpression.getParent())); } }
private Object evaluate(List<?> tuple, ExceptionExpression ee) throws ExpressionEvaluationException, BlockedException, TeiidComponentException { String msg = (String) internalEvaluate(ee.getMessage(), tuple); String sqlState = ee.getDefaultSQLState(); if (ee.getSqlState() != null) { sqlState = (String) internalEvaluate(ee.getSqlState(), tuple); } Integer errorCode = null; if (ee.getErrorCode() != null) { errorCode = (Integer) internalEvaluate(ee.getErrorCode(), tuple); } Exception parent = null; if (ee.getParent() != null) { parent = (Exception) internalEvaluate(ee.getParent(), tuple); } Exception result = new TeiidSQLException(parent, msg, sqlState, errorCode!=null?errorCode:0); result.setStackTrace(SourceWarning.EMPTY_STACK_TRACE); return result; }
@Test public void testRaiseErrorStatement() throws Exception { ExceptionExpression ee = new ExceptionExpression(); ee.setMessage(new Constant("Test only")); ee.setSqlState(new Constant("100")); ee.setParent(new ElementSymbol("e")); RaiseStatement errStmt = new RaiseStatement(ee, true); helpStmtTest("RAISE SQLWARNING SQLEXCEPTION 'Test only' SQLSTATE '100' chain e;", "RAISE SQLWARNING SQLEXCEPTION 'Test only' SQLSTATE '100' CHAIN e;", //$NON-NLS-1$ //$NON-NLS-2$ errStmt); }
final public RaiseStatement errorStatement(ParseInfo info) throws ParseException { Expression errMsg = null; jj_consume_token(ERROR); errMsg = expression(info); ExceptionExpression ee = new ExceptionExpression(); ee.setMessage(errMsg); {if (true) return new RaiseStatement(ee);} throw new Error("Missing return statement in function"); }
@Override public ExceptionExpression clone() { ExceptionExpression clone = new ExceptionExpression(); if (this.message != null) { clone.message = (Expression) this.message.clone(); } if (this.sqlState != null) { clone.sqlState = (Expression) this.sqlState.clone(); } if (this.errorCode != null) { clone.errorCode = (Expression) this.errorCode.clone(); } if (this.parent != null) { clone.parent = (Expression) this.parent.clone(); } return clone; }
@Override public void visit(ExceptionExpression exceptionExpression) { if (exceptionExpression.getMessage() != null) { exceptionExpression.setMessage(replaceExpression(exceptionExpression.getMessage())); } if (exceptionExpression.getSqlState() != null) { exceptionExpression.setSqlState(replaceExpression(exceptionExpression.getSqlState())); } if (exceptionExpression.getErrorCode() != null) { exceptionExpression.setErrorCode(replaceExpression(exceptionExpression.getErrorCode())); } if (exceptionExpression.getParent() != null) { exceptionExpression.setParent(replaceExpression(exceptionExpression.getParent())); } }
private Object evaluate(List<?> tuple, ExceptionExpression ee) throws ExpressionEvaluationException, BlockedException, TeiidComponentException { String msg = (String) internalEvaluate(ee.getMessage(), tuple); String sqlState = ee.getDefaultSQLState(); if (ee.getSqlState() != null) { sqlState = (String) internalEvaluate(ee.getSqlState(), tuple); } Integer errorCode = null; if (ee.getErrorCode() != null) { errorCode = (Integer) internalEvaluate(ee.getErrorCode(), tuple); } Exception parent = null; if (ee.getParent() != null) { parent = (Exception) internalEvaluate(ee.getParent(), tuple); } Exception result = new TeiidSQLException(parent, msg, sqlState, errorCode!=null?errorCode:0); result.setStackTrace(SourceWarning.EMPTY_STACK_TRACE); return result; }
ExceptionExpression ee = new ExceptionExpression(); ee.setMessage(err); ee.setSqlState(sqlState); ee.setErrorCode(errCode); ee.setParent(parent); {if (true) return ee;} throw new Error("Missing return statement in function");
final public RaiseStatement errorStatement(ParseInfo info) throws ParseException { Expression errMsg = null; jj_consume_token(ERROR); errMsg = expression(info); ExceptionExpression ee = new ExceptionExpression(); ee.setMessage(errMsg); {if (true) return new RaiseStatement(ee);} throw new Error("Missing return statement in function"); }
@Override public void visit(ExceptionExpression obj) { try { if (obj.getErrorCode() != null) { obj.setErrorCode(ResolverUtil.convertExpression(obj.getErrorCode(), DataTypeManager.DefaultDataTypes.INTEGER, metadata)); } obj.setMessage(ResolverUtil.convertExpression(obj.getMessage(), DataTypeManager.DefaultDataTypes.STRING, metadata)); if (obj.getSqlState() != null) { obj.setSqlState(ResolverUtil.convertExpression(obj.getSqlState(), DataTypeManager.DefaultDataTypes.STRING, metadata)); } checkException(obj.getParent()); } catch (QueryResolverException e) { handleException(e); } }
@Override public void visit(ExceptionExpression exceptionExpression) { preVisitVisitor(exceptionExpression); visitNode(exceptionExpression.getMessage()); visitNode(exceptionExpression.getSqlState()); visitNode(exceptionExpression.getErrorCode()); visitNode(exceptionExpression.getParent()); postVisitVisitor(exceptionExpression); }
@Test public void testErrorStatement() throws Exception { ExceptionExpression ee = new ExceptionExpression(); ee.setMessage(new Constant("Test only")); RaiseStatement errStmt = new RaiseStatement(ee); helpStmtTest("ERROR 'Test only';", "RAISE SQLEXCEPTION 'Test only';", //$NON-NLS-1$ //$NON-NLS-2$ errStmt); }
@Override public void visit(ExceptionExpression obj) { try { if (obj.getErrorCode() != null) { obj.setErrorCode(ResolverUtil.convertExpression(obj.getErrorCode(), DataTypeManager.DefaultDataTypes.INTEGER, metadata)); } obj.setMessage(ResolverUtil.convertExpression(obj.getMessage(), DataTypeManager.DefaultDataTypes.STRING, metadata)); if (obj.getSqlState() != null) { obj.setSqlState(ResolverUtil.convertExpression(obj.getSqlState(), DataTypeManager.DefaultDataTypes.STRING, metadata)); } checkException(obj.getParent()); } catch (QueryResolverException e) { handleException(e); } }