github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/pgwire/pgcode/codes.go (about) 1 // Copyright 2019 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 pgcode 12 13 // PG error codes from: http://www.postgresql.org/docs/9.5/static/errcodes-appendix.html. 14 // Specifically, errcodes.txt is copied from from Postgres' src/backend/utils/errcodes.txt. 15 // 16 // The error definitions were generated using the generate.sh script, 17 // with a bit of manual tweaking performed afterwards. 18 const ( 19 // Class 00 - Successful Completion 20 SuccessfulCompletion = "00000" 21 // Class 01 - Warning 22 Warning = "01000" 23 WarningDynamicResultSetsReturned = "0100C" 24 WarningImplicitZeroBitPadding = "01008" 25 WarningNullValueEliminatedInSetFunction = "01003" 26 WarningPrivilegeNotGranted = "01007" 27 WarningPrivilegeNotRevoked = "01006" 28 WarningStringDataRightTruncation = "01004" 29 WarningDeprecatedFeature = "01P01" 30 // Class 02 - No Data (this is also a warning class per the SQL standard) 31 NoData = "02000" 32 NoAdditionalDynamicResultSetsReturned = "02001" 33 // Class 03 - SQL Statement Not Yet Complete 34 SQLStatementNotYetComplete = "03000" 35 // Class 08 - Connection Exception 36 ConnectionException = "08000" 37 ConnectionDoesNotExist = "08003" 38 ConnectionFailure = "08006" 39 SQLclientUnableToEstablishSQLconnection = "08001" 40 SQLserverRejectedEstablishmentOfSQLconnection = "08004" 41 TransactionResolutionUnknown = "08007" 42 ProtocolViolation = "08P01" 43 // Class 09 - Triggered Action Exception 44 TriggeredActionException = "09000" 45 // Class 0A - Feature Not Supported 46 FeatureNotSupported = "0A000" 47 // Class 0B - Invalid Transaction Initiation 48 InvalidTransactionInitiation = "0B000" 49 // Class 0F - Locator Exception 50 LocatorException = "0F000" 51 InvalidLocatorSpecification = "0F001" 52 // Class 0L - Invalid Grantor 53 InvalidGrantor = "0L000" 54 InvalidGrantOperation = "0LP01" 55 // Class 0P - Invalid Role Specification 56 InvalidRoleSpecification = "0P000" 57 // Class 0Z - Diagnostics Exception 58 DiagnosticsException = "0Z000" 59 StackedDiagnosticsAccessedWithoutActiveHandler = "0Z002" 60 // Class 20 - Case Not Found 61 CaseNotFound = "20000" 62 // Class 21 - Cardinality Violation 63 CardinalityViolation = "21000" 64 // Class 22 - Data Exception 65 DataException = "22000" 66 ArraySubscript = "2202E" 67 CharacterNotInRepertoire = "22021" 68 DatetimeFieldOverflow = "22008" 69 DivisionByZero = "22012" 70 InvalidWindowFrameOffset = "22013" 71 ErrorInAssignment = "22005" 72 EscapeCharacterConflict = "2200B" 73 IndicatorOverflow = "22022" 74 IntervalFieldOverflow = "22015" 75 InvalidArgumentForLogarithm = "2201E" 76 InvalidArgumentForNtileFunction = "22014" 77 InvalidArgumentForNthValueFunction = "22016" 78 InvalidArgumentForPowerFunction = "2201F" 79 InvalidArgumentForWidthBucketFunction = "2201G" 80 InvalidCharacterValueForCast = "22018" 81 InvalidDatetimeFormat = "22007" 82 InvalidEscapeCharacter = "22019" 83 InvalidEscapeOctet = "2200D" 84 InvalidEscapeSequence = "22025" 85 NonstandardUseOfEscapeCharacter = "22P06" 86 InvalidIndicatorParameterValue = "22010" 87 InvalidParameterValue = "22023" 88 InvalidRegularExpression = "2201B" 89 InvalidRowCountInLimitClause = "2201W" 90 InvalidRowCountInResultOffsetClause = "2201X" 91 InvalidTimeZoneDisplacementValue = "22009" 92 InvalidUseOfEscapeCharacter = "2200C" 93 MostSpecificTypeMismatch = "2200G" 94 NullValueNotAllowed = "22004" 95 NullValueNoIndicatorParameter = "22002" 96 NumericValueOutOfRange = "22003" 97 SequenceGeneratorLimitExceeded = "2200H" 98 StringDataLengthMismatch = "22026" 99 StringDataRightTruncation = "22001" 100 Substring = "22011" 101 Trim = "22027" 102 UnterminatedCString = "22024" 103 ZeroLengthCharacterString = "2200F" 104 FloatingPointException = "22P01" 105 InvalidTextRepresentation = "22P02" 106 InvalidBinaryRepresentation = "22P03" 107 BadCopyFileFormat = "22P04" 108 UntranslatableCharacter = "22P05" 109 NotAnXMLDocument = "2200L" 110 InvalidXMLDocument = "2200M" 111 InvalidXMLContent = "2200N" 112 InvalidXMLComment = "2200S" 113 InvalidXMLProcessingInstruction = "2200T" 114 // Class 23 - Integrity Constraint Violation 115 IntegrityConstraintViolation = "23000" 116 RestrictViolation = "23001" 117 NotNullViolation = "23502" 118 ForeignKeyViolation = "23503" 119 UniqueViolation = "23505" 120 CheckViolation = "23514" 121 ExclusionViolation = "23P01" 122 // Class 24 - Invalid Cursor State 123 InvalidCursorState = "24000" 124 // Class 25 - Invalid Transaction State 125 InvalidTransactionState = "25000" 126 ActiveSQLTransaction = "25001" 127 BranchTransactionAlreadyActive = "25002" 128 HeldCursorRequiresSameIsolationLevel = "25008" 129 InappropriateAccessModeForBranchTransaction = "25003" 130 InappropriateIsolationLevelForBranchTransaction = "25004" 131 NoActiveSQLTransactionForBranchTransaction = "25005" 132 ReadOnlySQLTransaction = "25006" 133 SchemaAndDataStatementMixingNotSupported = "25007" 134 NoActiveSQLTransaction = "25P01" 135 InFailedSQLTransaction = "25P02" 136 // Class 26 - Invalid SQL Statement Name 137 InvalidSQLStatementName = "26000" 138 // Class 27 - Triggered Data Change Violation 139 TriggeredDataChangeViolation = "27000" 140 // Class 28 - Invalid Authorization Specification 141 InvalidAuthorizationSpecification = "28000" 142 InvalidPassword = "28P01" 143 // Class 2B - Dependent Privilege Descriptors Still Exist 144 DependentPrivilegeDescriptorsStillExist = "2B000" 145 DependentObjectsStillExist = "2BP01" 146 // Class 2D - Invalid Transaction Termination 147 InvalidTransactionTermination = "2D000" 148 // Class 2F - SQL Routine Exception 149 SQLRoutineException = "2F000" 150 RoutineExceptionFunctionExecutedNoReturnStatement = "2F005" 151 RoutineExceptionModifyingSQLDataNotPermitted = "2F002" 152 RoutineExceptionProhibitedSQLStatementAttempted = "2F003" 153 RoutineExceptionReadingSQLDataNotPermitted = "2F004" 154 // Class 34 - Invalid Cursor Name 155 InvalidCursorName = "34000" 156 // Class 38 - External Routine Exception 157 ExternalRoutineException = "38000" 158 ExternalRoutineContainingSQLNotPermitted = "38001" 159 ExternalRoutineModifyingSQLDataNotPermitted = "38002" 160 ExternalRoutineProhibitedSQLStatementAttempted = "38003" 161 ExternalRoutineReadingSQLDataNotPermitted = "38004" 162 // Class 39 - External Routine Invocation Exception 163 ExternalRoutineInvocationException = "39000" 164 ExternalRoutineInvalidSQLstateReturned = "39001" 165 ExternalRoutineNullValueNotAllowed = "39004" 166 ExternalRoutineTriggerProtocolViolated = "39P01" 167 ExternalRoutineSrfProtocolViolated = "39P02" 168 // Class 3B - Savepoint Exception 169 SavepointException = "3B000" 170 InvalidSavepointSpecification = "3B001" 171 // Class 3D - Invalid Catalog Name 172 InvalidCatalogName = "3D000" 173 // Class 3F - Invalid Schema Name 174 InvalidSchemaName = "3F000" 175 // Class 40 - Transaction Rollback 176 TransactionRollback = "40000" 177 TransactionIntegrityConstraintViolation = "40002" 178 SerializationFailure = "40001" 179 StatementCompletionUnknown = "40003" 180 DeadlockDetected = "40P01" 181 // Class 42 - Syntax or Access Rule Violation 182 SyntaxErrorOrAccessRuleViolation = "42000" 183 Syntax = "42601" 184 InsufficientPrivilege = "42501" 185 CannotCoerce = "42846" 186 Grouping = "42803" 187 Windowing = "42P20" 188 InvalidRecursion = "42P19" 189 InvalidForeignKey = "42830" 190 InvalidName = "42602" 191 NameTooLong = "42622" 192 ReservedName = "42939" 193 DatatypeMismatch = "42804" 194 IndeterminateDatatype = "42P18" 195 CollationMismatch = "42P21" 196 IndeterminateCollation = "42P22" 197 WrongObjectType = "42809" 198 UndefinedColumn = "42703" 199 UndefinedFunction = "42883" 200 UndefinedTable = "42P01" 201 UndefinedParameter = "42P02" 202 UndefinedObject = "42704" 203 DuplicateColumn = "42701" 204 DuplicateCursor = "42P03" 205 DuplicateDatabase = "42P04" 206 DuplicateFunction = "42723" 207 DuplicatePreparedStatement = "42P05" 208 DuplicateSchema = "42P06" 209 DuplicateRelation = "42P07" 210 DuplicateAlias = "42712" 211 DuplicateObject = "42710" 212 AmbiguousColumn = "42702" 213 AmbiguousFunction = "42725" 214 AmbiguousParameter = "42P08" 215 AmbiguousAlias = "42P09" 216 InvalidColumnReference = "42P10" 217 InvalidColumnDefinition = "42611" 218 InvalidCursorDefinition = "42P11" 219 InvalidDatabaseDefinition = "42P12" 220 InvalidFunctionDefinition = "42P13" 221 InvalidPreparedStatementDefinition = "42P14" 222 InvalidSchemaDefinition = "42P15" 223 InvalidTableDefinition = "42P16" 224 InvalidObjectDefinition = "42P17" 225 FileAlreadyExists = "42C01" 226 // Class 44 - WITH CHECK OPTION Violation 227 WithCheckOptionViolation = "44000" 228 // Class 53 - Insufficient Resources 229 InsufficientResources = "53000" 230 DiskFull = "53100" 231 OutOfMemory = "53200" 232 TooManyConnections = "53300" 233 ConfigurationLimitExceeded = "53400" 234 // Class 54 - Program Limit Exceeded 235 ProgramLimitExceeded = "54000" 236 StatementTooComplex = "54001" 237 TooManyColumns = "54011" 238 TooManyArguments = "54023" 239 // Class 55 - Object Not In Prerequisite State 240 ObjectNotInPrerequisiteState = "55000" 241 ObjectInUse = "55006" 242 CantChangeRuntimeParam = "55P02" 243 LockNotAvailable = "55P03" 244 // Class 57 - Operator Intervention 245 OperatorIntervention = "57000" 246 QueryCanceled = "57014" 247 AdminShutdown = "57P01" 248 CrashShutdown = "57P02" 249 CannotConnectNow = "57P03" 250 DatabaseDropped = "57P04" 251 // Class 58 - System 252 System = "58000" 253 Io = "58030" 254 UndefinedFile = "58P01" 255 DuplicateFile = "58P02" 256 // Class F0 - Configuration File Error 257 ConfigFile = "F0000" 258 LockFileExists = "F0001" 259 // Class HV - Foreign Data Wrapper (SQL/MED) 260 Fdw = "HV000" 261 FdwColumnNameNotFound = "HV005" 262 FdwDynamicParameterValueNeeded = "HV002" 263 FdwFunctionSequence = "HV010" 264 FdwInconsistentDescriptorInformation = "HV021" 265 FdwInvalidAttributeValue = "HV024" 266 FdwInvalidColumnName = "HV007" 267 FdwInvalidColumnNumber = "HV008" 268 FdwInvalidDataType = "HV004" 269 FdwInvalidDataTypeDescriptors = "HV006" 270 FdwInvalidDescriptorFieldIdentifier = "HV091" 271 FdwInvalidHandle = "HV00B" 272 FdwInvalidOptionIndex = "HV00C" 273 FdwInvalidOptionName = "HV00D" 274 FdwInvalidStringLengthOrBufferLength = "HV090" 275 FdwInvalidStringFormat = "HV00A" 276 FdwInvalidUseOfNullPointer = "HV009" 277 FdwTooManyHandles = "HV014" 278 FdwOutOfMemory = "HV001" 279 FdwNoSchemas = "HV00P" 280 FdwOptionNameNotFound = "HV00J" 281 FdwReplyHandle = "HV00K" 282 FdwSchemaNotFound = "HV00Q" 283 FdwTableNotFound = "HV00R" 284 FdwUnableToCreateExecution = "HV00L" 285 FdwUnableToCreateReply = "HV00M" 286 FdwUnableToEstablishConnection = "HV00N" 287 // Class P0 - PL/pgSQL Error 288 PLpgSQL = "P0000" 289 RaiseException = "P0001" 290 NoDataFound = "P0002" 291 TooManyRows = "P0003" 292 // Class XX - Internal Error 293 Internal = "XX000" 294 DataCorrupted = "XX001" 295 IndexCorrupted = "XX002" 296 ) 297 298 // The following errors are CockroachDB-specific. 299 300 const ( 301 // Uncategorized is used for errors that flow out to a client 302 // when there's no code known yet. 303 Uncategorized = "XXUUU" 304 305 // CCLRequired signals that a CCL binary is required to complete this 306 // task. 307 CCLRequired = "XXC01" 308 309 // CCLValidLicenseRequired signals that a valid CCL license is 310 // required to complete this task. 311 CCLValidLicenseRequired = "XXC02" 312 313 // TransactionCommittedWithSchemaChangeFailure signals that the 314 // non-DDL payload of a transaction was committed successfully but 315 // some DDL operation failed, without rolling back the rest of the 316 // transaction. 317 // 318 // We define a separate code instead of reusing a code from 319 // PostgreSQL (like StatementCompletionUnknown) because that makes 320 // it easier to document the error (this code only occurs in this 321 // particular situation) in a way that's unique to CockroachDB. 322 // 323 // We also use a "XX" code for this for several reasons: 324 // - it needs to override any other pg code set "underneath" in the cause. 325 // - it forces implementers of logic tests to be mindful about 326 // this situation. The logic test runner will remind the implementer 327 // that: 328 // serious error with code "XXA00" occurred; if expected, 329 // must use 'error pgcode XXA00 ...' 330 TransactionCommittedWithSchemaChangeFailure = "XXA00" 331 332 // Class 22C - Semantic errors in the structure of a SQL statement. 333 334 // ScalarOperationCannotRunWithoutFullSessionContext signals that an 335 // operator or built-in function was used that requires a full session 336 // context and thus cannot be run in a background job or away from the SQL 337 // gateway. 338 ScalarOperationCannotRunWithoutFullSessionContext = "22C01" 339 340 // Class 55C - Object Not In Prerequisite State (Cockroach extension) 341 342 // SchemaChangeOccurred signals that a DDL change to the targets of a 343 // CHANGEFEED has lead to its termination. If this error code is received 344 // the CHANGEFEED will have previously emitted a resolved timestamp which 345 // precedes the hlc timestamp of the relevant DDL transaction. 346 SchemaChangeOccurred = "55C01" 347 348 // NoPrimaryKey signals that a table descriptor is invalid because the table 349 // does not have a primary key. 350 NoPrimaryKey = "55C02" 351 352 // Class 58C - System errors related to CockroachDB node problems. 353 354 // RangeUnavailable signals that some data from the cluster cannot be 355 // accessed (e.g. because all replicas awol). 356 RangeUnavailable = "58C00" 357 // DeprecatedRangeUnavailable is code that we used for RangeUnavailable until 19.2. 358 // 20.1 needs to recognize it coming from 19.2 nodes. 359 // TODO(andrei): remove in 20.2. 360 DeprecatedRangeUnavailable = "XXC00" 361 362 // InternalConnectionFailure refers to a networking error encountered 363 // internally on a connection between different Cockroach nodes. 364 InternalConnectionFailure = "58C01" 365 // DeprecatedInternalConnectionFailure is code that we used for 366 // InternalConnectionFailure until 19.2. 367 // 20.1 needs to recognize it coming from 19.2 nodes. 368 // TODO(andrei): remove in 20.2. 369 DeprecatedInternalConnectionFailure = ConnectionFailure 370 )