forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opt: check for schema changes when validating UDTs in the query cache
The metadata stores tracks each UDT referenced in the query by its OID. It validates the cached data by checking that the OID still resolves to the expected type and that the type hasn't undergone schema changes since the query was resolved. The problem with tracking only by OID instead of by the name used to reference the type is that the query cache can incorrectly pass validation when the UDT's schema or database has been altered in some way. This previously led to behavior like the following: ``` defaultdb> create type sc1.t as enum ('foo', 'bar'); CREATE TYPE defaultdb> select 'foo'::sc1.t; t ------- foo (1 row) defaultdb> alter schema sc1 rename to sc2; ALTER SCHEMA defaultdb> select 'foo'::sc1.t; t ------- foo (1 row) ``` This patch adds schema tracking to the metadata dependency tracking. For now, this is only done for UDT resolution, but following commits will adapt data source and function resolution to also take advantage of this change. This allows catalog objects to be tracked in the metadata by ID rather than by name, which simplifies the implementation. This ensures a cached query will be properly invalidated if the schema or database of a UDT in the query is altered or dropped. Fixes cockroachdb#96674 Release note (bug fix): Fixed a bug that could cause a query involving user-defined types to ignore schema changes when the same query was invoked before and after the change.
- Loading branch information
1 parent
92b6c8c
commit 58c0a52
Showing
7 changed files
with
165 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters