yamlbase 0.7.2

A lightweight SQL server that serves YAML-defined tables over standard SQL protocols
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
/// PostgreSQL SQLSTATE error codes
/// Provides proper PostgreSQL error classification for better client compatibility
pub struct PostgresErrorCodes;

impl PostgresErrorCodes {
    /// Get SQLSTATE code for different error types
    pub fn get_sqlstate(error_type: &PostgresErrorType) -> &'static str {
        match error_type {
            // Class 00 — Successful Completion
            PostgresErrorType::Success => "00000",

            // Class 01 — Warning
            PostgresErrorType::Warning => "01000",
            PostgresErrorType::DynamicResultSetsReturned => "0100C",
            PostgresErrorType::ImplicitZeroBitPadding => "01008",
            PostgresErrorType::NullValueEliminatedInSetFunction => "01003",
            PostgresErrorType::PrivilegeNotGranted => "01007",
            PostgresErrorType::PrivilegeNotRevoked => "01006",
            PostgresErrorType::StringDataRightTruncationWarning => "01004",
            PostgresErrorType::DeprecatedFeature => "01P01",

            // Class 02 — No Data
            PostgresErrorType::NoData => "02000",
            PostgresErrorType::NoAdditionalDynamicResultSetsReturned => "02001",

            // Class 03 — SQL Statement Not Yet Complete
            PostgresErrorType::SqlStatementNotYetComplete => "03000",

            // Class 08 — Connection Exception
            PostgresErrorType::ConnectionException => "08000",
            PostgresErrorType::ConnectionDoesNotExist => "08003",
            PostgresErrorType::ConnectionFailure => "08006",
            PostgresErrorType::SqlclientUnableToEstablishSqlconnection => "08001",
            PostgresErrorType::SqlserverRejectedEstablishmentOfSqlconnection => "08004",
            PostgresErrorType::TransactionResolutionUnknown => "08007",
            PostgresErrorType::ProtocolViolation => "08P01",

            // Class 09 — Triggered Action Exception
            PostgresErrorType::TriggeredActionException => "09000",

            // Class 0A — Feature Not Supported
            PostgresErrorType::FeatureNotSupported => "0A000",

            // Class 0B — Invalid Transaction Initiation
            PostgresErrorType::InvalidTransactionInitiation => "0B000",

            // Class 0F — Locator Exception
            PostgresErrorType::LocatorException => "0F000",
            PostgresErrorType::InvalidLocatorSpecification => "0F001",

            // Class 0L — Invalid Grantor
            PostgresErrorType::InvalidGrantor => "0L000",
            PostgresErrorType::InvalidGrantOperation => "0LP01",

            // Class 0P — Invalid Role Specification
            PostgresErrorType::InvalidRoleSpecification => "0P000",

            // Class 0Z — Diagnostics Exception
            PostgresErrorType::DiagnosticsException => "0Z000",
            PostgresErrorType::StackedDiagnosticsAccessedWithoutActiveHandler => "0Z002",

            // Class 20 — Case Not Found
            PostgresErrorType::CaseNotFound => "20000",

            // Class 21 — Cardinality Violation
            PostgresErrorType::CardinalityViolation => "21000",

            // Class 22 — Data Exception
            PostgresErrorType::DataException => "22000",
            PostgresErrorType::ArraySubscriptError => "2202E",
            PostgresErrorType::CharacterNotInRepertoire => "22021",
            PostgresErrorType::DatetimeFieldOverflow => "22008",
            PostgresErrorType::DivisionByZero => "22012",
            PostgresErrorType::ErrorInAssignment => "22005",
            PostgresErrorType::EscapeCharacterConflict => "2200B",
            PostgresErrorType::IndicatorOverflow => "22022",
            PostgresErrorType::IntervalFieldOverflow => "22015",
            PostgresErrorType::InvalidArgumentForLogarithm => "2201E",
            PostgresErrorType::InvalidArgumentForNtileFunction => "22014",
            PostgresErrorType::InvalidArgumentForNthValueFunction => "22016",
            PostgresErrorType::InvalidArgumentForPowerFunction => "2201F",
            PostgresErrorType::InvalidArgumentForWidthBucketFunction => "2201G",
            PostgresErrorType::InvalidCharacterValueForCast => "22018",
            PostgresErrorType::InvalidDatetimeFormat => "22007",
            PostgresErrorType::InvalidEscapeCharacter => "22019",
            PostgresErrorType::InvalidEscapeOctet => "2200D",
            PostgresErrorType::InvalidEscapeSequence => "22025",
            PostgresErrorType::NonstandardUseOfEscapeCharacter => "22P06",
            PostgresErrorType::InvalidIndicatorParameterValue => "22010",
            PostgresErrorType::InvalidParameterValue => "22023",
            PostgresErrorType::InvalidRegularExpression => "2201B",
            PostgresErrorType::InvalidRowCountInLimitClause => "2201W",
            PostgresErrorType::InvalidRowCountInResultOffsetClause => "2201X",
            PostgresErrorType::InvalidTablesampleArgument => "2202H",
            PostgresErrorType::InvalidTablesampleRepeat => "2202G",
            PostgresErrorType::InvalidTimeZoneDisplacementValue => "22009",
            PostgresErrorType::InvalidUseOfEscapeCharacter => "2200C",
            PostgresErrorType::MostSpecificTypeMismatch => "2200G",
            PostgresErrorType::NullValueNotAllowed => "22004",
            PostgresErrorType::NullValueNoIndicatorParameter => "22002",
            PostgresErrorType::NumericValueOutOfRange => "22003",
            PostgresErrorType::SequenceGeneratorLimitExceeded => "2200H",
            PostgresErrorType::StringDataLengthMismatch => "22026",
            PostgresErrorType::StringDataRightTruncation => "22001",
            PostgresErrorType::SubstringError => "22011",
            PostgresErrorType::TrimError => "22027",
            PostgresErrorType::UnterminatedCString => "22024",
            PostgresErrorType::ZeroLengthCharacterString => "2200F",
            PostgresErrorType::FloatingPointException => "22P01",
            PostgresErrorType::InvalidTextRepresentation => "22P02",
            PostgresErrorType::InvalidBinaryRepresentation => "22P03",
            PostgresErrorType::BadCopyFileFormat => "22P04",
            PostgresErrorType::UntranslatableCharacter => "22P05",

            // Class 23 — Integrity Constraint Violation
            PostgresErrorType::IntegrityConstraintViolation => "23000",
            PostgresErrorType::RestrictViolation => "23001",
            PostgresErrorType::NotNullViolation => "23502",
            PostgresErrorType::ForeignKeyViolation => "23503",
            PostgresErrorType::UniqueViolation => "23505",
            PostgresErrorType::CheckViolation => "23514",
            PostgresErrorType::ExclusionViolation => "23P01",

            // Class 24 — Invalid Cursor State
            PostgresErrorType::InvalidCursorState => "24000",

            // Class 25 — Invalid Transaction State
            PostgresErrorType::InvalidTransactionState => "25000",
            PostgresErrorType::ActiveSqlTransaction => "25001",
            PostgresErrorType::BranchTransactionAlreadyActive => "25002",
            PostgresErrorType::HeldCursorRequiresSameIsolationLevel => "25008",
            PostgresErrorType::InappropriateAccessModeForBranchTransaction => "25003",
            PostgresErrorType::InappropriateIsolationLevelForBranchTransaction => "25004",
            PostgresErrorType::NoActiveSqlTransactionForBranchTransaction => "25005",
            PostgresErrorType::ReadOnlySqlTransaction => "25006",
            PostgresErrorType::SchemaAndDataStatementMixingNotSupported => "25007",
            PostgresErrorType::NoActiveSqlTransaction => "25P01",
            PostgresErrorType::InFailedSqlTransaction => "25P02",
            PostgresErrorType::IdleInTransactionSessionTimeout => "25P03",

            // Class 26 — Invalid SQL Statement Name
            PostgresErrorType::InvalidSqlStatementName => "26000",

            // Class 27 — Triggered Data Change Violation
            PostgresErrorType::TriggeredDataChangeViolation => "27000",

            // Class 28 — Invalid Authorization Specification
            PostgresErrorType::InvalidAuthorizationSpecification => "28000",
            PostgresErrorType::InvalidPassword => "28P01",

            // Class 2B — Dependent Privilege Descriptors Still Exist
            PostgresErrorType::DependentPrivilegeDescriptorsStillExist => "2B000",
            PostgresErrorType::DependentObjectsStillExist => "2BP01",

            // Class 2D — Invalid Transaction Termination
            PostgresErrorType::InvalidTransactionTermination => "2D000",

            // Class 2F — SQL Routine Exception
            PostgresErrorType::SqlRoutineException => "2F000",
            PostgresErrorType::FunctionExecutedNoReturnStatement => "2F005",
            PostgresErrorType::ModifyingSqlDataNotPermitted => "2F002",
            PostgresErrorType::ProhibitedSqlStatementAttempted => "2F003",
            PostgresErrorType::ReadingSqlDataNotPermitted => "2F004",

            // Class 34 — Invalid Cursor Name
            PostgresErrorType::InvalidCursorName => "34000",

            // Class 38 — External Routine Exception
            PostgresErrorType::ExternalRoutineException => "38000",
            PostgresErrorType::ContainingSqlNotPermitted => "38001",
            PostgresErrorType::ModifyingSqlDataNotPermittedExternal => "38002",
            PostgresErrorType::ProhibitedSqlStatementAttemptedExternal => "38003",
            PostgresErrorType::ReadingSqlDataNotPermittedExternal => "38004",

            // Class 39 — External Routine Invocation Exception
            PostgresErrorType::ExternalRoutineInvocationException => "39000",
            PostgresErrorType::InvalidSqlstateReturned => "39001",
            PostgresErrorType::NullValueNotAllowedExternal => "39004",
            PostgresErrorType::TriggerProtocolViolated => "39P01",
            PostgresErrorType::SrfProtocolViolated => "39P02",
            PostgresErrorType::EventTriggerProtocolViolated => "39P03",

            // Class 3B — Savepoint Exception
            PostgresErrorType::SavepointException => "3B000",
            PostgresErrorType::InvalidSavepointSpecification => "3B001",

            // Class 3D — Invalid Catalog Name
            PostgresErrorType::InvalidCatalogName => "3D000",

            // Class 3F — Invalid Schema Name
            PostgresErrorType::InvalidSchemaName => "3F000",

            // Class 40 — Transaction Rollback
            PostgresErrorType::TransactionRollback => "40000",
            PostgresErrorType::TransactionIntegrityConstraintViolation => "40002",
            PostgresErrorType::SerializationFailure => "40001",
            PostgresErrorType::StatementCompletionUnknown => "40003",
            PostgresErrorType::DeadlockDetected => "40P01",

            // Class 42 — Syntax Error or Access Rule Violation
            PostgresErrorType::SyntaxErrorOrAccessRuleViolation => "42000",
            PostgresErrorType::SyntaxError => "42601",
            PostgresErrorType::InsufficientPrivilege => "42501",
            PostgresErrorType::CannotCoerce => "42846",
            PostgresErrorType::GroupingError => "42803",
            PostgresErrorType::WindowingError => "42P20",
            PostgresErrorType::InvalidRecursion => "42P19",
            PostgresErrorType::InvalidForeignKey => "42830",
            PostgresErrorType::InvalidName => "42602",
            PostgresErrorType::NameTooLong => "42622",
            PostgresErrorType::ReservedName => "42939",
            PostgresErrorType::DatatypeMismatch => "42804",
            PostgresErrorType::IndeterminateDatatype => "42P18",
            PostgresErrorType::CollationMismatch => "42P21",
            PostgresErrorType::IndeterminateCollation => "42P22",
            PostgresErrorType::WrongObjectType => "42809",
            PostgresErrorType::GeneratedAlways => "428C9",
            PostgresErrorType::UndefinedColumn => "42703",
            PostgresErrorType::UndefinedFunction => "42883",
            PostgresErrorType::UndefinedTable => "42P01",
            PostgresErrorType::UndefinedParameter => "42P02",
            PostgresErrorType::UndefinedObject => "42704",
            PostgresErrorType::DuplicateColumn => "42701",
            PostgresErrorType::DuplicateCursor => "42P03",
            PostgresErrorType::DuplicateDatabase => "42P04",
            PostgresErrorType::DuplicateFunction => "42723",
            PostgresErrorType::DuplicatePreparedStatement => "42P05",
            PostgresErrorType::DuplicateSchema => "42P06",
            PostgresErrorType::DuplicateTable => "42P07",
            PostgresErrorType::DuplicateAlias => "42712",
            PostgresErrorType::DuplicateObject => "42710",
            PostgresErrorType::AmbiguousColumn => "42702",
            PostgresErrorType::AmbiguousFunction => "42725",
            PostgresErrorType::AmbiguousParameter => "42P08",
            PostgresErrorType::AmbiguousAlias => "42P09",
            PostgresErrorType::InvalidColumnReference => "42P10",
            PostgresErrorType::InvalidColumnDefinition => "42611",
            PostgresErrorType::InvalidCursorDefinition => "42P11",
            PostgresErrorType::InvalidDatabaseDefinition => "42P12",
            PostgresErrorType::InvalidFunctionDefinition => "42P13",
            PostgresErrorType::InvalidPreparedStatementDefinition => "42P14",
            PostgresErrorType::InvalidSchemaDefinition => "42P15",
            PostgresErrorType::InvalidTableDefinition => "42P16",
            PostgresErrorType::InvalidObjectDefinition => "42P17",

            // Class 44 — WITH CHECK OPTION Violation
            PostgresErrorType::WithCheckOptionViolation => "44000",

            // Class 53 — Insufficient Resources
            PostgresErrorType::InsufficientResources => "53000",
            PostgresErrorType::DiskFull => "53100",
            PostgresErrorType::OutOfMemory => "53200",
            PostgresErrorType::TooManyConnections => "53300",
            PostgresErrorType::ConfigurationLimitExceeded => "53400",

            // Class 54 — Program Limit Exceeded
            PostgresErrorType::ProgramLimitExceeded => "54000",
            PostgresErrorType::StatementTooComplex => "54001",
            PostgresErrorType::TooManyColumns => "54011",
            PostgresErrorType::TooManyArguments => "54023",

            // Class 55 — Object Not In Prerequisite State
            PostgresErrorType::ObjectNotInPrerequisiteState => "55000",
            PostgresErrorType::ObjectInUse => "55006",
            PostgresErrorType::CantChangeRuntimeParam => "55P02",
            PostgresErrorType::LockNotAvailable => "55P03",
            PostgresErrorType::UnsafeNewEnumValueUsage => "55P04",

            // Class 57 — Operator Intervention
            PostgresErrorType::OperatorIntervention => "57000",
            PostgresErrorType::QueryCanceled => "57014",
            PostgresErrorType::AdminShutdown => "57P01",
            PostgresErrorType::CrashShutdown => "57P02",
            PostgresErrorType::CannotConnectNow => "57P03",
            PostgresErrorType::DatabaseDropped => "57P04",

            // Class 58 — System Error
            PostgresErrorType::SystemError => "58000",
            PostgresErrorType::IoError => "58030",
            PostgresErrorType::UndefinedFile => "58P01",
            PostgresErrorType::DuplicateFile => "58P02",

            // Class 72 — Snapshot Failure
            PostgresErrorType::SnapshotTooOld => "72000",

            // Class F0 — Configuration File Error
            PostgresErrorType::ConfigFileError => "F0000",
            PostgresErrorType::LockFileExists => "F0001",

            // Class HV — Foreign Data Wrapper Error
            PostgresErrorType::FdwError => "HV000",
            PostgresErrorType::FdwColumnNameNotFound => "HV005",
            PostgresErrorType::FdwDynamicParameterValueNeeded => "HV002",
            PostgresErrorType::FdwFunctionSequenceError => "HV010",
            PostgresErrorType::FdwInconsistentDescriptorInformation => "HV021",
            PostgresErrorType::FdwInvalidAttributeValue => "HV024",
            PostgresErrorType::FdwInvalidColumnName => "HV007",
            PostgresErrorType::FdwInvalidColumnNumber => "HV008",
            PostgresErrorType::FdwInvalidDataType => "HV004",
            PostgresErrorType::FdwInvalidDataTypeDescriptors => "HV006",
            PostgresErrorType::FdwInvalidDescriptorFieldIdentifier => "HV091",
            PostgresErrorType::FdwInvalidHandle => "HV00B",
            PostgresErrorType::FdwInvalidOptionIndex => "HV00C",
            PostgresErrorType::FdwInvalidOptionName => "HV00D",
            PostgresErrorType::FdwInvalidStringLengthOrBufferLength => "HV090",
            PostgresErrorType::FdwInvalidStringFormat => "HV00A",
            PostgresErrorType::FdwInvalidUseOfNullPointer => "HV009",
            PostgresErrorType::FdwTooManyHandles => "HV014",
            PostgresErrorType::FdwOutOfMemory => "HV001",
            PostgresErrorType::FdwNoSchemas => "HV00P",
            PostgresErrorType::FdwOptionNameNotFound => "HV00J",
            PostgresErrorType::FdwReplyHandle => "HV00K",
            PostgresErrorType::FdwSchemaNotFound => "HV00Q",
            PostgresErrorType::FdwTableNotFound => "HV00R",
            PostgresErrorType::FdwUnableToCreateExecution => "HV00L",
            PostgresErrorType::FdwUnableToCreateReply => "HV00M",
            PostgresErrorType::FdwUnableToEstablishConnection => "HV00N",

            // Class P0 — PL/pgSQL Error
            PostgresErrorType::PlpgsqlError => "P0000",
            PostgresErrorType::RaiseException => "P0001",
            PostgresErrorType::NoDataFound => "P0002",
            PostgresErrorType::TooManyRows => "P0003",
            PostgresErrorType::AssertFailure => "P0004",

            // Class XX — Internal Error
            PostgresErrorType::InternalError => "XX000",
            PostgresErrorType::DataCorrupted => "XX001",
            PostgresErrorType::IndexCorrupted => "XX002",
        }
    }

    /// Get human-readable error message for SQLSTATE
    pub fn get_error_message(error_type: &PostgresErrorType) -> &'static str {
        match error_type {
            PostgresErrorType::Success => "successful completion",
            PostgresErrorType::SyntaxError => "syntax error",
            PostgresErrorType::UndefinedTable => "relation does not exist",
            PostgresErrorType::UndefinedColumn => "column does not exist",
            PostgresErrorType::UndefinedFunction => "function does not exist",
            PostgresErrorType::InsufficientPrivilege => "permission denied",
            PostgresErrorType::FeatureNotSupported => "feature not supported",
            PostgresErrorType::InvalidPassword => "password authentication failed",
            PostgresErrorType::ConnectionFailure => "connection failure",
            PostgresErrorType::ProtocolViolation => "protocol violation",
            PostgresErrorType::InternalError => "internal error",
            _ => "unknown error",
        }
    }
}

