@Override public Result executeQuery( String query, MapValue parameters, TransactionalContext context ) throws QueryExecutionKernelException { try { return inner.execute( query, parameters, context, false ); } catch ( CypherException e ) { throw new QueryExecutionKernelException( e ); } }
private static QueryExecutionException converted( CypherException e ) { return new QueryExecutionKernelException( e ).asUserException(); } }
@Override public Result profileQuery( String query, MapValue parameters, TransactionalContext context ) throws QueryExecutionKernelException { try { return inner.execute( query, parameters, context, true ); } catch ( CypherException e ) { throw new QueryExecutionKernelException( e ); } }
@Override State beginTransaction( MutableTransactionState ctx, TransactionStateMachineSPI spi, Bookmark bookmark, Duration txTimeout, Map<String,Object> txMetadata ) throws KernelException { throw new QueryExecutionKernelException( new InvalidSemanticsException( "Nested transactions are not supported." ) ); }
@Override State commitTransaction( MutableTransactionState ctx, TransactionStateMachineSPI spi ) throws KernelException { throw new QueryExecutionKernelException( new InvalidSemanticsException( "No current transaction to commit." ) ); }
private Result throwQueryExecutionException( String message, Object... parameters ) throws QueryExecutionKernelException { throw new QueryExecutionKernelException( new UnstableSnapshotException( message, parameters ) ); }
@Override public BoltResult start() throws KernelException { try { Result result = queryExecutionEngine.executeQuery( statement, params, transactionalContext ); if ( result instanceof QueryResultProvider ) { return newBoltResult( (QueryResultProvider) result, clock ); } else { throw new IllegalStateException( format( "Unexpected query execution result. Expected to get instance of %s but was %s.", QueryResultProvider.class.getName(), result.getClass().getName() ) ); } } catch ( KernelException e ) { close( false ); throw new QueryExecutionKernelException( e ); } catch ( Throwable e ) { close( false ); throw e; } }
private void checkIfDirty() { if ( versionContext.isDirty() ) { throw new QueryExecutionKernelException( new UnstableSnapshotException( "Unable to get clean data snapshot for query serialisation." ) ) .asUserException(); } }
@Override State run( MutableTransactionState ctx, TransactionStateMachineSPI spi, String statement, MapValue params, Bookmark bookmark, Duration ignored1, Map<String,Object> ignored2 ) throws KernelException { checkState( ignored1 == null, "Explicit Transaction should not run with tx_timeout" ); checkState( ignored2 == null, "Explicit Transaction should not run with tx_metadata" ); if ( statement.isEmpty() ) { statement = ctx.lastStatement; } else { ctx.lastStatement = statement; } if ( spi.isPeriodicCommit( statement ) ) { throw new QueryExecutionKernelException( new InvalidSemanticsException( "Executing queries that use periodic commit in an " + "open transaction is not possible." ) ); } else { BoltResultHandle resultHandle = spi.executeQuery( ctx.loginContext, statement, params, null, null /*ignored in explict tx run*/ ); startExecution( ctx, resultHandle ); return EXPLICIT_TRANSACTION; } }
@Test public void shouldLogMessageIfCypherSyntaxErrorOccurs() throws Exception { // given TransitionalPeriodTransactionMessContainer kernel = mockKernel(); QueryExecutionEngine executionEngine = mock( QueryExecutionEngine.class ); TransactionalContext transactionalContext = prepareKernelWithQuerySession( kernel ); when( executionEngine.executeQuery( "matsch (n) return n", NO_PARAMS, transactionalContext ) ) .thenThrow( new QueryExecutionKernelException( new SyntaxException( "did you mean MATCH?" ) ) ); TransactionRegistry registry = mock( TransactionRegistry.class ); when( registry.begin( any( TransactionHandle.class ) ) ).thenReturn( 1337L ); GraphDatabaseQueryService queryService = mock( GraphDatabaseQueryService.class ); TransactionHandle handle = new TransactionHandle( kernel, executionEngine, queryService, registry, uriScheme, false, AUTH_DISABLED, anyLong(), NullLogProvider.getInstance() ); ExecutionResultSerializer output = mock( ExecutionResultSerializer.class ); // when Statement statement = new Statement( "matsch (n) return n", map(), false, (ResultDataContent[]) null ); handle.commit( statements( statement ), output, mock( HttpServletRequest.class ) ); // then verify( registry ).forget( 1337L ); InOrder outputOrder = inOrder( output ); outputOrder.verify( output ).errors( argThat( hasErrors( Status.Statement.SyntaxError ) ) ); outputOrder.verify( output ).finish(); verifyNoMoreInteractions( output ); }
if ( (statements.hasNext() || hasPrevious) && hasPeriodicCommit ) throw new QueryExecutionKernelException( new InvalidSemanticsException( "Cannot execute another statement after executing " + "PERIODIC COMMIT statement in the same transaction" ) );
private static QueryExecutionException converted( CypherException e ) { return new QueryExecutionKernelException( e ).asUserException(); } }
@Override public Result profileQuery( String query, MapValue parameters, TransactionalContext context ) throws QueryExecutionKernelException { try { return inner.execute( query, parameters, context, true ); } catch ( CypherException e ) { throw new QueryExecutionKernelException( e ); } }
@Override public Result executeQuery( String query, MapValue parameters, TransactionalContext context ) throws QueryExecutionKernelException { try { return inner.execute( query, parameters, context, false ); } catch ( CypherException e ) { throw new QueryExecutionKernelException( e ); } }
private Result throwQueryExecutionException( String message, Object... parameters ) throws QueryExecutionKernelException { throw new QueryExecutionKernelException( new UnstableSnapshotException( message, parameters ) ); }
@Override State beginTransaction( MutableTransactionState ctx, TransactionStateMachineSPI spi, Bookmark bookmark, Duration txTimeout, Map<String,Object> txMetadata ) throws KernelException { throw new QueryExecutionKernelException( new InvalidSemanticsException( "Nested transactions are not supported." ) ); }
@Override State commitTransaction( MutableTransactionState ctx, TransactionStateMachineSPI spi ) throws KernelException { throw new QueryExecutionKernelException( new InvalidSemanticsException( "No current transaction to commit." ) ); }
@Override public BoltResult start() throws KernelException { try { Result result = queryExecutionEngine.executeQuery( statement, params, transactionalContext ); if ( result instanceof QueryResultProvider ) { return newBoltResult( (QueryResultProvider) result, clock ); } else { throw new IllegalStateException( format( "Unexpected query execution result. Expected to get instance of %s but was %s.", QueryResultProvider.class.getName(), result.getClass().getName() ) ); } } catch ( KernelException e ) { close( false ); throw new QueryExecutionKernelException( e ); } catch ( Throwable e ) { close( false ); throw e; } }
private void checkIfDirty() { if ( versionContext.isDirty() ) { throw new QueryExecutionKernelException( new UnstableSnapshotException( "Unable to get clean data snapshot for query serialisation." ) ) .asUserException(); } }
@Override State run( MutableTransactionState ctx, TransactionStateMachineSPI spi, String statement, MapValue params, Bookmark bookmark, Duration ignored1, Map<String,Object> ignored2 ) throws KernelException { checkState( ignored1 == null, "Explicit Transaction should not run with tx_timeout" ); checkState( ignored2 == null, "Explicit Transaction should not run with tx_metadata" ); if ( statement.isEmpty() ) { statement = ctx.lastStatement; } else { ctx.lastStatement = statement; } if ( spi.isPeriodicCommit( statement ) ) { throw new QueryExecutionKernelException( new InvalidSemanticsException( "Executing queries that use periodic commit in an " + "open transaction is not possible." ) ); } else { BoltResultHandle resultHandle = spi.executeQuery( ctx.loginContext, statement, params, null, null /*ignored in explict tx run*/ ); startExecution( ctx, resultHandle ); return EXPLICIT_TRANSACTION; } }