diff --git a/core/src/main/java/org/polypheny/db/languages/LanguageManager.java b/core/src/main/java/org/polypheny/db/languages/LanguageManager.java index 48146f6bcf..07a6321158 100644 --- a/core/src/main/java/org/polypheny/db/languages/LanguageManager.java +++ b/core/src/main/java/org/polypheny/db/languages/LanguageManager.java @@ -108,7 +108,7 @@ public List anyPrepareQuery( QueryContext context, Statem throw new GenericRuntimeException( String.format( "%s query is empty", context.getLanguage().serializedName() ) ); } - parsedQueries = context.getLanguage().splitter().apply( context ); + parsedQueries = context.getLanguage().parser().apply( context ); } catch ( Throwable e ) { log.warn( "Error on preparing query: {}", e.getMessage() ); if ( transaction.isAnalyze() ) { @@ -133,7 +133,7 @@ public List anyPrepareQuery( QueryContext context, Statem try { // test if parsing was successful if ( parsed.getQueryNode().isEmpty() ) { - Exception e = new GenericRuntimeException( "Error during parsing of query \"" + context.getQuery() + "\"" ); + Exception e = new GenericRuntimeException( "Error during parsing of query \"%s\"".formatted( context.getQuery() ) ); return handleParseException( statement, parsed, transaction, e, implementationContexts ); } diff --git a/core/src/main/java/org/polypheny/db/languages/QueryLanguage.java b/core/src/main/java/org/polypheny/db/languages/QueryLanguage.java index 5a1de840f0..9a95d43308 100644 --- a/core/src/main/java/org/polypheny/db/languages/QueryLanguage.java +++ b/core/src/main/java/org/polypheny/db/languages/QueryLanguage.java @@ -41,7 +41,7 @@ public record QueryLanguage( @Nullable ParserFactory factory, @NotNull Supplier processorSupplier, @Nullable BiFunction validatorSupplier, - @NotNull Function> splitter, + @NotNull Function> parser, @NotNull Function limitRemover ) { diff --git a/core/src/main/java/org/polypheny/db/processing/QueryContext.java b/core/src/main/java/org/polypheny/db/processing/QueryContext.java index c90f58f30f..b21929afcc 100644 --- a/core/src/main/java/org/polypheny/db/processing/QueryContext.java +++ b/core/src/main/java/org/polypheny/db/processing/QueryContext.java @@ -50,6 +50,9 @@ public class QueryContext { @Builder.Default boolean isAnalysed = false; + @Builder.Default + boolean isAutoGenerated = false; + @Builder.Default boolean usesCache = true; @@ -100,6 +103,7 @@ public static ParsedQueryContext fromQuery( String query, Node queryNode, QueryC return ParsedQueryContext.builder() .query( query ) .queryNode( queryNode ) + .isAutoGenerated( context.isAutoGenerated ) .language( context.language ) .isAnalysed( context.isAnalysed ) .usesCache( context.usesCache ) diff --git a/core/src/main/java/org/polypheny/db/transaction/Transaction.java b/core/src/main/java/org/polypheny/db/transaction/Transaction.java index 6994f65f4c..73fc015925 100644 --- a/core/src/main/java/org/polypheny/db/transaction/Transaction.java +++ b/core/src/main/java/org/polypheny/db/transaction/Transaction.java @@ -92,6 +92,8 @@ public interface Transaction { void updateAccessMode( AccessMode accessCandidate ); + TransactionManager getTransactionManager(); + /** * Flavor, how multimedia results should be returned from a store. */ diff --git a/dbms/src/main/java/org/polypheny/db/transaction/TransactionImpl.java b/dbms/src/main/java/org/polypheny/db/transaction/TransactionImpl.java index c29472892b..ea412f8777 100644 --- a/dbms/src/main/java/org/polypheny/db/transaction/TransactionImpl.java +++ b/dbms/src/main/java/org/polypheny/db/transaction/TransactionImpl.java @@ -78,7 +78,7 @@ public class TransactionImpl implements Transaction, Comparable { private final LogicalUser user; @Getter private final LogicalNamespace defaultNamespace; - + @Getter private final TransactionManagerImpl transactionManager; @Getter diff --git a/plugins/mql-language/src/main/java/org/polypheny/db/languages/MongoLanguagePlugin.java b/plugins/mql-language/src/main/java/org/polypheny/db/languages/MongoLanguagePlugin.java index 685e092852..56db38b764 100644 --- a/plugins/mql-language/src/main/java/org/polypheny/db/languages/MongoLanguagePlugin.java +++ b/plugins/mql-language/src/main/java/org/polypheny/db/languages/MongoLanguagePlugin.java @@ -124,6 +124,7 @@ private static List anyQuerySplitter( QueryContext context ) .namespaceId( context.getNamespaceId() ) .transactionManager( context.getTransactionManager() ) .origin( context.getOrigin() ) + .isAutoGenerated( true ) .informationTarget( context.getInformationTarget() ) .build() ).map( LanguageManager::toQueryNodes ).toList(); @@ -137,11 +138,6 @@ private static List anyQuerySplitter( QueryContext context ) } - public String preprocessing( String query, QueryContext context ) { - return query; - } - - public static void registerOperators() { if ( isInit ) { throw new GenericRuntimeException( "Mql operators were already registered." ); diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/StatementProcessor.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/StatementProcessor.java index 60eb923cc8..3a25f65135 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/StatementProcessor.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/StatementProcessor.java @@ -61,6 +61,7 @@ public static void implement( PIStatement piStatement ) { .query( piStatement.getQuery() ) .language( piStatement.getLanguage() ) .namespaceId( piStatement.getNamespace().id ) + .transactionManager( piStatement.getTransaction().getTransactionManager() ) .origin( ORIGIN ) .build(); List implementations = LanguageManager.getINSTANCE().anyPrepareQuery( context, statement ); diff --git a/plugins/sql-language/src/test/java/org/polypheny/db/sql/SqlLanguagePluginTest.java b/plugins/sql-language/src/test/java/org/polypheny/db/sql/SqlLanguagePluginTest.java index b887ce0de3..674d189509 100644 --- a/plugins/sql-language/src/test/java/org/polypheny/db/sql/SqlLanguagePluginTest.java +++ b/plugins/sql-language/src/test/java/org/polypheny/db/sql/SqlLanguagePluginTest.java @@ -53,7 +53,7 @@ public QueryContext getContext( String query ) { public void testQueryWithSemicolon() { QueryContext context = getContext( "SELECT * FROM employee WHERE ename = ';'" ); - List res = sql.splitter().apply( context ); + List res = sql.parser().apply( context ); assertEquals( 1, res.size() ); } @@ -62,7 +62,7 @@ public void testQueryWithSemicolon() { public void testTwoQueries() { QueryContext context = getContext( "SELECT * FROM employee WHERE ename = 'a'; SELECT * FROM employee WHERE ename = 'b'" ); - List res = sql.splitter().apply( context ); + List res = sql.parser().apply( context ); assertEquals( 2, res.size() ); } @@ -71,7 +71,7 @@ public void testTwoQueries() { public void testTwoQueriesWithSemicolon() { QueryContext context = getContext( "SELECT * FROM employee WHERE ename = ';'; SELECT * FROM employee WHERE ename = ';'" ); - List res = sql.splitter().apply( context ); + List res = sql.parser().apply( context ); assertEquals( 2, res.size() ); }