Skip to content

Commit

Permalink
Implement option to set concurrency mode on namespace creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Hafner committed Jan 2, 2025
1 parent 8f4c22a commit 99d5d9d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 26 deletions.
12 changes: 0 additions & 12 deletions core/src/main/java/org/polypheny/db/ddl/DdlManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
7 changes: 0 additions & 7 deletions dbms/src/main/java/org/polypheny/db/ddl/DdlManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}


Expand Down
9 changes: 7 additions & 2 deletions plugins/sql-language/src/main/codegen/Parser.jj
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,7 @@ SqlCreate SqlCreateNamespace(Span s, boolean replace) :
final boolean ifNotExists;
final SqlIdentifier id;
final DataModel dataModel;
boolean useMvcc = false;
}
{
(
Expand All @@ -1878,11 +1879,13 @@ SqlCreate SqlCreateNamespace(Span s, boolean replace) :
{ dataModel = DataModel.RELATIONAL; }
)
(<NAMESPACE> | <SCHEMA>) ifNotExists = IfNotExistsOpt() id = CompoundIdentifier()
[ <CONCURRENCY> <MVCC> { 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;
Expand Down Expand Up @@ -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" >
Expand Down Expand Up @@ -7817,6 +7821,7 @@ SqlPostfixOperator PostfixRowOperator() :
| < MORE_: "MORE" >
| < MULTISET: "MULTISET" >
| < MUMPS: "MUMPS" >
| < MVCC: "MVCC" >
| < NAME: "NAME" >
| < NAMES: "NAMES" >
| < NAMESPACE: "NAMESPACE" >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down Expand Up @@ -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 );
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}


Expand Down

0 comments on commit 99d5d9d

Please sign in to comment.