From 99d5d9df6d8ee1fb919f67feb6b8602dca3d830a Mon Sep 17 00:00:00 2001 From: Tobias Hafner Date: Thu, 2 Jan 2025 16:10:24 +0100 Subject: [PATCH] Implement option to set concurrency mode on namespace creation --- .../main/java/org/polypheny/db/ddl/DdlManager.java | 12 ------------ .../java/org/polypheny/db/ddl/DdlManagerImpl.java | 7 ------- .../polypheny/db/languages/mql/MqlUseNamespace.java | 2 +- plugins/sql-language/src/main/codegen/Parser.jj | 9 +++++++-- .../db/sql/language/ddl/SqlCreateNamespace.java | 7 +++++-- .../polypheny/db/sql/language/ddl/SqlDdlNodes.java | 4 ++-- 6 files changed, 15 insertions(+), 26 deletions(-) diff --git a/core/src/main/java/org/polypheny/db/ddl/DdlManager.java b/core/src/main/java/org/polypheny/db/ddl/DdlManager.java index db01d86103..0b65323ca4 100644 --- a/core/src/main/java/org/polypheny/db/ddl/DdlManager.java +++ b/core/src/main/java/org/polypheny/db/ddl/DdlManager.java @@ -89,18 +89,6 @@ public static DdlManager getInstance() { return INSTANCE; } - - /** - * Creates a namespace with the provided options. - * - * @param name name of the new namespace - * @param type the namespace type, RELATIONAL, DOCUMENT, etc. - * @param ifNotExists whether to silently ignore if a namespace with this name does already exist - * @param replace whether to replace an existing namespace with this name - * @param statement the query statement - */ - public abstract long createNamespace( String name, DataModel type, boolean ifNotExists, boolean replace, Statement statement ); - /** * Creates a namespace with the provided options. * diff --git a/dbms/src/main/java/org/polypheny/db/ddl/DdlManagerImpl.java b/dbms/src/main/java/org/polypheny/db/ddl/DdlManagerImpl.java index 92f18f1c63..5096518aa7 100644 --- a/dbms/src/main/java/org/polypheny/db/ddl/DdlManagerImpl.java +++ b/dbms/src/main/java/org/polypheny/db/ddl/DdlManagerImpl.java @@ -172,13 +172,6 @@ protected DataStore getDataStoreInstance( long storeId ) { } - @Override - //TODO TH: remove this if no longer used - public long createNamespace( String initialName, DataModel type, boolean ifNotExists, boolean replace, Statement statement ) { - return createNamespace( initialName, type, ifNotExists, replace, statement, false ); - } - - @Override public long createNamespace( String initialName, DataModel type, boolean ifNotExists, boolean replace, Statement statement, boolean useMvcc ) { String name = initialName.toLowerCase(); diff --git a/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlUseNamespace.java b/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlUseNamespace.java index b717b13c64..7813d9c435 100644 --- a/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlUseNamespace.java +++ b/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlUseNamespace.java @@ -50,7 +50,7 @@ public MqlUseNamespace( ParserPos pos, String namespace ) { @Override public void execute( Context context, Statement statement, ParsedQueryContext parsedQueryContext ) { - DdlManager.getInstance().createNamespace( this.namespace, DataModel.DOCUMENT, true, false, statement ); + DdlManager.getInstance().createNamespace( this.namespace, DataModel.DOCUMENT, true, false, statement, false ); } diff --git a/plugins/sql-language/src/main/codegen/Parser.jj b/plugins/sql-language/src/main/codegen/Parser.jj index 62e3cef494..f3ccec4f54 100644 --- a/plugins/sql-language/src/main/codegen/Parser.jj +++ b/plugins/sql-language/src/main/codegen/Parser.jj @@ -1866,6 +1866,7 @@ SqlCreate SqlCreateNamespace(Span s, boolean replace) : final boolean ifNotExists; final SqlIdentifier id; final DataModel dataModel; + boolean useMvcc = false; } { ( @@ -1878,11 +1879,13 @@ SqlCreate SqlCreateNamespace(Span s, boolean replace) : { dataModel = DataModel.RELATIONAL; } ) ( | ) ifNotExists = IfNotExistsOpt() id = CompoundIdentifier() + [ { useMvcc = true; } ] { - return SqlDdlNodes.createNamespace(s.end(this), replace, ifNotExists, id, dataModel); -} + return SqlDdlNodes.createNamespace(s.end(this), replace, ifNotExists, id, dataModel, useMvcc); + } } + SqlNodeList Options() : { final Span s; @@ -7565,6 +7568,7 @@ SqlPostfixOperator PostfixRowOperator() : | < COMMAND_FUNCTION_CODE: "COMMAND_FUNCTION_CODE" > | < COMMIT: "COMMIT" > | < COMMITTED: "COMMITTED" > +| < CONCURRENCY: "CONCURRENCY" > | < CONDITION: "CONDITION" > | < CONDITIONAL: "CONDITIONAL" > | < CONDITION_NUMBER: "CONDITION_NUMBER" > @@ -7817,6 +7821,7 @@ SqlPostfixOperator PostfixRowOperator() : | < MORE_: "MORE" > | < MULTISET: "MULTISET" > | < MUMPS: "MUMPS" > +| < MVCC: "MVCC" > | < NAME: "NAME" > | < NAMES: "NAMES" > | < NAMESPACE: "NAMESPACE" > diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlCreateNamespace.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlCreateNamespace.java index 2a05a48147..9bfb5be2ac 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlCreateNamespace.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlCreateNamespace.java @@ -49,16 +49,19 @@ public class SqlCreateNamespace extends SqlCreate implements ExecutableStatement private final DataModel type; + private final boolean useMvcc; + private static final SqlOperator OPERATOR = new SqlSpecialOperator( "CREATE NAMESPACE", Kind.CREATE_NAMESPACE ); /** * Creates a SqlCreateNamespace. */ - SqlCreateNamespace( ParserPos pos, boolean replace, boolean ifNotExists, SqlIdentifier name, DataModel dataModel ) { + SqlCreateNamespace( ParserPos pos, boolean replace, boolean ifNotExists, SqlIdentifier name, DataModel dataModel, boolean useMvcc ) { super( OPERATOR, pos, replace, ifNotExists ); this.name = Objects.requireNonNull( name ); this.type = dataModel; + this.useMvcc = useMvcc; } @@ -93,7 +96,7 @@ public void unparse( SqlWriter writer, int leftPrec, int rightPrec ) { @Override public void execute( Context context, Statement statement, ParsedQueryContext parsedQueryContext ) { - DdlManager.getInstance().createNamespace( name.getSimple(), type, ifNotExists, replace, statement ); + DdlManager.getInstance().createNamespace( name.getSimple(), type, ifNotExists, replace, statement, useMvcc ); } diff --git a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlDdlNodes.java b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlDdlNodes.java index 3322bde735..ffb07d7f08 100644 --- a/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlDdlNodes.java +++ b/plugins/sql-language/src/main/java/org/polypheny/db/sql/language/ddl/SqlDdlNodes.java @@ -43,8 +43,8 @@ private SqlDdlNodes() { /** * Creates a CREATE NAMESPACE. */ - public static SqlCreateNamespace createNamespace( ParserPos pos, boolean replace, boolean ifNotExists, SqlIdentifier name, DataModel dataModel ) { - return new SqlCreateNamespace( pos, replace, ifNotExists, name, dataModel ); + public static SqlCreateNamespace createNamespace( ParserPos pos, boolean replace, boolean ifNotExists, SqlIdentifier name, DataModel dataModel, boolean useMvcc ) { + return new SqlCreateNamespace( pos, replace, ifNotExists, name, dataModel, useMvcc ); }