Skip to content

Commit 146939b

Browse files
authored
Merge pull request #1085 from daneshk/main
Change the compiler validation to support disabling PS cache
2 parents b95a9d8 + e1c9191 commit 146939b

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

Diff for: ballerina/Dependencies.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ dependencies = [
143143
[[package]]
144144
org = "ballerina"
145145
name = "sql"
146-
version = "1.14.0"
146+
version = "1.14.1"
147147
dependencies = [
148148
{org = "ballerina", name = "io"},
149149
{org = "ballerina", name = "jballerina.java"},

Diff for: compiler-plugin-tests/src/test/java/io/ballerina/stdlib/postgresql/compiler/CompilerPluginTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ public void testPostgreSQLOptionRecord() {
109109

110110
for (int i = 0; i < diagnosticErrorStream.size(); i++) {
111111
Diagnostic diagnostic = diagnosticErrorStream.get(i);
112-
if (i <= 7) {
113-
Assert.assertEquals(diagnostic.diagnosticInfo().code(), POSTGRESQL_101.getCode());
114-
Assert.assertEquals(diagnostic.diagnosticInfo().messageFormat(),
115-
POSTGRESQL_101.getMessage());
116-
} else {
112+
if (8 <= i && i <= 10) {
117113
Assert.assertEquals(diagnostic.diagnosticInfo().code(), POSTGRESQL_102.getCode());
118114
Assert.assertEquals(diagnostic.diagnosticInfo().messageFormat(),
119115
POSTGRESQL_102.getMessage());
116+
} else {
117+
Assert.assertEquals(diagnostic.diagnosticInfo().code(), POSTGRESQL_101.getCode());
118+
Assert.assertEquals(diagnostic.diagnosticInfo().messageFormat(),
119+
POSTGRESQL_101.getMessage());
120120
}
121121
}
122122
}

Diff for: compiler-plugin/src/main/java/io/ballerina/stdlib/postgresql/compiler/Utils.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,6 @@ public static void validateOptions(SyntaxNodeAnalysisContext ctx, String name, E
153153
case Constants.Options.ROW_FETCH_SIZE:
154154
case Constants.Options.CACHED_METADATA_FIELD_COUNT:
155155
case Constants.Options.CACHED_METADATA_FIELD_SIZE:
156-
case Constants.Options.PREPARED_STATEMENT_THRESHOLD:
157-
case Constants.Options.PREPARED_STATEMENT_CACHE_QUERIES:
158-
case Constants.Options.PREPARED_STATEMENT_CACHE_SIZE_MIB:
159156
int sizeVal = Integer.parseInt(getTerminalNodeValue(valueNode, "1"));
160157
if (sizeVal <= 0) {
161158
DiagnosticInfo diagnosticInfo = new DiagnosticInfo(POSTGRESQL_102.getCode(),
@@ -164,6 +161,17 @@ public static void validateOptions(SyntaxNodeAnalysisContext ctx, String name, E
164161
DiagnosticFactory.createDiagnostic(diagnosticInfo, valueNode.location()));
165162
}
166163
break;
164+
case Constants.Options.PREPARED_STATEMENT_THRESHOLD:
165+
case Constants.Options.PREPARED_STATEMENT_CACHE_QUERIES:
166+
case Constants.Options.PREPARED_STATEMENT_CACHE_SIZE_MIB:
167+
int thresholdVal = Integer.parseInt(getTerminalNodeValue(valueNode, "0"));
168+
if (thresholdVal < 0) {
169+
DiagnosticInfo diagnosticInfo = new DiagnosticInfo(POSTGRESQL_101.getCode(),
170+
POSTGRESQL_101.getMessage(), POSTGRESQL_101.getSeverity());
171+
ctx.reportDiagnostic(
172+
DiagnosticFactory.createDiagnostic(diagnosticInfo, valueNode.location()));
173+
}
174+
break;
167175
default:
168176
// Can ignore all the other fields
169177
}

0 commit comments

Comments
 (0)