-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Oracle Alter Session Statements (#1234)
* Implement Oracle Alter Session Statements according to https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_2012.htm * Implement PMD Rule "SwitchStmtsShouldHaveDefault" * Reorganize Test Case imports
- Loading branch information
1 parent
3082de3
commit 3a46a29
Showing
14 changed files
with
460 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
src/main/java/net/sf/jsqlparser/statement/alter/AlterSession.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
/*- | ||
* #%L | ||
* JSQLParser library | ||
* %% | ||
* Copyright (C) 2004 - 2021 JSQLParser | ||
* %% | ||
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0 | ||
* #L% | ||
*/ | ||
/* | ||
* Copyright (C) 2021 JSQLParser. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under the terms of the | ||
* GNU Lesser General Public License as published by the Free Software Foundation; either version | ||
* 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along with this library; | ||
* if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
* 02110-1301 USA | ||
*/ | ||
|
||
package net.sf.jsqlparser.statement.alter; | ||
|
||
import java.util.List; | ||
import net.sf.jsqlparser.statement.Statement; | ||
import net.sf.jsqlparser.statement.StatementVisitor; | ||
|
||
/** | ||
* | ||
* @author are | ||
* @@link https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_2012.htm | ||
*/ | ||
public class AlterSession implements Statement { | ||
private AlterSessionOperation operation; | ||
private List<String> parameters; | ||
|
||
public AlterSession(AlterSessionOperation operation, List<String> parameters) { | ||
this.operation = operation; | ||
this.parameters = parameters; | ||
} | ||
|
||
public AlterSessionOperation getOperation() { | ||
return operation; | ||
} | ||
|
||
public void setOperation(AlterSessionOperation operation) { | ||
this.operation = operation; | ||
} | ||
|
||
public List<String> getParameters() { | ||
return parameters; | ||
} | ||
|
||
public void setParameters(List<String> parameters) { | ||
this.parameters = parameters; | ||
} | ||
|
||
private static void appendParamaters(StringBuilder builder, List<String> parameters) { | ||
for (String s: parameters) { | ||
builder.append(" ").append(s); | ||
} | ||
} | ||
|
||
@Override | ||
@SuppressWarnings({"PMD.ExcessiveMethodLength", "PMD.CyclomaticComplexity"}) | ||
public String toString() { | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append("ALTER SESSION "); | ||
switch (operation) { | ||
case ADVISE_COMMIT: | ||
builder.append("ADVISE COMMIT"); | ||
break; | ||
case ADVISE_ROLLBACK: | ||
builder.append("ADVISE ROLLBACK"); | ||
break; | ||
case ADVISE_NOTHING: | ||
builder.append("ADVISE NOTHING"); | ||
break; | ||
case CLOSE_DATABASE_LINK: | ||
builder.append("CLOSE DATABASE LINK "); | ||
appendParamaters(builder, parameters); | ||
break; | ||
case ENABLE_COMMIT_IN_PROCEDURE: | ||
builder.append("ENABLE COMMIT IN PROCEDURE"); | ||
break; | ||
case DISABLE_COMMIT_IN_PROCEDURE: | ||
builder.append("DISABLE COMMIT IN PROCEDURE"); | ||
break; | ||
case ENABLE_GUARD: | ||
builder.append("ENABLE GUARD"); | ||
break; | ||
case DISABLE_GUARD: | ||
builder.append("DISABLE GUARD"); | ||
break; | ||
|
||
case ENABLE_PARALLEL_DML: | ||
builder.append("ENABLE PARALLEL DML"); | ||
appendParamaters(builder, parameters); | ||
break; | ||
|
||
case DISABLE_PARALLEL_DML: | ||
builder.append("DISABLE PARALLEL DML"); | ||
appendParamaters(builder, parameters); | ||
break; | ||
|
||
case FORCE_PARALLEL_DML: | ||
builder.append("FORCE PARALLEL DML"); | ||
appendParamaters(builder, parameters); | ||
break; | ||
|
||
case ENABLE_PARALLEL_DDL: | ||
builder.append("ENABLE PARALLEL DDL"); | ||
appendParamaters(builder, parameters); | ||
break; | ||
|
||
case DISABLE_PARALLEL_DDL: | ||
builder.append("DISABLE PARALLEL DDL"); | ||
break; | ||
|
||
case FORCE_PARALLEL_DDL: | ||
builder.append("FORCE PARALLEL DDL"); | ||
appendParamaters(builder, parameters); | ||
break; | ||
|
||
case ENABLE_PARALLEL_QUERY: | ||
builder.append("ENABLE PARALLEL QUERY"); | ||
appendParamaters(builder, parameters); | ||
break; | ||
|
||
case DISABLE_PARALLEL_QUERY: | ||
builder.append("DISABLE PARALLEL QUERY"); | ||
break; | ||
|
||
case FORCE_PARALLEL_QUERY: | ||
builder.append("FORCE PARALLEL QUERY"); | ||
appendParamaters(builder, parameters); | ||
break; | ||
|
||
case ENABLE_RESUMABLE: | ||
builder.append("ENABLE RESUMABLE"); | ||
appendParamaters(builder, parameters); | ||
break; | ||
|
||
case DISABLE_RESUMABLE: | ||
builder.append("DISABLE RESUMABLE"); | ||
break; | ||
|
||
case SET: | ||
builder.append("SET"); | ||
appendParamaters(builder, parameters); | ||
break; | ||
default: | ||
// not going to happen | ||
|
||
} | ||
return builder.toString(); | ||
} | ||
|
||
@Override | ||
public void accept(StatementVisitor statementVisitor) { | ||
statementVisitor.visit(this); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/net/sf/jsqlparser/statement/alter/AlterSessionOperation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*- | ||
* #%L | ||
* JSQLParser library | ||
* %% | ||
* Copyright (C) 2004 - 2021 JSQLParser | ||
* %% | ||
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0 | ||
* #L% | ||
*/ | ||
/* | ||
* Copyright (C) 2021 JSQLParser. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under the terms of the | ||
* GNU Lesser General Public License as published by the Free Software Foundation; either version | ||
* 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along with this library; | ||
* if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
* 02110-1301 USA | ||
*/ | ||
|
||
package net.sf.jsqlparser.statement.alter; | ||
|
||
/** | ||
* | ||
* @author are | ||
*/ | ||
public enum AlterSessionOperation { | ||
ADVISE_COMMIT | ||
, ADVISE_ROLLBACK | ||
, ADVISE_NOTHING | ||
, CLOSE_DATABASE_LINK | ||
, ENABLE_COMMIT_IN_PROCEDURE | ||
, DISABLE_COMMIT_IN_PROCEDURE | ||
, ENABLE_GUARD | ||
, DISABLE_GUARD | ||
, ENABLE_PARALLEL_DML | ||
, DISABLE_PARALLEL_DML | ||
, FORCE_PARALLEL_DML | ||
, ENABLE_PARALLEL_DDL | ||
, DISABLE_PARALLEL_DDL | ||
, FORCE_PARALLEL_DDL | ||
, ENABLE_PARALLEL_QUERY | ||
, DISABLE_PARALLEL_QUERY | ||
, FORCE_PARALLEL_QUERY | ||
, ENABLE_RESUMABLE | ||
, DISABLE_RESUMABLE | ||
, SET | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/net/sf/jsqlparser/util/deparser/AlterSessionDeParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/*- | ||
* #%L | ||
* JSQLParser library | ||
* %% | ||
* Copyright (C) 2004 - 2019 JSQLParser | ||
* %% | ||
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0 | ||
* #L% | ||
*/ | ||
package net.sf.jsqlparser.util.deparser; | ||
|
||
import net.sf.jsqlparser.statement.alter.AlterSession; | ||
|
||
public class AlterSessionDeParser extends AbstractDeParser<AlterSession> { | ||
|
||
public AlterSessionDeParser(StringBuilder buffer) { | ||
super(buffer); | ||
} | ||
|
||
@Override | ||
public void deParse(AlterSession alterSession) { | ||
buffer.append(alterSession.toString()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/net/sf/jsqlparser/util/validation/validator/AlterSessionValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/*- | ||
* #%L | ||
* JSQLParser library | ||
* %% | ||
* Copyright (C) 2004 - 2020 JSQLParser | ||
* %% | ||
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0 | ||
* #L% | ||
*/ | ||
package net.sf.jsqlparser.util.validation.validator; | ||
|
||
import net.sf.jsqlparser.statement.alter.AlterSession; | ||
|
||
/** | ||
* @author gitmotte | ||
*/ | ||
public class AlterSessionValidator extends AbstractValidator<AlterSession> { | ||
@Override | ||
public void validate(AlterSession statement) { | ||
//@todo: implement this method | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.