Skip to content

Commit 536d15e

Browse files
committed
Use "@default" for currentSchema and currentCatalog (when it could be null).
The problematic case that this change addresses is: Imagine the connection is "fresh", and the connection-string defines something like schema=S1 So the current schema of the connection would be S1, but currentSchema is still null. So we prepare a statement for S1, but the cache key contains null. If we then invoke setSchema(null) the connection is in schema-less state. Preparing the same statement would retrieve the one from above, which is prepared for S1. --- The FIX for this case, use "@default" instead of null, such that the cache key isn't problematic for the above case.
1 parent b3077ee commit 536d15e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ebean-datasource/src/main/java/io/ebean/datasource/pool/PooledConnection.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ final class PooledConnection extends ConnectionDelegator {
124124
this.originalCatalog = pool.catalog();
125125
this.initialisedSchema = originalSchema != null;
126126
this.initialisedCatalog = originalCatalog != null;
127+
this.currentSchema = originalSchema != null ? originalSchema : "@default";
128+
this.currentCatalog = originalCatalog != null ? originalCatalog : "@default";
127129
this.pstmtCache = new PstmtCache(pool.pstmtCacheSize());
128130
this.maxStackTrace = pool.maxStackTraceSize();
129131
this.creationTime = System.currentTimeMillis();

0 commit comments

Comments
 (0)