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

Rowid variable arrays #2401

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ host_variable_array_times: OCCURS host_variable_array_size TIMES?;
host_variable_array_size: T=dbs_integerliteral_expanded {validateIntegerRange($T.start, $T.text, 1, 32767);};

sql_host_variables: result_set_locator_variable | lob_xml_host_variables | lob_host_variables_arrays | lob_host_variables
| tableLocators_variable | rowid_host_variables;
| tableLocators_variable | rowid_host_variables_arrays | rowid_host_variables;

result_set_locator_variable: dbs_level_01 entry_name host_variable_usage result_set_locator;

Expand All @@ -55,6 +55,8 @@ lob_host_variables_arrays: dbs_host_var_levels_arrays entry_name host_variable_u

rowid_host_variables: dbs_host_var_levels entry_name host_variable_usage ROWID;

rowid_host_variables_arrays: dbs_host_var_levels_arrays entry_name host_variable_usage ROWID occurs_clause;

dbs_host_var_levels: dbs_level_01 | T=dbs_integer {validateIntegerRange($T.text, 2, 48);};

dbs_host_var_levels_arrays: T=dbs_integer {validateIntegerRange($T.text, 2, 48);};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ public List<Node> visitRowid_host_variables(Db2SqlParser.Rowid_host_variablesCon
return createHostVariableDefinitionNode(ctx, ctx.dbs_host_var_levels(), ctx.entry_name());
}

@Override
public List<Node> visitRowid_host_variables_arrays(Db2SqlParser.Rowid_host_variables_arraysContext ctx) {
return createHostVariableDefinitionNode(ctx, ctx.dbs_host_var_levels_arrays(), ctx.entry_name());
}

@Override
public List<Node> visitLob_xml_host_variables(Db2SqlParser.Lob_xml_host_variablesContext ctx) {
List<Node> hostVariableDefinitionNode = createHostVariableDefinitionNode(ctx, ctx.dbs_host_var_levels(), ctx.entry_name());
Expand Down
3 changes: 2 additions & 1 deletion server/engine/src/main/resources/LanguageKeywords_sql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ CLOB-LOCATOR=
DBCLOB-LOCATOR=
BLOB-FILE=
CLOB-FILE=
DBCLOB-FILE=
DBCLOB-FILE=
OCCURS=
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,36 @@ public class TestSqlHostVariable {
+ " 52 {$*VAR1|1} USAGE IS SQL TYPE IS ROWID.\n"
+ " PROCEDURE DIVISION.\n";


public static final String ROWID_ARRAYS_TEXT1 =
" Identification Division.\n"
+ " Program-Id. 'TEST1'.\n"
+ " Data Division.\n"
+ " Working-Storage Section.\n"
+ " 01 {$*VAR}.\n"
+ " 02 {$*VAR1} USAGE IS SQL TYPE IS ROWID OCCURS 10 TIMES.\n"
+ " PROCEDURE DIVISION.\n";

public static final String ROWID_ARRAYS_TEXT2 =
" Identification Division.\n"
+ " Program-Id. 'TEST1'.\n"
+ " Data Division.\n"
+ " Working-Storage Section.\n"
+ " 01 {$*VAR}.\n"
+ " 52 {$*VAR1|1} USAGE IS SQL TYPE IS ROWID OCCURS 10 TIMES.\n"
+ " PROCEDURE DIVISION.\n";

public static final String ROWID_ARRAYS_TEXT3 =
" Identification Division.\n"
+ " Program-Id. 'TEST1'.\n"
+ " Data Division.\n"
+ " Working-Storage Section.\n"
+ " 01 {$*GREET}.\n"
+ " 40 {$*VAR} USAGE IS SQL TYPE IS ROWID OCCURS 100000 {TIMES|1}.\n"
+ " PROCEDURE DIVISION.\n"
+ " DISPLAY {$VAR}(1).";


@Test
void testSupportForResultSetLocator() {
UseCaseEngine.runTest(TEXT, ImmutableList.of(), ImmutableMap.of());
Expand Down Expand Up @@ -414,6 +444,37 @@ void testRowidVariables_levelError() {
));
}

@Test
void testRowidVariablesArrays() {
UseCaseEngine.runTest(ROWID_ARRAYS_TEXT1, ImmutableList.of(), ImmutableMap.of());
}

@Test
void testRowidVariablesArrays_levelError() {
UseCaseEngine.runTest(ROWID_ARRAYS_TEXT2, ImmutableList.of(), ImmutableMap.of(
"1",
new Diagnostic(
new Range(),
"Allowed range is 2 to 48",
DiagnosticSeverity.Error,
ErrorSource.PARSING.getText()
)
));
}

@Test
void testRowidVariablesArrays_rangeError() {
UseCaseEngine.runTest(ROWID_ARRAYS_TEXT3, ImmutableList.of(), ImmutableMap.of(
"1",
new Diagnostic(
new Range(),
"Allowed range is 1 to 32767",
DiagnosticSeverity.Error,
ErrorSource.PARSING.getText()
)
));
}

@Test
void testLobVariablesArrays() {
UseCaseEngine.runTest(LOD_VARS_ARRAYS_TEXT1, ImmutableList.of(), ImmutableMap.of());
Expand Down
Loading