#[derive(Debug, Clone)]
pub enum PostgresErrorType {
    // Class 00 — Successful Completion
    Success,

    // Class 01 — Warning
    Warning,
    DynamicResultSetsReturned,
    ImplicitZeroBitPadding,
    NullValueEliminatedInSetFunction,
    PrivilegeNotGranted,
    PrivilegeNotRevoked,
    StringDataRightTruncationWarning,
    DeprecatedFeature,

    // Class 02 — No Data
    NoData,
    NoAdditionalDynamicResultSetsReturned,

    // Class 03 — SQL Statement Not Yet Complete
    SqlStatementNotYetComplete,

    // Class 08 — Connection Exception
    ConnectionException,
    ConnectionDoesNotExist,
    ConnectionFailure,
    SqlclientUnableToEstablishSqlconnection,
    SqlserverRejectedEstablishmentOfSqlconnection,
    TransactionResolutionUnknown,
    ProtocolViolation,

    // Class 09 — Triggered Action Exception
    TriggeredActionException,

    // Class 0A — Feature Not Supported
    FeatureNotSupported,

    // Class 0B — Invalid Transaction Initiation
    InvalidTransactionInitiation,

    // Class 0F — Locator Exception
    LocatorException,
    InvalidLocatorSpecification,

    // Class 0L — Invalid Grantor
    InvalidGrantor,
    InvalidGrantOperation,

