-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql, *: allow table scopeing under pg_temp_<session_id> physical schema
Previously, CRDB only supported the `public` physical schema. All table entries in `system.namespace` assumed an implied `public` schema, so name resolution for tables only required a databaseID and table name to unqiely identify a table. As highlighted in the temp tables RFC, temp tables will be scoped under a session specific schema of the form `pg_temp_<session_id>`. This motivated adding support for additional physical schemas. This PR involves the following changes to `system.namespace`: - A new `system.namespace` table is constructed for cluster versions >= 20.1, which has an additional primary key column `publicSchemaID`. - The older `system.namespace` table is marked deprecated. All `system.namespace` accesses for cluster versions < 20.1 continue to refer to this deprecated table. This is invisible to users. - The new `system.namespace` table is moved out of the SystemConfig range. This means `system.namespace` is no longer gossiped for cluster versions >= 20.1 . - Every new database creation adds the `public` schema to `system.namespace` by default. The `searchPath` is responsible for establishing the order in which schemas are searched during name resolution. This PR involves the following changes to the `searchPath`: - The search semantics are updated to match those described in the temp tables RFC. - The search path is now aware of the session specific temporary schema, which can be used during name resolution. - The distSQL api proto had to be updated to pass the temporary schema to other nodes in addition to the list of paths. Follow-up work: - The `TableCollection` cache needs to be updated to have knowledge about schemaIDs. Once this is done, there is a TODO in the code that allows the `CachedPhysicalAccessor` to work correctly. - Migration for clusters upgrading to 20.1. The new `system.namespace` table needs to be populated from the deprecated table and a `public` schema needs to be added for every database during migration. Release note (sql change): CREATE TABLE pg_temp.abc(a int) now creates a temporary table. See temp tables RFC (guide-level explanation) for more details about the search path semantics.
- Loading branch information
1 parent
a576473
commit ec15991
Showing
89 changed files
with
1,624 additions
and
726 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2215,6 +2215,8 @@ writing ` + os.DevNull + ` | |
debug/nodes/1/ranges/22.json | ||
debug/nodes/1/ranges/23.json | ||
debug/nodes/1/ranges/24.json | ||
debug/nodes/1/ranges/25.json | ||
debug/nodes/1/ranges/26.json | ||
debug/schema/[email protected] | ||
debug/schema/[email protected] | ||
debug/schema/[email protected] | ||
|
@@ -2225,6 +2227,7 @@ writing ` + os.DevNull + ` | |
debug/schema/system/lease.json | ||
debug/schema/system/locations.json | ||
debug/schema/system/namespace.json | ||
debug/schema/system/namespace_deprecated.json | ||
debug/schema/system/rangelog.json | ||
debug/schema/system/replication_constraint_stats.json | ||
debug/schema/system/replication_critical_localities.json | ||
|
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
Oops, something went wrong.