Repository: GoogleCloudPlatform/pgadapter
Pull request #1163 (2023-10-30 15:46:57)

build(deps): bump github.com/docker/docker from 24.0.6+incompatible to 24.0.7+incompatible in /samples/golang/gorm
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 24.0.6+incompatible to 24.0.7+incompatible.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/docker/docker/releases">github.com/docker/docker's releases</a>.</em></p>
<blockquote>
<h2>v24.0.7</h2>
<h2>24.0.7</h2>
<p>For a full list of pull requests and changes in this release, refer to the relevant GitHub milestones:</p>
<ul>
<li><a href="https://github.com/docker/cli/issues?q=is%3Aclosed+milestone%3A24.0.7">docker/cli, 24.0.7 milestone</a></li>
<li><a href="https://github.com/moby/moby/issues?q=is%3Aclosed+milestone%3A24.0.7">moby/moby, 24.0.7 milestone</a></li>
</ul>
<h3>Bug fixes and enhancements</h3>
<ul>
<li>Write overlay2 layer metadata atomically. <a href="https://redirect.github.com/moby/moby/pull/46703">moby/moby#46703</a></li>
<li>Fix &quot;Rootful-in-Rootless&quot; Docker-in-Docker on systemd version 250 and later. <a href="https://redirect.github.com/moby/moby/pull/46626">moby/moby#46626</a></li>
<li>Fix <code>dockerd-rootless-setuptools.sh</code> when username contains a backslash. <a href="https://redirect.github.com/moby/moby/pull/46407">moby/moby#46407</a></li>
<li>Fix a bug that would prevent network sandboxes to be fully deleted when stopping containers with no network attachments and when <code>dockerd --bridge=none</code> is used. <a href="https://redirect.github.com/moby/moby/pull/46702">moby/moby#46702</a></li>
<li>Fix a bug where cancelling an API request could interrupt container restart. <a href="https://redirect.github.com/moby/moby/pull/46697">moby/moby#46697</a></li>
<li>Fix an issue where containers would fail to start when providing <code>--ip-range</code> with a range larger than the subnet. <a href="https://redirect.github.com/docker/for-mac/issues/6870">docker/for-mac#6870</a></li>
<li>Fix data corruption with zstd output. <a href="https://redirect.github.com/moby/moby/pull/46709">moby/moby#46709</a></li>
<li>Fix the conditions under which the container's MAC address is applied. <a href="https://redirect.github.com/moby/moby/pull/46478">moby/moby#46478</a></li>
<li>Improve the performance of the stats collector. <a href="https://redirect.github.com/moby/moby/pull/46448">moby/moby#46448</a></li>
<li>Fix an issue with source policy rules ending up in the wrong order. <a href="https://redirect.github.com/moby/moby/pull/46441">moby/moby#46441</a></li>
</ul>
<h3>Packaging updates</h3>
<ul>
<li>Add support for Fedora 39 and Ubuntu 23.10. <a href="https://redirect.github.com/docker/docker-ce-packaging/pull/940">docker/docker-ce-packaging#940</a>, <a href="https://redirect.github.com/docker/docker-ce-packaging/pull/955">docker/docker-ce-packaging#955</a></li>
<li>Fix <code>docker.socket</code> not getting disabled when uninstalling the <code>docker-ce</code> RPM package. <a href="https://redirect.github.com/docker/docker-ce-packaging/pull/852">docker/docker-ce-packaging#852</a></li>
<li>Upgrade Go to <code>go1.20.10</code>. <a href="https://redirect.github.com/docker/docker-ce-packaging/pull/951">docker/docker-ce-packaging#951</a></li>
<li>Upgrade containerd to <code>v1.7.6</code> (static binaries only). <a href="https://redirect.github.com/moby/moby/pull/46103">moby/moby#46103</a></li>
<li>Upgrade the <code>containerd.io</code> package to <a href="https://github.com/containerd/containerd/releases/tag/v1.6.24"><code>v1.6.24</code></a>.</li>
</ul>
<h3>Security</h3>
<ul>
<li>Deny containers access to <code>/sys/devices/virtual/powercap</code> by default. This change hardens against <a href="https://scout.docker.com/v/CVE-2020-8694">CVE-2020-8694</a>, <a href="https://scout.docker.com/v/CVE-2020-8695">CVE-2020-8695</a>, and <a href="https://scout.docker.com/v/CVE-2020-12912">CVE-2020-12912</a>, and an attack known as <a href="https://platypusattack.com/">the PLATYPUS attack</a>. For more details, see <a href="https://github.com/moby/moby/security/advisories/GHSA-jq35-85cj-fj4p">advisory</a>, <a href="https://github.com/moby/moby/commit/c9ccbfad11a60e703e91b6cca4f48927828c7e35">commit</a>.</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/moby/moby/commit/311b9ff0aa93aa55880e1e5f8871c4fb69583426"><code>311b9ff</code></a> Merge pull request <a href="https://redirect.github.com/docker/docker/issues/46697">#46697</a> from thaJeztah/24.0_backport_restart_nocancel</li>
<li><a href="https://github.com/moby/moby/commit/af608045eef0b87f31a24d21fb7af80de76134aa"><code>af60804</code></a> Merge pull request from GHSA-jq35-85cj-fj4p</li>
<li><a href="https://github.com/moby/moby/commit/3cf363e1ee33fe00dbedfdb7d6caf299990d5568"><code>3cf363e</code></a> Merge pull request <a href="https://redirect.github.com/docker/docker/issues/46709">#46709</a> from thaJeztah/24.0_backport_bump_compress</li>
<li><a href="https://github.com/moby/moby/commit/05d7386665793b7f8398eb80b4e85adff5486035"><code>05d7386</code></a> daemon: daemon.containerRestart: don't cancel restart on context cancel</li>
<li><a href="https://github.com/moby/moby/commit/649c9440f28c7334ee5c9f17889448a81dcc8729"><code>649c944</code></a> Merge pull request <a href="https://redirect.github.com/docker/docker/issues/46703">#46703</a> from thaJeztah/24.0_backport_atomic-layer-data-write</li>
<li><a href="https://github.com/moby/moby/commit/9b20b1a5fe0919a79cc15f6a3f331f2cdae0a37a"><code>9b20b1a</code></a> Merge pull request <a href="https://redirect.github.com/docker/docker/issues/46702">#46702</a> from thaJeztah/24.0_backport_releaseNetwork_Network...</li>
<li><a href="https://github.com/moby/moby/commit/dd37b0b960ec4d3da0ca2efe78fa47484d4c6380"><code>dd37b0b</code></a> vendor: github.com/klauspost/compress v1.17.2</li>
<li><a href="https://github.com/moby/moby/commit/7058c0d24da8ac9267e52224b6a3beaa24ce5e9f"><code>7058c0d</code></a> vendor: github.com/klauspost/compress v1.16.5</li>
<li><a href="https://github.com/moby/moby/commit/57bd38858262922b86ceea37770536ff535fa2af"><code>57bd388</code></a> daemon: overlay2: Write layer metadata atomically</li>
<li><a href="https://github.com/moby/moby/commit/05d95fd5038a8a56ff69294a3bdd33b2d2769ba3"><code>05d95fd</code></a> daemon: release sandbox even when NetworkDisabled</li>
<li>Additional commits viewable in <a href="https://github.com/docker/docker/compare/v24.0.6...v24.0.7">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/docker/docker&package-manager=go_modules&previous-version=24.0.6+incompatible&new-version=24.0.7+incompatible)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/GoogleCloudPlatform/pgadapter/network/alerts).

