github.com/cockroachdb/cockroachdb-parser@v0.23.3-0.20240213214944-911057d40c9a/pkg/sql/sem/catconstants/constants.go (about)

     1  // Copyright 2017 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  import "math"
    14  
    15  // ReportableAppNamePrefix indicates that the application name can be
    16  // reported in telemetry without scrubbing. (Note this only applies to
    17  // the application name itself. Query data is still scrubbed as
    18  // usual.)
    19  const ReportableAppNamePrefix = "$ "
    20  
    21  // InternalAppNamePrefix indicates that the application name identifies
    22  // an internal task / query / job to CockroachDB. Different application
    23  // names are used to classify queries in different categories.
    24  const InternalAppNamePrefix = ReportableAppNamePrefix + "internal"
    25  
    26  // DelegatedAppNamePrefix is added to a regular client application
    27  // name for SQL queries that are ran internally on behalf of other SQL
    28  // queries inside that application. This is not the same as
    29  // ReportableAppNamePrefix; in particular the application name with
    30  // DelegatedAppNamePrefix should be scrubbed in reporting.
    31  const DelegatedAppNamePrefix = "$$ "
    32  
    33  // InternalSQLAppName is the application_name used by
    34  // the cockroach CLI by default
    35  const InternalSQLAppName = "cockroach sql"
    36  
    37  // SystemDatabaseName is the name of the system database.
    38  const SystemDatabaseName = "system"
    39  
    40  // SystemTableName is a type for system table names.
    41  type SystemTableName string
    42  
    43  // SystemTenantName is the tenant name of the system tenant.
    44  const SystemTenantName = "system"
    45  
    46  // Names of tables in the system database.
    47  const (
    48  	NamespaceTableName                     SystemTableName = "namespace"
    49  	DescriptorTableName                    SystemTableName = "descriptor"
    50  	UsersTableName                         SystemTableName = "users"
    51  	ZonesTableName                         SystemTableName = "zones"
    52  	SettingsTableName                      SystemTableName = "settings"
    53  	DescIDSequenceTableName                SystemTableName = "descriptor_id_seq"
    54  	TenantIDSequenceTableName              SystemTableName = "tenant_id_seq"
    55  	TenantsTableName                       SystemTableName = "tenants"
    56  	LeaseTableName                         SystemTableName = "lease"
    57  	EventLogTableName                      SystemTableName = "eventlog"
    58  	RangeEventTableName                    SystemTableName = "rangelog"
    59  	UITableName                            SystemTableName = "ui"
    60  	JobsTableName                          SystemTableName = "jobs"
    61  	WebSessionsTableName                   SystemTableName = "web_sessions"
    62  	TableStatisticsTableName               SystemTableName = "table_statistics"
    63  	LocationsTableName                     SystemTableName = "locations"
    64  	RoleMembersTableName                   SystemTableName = "role_members"
    65  	CommentsTableName                      SystemTableName = "comments"
    66  	ReportsMetaTableName                   SystemTableName = "reports_meta"
    67  	ReplicationConstraintStatsTableName    SystemTableName = "replication_constraint_stats"
    68  	ReplicationCriticalLocalitiesTableName SystemTableName = "replication_critical_localities"
    69  	ReplicationStatsTableName              SystemTableName = "replication_stats"
    70  	ProtectedTimestampsMetaTableName       SystemTableName = "protected_ts_meta"
    71  	ProtectedTimestampsRecordsTableName    SystemTableName = "protected_ts_records"
    72  	RoleOptionsTableName                   SystemTableName = "role_options"
    73  	StatementBundleChunksTableName         SystemTableName = "statement_bundle_chunks"
    74  	StatementDiagnosticsRequestsTableName  SystemTableName = "statement_diagnostics_requests"
    75  	StatementDiagnosticsTableName          SystemTableName = "statement_diagnostics"
    76  	ScheduledJobsTableName                 SystemTableName = "scheduled_jobs"
    77  	SqllivenessTableName                   SystemTableName = "sqlliveness"
    78  	MigrationsTableName                    SystemTableName = "migrations"
    79  	JoinTokensTableName                    SystemTableName = "join_tokens"
    80  	StatementStatisticsTableName           SystemTableName = "statement_statistics"
    81  	TransactionStatisticsTableName         SystemTableName = "transaction_statistics"
    82  	StatementActivityTableName             SystemTableName = "statement_activity"
    83  	TransactionActivityTableName           SystemTableName = "transaction_activity"
    84  	DatabaseRoleSettingsTableName          SystemTableName = "database_role_settings"
    85  	TenantUsageTableName                   SystemTableName = "tenant_usage"
    86  	SQLInstancesTableName                  SystemTableName = "sql_instances"
    87  	SpanConfigurationsTableName            SystemTableName = "span_configurations"
    88  	TaskPayloadsTableName                  SystemTableName = "task_payloads"
    89  	TenantSettingsTableName                SystemTableName = "tenant_settings"
    90  	TenantTasksTableName                   SystemTableName = "tenant_tasks"
    91  	SpanCountTableName                     SystemTableName = "span_count"
    92  	SystemPrivilegeTableName               SystemTableName = "privileges"
    93  	SystemExternalConnectionsTableName     SystemTableName = "external_connections"
    94  	RoleIDSequenceName                     SystemTableName = "role_id_seq"
    95  	SystemJobInfoTableName                 SystemTableName = "job_info"
    96  	SpanStatsUniqueKeys                    SystemTableName = "span_stats_unique_keys"
    97  	SpanStatsBuckets                       SystemTableName = "span_stats_buckets"
    98  	SpanStatsSamples                       SystemTableName = "span_stats_samples"
    99  	SpanStatsTenantBoundaries              SystemTableName = "span_stats_tenant_boundaries"
   100  	RegionalLiveness                       SystemTableName = "region_liveness"
   101  	MVCCStatistics                         SystemTableName = "mvcc_statistics"
   102  	StmtExecInsightsTableName              SystemTableName = "statement_execution_insights"
   103  	TxnExecInsightsTableName               SystemTableName = "transaction_execution_insights"
   104  )
   105  
   106  // Oid for virtual database and table.
   107  const (
   108  	CrdbInternalID = math.MaxUint32 - iota
   109  	CrdbInternalBackwardDependenciesTableID
   110  	CrdbInternalBuildInfoTableID
   111  	CrdbInternalBuiltinFunctionsTableID
   112  	CrdbInternalBuiltinFunctionCommentsTableID
   113  	CrdbInternalCatalogCommentsTableID
   114  	CrdbInternalCatalogDescriptorTableID
   115  	CrdbInternalCatalogNamespaceTableID
   116  	CrdbInternalCatalogZonesTableID
   117  	CrdbInternalClusterContendedIndexesViewID
   118  	CrdbInternalClusterContendedKeysViewID
   119  	CrdbInternalClusterContendedTablesViewID
   120  	CrdbInternalClusterContentionEventsTableID
   121  	CrdbInternalClusterDistSQLFlowsTableID
   122  	CrdbInternalClusterExecutionInsightsTableID
   123  	CrdbInternalClusterTxnExecutionInsightsTableID
   124  	CrdbInternalNodeTxnExecutionInsightsTableID
   125  	CrdbInternalClusterLocksTableID
   126  	CrdbInternalClusterQueriesTableID
   127  	CrdbInternalClusterTransactionsTableID
   128  	CrdbInternalClusterSessionsTableID
   129  	CrdbInternalClusterSettingsTableID
   130  	CrdbInternalClusterStmtStatsTableID
   131  	CrdbInternalClusterTxnStatsTableID
   132  	CrdbInternalCreateFunctionStmtsTableID
   133  	CrdbInternalCreateProcedureStmtsTableID
   134  	CrdbInternalCreateSchemaStmtsTableID
   135  	CrdbInternalCreateStmtsTableID
   136  	CrdbInternalCreateTypeStmtsTableID
   137  	CrdbInternalDatabasesTableID
   138  	CrdbInternalFeatureUsageID
   139  	CrdbInternalForwardDependenciesTableID
   140  	CrdbInternalKVNodeLivenessTableID
   141  	CrdbInternalGossipNodesTableID
   142  	CrdbInternalGossipAlertsTableID
   143  	CrdbInternalGossipLivenessTableID
   144  	CrdbInternalGossipNetworkTableID
   145  	CrdbInternalTransactionContentionEvents
   146  	CrdbInternalIndexColumnsTableID
   147  	CrdbInternalIndexSpansTableID
   148  	CrdbInternalIndexUsageStatisticsTableID
   149  	CrdbInternalInflightTraceSpanTableID
   150  	CrdbInternalJobsTableID
   151  	CrdbInternalSystemJobsTableID
   152  	CrdbInternalKVNodeStatusTableID
   153  	CrdbInternalKVStoreStatusTableID
   154  	CrdbInternalLeasesTableID
   155  	CrdbInternalLocalContentionEventsTableID
   156  	CrdbInternalLocalDistSQLFlowsTableID
   157  	CrdbInternalNodeExecutionInsightsTableID
   158  	CrdbInternalLocalQueriesTableID
   159  	CrdbInternalLocalTransactionsTableID
   160  	CrdbInternalLocalSessionsTableID
   161  	CrdbInternalLocalMetricsTableID
   162  	CrdbInternalNodeMemoryMonitorsTableID
   163  	CrdbInternalNodeStmtStatsTableID
   164  	CrdbInternalNodeTxnStatsTableID
   165  	CrdbInternalPartitionsTableID
   166  	CrdbInternalRangesNoLeasesTableID
   167  	CrdbInternalRangesViewID
   168  	CrdbInternalRuntimeInfoTableID
   169  	CrdbInternalSchemaChangesTableID
   170  	CrdbInternalSessionTraceTableID
   171  	CrdbInternalSessionVariablesTableID
   172  	CrdbInternalStmtActivityTableID
   173  	CrdbInternalStmtStatsTableID
   174  	CrdbInternalStmtStatsPersistedTableID
   175  	CrdbInternalStmtStatsPersistedV22_2TableID
   176  	CrdbInternalTableColumnsTableID
   177  	CrdbInternalTableIndexesTableID
   178  	CrdbInternalTableSpansTableID
   179  	CrdbInternalTablesTableID
   180  	CrdbInternalTablesTableLastStatsID
   181  	CrdbInternalTransactionStatsTableID
   182  	CrdbInternalTxnActivityTableID
   183  	CrdbInternalTxnStatsTableID
   184  	CrdbInternalTxnStatsPersistedTableID
   185  	CrdbInternalTxnStatsPersistedV22_2TableID
   186  	CrdbInternalZonesTableID
   187  	CrdbInternalInvalidDescriptorsTableID
   188  	CrdbInternalClusterDatabasePrivilegesTableID
   189  	CrdbInternalCrossDbRefrences
   190  	CrdbInternalLostTableDescriptors
   191  	CrdbInternalClusterInflightTracesTable
   192  	CrdbInternalRegionsTable
   193  	CrdbInternalDefaultPrivilegesTable
   194  	CrdbInternalActiveRangeFeedsTable
   195  	CrdbInternalTenantUsageDetailsViewID
   196  	CrdbInternalPgCatalogTableIsImplementedTableID
   197  	CrdbInternalSuperRegions
   198  	CrdbInternalDroppedRelationsViewID
   199  	CrdbInternalShowTenantCapabilitiesCacheTableID
   200  	CrdbInternalInheritedRoleMembersTableID
   201  	CrdbInternalKVSystemPrivilegesViewID
   202  	CrdbInternalKVFlowControllerID
   203  	CrdbInternalKVFlowHandlesID
   204  	CrdbInternalKVFlowTokenDeductions
   205  	CrdbInternalRepairableCatalogCorruptionsViewID
   206  	CrdbInternalKVProtectedTS
   207  	InformationSchemaID
   208  	InformationSchemaAdministrableRoleAuthorizationsID
   209  	InformationSchemaApplicableRolesID
   210  	InformationSchemaAttributesTableID
   211  	InformationSchemaCharacterSets
   212  	InformationSchemaCheckConstraintRoutineUsageTableID
   213  	InformationSchemaCheckConstraints
   214  	InformationSchemaCollationCharacterSetApplicability
   215  	InformationSchemaCollations
   216  	InformationSchemaColumnColumnUsageTableID
   217  	InformationSchemaColumnDomainUsageTableID
   218  	InformationSchemaColumnOptionsTableID
   219  	InformationSchemaColumnPrivilegesID
   220  	InformationSchemaColumnStatisticsTableID
   221  	InformationSchemaColumnUDTUsageID
   222  	InformationSchemaColumnsExtensionsTableID
   223  	InformationSchemaColumnsTableID
   224  	InformationSchemaConstraintColumnUsageTableID
   225  	InformationSchemaConstraintTableUsageTableID
   226  	InformationSchemaDataTypePrivilegesTableID
   227  	InformationSchemaDomainConstraintsTableID
   228  	InformationSchemaDomainUdtUsageTableID
   229  	InformationSchemaDomainsTableID
   230  	InformationSchemaElementTypesTableID
   231  	InformationSchemaEnabledRolesID
   232  	InformationSchemaEnginesTableID
   233  	InformationSchemaEventsTableID
   234  	InformationSchemaFilesTableID
   235  	InformationSchemaForeignDataWrapperOptionsTableID
   236  	InformationSchemaForeignDataWrappersTableID
   237  	InformationSchemaForeignServerOptionsTableID
   238  	InformationSchemaForeignServersTableID
   239  	InformationSchemaForeignTableOptionsTableID
   240  	InformationSchemaForeignTablesTableID
   241  	InformationSchemaInformationSchemaCatalogNameTableID
   242  	InformationSchemaKeyColumnUsageTableID
   243  	InformationSchemaKeywordsTableID
   244  	InformationSchemaOptimizerTraceTableID
   245  	InformationSchemaParametersTableID
   246  	InformationSchemaPartitionsTableID
   247  	InformationSchemaPluginsTableID
   248  	InformationSchemaProcesslistTableID
   249  	InformationSchemaProfilingTableID
   250  	InformationSchemaReferentialConstraintsTableID
   251  	InformationSchemaResourceGroupsTableID
   252  	InformationSchemaRoleColumnGrantsTableID
   253  	InformationSchemaRoleRoutineGrantsTableID
   254  	InformationSchemaRoleTableGrantsID
   255  	InformationSchemaRoleUdtGrantsTableID
   256  	InformationSchemaRoleUsageGrantsTableID
   257  	InformationSchemaRoutinePrivilegesTableID
   258  	InformationSchemaRoutineTableID
   259  	InformationSchemaSQLFeaturesTableID
   260  	InformationSchemaSQLImplementationInfoTableID
   261  	InformationSchemaSQLPartsTableID
   262  	InformationSchemaSQLSizingTableID
   263  	InformationSchemaSchemataExtensionsTableID
   264  	InformationSchemaSchemataTableID
   265  	InformationSchemaSchemataTablePrivilegesID
   266  	InformationSchemaSequencesID
   267  	InformationSchemaSessionVariables
   268  	InformationSchemaStGeometryColumnsTableID
   269  	InformationSchemaStSpatialReferenceSystemsTableID
   270  	InformationSchemaStUnitsOfMeasureTableID
   271  	InformationSchemaStatisticsTableID
   272  	InformationSchemaTableConstraintTableID
   273  	InformationSchemaTableConstraintsExtensionsTableID
   274  	InformationSchemaTablePrivilegesID
   275  	InformationSchemaTablesExtensionsTableID
   276  	InformationSchemaTablesTableID
   277  	InformationSchemaTablespacesExtensionsTableID
   278  	InformationSchemaTablespacesTableID
   279  	InformationSchemaTransformsTableID
   280  	InformationSchemaTriggeredUpdateColumnsTableID
   281  	InformationSchemaTriggersTableID
   282  	InformationSchemaTypePrivilegesID
   283  	InformationSchemaUdtPrivilegesTableID
   284  	InformationSchemaUsagePrivilegesTableID
   285  	InformationSchemaUserAttributesTableID
   286  	InformationSchemaUserDefinedTypesTableID
   287  	InformationSchemaUserMappingOptionsTableID
   288  	InformationSchemaUserMappingsTableID
   289  	InformationSchemaUserPrivilegesID
   290  	InformationSchemaViewColumnUsageTableID
   291  	InformationSchemaViewRoutineUsageTableID
   292  	InformationSchemaViewTableUsageTableID
   293  	InformationSchemaViewsTableID
   294  	PgCatalogID
   295  	PgCatalogAggregateTableID
   296  	PgCatalogAmTableID
   297  	PgCatalogAmopTableID
   298  	PgCatalogAmprocTableID
   299  	PgCatalogAttrDefTableID
   300  	PgCatalogAttributeTableID
   301  	PgCatalogAuthIDTableID
   302  	PgCatalogAuthMembersTableID
   303  	PgCatalogAvailableExtensionVersionsTableID
   304  	PgCatalogAvailableExtensionsTableID
   305  	PgCatalogCastTableID
   306  	PgCatalogClassTableID
   307  	PgCatalogCollationTableID
   308  	PgCatalogConfigTableID
   309  	PgCatalogConstraintTableID
   310  	PgCatalogConversionTableID
   311  	PgCatalogCursorsTableID
   312  	PgCatalogDatabaseTableID
   313  	PgCatalogDbRoleSettingTableID
   314  	PgCatalogDefaultACLTableID
   315  	PgCatalogDependTableID
   316  	PgCatalogDescriptionTableID
   317  	PgCatalogEnumTableID
   318  	PgCatalogEventTriggerTableID
   319  	PgCatalogExtensionTableID
   320  	PgCatalogFileSettingsTableID
   321  	PgCatalogForeignDataWrapperTableID
   322  	PgCatalogForeignServerTableID
   323  	PgCatalogForeignTableTableID
   324  	PgCatalogGroupTableID
   325  	PgCatalogHbaFileRulesTableID
   326  	PgCatalogIndexTableID
   327  	PgCatalogIndexesTableID
   328  	PgCatalogInheritsTableID
   329  	PgCatalogInitPrivsTableID
   330  	PgCatalogLanguageTableID
   331  	PgCatalogLargeobjectMetadataTableID
   332  	PgCatalogLargeobjectTableID
   333  	PgCatalogLocksTableID
   334  	PgCatalogMatViewsTableID
   335  	PgCatalogNamespaceTableID
   336  	PgCatalogOpclassTableID
   337  	PgCatalogOperatorTableID
   338  	PgCatalogOpfamilyTableID
   339  	PgCatalogPartitionedTableTableID
   340  	PgCatalogPoliciesTableID
   341  	PgCatalogPolicyTableID
   342  	PgCatalogPreparedStatementsTableID
   343  	PgCatalogPreparedXactsTableID
   344  	PgCatalogProcTableID
   345  	PgCatalogPublicationRelTableID
   346  	PgCatalogPublicationTableID
   347  	PgCatalogPublicationTablesTableID
   348  	PgCatalogRangeTableID
   349  	PgCatalogReplicationOriginStatusTableID
   350  	PgCatalogReplicationOriginTableID
   351  	PgCatalogReplicationSlotsTableID
   352  	PgCatalogRewriteTableID
   353  	PgCatalogRolesTableID
   354  	PgCatalogRulesTableID
   355  	PgCatalogSecLabelsTableID
   356  	PgCatalogSecurityLabelTableID
   357  	PgCatalogSequenceTableID
   358  	PgCatalogSequencesTableID
   359  	PgCatalogSettingsTableID
   360  	PgCatalogShadowTableID
   361  	PgCatalogSharedDescriptionTableID
   362  	PgCatalogSharedSecurityLabelTableID
   363  	PgCatalogShdependTableID
   364  	PgCatalogShmemAllocationsTableID
   365  	PgCatalogStatActivityTableID
   366  	PgCatalogStatAllIndexesTableID
   367  	PgCatalogStatAllTablesTableID
   368  	PgCatalogStatArchiverTableID
   369  	PgCatalogStatBgwriterTableID
   370  	PgCatalogStatDatabaseConflictsTableID
   371  	PgCatalogStatDatabaseTableID
   372  	PgCatalogStatGssapiTableID
   373  	PgCatalogStatProgressAnalyzeTableID
   374  	PgCatalogStatProgressBasebackupTableID
   375  	PgCatalogStatProgressClusterTableID
   376  	PgCatalogStatProgressCreateIndexTableID
   377  	PgCatalogStatProgressVacuumTableID
   378  	PgCatalogStatReplicationTableID
   379  	PgCatalogStatSlruTableID
   380  	PgCatalogStatSslTableID
   381  	PgCatalogStatSubscriptionTableID
   382  	PgCatalogStatSysIndexesTableID
   383  	PgCatalogStatSysTablesTableID
   384  	PgCatalogStatUserFunctionsTableID
   385  	PgCatalogStatUserIndexesTableID
   386  	PgCatalogStatUserTablesTableID
   387  	PgCatalogStatWalReceiverTableID
   388  	PgCatalogStatXactAllTablesTableID
   389  	PgCatalogStatXactSysTablesTableID
   390  	PgCatalogStatXactUserFunctionsTableID
   391  	PgCatalogStatXactUserTablesTableID
   392  	PgCatalogStatioAllIndexesTableID
   393  	PgCatalogStatioAllSequencesTableID
   394  	PgCatalogStatioAllTablesTableID
   395  	PgCatalogStatioSysIndexesTableID
   396  	PgCatalogStatioSysSequencesTableID
   397  	PgCatalogStatioSysTablesTableID
   398  	PgCatalogStatioUserIndexesTableID
   399  	PgCatalogStatioUserSequencesTableID
   400  	PgCatalogStatioUserTablesTableID
   401  	PgCatalogStatisticExtDataTableID
   402  	PgCatalogStatisticExtTableID
   403  	PgCatalogStatisticTableID
   404  	PgCatalogStatsExtTableID
   405  	PgCatalogStatsTableID
   406  	PgCatalogSubscriptionRelTableID
   407  	PgCatalogSubscriptionTableID
   408  	PgCatalogTablesTableID
   409  	PgCatalogTablespaceTableID
   410  	PgCatalogTimezoneAbbrevsTableID
   411  	PgCatalogTimezoneNamesTableID
   412  	PgCatalogTransformTableID
   413  	PgCatalogTriggerTableID
   414  	PgCatalogTsConfigMapTableID
   415  	PgCatalogTsConfigTableID
   416  	PgCatalogTsDictTableID
   417  	PgCatalogTsParserTableID
   418  	PgCatalogTsTemplateTableID
   419  	PgCatalogTypeTableID
   420  	PgCatalogUserMappingTableID
   421  	PgCatalogUserMappingsTableID
   422  	PgCatalogUserTableID
   423  	PgCatalogViewsTableID
   424  	PgExtensionSchemaID
   425  	PgExtensionGeographyColumnsTableID
   426  	PgExtensionGeometryColumnsTableID
   427  	PgExtensionSpatialRefSysTableID
   428  	MinVirtualID = PgExtensionSpatialRefSysTableID
   429  )
   430  
   431  // ConstraintType is used to identify the type of a constraint.
   432  type ConstraintType string
   433  
   434  const (
   435  	// ConstraintTypePK identifies a PRIMARY KEY constraint.
   436  	ConstraintTypePK ConstraintType = "PRIMARY KEY"
   437  	// ConstraintTypeFK identifies a FOREIGN KEY constraint.
   438  	ConstraintTypeFK ConstraintType = "FOREIGN KEY"
   439  	// ConstraintTypeUnique identifies a UNIQUE constraint.
   440  	ConstraintTypeUnique ConstraintType = "UNIQUE"
   441  	// ConstraintTypeCheck identifies a CHECK constraint.
   442  	ConstraintTypeCheck ConstraintType = "CHECK"
   443  	// ConstraintTypeUniqueWithoutIndex identifies a UNIQUE_WITHOUT_INDEX constraint.
   444  	ConstraintTypeUniqueWithoutIndex ConstraintType = "UNIQUE WITHOUT INDEX"
   445  )
   446  
   447  // SafeValue implements the redact.SafeValue interface.
   448  func (ConstraintType) SafeValue() {}