    // Class 0P — Invalid Role Specification
    InvalidRoleSpecification,

    // Class 0Z — Diagnostics Exception
    DiagnosticsException,
    StackedDiagnosticsAccessedWithoutActiveHandler,

    // Class 20 — Case Not Found
    CaseNotFound,

    // Class 21 — Cardinality Violation
    CardinalityViolation,

    // Class 22 — Data Exception
    DataException,
    ArraySubscriptError,
    CharacterNotInRepertoire,
    DatetimeFieldOverflow,
    DivisionByZero,
    ErrorInAssignment,
    EscapeCharacterConflict,
    IndicatorOverflow,
    IntervalFieldOverflow,
    InvalidArgumentForLogarithm,
    InvalidArgumentForNtileFunction,
    InvalidArgumentForNthValueFunction,
    InvalidArgumentForPowerFunction,
    InvalidArgumentForWidthBucketFunction,
    InvalidCharacterValueForCast,
    InvalidDatetimeFormat,
    InvalidEscapeCharacter,
    InvalidEscapeOctet,
    InvalidEscapeSequence,
    NonstandardUseOfEscapeCharacter,
    InvalidIndicatorParameterValue,
    InvalidParameterValue,
    InvalidRegularExpression,
    InvalidRowCountInLimitClause,
    InvalidRowCountInResultOffsetClause,
    InvalidTablesampleArgument,
    InvalidTablesampleRepeat,
    InvalidTimeZoneDisplacementValue,
    InvalidUseOfEscapeCharacter,
    MostSpecificTypeMismatch,
    NullValueNotAllowed,
    NullValueNoIndicatorParameter,
    NumericValueOutOfRange,
    SequenceGeneratorLimitExceeded,
    StringDataLengthMismatch,
    StringDataRightTruncation,
    SubstringError,
    TrimError,
    UnterminatedCString,
    ZeroLengthCharacterString,
    FloatingPointException,
    InvalidTextRepresentation,
    InvalidBinaryRepresentation,
    BadCopyFileFormat,
    UntranslatableCharacter,