</details>


Patch:
diff --git a/benchmarks/latency-comparison/golang/go.mod b/benchmarks/latency-comparison/golang/go.mod
index 54605323..6557ec23 100644
--- a/benchmarks/latency-comparison/golang/go.mod
+++ b/benchmarks/latency-comparison/golang/go.mod
@@ -4,7 +4,7 @@ go 1.19
 
 require (
 	cloud.google.com/go/spanner v1.45.1
-	github.com/docker/docker v23.0.7+incompatible
+	github.com/docker/docker v24.0.7+incompatible
 	github.com/jackc/pgx/v4 v4.18.1
 	github.com/jackc/pgx/v5 v5.3.1
 	github.com/montanaflynn/stats v0.7.0
diff --git a/benchmarks/latency-comparison/golang/go.sum b/benchmarks/latency-comparison/golang/go.sum
index beb69a95..3b9ce8c6 100644
--- a/benchmarks/latency-comparison/golang/go.sum
+++ b/benchmarks/latency-comparison/golang/go.sum
@@ -9,6 +9,7 @@ cloud.google.com/go/iam v0.13.0 h1:+CmB+K0J/33d0zSQ9SlFWUeCCEn5XJA0ZMZ3pHE9u8k=
 cloud.google.com/go/longrunning v0.4.1 h1:v+yFJOfKC3yZdY6ZUI933pIYdhyhV8S3NpWrXWmg7jM=
 cloud.google.com/go/spanner v1.45.1 h1:vHFqBMuPdTCwA8b9+IyQbGppQoqx7xJfcSa81d7gtAk=
 cloud.google.com/go/spanner v1.45.1/go.mod h1:FIws5LowYz8YAE1J8fOS7DJup8ff7xJeetWEo5REA2M=
+github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8 h1:V8krnnfGj4pV65YLUm3C0/8bl7V5Nry2Pwvy3ru/wLc=
 github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
 github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
@@ -37,7 +38,6 @@ github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMe
 github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
 github.com/containerd/containerd v1.6.19 h1:F0qgQPrG0P2JPgwpxWxYavrVeXAG0ezUIB9Z/4FTUAU=
 github.com/containerd/containerd v1.6.19/go.mod h1:HZCDMn4v/Xl2579/MvtOC2M206i+JJ6VxFWU/NetrGY=
-github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg=
 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
 github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
 github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
@@ -52,8 +52,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
 github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
-github.com/docker/docker v23.0.7+incompatible h1:6RD6ZfR9LYacFt90L41R/6/SyO+RZ1zWU7+bt6tdRNk=
-github.com/docker/docker v23.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
+github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM=
+github.com/docker/docker v24.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
 github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
 github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
 github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
diff --git a/pom.xml b/pom.xml
index 673b01d6..f6c57de3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -139,7 +139,7 @@
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-text</artifactId>
-      <version>1.10.0</version>
+      <version>1.11.0</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
diff --git a/samples/golang/gorm/go.mod b/samples/golang/gorm/go.mod
index 17f2203c..432f392a 100644
--- a/samples/golang/gorm/go.mod
+++ b/samples/golang/gorm/go.mod
@@ -25,7 +25,7 @@ require (
 	github.com/containerd/log v0.1.0 // indirect
 	github.com/cpuguy83/dockercfg v0.3.1 // indirect
 	github.com/docker/distribution v2.8.2+incompatible // indirect
-	github.com/docker/docker v24.0.6+incompatible // indirect
+	github.com/docker/docker v24.0.7+incompatible // indirect
 	github.com/docker/go-connections v0.4.0 // indirect
 	github.com/docker/go-units v0.5.0 // indirect
 	github.com/go-ole/go-ole v1.2.6 // indirect
diff --git a/samples/golang/gorm/go.sum b/samples/golang/gorm/go.sum
index b7c5a495..fc3d2f15 100644
--- a/samples/golang/gorm/go.sum
+++ b/samples/golang/gorm/go.sum
@@ -36,8 +36,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
 github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
-github.com/docker/docker v24.0.6+incompatible h1:hceabKCtUgDqPu+qm0NgsaXf28Ljf4/pWFL7xjWWDgE=
-github.com/docker/docker v24.0.6+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
+github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM=
+github.com/docker/docker v24.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
 github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
 github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
 github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
diff --git a/samples/golang/pgx/go.mod b/samples/golang/pgx/go.mod
index be91423b..ba6259d7 100644
--- a/samples/golang/pgx/go.mod
+++ b/samples/golang/pgx/go.mod
@@ -17,7 +17,7 @@ require (
 	github.com/containerd/containerd v1.7.3 // indirect
 	github.com/cpuguy83/dockercfg v0.3.1 // indirect
 	github.com/docker/distribution v2.8.2+incompatible // indirect
-	github.com/docker/docker v24.0.5+incompatible // indirect
+	github.com/docker/docker v24.0.7+incompatible // indirect
 	github.com/docker/go-connections v0.4.0 // indirect
 	github.com/docker/go-units v0.5.0 // indirect
 	github.com/gogo/protobuf v1.3.2 // indirect
diff --git a/samples/golang/pgx/go.sum b/samples/golang/pgx/go.sum
index b606014c..9c22c05c 100644
--- a/samples/golang/pgx/go.sum
+++ b/samples/golang/pgx/go.sum
@@ -32,8 +32,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
 github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
-github.com/docker/docker v24.0.5+incompatible h1:WmgcE4fxyI6EEXxBRxsHnZXrO1pQ3smi0k/jho4HLeY=
-github.com/docker/docker v24.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
+github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM=
+github.com/docker/docker v24.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
 github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
 github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
 github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
diff --git a/samples/java/hibernate/pom.xml b/samples/java/hibernate/pom.xml
index 39481e29..ea47ff7d 100644
--- a/samples/java/hibernate/pom.xml
+++ b/samples/java/hibernate/pom.xml
@@ -16,6 +16,7 @@
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
   </properties>
   <dependencies>
+    <!-- [START spanner_hibernate_dependencies] -->
     <!-- Hibernate core dependency -->
     <dependency>
       <groupId>org.hibernate.orm</groupId>
@@ -29,6 +30,7 @@
       <artifactId>postgresql</artifactId>
       <version>42.6.0</version>
     </dependency>
+    <!-- [END spanner_hibernate_dependencies] -->
 
     <!-- Jackson is required if you want to use JSONB with Hibernate. -->
     <dependency>
diff --git a/src/main/java/com/google/cloud/spanner/pgadapter/statements/SimpleParser.java b/src/main/java/com/google/cloud/spanner/pgadapter/statements/SimpleParser.java
index d8d7f06c..eac80132 100644
--- a/src/main/java/com/google/cloud/spanner/pgadapter/statements/SimpleParser.java
+++ b/src/main/java/com/google/cloud/spanner/pgadapter/statements/SimpleParser.java
@@ -806,7 +806,9 @@ public class SimpleParser {
         || peekKeyword("full")
         || peekKeyword("inner")
         || peekKeyword("outer")
-        || peekKeyword("cross");
+        || peekKeyword("cross")
+        || peekKeyword("on")
+        || peekKeyword("using");
   }
 
   boolean eatJoinType() {
diff --git a/src/main/java/com/google/cloud/spanner/pgadapter/statements/TableParser.java b/src/main/java/com/google/cloud/spanner/pgadapter/statements/TableParser.java
index 852e7c97..1a09e2e5 100644
--- a/src/main/java/com/google/cloud/spanner/pgadapter/statements/TableParser.java
+++ b/src/main/java/com/google/cloud/spanner/pgadapter/statements/TableParser.java
@@ -20,6 +20,7 @@ import com.google.cloud.spanner.pgadapter.statements.SimpleParser.TableOrIndexNa
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
+import java.util.HashSet;
 import java.util.Map.Entry;
 import java.util.Objects;
 import java.util.Set;
@@ -38,11 +39,12 @@ class TableParser {
 
   Tuple<Set<TableOrIndexName>, Statement> detectAndReplaceTables(
       ImmutableMap<TableOrIndexName, TableOrIndexName> detectAndReplaceMap) {
-    return detectAndReplaceTables(detectAndReplaceMap, true);
+    return detectAndReplaceTables(detectAndReplaceMap, new HashSet<>(), true);
   }
 
   Tuple<Set<TableOrIndexName>, Statement> detectAndReplaceTables(
       ImmutableMap<TableOrIndexName, TableOrIndexName> detectAndReplaceMap,
+      Set<TableOrIndexName> replacedTables,
       boolean searchForKeywordBeforeFirstTable) {
     boolean potentialMatch = false;
     String lowerCaseSql = parser.getSql().toLowerCase();
@@ -84,9 +86,18 @@ class TableParser {
       }
       searchForKeywordBeforeFirstTable = true;
       detectedOrReplacedTable =
-          parseTableList(detectAndReplaceMap, detectedTablesBuilder, multipleTables)
+          parseTableList(detectAndReplaceMap, replacedTables, detectedTablesBuilder, multipleTables)
               || detectedOrReplacedTable;
     }
+    // Reset to start replace full-qualified column names of tables that have been replaced.
+    parser.setPos(0);
+    String replaced =
+        replaceFullyQualifiedColumnNames(
+            detectAndReplaceMap, replacedTables, 0, parser.getSql().length());
+    if (replaced != null) {
+      parser.setSql(replaced);
+    }
+
     return detectedOrReplacedTable
         ? Tuple.of(
             detectedTablesBuilder.build(),
@@ -96,6 +107,7 @@ class TableParser {
 
   private boolean parseTableList(
       ImmutableMap<TableOrIndexName, TableOrIndexName> detectAndReplaceMap,
+      Set<TableOrIndexName> replacedTables,
       ImmutableSet.Builder<TableOrIndexName> detectedTablesBuilder,
       boolean multipleTables) {
     boolean detectedOrReplacedTable = false;
@@ -108,6 +120,7 @@ class TableParser {
         Tuple<Set<TableOrIndexName>, Statement> subResult =
             subParser.detectAndReplaceTables(
                 detectAndReplaceMap,
+                replacedTables,
                 subParser.parser.peekKeyword("select") || subParser.parser.peekKeyword("with"));
         if (!subResult.x().isEmpty()) {
           detectedOrReplacedTable = true;
@@ -131,10 +144,10 @@ class TableParser {
         if (detectAndReplaceMap.containsKey(tableOrIndexName)) {
           detectedOrReplacedTable = true;
           // Add the translated table name to the set of discovered tables so that a CTE can be
-          // added
-          // for it.
+          // added for it.
           detectedTablesBuilder.add(
               Objects.requireNonNull(detectAndReplaceMap.get(tableOrIndexName)));
+          replacedTables.add(tableOrIndexName);
           // Check if the entry in the table map contains a different replacement value than the
           // original. Some tables may be added to the map of replacements with the same replacement
           // value as the original with the sole purpose of detecting the use of the table.
@@ -159,13 +172,58 @@ class TableParser {
       }
       if (wasJoin) {
         // Skip the join condition.
+        int positionBeforeJoinCondition = parser.getPos();
         parser.eatJoinCondition();
+        // Replace fully-qualified table names with unqualified table names in the join condition.
+        String joinCondition =
+            replaceFullyQualifiedColumnNames(
+                detectAndReplaceMap, replacedTables, positionBeforeJoinCondition, parser.getPos());
+        if (joinCondition != null) {
+          parser.setSql(
+              parser.getSql().substring(0, positionBeforeJoinCondition)
+                  + joinCondition
+                  + parser.getSql().substring(parser.getPos()));
+          // Set the position of the parser to after the replaced join condition.
+          parser.setPos(positionBeforeJoinCondition + joinCondition.length());
+        }
       }
     } while (multipleTables && (parser.eatToken(",") || (wasJoin = parser.eatJoinType())));
 
     return detectedOrReplacedTable;
   }
 
+  private String replaceFullyQualifiedColumnNames(
+      ImmutableMap<TableOrIndexName, TableOrIndexName> detectAndReplaceMap,
+      Set<TableOrIndexName> replacedTables,
+      int replaceFromPosition,
+      int replaceToPosition) {
+    boolean replaced = false;
+    String sql = parser.getSql().substring(replaceFromPosition, replaceToPosition);
+    for (TableOrIndexName table : replacedTables) {
+      if (table.schema != null) {
+        TableOrIndexName replacement = detectAndReplaceMap.get(table);
+        if (replacement != null) {
+          while (true) {
+            String replacedSql =
+                sql.replaceAll(
+                    table.getUnquotedSchema() + "\\." + table.getUnquotedName() + "\\.(.+)",
+                    replacement.getUnquotedName() + ".$1");
+            if (!Objects.equals(replacedSql, sql)) {
+              sql = replacedSql;
+              replaced = true;
+            } else {
+              break;
+            }
+          }
+        }
+      }
+    }
+    if (replaced) {
+      return sql;
+    }
+    return null;
+  }
+
   @Override
   public String toString() {
     return parser.toString();
diff --git a/src/main/java/com/google/cloud/spanner/pgadapter/utils/ClientAutoDetector.java b/src/main/java/com/google/cloud/spanner/pgadapter/utils/ClientAutoDetector.java
index c28222a3..596b057c 100644
--- a/src/main/java/com/google/cloud/spanner/pgadapter/utils/ClientAutoDetector.java
+++ b/src/main/java/com/google/cloud/spanner/pgadapter/utils/ClientAutoDetector.java
@@ -432,7 +432,9 @@ public class ClientAutoDetector {
                   Suppliers.ofInstance("'' as regtype")),
               RegexQueryPartReplacer.replace(
                   Pattern.compile("WHERE t\\.oid = to_regtype\\(\\$1\\)"),
-                  Suppliers.ofInstance("WHERE t.typname = \\$1")));
+                  Suppliers.ofInstance("WHERE t.typname = \\$1")),
+              RegexQueryPartReplacer.replace(
+                  Pattern.compile("COLLATE \"C\""), Suppliers.ofInstance("")));
 
       @Override
       boolean isClient(List<String> orderedParameterKeys, Map<String, String> parameters) {
diff --git a/wrappers/golang/go.mod b/wrappers/golang/go.mod
index e37bb7ad..d36d1d2f 100644
--- a/wrappers/golang/go.mod
+++ b/wrappers/golang/go.mod
@@ -3,7 +3,7 @@ module github.com/GoogleCloudPlatform/pgadapter/wrappers/golang
 go 1.20
 
 require (
-	github.com/docker/docker v24.0.5+incompatible
+	github.com/docker/docker v24.0.7+incompatible
 	github.com/testcontainers/testcontainers-go v0.22.0
 	golang.org/x/oauth2 v0.9.0
 )
diff --git a/wrappers/golang/go.sum b/wrappers/golang/go.sum
index aedc7748..01f0fc1f 100644
--- a/wrappers/golang/go.sum
+++ b/wrappers/golang/go.sum
@@ -30,8 +30,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
 github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
-github.com/docker/docker v24.0.5+incompatible h1:WmgcE4fxyI6EEXxBRxsHnZXrO1pQ3smi0k/jho4HLeY=
-github.com/docker/docker v24.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
+github.com/docker/docker v24.0.7+incompatible h1:Wo6l37AuwP3JaMnZa226lzVXGA3F9Ig1seQen0cKYlM=
+github.com/docker/docker v24.0.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
 github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
 github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
 github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=


Test patch:
diff --git a/src/test/java/com/google/cloud/spanner/pgadapter/python/sqlalchemy2/SqlAlchemy2SampleTest.java b/src/test/java/com/google/cloud/spanner/pgadapter/python/sqlalchemy2/SqlAlchemy2SampleTest.java
index fa9dec01..5cd60c81 100644
--- a/src/test/java/com/google/cloud/spanner/pgadapter/python/sqlalchemy2/SqlAlchemy2SampleTest.java
+++ b/src/test/java/com/google/cloud/spanner/pgadapter/python/sqlalchemy2/SqlAlchemy2SampleTest.java
@@ -1083,9 +1083,9 @@ public class SqlAlchemy2SampleTest extends AbstractMockServerTest {
             + "        schema_name as nspname, null as nspowner, null as nspacl\n"
             + "  from information_schema.schemata\n"
             + ")\n"
-            + "SELECT pg_catalog.pg_class.relname \n"
-            + "FROM pg_class JOIN pg_namespace ON pg_catalog.pg_namespace.oid = pg_catalog.pg_class.relnamespace \n"
-            + "WHERE pg_catalog.pg_class.relname = $1::VARCHAR(64) COLLATE \"C\" AND pg_catalog.pg_class.relkind = ANY (ARRAY[$2::VARCHAR, $3::VARCHAR, $4::VARCHAR, $5::VARCHAR, $6::VARCHAR]) AND true COLLATE \"C\"";
+            + "SELECT pg_class.relname \n"
+            + "FROM pg_class JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace \n"
+            + "WHERE pg_class.relname = $1::VARCHAR(64)  AND pg_class.relkind = ANY (ARRAY[$2::VARCHAR, $3::VARCHAR, $4::VARCHAR, $5::VARCHAR, $6::VARCHAR]) AND true ";
     mockSpanner.putStatementResult(
         StatementResult.query(
             Statement.of(checkTableExistsSql),
diff --git a/src/test/java/com/google/cloud/spanner/pgadapter/statements/TableParserTest.java b/src/test/java/com/google/cloud/spanner/pgadapter/statements/TableParserTest.java
index 97ec9fb6..0e2fe3cf 100644
--- a/src/test/java/com/google/cloud/spanner/pgadapter/statements/TableParserTest.java
+++ b/src/test/java/com/google/cloud/spanner/pgadapter/statements/TableParserTest.java
@@ -137,6 +137,21 @@ public class TableParserTest {
             "pg_type",
             null,
             "pg_type"));
+    assertEquals(
+        Statement.of(
+            "select pg_class.relname from pg_namespace "
+                + "inner join pg_class on pg_namespace.oid = pg_class.relnamespace "
+                + "where pg_class.relname = $1::VARCHAR AND pg_class.relkind = ANY (ARRAY[$2::VARCHAR, $3::VARCHAR, $4::VARCHAR, $5::VARCHAR, $6::VARCHAR]) AND true AND pg_namespace.nspname != $7::VARCHAR'"),
+        replace(
+            Statement.of(
+                "select pg_catalog.pg_class.relname from pg_catalog.pg_namespace "
+                    + "inner join pg_catalog.pg_class on pg_catalog.pg_namespace.oid = pg_catalog.pg_class.relnamespace "
+                    + "where pg_catalog.pg_class.relname = $1::VARCHAR AND pg_catalog.pg_class.relkind = ANY (ARRAY[$2::VARCHAR, $3::VARCHAR, $4::VARCHAR, $5::VARCHAR, $6::VARCHAR]) AND true AND pg_catalog.pg_namespace.nspname != $7::VARCHAR'"),
+            ImmutableMap.of(
+                TableOrIndexName.of("pg_catalog", "pg_namespace"),
+                    TableOrIndexName.of(null, "pg_namespace"),
+                TableOrIndexName.of("pg_catalog", "pg_class"),
+                    TableOrIndexName.of(null, "pg_class"))));
 
     assertEquals(
         Statement.of("insert into pg_type (name) values ('foo')"),
@@ -863,4 +878,9 @@ public class TableParserTest {
                 new TableOrIndexName(schema, table), new TableOrIndexName(withSchema, withTable)))
         .y();
   }
+
+  static Statement replace(
+      Statement original, ImmutableMap<TableOrIndexName, TableOrIndexName> detectAndReplaceMap) {
+    return new TableParser(original).detectAndReplaceTables(detectAndReplaceMap).y();
+  }
 }