Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbeaver/pro#2861 Add block bound strings for db2 #33960

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@
import org.jkiss.dbeaver.model.exec.jdbc.JDBCDatabaseMetaData;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource;
import org.jkiss.dbeaver.model.sql.SQLConstants;

public class DB2ISQLDialect extends GenericSQLDialect {
private static final String[][] BEGIN_END_BLOCK = new String[][]{
{SQLConstants.BLOCK_BEGIN, SQLConstants.BLOCK_END},
{SQLConstants.KEYWORD_CASE, SQLConstants.BLOCK_END}
};

public DB2ISQLDialect() {
super("IBM DB2 i", "db2_i");
Expand All @@ -38,6 +43,11 @@ public void initDriverSettings(JDBCSession session, JDBCDataSource dataSource, J
turnFunctionIntoKeyword("TRUNCATE");
}

@Override
public String[][] getBlockBoundStrings() {
return BEGIN_END_BLOCK;
}

@Override
public boolean supportsAliasInSelect() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@
import org.jkiss.dbeaver.model.exec.jdbc.JDBCDatabaseMetaData;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource;
import org.jkiss.dbeaver.model.sql.SQLConstants;

public class DB2ZOSSQLDialect extends GenericSQLDialect {
private static final String[][] BEGIN_END_BLOCK = new String[][]{
{SQLConstants.BLOCK_BEGIN, SQLConstants.BLOCK_END},
{SQLConstants.KEYWORD_CASE, SQLConstants.BLOCK_END}
};

public DB2ZOSSQLDialect() {
super("DB2 for z/OS", "db2_zos");
Expand All @@ -37,6 +42,11 @@ public void initDriverSettings(JDBCSession session, JDBCDataSource dataSource, J
turnFunctionIntoKeyword("TRUNCATE");
}

@Override
public String[][] getBlockBoundStrings() {
return BEGIN_END_BLOCK;
}

@Override
public boolean supportsAliasInSelect() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.jkiss.dbeaver.model.impl.data.formatters.BinaryFormatterHexString;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCSQLDialect;
import org.jkiss.dbeaver.model.sql.SQLConstants;
import org.jkiss.dbeaver.model.sql.parser.rules.SQLMultiWordRule;
import org.jkiss.dbeaver.model.sql.parser.tokens.SQLTokenType;
import org.jkiss.dbeaver.model.struct.rdb.DBSProcedure;
Expand All @@ -48,7 +49,7 @@

/**
* DB2 SQL dialect
*
*
* @author Denis Forveille
*
*/
Expand All @@ -59,6 +60,11 @@ public class DB2SQLDialect extends JDBCSQLDialect implements TPRuleProvider {
public static final String[] EXEC_KEYWORDS = new String[]{"CALL"};

private static final boolean LOAD_ROUTINES_FROM_SYSCAT = false;
private static final String[][] BEGIN_END_BLOCK = new String[][]{
{SQLConstants.BLOCK_BEGIN, SQLConstants.BLOCK_END},
{SQLConstants.KEYWORD_CASE, SQLConstants.BLOCK_END}
};


public DB2SQLDialect() {
super("Db2 for LUW", "db2_luw");
Expand All @@ -74,8 +80,7 @@ public void initDriverSettings(JDBCSession session, JDBCDataSource dataSource, J

@NotNull
@Override
public MultiValueInsertMode getDefaultMultiValueInsertMode()
{
public MultiValueInsertMode getDefaultMultiValueInsertMode() {
return MultiValueInsertMode.GROUP_ROWS;
}

Expand All @@ -86,11 +91,15 @@ public boolean supportsAliasInSelect() {

@NotNull
@Override
public String[] getExecuteKeywords()
{
public String[] getExecuteKeywords() {
return EXEC_KEYWORDS;
}

@Override
public String[][] getBlockBoundStrings() {
return BEGIN_END_BLOCK;
}

@Override
protected void loadFunctions(JDBCSession session, JDBCDatabaseMetaData metaData, Set<String> allFunctions) throws DBException, SQLException {
if (LOAD_ROUTINES_FROM_SYSCAT) {
Expand Down Expand Up @@ -152,7 +161,7 @@ public DBDBinaryFormatter getNativeBinaryFormatter() {

@Override
public String getScriptDelimiterRedefiner() {
return "--#SET TERMINATOR";
return "--#SET TERMINATOR";
}

@NotNull
Expand Down