Skip to content

Commit

Permalink
Use "@default" for currentSchema and currentCatalog (when it could be…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
rbygrave committed Nov 1, 2024
1 parent b3077ee commit 536d15e
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ final class PooledConnection extends ConnectionDelegator {
this.originalCatalog = pool.catalog();
this.initialisedSchema = originalSchema != null;
this.initialisedCatalog = originalCatalog != null;
this.currentSchema = originalSchema != null ? originalSchema : "@default";
this.currentCatalog = originalCatalog != null ? originalCatalog : "@default";
this.pstmtCache = new PstmtCache(pool.pstmtCacheSize());
this.maxStackTrace = pool.maxStackTraceSize();
this.creationTime = System.currentTimeMillis();
Expand Down

0 comments on commit 536d15e

Please sign in to comment.