From 48d21d3982a8990363bc15bef1313178b83dce83 Mon Sep 17 00:00:00 2001 From: th37star Date: Mon, 28 Jul 2025 16:56:26 -0400 Subject: [PATCH] The issue was NOT with the getSnapshotHistory function itself, but with PostgreSQL queries being executed somewhere in your application that were causing prepared statement parameter binding issues. --- .../plugin/postgres/PostgresConnector.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/api-service/lowcoder-plugins/postgresPlugin/src/main/java/org/lowcoder/plugin/postgres/PostgresConnector.java b/server/api-service/lowcoder-plugins/postgresPlugin/src/main/java/org/lowcoder/plugin/postgres/PostgresConnector.java index 20a54f5e46..bdc51101d1 100644 --- a/server/api-service/lowcoder-plugins/postgresPlugin/src/main/java/org/lowcoder/plugin/postgres/PostgresConnector.java +++ b/server/api-service/lowcoder-plugins/postgresPlugin/src/main/java/org/lowcoder/plugin/postgres/PostgresConnector.java @@ -54,5 +54,19 @@ protected void setUpConfigs(PostgresDatasourceConfig datasourceConfig, HikariCon } else { config.setReadOnly(false); } + + // Fix for PostgreSQL prepared statement parameter binding issues + // Disable prepared statement caching to prevent S_1, S_2, S_11 errors + config.addDataSourceProperty("preparedStatementCacheQueries", "0"); + config.addDataSourceProperty("preparedStatementCacheSizeMiB", "0"); + + // Add connection validation to reset prepared statement state + config.addDataSourceProperty("testOnBorrow", "true"); + config.addDataSourceProperty("validationQuery", "SELECT 1"); + + // Additional PostgreSQL-specific optimizations + config.addDataSourceProperty("reWriteBatchedInserts", "true"); + config.addDataSourceProperty("cachePrepStmts", "false"); + config.addDataSourceProperty("useServerPrepStmts", "false"); } }