github.com/cockroachdb/cockroachdb-parser@v0.23.3-0.20240213214944-911057d40c9a/pkg/sql/sem/catconstants/schemas.go (about) 1 // Copyright 2021 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package catconstants 12 13 // PublicSchemaID redefines keys.PublicSchemaID to avoid an import. It exists 14 // to deal with time-travel queries from moments before the time when all 15 // databases other than system were given a public schema. 16 const PublicSchemaID = 29 17 18 // StaticSchemaIDMapVirtualPublicSchema is a map of statically known schema IDs 19 // on versions prior to PublicSchemasWithDescriptors. 20 var StaticSchemaIDMapVirtualPublicSchema = map[uint32]string{ 21 PublicSchemaID: PublicSchemaName, 22 PgCatalogID: PgCatalogName, 23 InformationSchemaID: InformationSchemaName, 24 CrdbInternalID: CRDBInternalSchemaName, 25 PgExtensionSchemaID: PgExtensionSchemaName, 26 } 27 28 // StaticSchemaIDMap is a map of statically known schema IDs on versions 29 // PublicSchemasWithDescriptors and onwards. 30 var StaticSchemaIDMap = map[uint32]string{ 31 PgCatalogID: PgCatalogName, 32 InformationSchemaID: InformationSchemaName, 33 CrdbInternalID: CRDBInternalSchemaName, 34 PgExtensionSchemaID: PgExtensionSchemaName, 35 } 36 37 // GetStaticSchemaIDMap returns a map of schema ids to schema names for the 38 // static schemas. 39 func GetStaticSchemaIDMap() map[uint32]string { 40 return StaticSchemaIDMapVirtualPublicSchema 41 } 42 43 // PgCatalogName is the name of the pg_catalog system schema. 44 const PgCatalogName = "pg_catalog" 45 46 // PublicSchemaName is the name of the public schema. 47 const PublicSchemaName = "public" 48 49 // UserSchemaName is the alias for schema names for users. 50 const UserSchemaName = "$user" 51 52 // InformationSchemaName is the name of the information_schema system schema. 53 const InformationSchemaName = "information_schema" 54 55 // CRDBInternalSchemaName is the name of the crdb_internal system schema. 56 const CRDBInternalSchemaName = "crdb_internal" 57 58 // PgSchemaPrefix is a prefix for Postgres system schemas. Users cannot 59 // create schemas with this prefix. 60 const PgSchemaPrefix = "pg_" 61 62 // PgTempSchemaName is the alias for temporary schemas across sessions. 63 const PgTempSchemaName = "pg_temp" 64 65 // PgExtensionSchemaName is the alias for schemas which are usually "public" in postgres 66 // when installing an extension, but must be stored as a separate schema in CRDB. 67 const PgExtensionSchemaName = "pg_extension" 68 69 // VirtualSchemaNames is a set of all virtual schema names. 70 var VirtualSchemaNames = map[string]struct{}{ 71 PgCatalogName: {}, 72 InformationSchemaName: {}, 73 CRDBInternalSchemaName: {}, 74 PgExtensionSchemaName: {}, 75 }