    // Class 23 — Integrity Constraint Violation
    IntegrityConstraintViolation,
    RestrictViolation,
    NotNullViolation,
    ForeignKeyViolation,
    UniqueViolation,
    CheckViolation,
    ExclusionViolation,

    // Class 24 — Invalid Cursor State
    InvalidCursorState,

    // Class 25 — Invalid Transaction State
    InvalidTransactionState,
    ActiveSqlTransaction,
    BranchTransactionAlreadyActive,
    HeldCursorRequiresSameIsolationLevel,
    InappropriateAccessModeForBranchTransaction,
    InappropriateIsolationLevelForBranchTransaction,
    NoActiveSqlTransactionForBranchTransaction,
    ReadOnlySqlTransaction,
    SchemaAndDataStatementMixingNotSupported,
    NoActiveSqlTransaction,
    InFailedSqlTransaction,
    IdleInTransactionSessionTimeout,

    // Class 26 — Invalid SQL Statement Name
    InvalidSqlStatementName,

    // Class 27 — Triggered Data Change Violation
    TriggeredDataChangeViolation,

    // Class 28 — Invalid Authorization Specification
    InvalidAuthorizationSpecification,
    InvalidPassword,

    // Class 2B — Dependent Privilege Descriptors Still Exist
    DependentPrivilegeDescriptorsStillExist,
    DependentObjectsStillExist,

