Skip to content

Commit

Permalink
Sync with master
Browse files Browse the repository at this point in the history
  • Loading branch information
warunalakshitha committed Nov 16, 2024
2 parents cd7d96a + f2a0adc commit c01a890
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ gradle-app.setting
.project
.settings
.vscode
.cache

# log files
**/test_log.conf
Expand Down
2 changes: 1 addition & 1 deletion ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ graalvmCompatible = true
groupId = "io.ballerina.stdlib"
artifactId = "postgresql-native"
version = "1.13.2"
path = "../native/build/libs/postgresql-native-1.13.2-SNAPSHOT.jar"
path = "../native/build/libs/postgresql-native-1.13.2.jar"

[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
Expand Down
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ id = "postgresql-compiler-plugin"
class = "io.ballerina.stdlib.postgresql.compiler.PostgreSQLCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/postgresql-compiler-plugin-1.13.2-SNAPSHOT.jar"
path = "../compiler-plugin/build/libs/postgresql-compiler-plugin-1.13.2.jar"
4 changes: 3 additions & 1 deletion ballerina/client.bal
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ type ClientConfiguration record {|
# + cachedMetadataFieldSize - The maximum size (in megabytes) of fields to be cached per connection.
# A value of 0 disables the cache
# + preparedStatementThreshold - The number of `PreparedStatement` executions required before switching
# over to use server-side prepared statements
# over to use server-side prepared statements. A value of 0 disables the cache.
# + preparedStatementCacheQueries - The number of queries that are cached in each connection
# A value of 0 for preparedStatementThreshold disables the cache.
# + preparedStatementCacheSize - The maximum size (in mebibytes) of the prepared queries
# A value of 0 for preparedStatementThreshold disables the cache.
# + cancelSignalTimeout - Time (in seconds) by which the cancel command is sent out of band over its own connection
# so that the cancel message itself can get stuck. The default value is 10 seconds
# + keepAliveTcpProbe - Enable or disable the TCP keep-alive probe
Expand Down
8 changes: 4 additions & 4 deletions ballerina/tests/connection-init-test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ function testWithOptions2() returns error? {
rowFetchSize: 0,
cachedMetadataFieldsCount: 0,
cachedMetadataFieldSize: 0,
preparedStatementThreshold: 0,
preparedStatementCacheQueries: 0,
preparedStatementCacheSize: 0,
preparedStatementThreshold: -1,
preparedStatementCacheQueries: -1,
preparedStatementCacheSize: -1,
cancelSignalTimeout: 0,
keepAliveTcpProbe: false
};
Expand Down Expand Up @@ -240,7 +240,7 @@ function testWithConnectionParams3() returns error? {
rowFetchSize: 20,
cachedMetadataFieldsCount: 65536,
cachedMetadataFieldSize: 5,
preparedStatementThreshold: 5,
preparedStatementThreshold: 0,
preparedStatementCacheQueries: 256,
preparedStatementCacheSize: 5,
cancelSignalTimeout: 10,
Expand Down
3 changes: 1 addition & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added

### Changed
- [Allow prepareThreshold, preparedStatementCacheQueries and preparedStatementCacheSizeMiB to pass 0 values](https://github.com/ballerina-platform/ballerina-standard-library/issues/7345)

## [1.10.0] - 2023-06-30

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ public void testPostgreSQLOptionRecord() {

for (int i = 0; i < diagnosticErrorStream.size(); i++) {
Diagnostic diagnostic = diagnosticErrorStream.get(i);
if (i <= 7) {
Assert.assertEquals(diagnostic.diagnosticInfo().code(), POSTGRESQL_101.getCode());
Assert.assertEquals(diagnostic.diagnosticInfo().messageFormat(),
POSTGRESQL_101.getMessage());
} else {
if (8 <= i && i <= 10) {
Assert.assertEquals(diagnostic.diagnosticInfo().code(), POSTGRESQL_102.getCode());
Assert.assertEquals(diagnostic.diagnosticInfo().messageFormat(),
POSTGRESQL_102.getMessage());
} else {
Assert.assertEquals(diagnostic.diagnosticInfo().code(), POSTGRESQL_101.getCode());
Assert.assertEquals(diagnostic.diagnosticInfo().messageFormat(),
POSTGRESQL_101.getMessage());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ public static void validateOptions(SyntaxNodeAnalysisContext ctx, String name, E
case Constants.Options.ROW_FETCH_SIZE:
case Constants.Options.CACHED_METADATA_FIELD_COUNT:
case Constants.Options.CACHED_METADATA_FIELD_SIZE:
case Constants.Options.PREPARED_STATEMENT_THRESHOLD:
case Constants.Options.PREPARED_STATEMENT_CACHE_QUERIES:
case Constants.Options.PREPARED_STATEMENT_CACHE_SIZE_MIB:
int sizeVal = Integer.parseInt(getTerminalNodeValue(valueNode, "1"));
if (sizeVal <= 0) {
DiagnosticInfo diagnosticInfo = new DiagnosticInfo(POSTGRESQL_102.getCode(),
Expand All @@ -164,6 +161,17 @@ public static void validateOptions(SyntaxNodeAnalysisContext ctx, String name, E
DiagnosticFactory.createDiagnostic(diagnosticInfo, valueNode.location()));
}
break;
case Constants.Options.PREPARED_STATEMENT_THRESHOLD:
case Constants.Options.PREPARED_STATEMENT_CACHE_QUERIES:
case Constants.Options.PREPARED_STATEMENT_CACHE_SIZE_MIB:
int thresholdVal = Integer.parseInt(getTerminalNodeValue(valueNode, "0"));
if (thresholdVal < 0) {
DiagnosticInfo diagnosticInfo = new DiagnosticInfo(POSTGRESQL_101.getCode(),
POSTGRESQL_101.getMessage(), POSTGRESQL_101.getSeverity());
ctx.reportDiagnostic(
DiagnosticFactory.createDiagnostic(diagnosticInfo, valueNode.location()));
}
break;
default:
// Can ignore all the other fields
}
Expand Down
4 changes: 3 additions & 1 deletion docs/spec/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ public isolated function init(string host = "localhost", string? username = "pos
# + cachedMetadataFieldSize - The maximum size (in megabytes) of fields to be cached per connection.
# A value of 0 disables the cache
# + preparedStatementThreshold - The number of `PreparedStatement` executions required before switching
# over to use server-side prepared statements
# over to use server-side prepared statements. A value of 0 disables the cache.
# + preparedStatementCacheQueries - The number of queries that are cached in each connection
# A value of 0 for preparedStatementThreshold disables the cache.
# + preparedStatementCacheSize - The maximum size (in mebibytes) of the prepared queries
# A value of 0 for preparedStatementThreshold disables the cache.
# + cancelSignalTimeout - Time (in seconds) by which the cancel command is sent out of band over its own connection
# so that the cancel message itself can get stuck. The default value is 10 seconds
# + keepAliveTcpProbe - Enable or disable the TCP keep-alive probe
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=io.ballerina.stdlib
version=1.13.2-SNAPSHOT
version=1.13.3-SNAPSHOT

puppycrawlCheckstyleVersion=10.12.1
postgreSQLDriverVersion=42.6.1
Expand Down
10 changes: 10 additions & 0 deletions load-tests/execute_operation/results/summary.csv
Original file line number Diff line number Diff line change
Expand Up @@ -719,3 +719,13 @@ HTTP Request,604319,47,18,36,58,957,1,7763,100.00%,1259.5,168.5,188.03,173041696
HTTP Request,638978,44,13,37,95,879,1,10912,100.00%,1331.9,178.2,201.40,1730503235,50,60
HTTP Request,939865,30,11,25,46,587,1,4120,100.00%,1958.5,262.0,112.63,1730589664,50,60
HTTP Request,841090,34,13,28,45,673,1,4822,100.00%,1752.8,234.5,131.20,1730676041,50,60
HTTP Request,914706,31,12,23,34,658,1,5992,100.00%,1906.3,255.0,132.36,1730762540,50,60
HTTP Request,804811,35,12,26,49,720,1,8851,100.00%,1677.4,224.4,152.91,1730848907,50,60
HTTP Request,818821,35,13,26,43,712,0,5243,100.00%,1706.4,228.3,142.12,1730935271,50,60
HTTP Request,825928,34,13,27,43,705,1,4699,100.00%,1721.3,230.3,136.48,1731021710,50,60
HTTP Request,723120,39,15,29,43,829,1,5692,100.00%,1507.1,201.6,165.21,1731108057,50,60
HTTP Request,882548,32,25,39,45,60,0,30032,100.00%,1732.3,232.5,404.33,1731367244,50,60
HTTP Request,775566,37,14,30,46,760,1,6945,100.00%,1616.4,216.2,151.12,1731453704,50,60
HTTP Request,724977,39,15,30,46,800,1,5114,100.00%,1510.8,202.1,159.26,1731540104,50,60
HTTP Request,844589,33,13,25,36,722,1,5957,100.00%,1760.2,235.5,148.59,1731626489,50,60
HTTP Request,994418,28,11,22,33,599,1,5179,100.00%,2072.4,277.3,118.26,1731712872,50,60
10 changes: 10 additions & 0 deletions load-tests/query_operation/results/summary.csv
Original file line number Diff line number Diff line change
Expand Up @@ -709,3 +709,13 @@ HTTP Request,1309063,21,14,49,56,69,1,183,0.00%,2728.2,634.0,17.31,1730417870,50
HTTP Request,1345983,20,13,49,56,68,0,182,0.00%,2805.4,652.0,17.15,1730504162,50,60
HTTP Request,1270238,21,15,50,57,69,1,182,0.00%,2647.3,615.2,17.46,1730590550,50,60
HTTP Request,1254060,21,15,51,57,70,1,161,0.00%,2613.6,607.4,17.73,1730676943,50,60
HTTP Request,1285501,21,14,50,57,70,0,197,0.00%,2678.9,622.6,17.52,1730763431,50,60
HTTP Request,1343609,20,14,49,56,68,0,164,0.00%,2800.3,650.8,17.07,1730849796,50,60
HTTP Request,1284997,21,14,50,57,71,1,203,0.00%,2678.1,622.4,17.75,1730936157,50,60
HTTP Request,1337283,20,14,49,56,69,1,171,0.00%,2786.8,647.7,17.31,1731022592,50,60
HTTP Request,1341917,20,13,49,56,69,1,215,0.00%,2797.0,650.0,17.25,1731108968,50,60
HTTP Request,1282142,21,12,48,54,67,0,30051,0.01%,2520.2,586.3,293.20,1731368126,50,60
HTTP Request,1347792,20,14,49,55,68,0,194,0.00%,2808.8,652.8,17.08,1731454613,50,60
HTTP Request,1346523,20,13,49,56,69,1,188,0.00%,2806.3,652.2,17.33,1731541012,50,60
HTTP Request,1338794,20,14,49,55,68,0,231,0.00%,2790.2,648.4,17.03,1731627400,50,60
HTTP Request,1748895,15,10,42,48,57,0,207,0.00%,3644.5,847.0,14.20,1731713749,50,60
10 changes: 10 additions & 0 deletions load-tests/stored_procedures/results/summary.csv
Original file line number Diff line number Diff line change
Expand Up @@ -716,3 +716,13 @@ HTTP Request,1102450,25,18,56,62,76,1,207,0.00%,2297.7,354.5,19.07,1730418752,50
HTTP Request,1174442,23,16,54,60,73,1,166,0.00%,2447.8,377.7,18.44,1730505046,50,60
HTTP Request,1113027,25,18,54,61,75,1,167,0.00%,2319.7,357.9,18.57,1730591458,50,60
HTTP Request,1064837,26,19,56,63,77,1,201,0.00%,2219.1,342.4,19.28,1730677828,50,60
HTTP Request,1166939,23,17,53,60,73,1,183,0.00%,2431.8,375.2,18.24,1730764324,50,60
HTTP Request,1129571,24,17,55,61,74,1,190,0.00%,2354.2,363.2,18.62,1730850697,50,60
HTTP Request,1135687,24,17,55,62,76,1,211,0.00%,2367.0,365.2,19.13,1730937082,50,60
HTTP Request,1174668,23,16,53,60,74,0,191,0.00%,2448.0,377.7,18.36,1731023469,50,60
HTTP Request,1163586,24,17,53,60,73,1,177,0.00%,2425.0,374.2,18.30,1731109858,50,60
HTTP Request,1129883,24,14,51,58,71,0,30056,0.01%,2238.3,345.9,313.59,1731369050,50,60
HTTP Request,1135626,24,17,54,61,75,1,176,0.00%,2366.9,365.2,18.69,1731455540,50,60
HTTP Request,1158539,24,17,54,61,74,1,202,0.00%,2414.2,372.5,18.42,1731541918,50,60
HTTP Request,1152565,24,17,53,60,73,1,175,0.00%,2402.1,370.6,18.17,1731628334,50,60
HTTP Request,1517031,18,13,45,51,61,0,134,0.00%,3161.6,487.8,15.12,1731714745,50,60
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,22 @@ public static BMap generateOptionsMap(BMap postgresqlOptions) {
if (postgresqlOptions.containsKey(Constants.Options.PREPARE_THRESHOLD)) {
long preparedStatementThreshold = getIntegerValue(postgresqlOptions.
getIntValue(Constants.Options.PREPARE_THRESHOLD));
if (preparedStatementThreshold > 0) {
if (preparedStatementThreshold >= 0) {
options.put(Constants.DatabaseProps.PREPARE_THRESHOLD, preparedStatementThreshold);
}
}
if (postgresqlOptions.containsKey(Constants.Options.PREPARED_STATEMENT_CACHE_QUERIES)) {
long preparedStatementCacheQueries = getIntegerValue(postgresqlOptions
.getIntValue(Constants.Options.PREPARED_STATEMENT_CACHE_QUERIES));
if (preparedStatementCacheQueries > 0) {
if (preparedStatementCacheQueries >= 0) {
options.put(Constants.DatabaseProps.PREPARED_STATEMENT_CACHE_QUERIES,
preparedStatementCacheQueries);
}
}
if (postgresqlOptions.containsKey(Constants.Options.PREPARED_STATEMENT_CACHE_QUERIES)) {
long preparedStatementCacheSize = getIntegerValue(postgresqlOptions
.getIntValue(Constants.Options.PREPARED_STATEMENT_CACHE_SIZE_MIB));
if (preparedStatementCacheSize > 0) {
if (preparedStatementCacheSize >= 0) {
options.put(Constants.DatabaseProps.PREPARED_STATEMENT_CACHE_SIZE_MIB, preparedStatementCacheSize);
}
}
Expand Down

0 comments on commit c01a890

Please sign in to comment.