Skip to content

Commit

Permalink
Merge pull request #1095 from warunalakshitha/syncMaster
Browse files Browse the repository at this point in the history
Migrate to new Runtime APIs
  • Loading branch information
warunalakshitha authored Nov 16, 2024
2 parents cd7d96a + a7f16e1 commit f6d72ae
Show file tree
Hide file tree
Showing 19 changed files with 94 additions and 50 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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ subprojects {
ballerinaStdLibs "io.ballerina.stdlib:auth-ballerina:${stdlibAuthVersion}"
ballerinaStdLibs "io.ballerina.stdlib:jwt-ballerina:${stdlibJwtVersion}"
ballerinaStdLibs "io.ballerina.stdlib:oauth2-ballerina:${stdlibOAuth2Version}"
ballerinaStdLibs "io.ballerina.lib:data.jsondata-ballerina:${stdlibDataJsonDataVersion}"
ballerinaStdLibs "io.ballerina.stdlib:url-ballerina:${stdlibUrlVersion}"
ballerinaStdLibs "io.ballerina.stdlib:http-ballerina:${stdlibHttpVersion}"
ballerinaStdLibs "io.ballerina.stdlib:observe-ballerina:${observeVersion}"
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
47 changes: 24 additions & 23 deletions 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 All @@ -11,52 +11,53 @@ researchgateReleaseVersion=2.8.0
testngVersion=7.6.1
ballerinaGradlePluginVersion=2.0.1

ballerinaLangVersion=2201.10.0-20241025-103700-5c9e6a27
ballerinaLangVersion=2201.11.0-20241112-214900-6b80ab87


# Direct Dependencies
# Level 01
stdlibIoVersion=1.6.2-20240928-084100-656404f
stdlibTimeVersion=2.5.1-20240930-120200-e59222b
stdlibIoVersion=1.6.2-20241112-233100-995cf5f
stdlibTimeVersion=2.6.0-20241113-073800-201b904

# Level 02
stdlibLogVersion=2.10.1-20240930-154200-5ab2aa4
stdlibOsVersion=1.8.1-20241001-120600-dd1626e
stdlibLogVersion=2.10.1-20241113-120000-4577868
stdlibOsVersion=1.8.1-20241113-122000-cca973b

# Level 03
stdlibFileVersion=1.10.1-20241007-160900-03f7b64
stdlibFileVersion=1.10.1-20241113-151700-e1a2e38

# Level 07
stdlibSqlVersion=1.14.2-20241107-114900-a6efcf1
stdlibSqlVersion=1.15.0-20241116-124800-0bc6a40

# Ballerinax Observer
observeVersion=1.3.1-20241007-161000-645452d
observeInternalVersion=1.3.1-20241015-172900-cdc3cb3
observeVersion=1.4.0-20241113-092000-b83ae74
observeInternalVersion=1.3.1-20241113-101700-265054d

# Transitive Dependencies
# Level 01
stdlibUrlVersion=2.4.1-20240930-120200-b7fb9e1
stdlibUrlVersion=2.4.1-20241113-073900-335ff51

# Level 02
stdlibConstraintVersion=1.5.1-20240930-123400-5ecd396
stdlibCryptoVersion=2.7.3-20240930-132000-5ecc9ab
stdlibTaskVersion=2.5.1-20241002-145700-5bdb843
stdlibConstraintVersion=1.6.0-20241113-090900-d276ad5
stdlibCryptoVersion=2.7.3-20241113-081400-d015a39
stdlibTaskVersion=2.5.1-20241113-123500-f905281

# Level 03
stdlibCacheVersion=3.8.1-20241007-154900-63f4403
stdlibMimeVersion=2.10.1-20241009-141200-8b6c9f0
stdlibUuidVersion=1.8.1-20241009-134600-a05012b
stdlibCacheVersion=3.8.1-20241113-125700-b75a1bf
stdlibMimeVersion=2.10.2-20241113-154200-d953747
stdlibUuidVersion=1.8.1-20241113-154400-443c67b

# Level 04
stdlibAuthVersion=2.12.1-20241010-130800-733dbef
stdlibJwtVersion=2.13.1-20241010-123600-5ea6a94
stdlibOAuth2Version=2.12.1-20241029-084800-d7ba9e5
stdlibAuthVersion=2.12.1-20241113-162300-ded40eb
stdlibJwtVersion=2.13.1-20241113-162400-b59ccfa
stdlibOAuth2Version=2.12.1-20241113-162400-4c6ddfe
stdlibDataJsonDataVersion=0.3.0-20241114-143900-285d739

# Level 05
stdlibHttpVersion=2.13.0-20241029-110700-30ed05b
stdlibHttpVersion=2.13.0-20241114-182900-7e9f66a

# Level 06
stdlibTransactionVersion=1.10.1-20241021-105400-f7e16a8
stdlibTransactionVersion=1.10.1-20241116-112500-189a4e5

# Ballerina extended library
stdlibPostgresqlDriverVersion=1.5.2-20241106-162800-582e4be
stdlibPostgresqlDriverVersion=1.5.2-20241116-204700-582e4be
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 @@ -17,12 +17,12 @@
*/
package io.ballerina.stdlib.postgresql.parameterprocessor;

import io.ballerina.runtime.api.PredefinedTypes;
import io.ballerina.runtime.api.TypeTags;
import io.ballerina.runtime.api.creators.TypeCreator;
import io.ballerina.runtime.api.creators.ValueCreator;
import io.ballerina.runtime.api.types.ArrayType;
import io.ballerina.runtime.api.types.PredefinedTypes;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.utils.XmlUtils;
import io.ballerina.runtime.api.values.BArray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
*/
package io.ballerina.stdlib.postgresql.parameterprocessor;

import io.ballerina.runtime.api.TypeTags;
import io.ballerina.runtime.api.types.ArrayType;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BArray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
*/
package io.ballerina.stdlib.postgresql.utils;

import io.ballerina.runtime.api.PredefinedTypes;
import io.ballerina.runtime.api.TypeTags;
import io.ballerina.runtime.api.creators.TypeCreator;
import io.ballerina.runtime.api.creators.ValueCreator;
import io.ballerina.runtime.api.types.ArrayType;
import io.ballerina.runtime.api.types.Field;
import io.ballerina.runtime.api.types.PredefinedTypes;
import io.ballerina.runtime.api.types.StructureType;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.utils.JsonUtils;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BArray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

package io.ballerina.stdlib.postgresql.utils;

import io.ballerina.runtime.api.TypeTags;
import io.ballerina.runtime.api.creators.ValueCreator;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.api.values.BDecimal;
Expand Down
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 f6d72ae

Please sign in to comment.