    // Class 2D — Invalid Transaction Termination
    InvalidTransactionTermination,

    // Class 2F — SQL Routine Exception
    SqlRoutineException,
    FunctionExecutedNoReturnStatement,
    ModifyingSqlDataNotPermitted,
    ProhibitedSqlStatementAttempted,
    ReadingSqlDataNotPermitted,

    // Class 34 — Invalid Cursor Name
    InvalidCursorName,

    // Class 38 — External Routine Exception
    ExternalRoutineException,
    ContainingSqlNotPermitted,
    ModifyingSqlDataNotPermittedExternal,
    ProhibitedSqlStatementAttemptedExternal,
    ReadingSqlDataNotPermittedExternal,

    // Class 39 — External Routine Invocation Exception
    ExternalRoutineInvocationException,
    InvalidSqlstateReturned,
    NullValueNotAllowedExternal,
    TriggerProtocolViolated,
    SrfProtocolViolated,
    EventTriggerProtocolViolated,

    // Class 3B — Savepoint Exception
    SavepointException,
    InvalidSavepointSpecification,

    // Class 3D — Invalid Catalog Name
    InvalidCatalogName,

    // Class 3F — Invalid Schema Name
    InvalidSchemaName,

    // Class 40 — Transaction Rollback
    TransactionRollback,
    TransactionIntegrityConstraintViolation,
    SerializationFailure,
    StatementCompletionUnknown,
    DeadlockDetected,

    // Class 42 — Syntax Error or Access Rule Violation
    SyntaxErrorOrAccessRuleViolation,
    SyntaxError,
    InsufficientPrivilege,
    CannotCoerce,
    GroupingError,
    WindowingError,
    InvalidRecursion,
    InvalidForeignKey,
    InvalidName,
    NameTooLong,
    ReservedName,
    DatatypeMismatch,
    IndeterminateDatatype,
    CollationMismatch,
    IndeterminateCollation,
    WrongObjectType,
    GeneratedAlways,
    UndefinedColumn,
    UndefinedFunction,
    UndefinedTable,
    UndefinedParameter,
    UndefinedObject,
    DuplicateColumn,
    DuplicateCursor,
    DuplicateDatabase,
    DuplicateFunction,
    DuplicatePreparedStatement,
    DuplicateSchema,
    DuplicateTable,
    DuplicateAlias,
    DuplicateObject,
    AmbiguousColumn,
    AmbiguousFunction,
    AmbiguousParameter,
    AmbiguousAlias,
    InvalidColumnReference,
    InvalidColumnDefinition,
    InvalidCursorDefinition,
    InvalidDatabaseDefinition,
    InvalidFunctionDefinition,
    InvalidPreparedStatementDefinition,
    InvalidSchemaDefinition,
    InvalidTableDefinition,
    InvalidObjectDefinition,

    // Class 44 — WITH CHECK OPTION Violation
    WithCheckOptionViolation,

    // Class 53 — Insufficient Resources
    InsufficientResources,
    DiskFull,
    OutOfMemory,
    TooManyConnections,
    ConfigurationLimitExceeded,

    // Class 54 — Program Limit Exceeded
    ProgramLimitExceeded,
    StatementTooComplex,
    TooManyColumns,
    TooManyArguments,

    // Class 55 — Object Not In Prerequisite State
    ObjectNotInPrerequisiteState,
    ObjectInUse,
    CantChangeRuntimeParam,
    LockNotAvailable,
    UnsafeNewEnumValueUsage,

    // Class 57 — Operator Intervention
    OperatorIntervention,
    QueryCanceled,
    AdminShutdown,
    CrashShutdown,
    CannotConnectNow,
    DatabaseDropped,

    // Class 58 — System Error
    SystemError,
    IoError,
    UndefinedFile,
    DuplicateFile,

    // Class 72 — Snapshot Failure
    SnapshotTooOld,

    // Class F0 — Configuration File Error
    ConfigFileError,
    LockFileExists,

    // Class HV — Foreign Data Wrapper Error
    FdwError,
    FdwColumnNameNotFound,
    FdwDynamicParameterValueNeeded,
    FdwFunctionSequenceError,
    FdwInconsistentDescriptorInformation,
    FdwInvalidAttributeValue,
    FdwInvalidColumnName,
    FdwInvalidColumnNumber,
    FdwInvalidDataType,
    FdwInvalidDataTypeDescriptors,
    FdwInvalidDescriptorFieldIdentifier,
    FdwInvalidHandle,
    FdwInvalidOptionIndex,
    FdwInvalidOptionName,
    FdwInvalidStringLengthOrBufferLength,
    FdwInvalidStringFormat,
    FdwInvalidUseOfNullPointer,
    FdwTooManyHandles,
    FdwOutOfMemory,
    FdwNoSchemas,
    FdwOptionNameNotFound,
    FdwReplyHandle,
    FdwSchemaNotFound,
    FdwTableNotFound,
    FdwUnableToCreateExecution,
    FdwUnableToCreateReply,
    FdwUnableToEstablishConnection,

    // Class P0 — PL/pgSQL Error
    PlpgsqlError,
    RaiseException,
    NoDataFound,
    TooManyRows,
    AssertFailure,

    // Class XX — Internal Error
    InternalError,
    DataCorrupted,
    IndexCorrupted,
}