Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultRetryConnectAttempts = 10 DefaultRetryConnectDelay = time.Second * 3 DefaultMaxOpenConns = 15 DefaultMaxIdleConns = 15 DefaultConnMaxLifetime = time.Minute * 5 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrorCode ¶
type ErrorCode string
ErrorCode is a Postgres error code.
const ( Err00000 ErrorCode = "00000" // SuccessfulCompletion Err01000 ErrorCode = "01000" // Warning Err0100C ErrorCode = "0100C" // DynamicResultSetsReturned Err01008 ErrorCode = "01008" // ImplicitZeroBitPadding Err01003 ErrorCode = "01003" // NullValueEliminatedInSetFunction Err01007 ErrorCode = "01007" // PrivilegeNotGranted Err01006 ErrorCode = "01006" // PrivilegeNotRevoked Err01004 ErrorCode = "01004" // StringDataRightTruncation Err01P01 ErrorCode = "01P01" // DeprecatedFeature Err02000 ErrorCode = "02000" // NoData Err02001 ErrorCode = "02001" // NoAdditionalDynamicResultSetsReturned Err03000 ErrorCode = "03000" // SqlStatementNotYetComplete Err08000 ErrorCode = "08000" // ConnectionException Err08003 ErrorCode = "08003" // ConnectionDoesNotExist Err08006 ErrorCode = "08006" // ConnectionFailure Err08001 ErrorCode = "08001" // SqlclientUnableToEstablishSqlconnection Err08004 ErrorCode = "08004" // SqlserverRejectedEstablishmentOfSqlconnection Err08007 ErrorCode = "08007" // TransactionResolutionUnknown Err08P01 ErrorCode = "08P01" // ProtocolViolation Err09000 ErrorCode = "09000" // TriggeredActionException Err0A000 ErrorCode = "0A000" // FeatureNotSupported Err0B000 ErrorCode = "0B000" // InvalidTransactionInitiation Err0F000 ErrorCode = "0F000" // LocatorException Err0F001 ErrorCode = "0F001" // InvalidLocatorSpecification Err0L000 ErrorCode = "0L000" // InvalidGrantor Err0LP01 ErrorCode = "0LP01" // InvalidGrantOperation Err0P000 ErrorCode = "0P000" // InvalidRoleSpecification Err0Z000 ErrorCode = "0Z000" // DiagnosticsException Err0Z002 ErrorCode = "0Z002" // StackedDiagnosticsAccessedWithoutActiveHandler Err20000 ErrorCode = "20000" // CaseNotFound Err21000 ErrorCode = "21000" // CardinalityViolation Err22000 ErrorCode = "22000" // DataException Err2202E ErrorCode = "2202E" // ArraySubscriptError Err22021 ErrorCode = "22021" // CharacterNotInRepertoire Err22008 ErrorCode = "22008" // DatetimeFieldOverflow Err22012 ErrorCode = "22012" // DivisionByZero Err22005 ErrorCode = "22005" // ErrorInAssignment Err2200B ErrorCode = "2200B" // EscapeCharacterConflict Err22022 ErrorCode = "22022" // IndicatorOverflow Err22015 ErrorCode = "22015" // IntervalFieldOverflow Err2201E ErrorCode = "2201E" // InvalidArgumentForLogarithm Err22014 ErrorCode = "22014" // InvalidArgumentForNtileFunction Err22016 ErrorCode = "22016" // InvalidArgumentForNthValueFunction Err2201F ErrorCode = "2201F" // InvalidArgumentForPowerFunction Err2201G ErrorCode = "2201G" // InvalidArgumentForWidthBucketFunction Err22018 ErrorCode = "22018" // InvalidCharacterValueForCast Err22007 ErrorCode = "22007" // InvalidDatetimeFormat Err22019 ErrorCode = "22019" // InvalidEscapeCharacter Err2200D ErrorCode = "2200D" // InvalidEscapeOctet Err22025 ErrorCode = "22025" // InvalidEscapeSequence Err22P06 ErrorCode = "22P06" // NonstandardUseOfEscapeCharacter Err22010 ErrorCode = "22010" // InvalidIndicatorParameterValue Err22023 ErrorCode = "22023" // InvalidParameterValue Err22013 ErrorCode = "22013" // InvalidPrecedingOrFollowingSize Err2201B ErrorCode = "2201B" // InvalidRegularExpression Err2201W ErrorCode = "2201W" // InvalidRowCountInLimitClause Err2201X ErrorCode = "2201X" // InvalidRowCountInResultOffsetClause Err2202H ErrorCode = "2202H" // InvalidTablesampleArgument Err2202G ErrorCode = "2202G" // InvalidTablesampleRepeat Err22009 ErrorCode = "22009" // InvalidTimeZoneDisplacementValue Err2200C ErrorCode = "2200C" // InvalidUseOfEscapeCharacter Err2200G ErrorCode = "2200G" // MostSpecificTypeMismatch Err22004 ErrorCode = "22004" // NullValueNotAllowed Err22002 ErrorCode = "22002" // NullValueNoIndicatorParameter Err22003 ErrorCode = "22003" // NumericValueOutOfRange Err2200H ErrorCode = "2200H" // SequenceGeneratorLimitExceeded Err22026 ErrorCode = "22026" // StringDataLengthMismatch Err22001 ErrorCode = "22001" // StringDataRightTruncation Err22011 ErrorCode = "22011" // SubstringError Err22027 ErrorCode = "22027" // TrimError Err22024 ErrorCode = "22024" // UnterminatedCString Err2200F ErrorCode = "2200F" // ZeroLengthCharacterString Err22P01 ErrorCode = "22P01" // FloatingPointException Err22P02 ErrorCode = "22P02" // InvalidTextRepresentation Err22P03 ErrorCode = "22P03" // InvalidBinaryRepresentation Err22P04 ErrorCode = "22P04" // BadCopyFileFormat Err22P05 ErrorCode = "22P05" // UntranslatableCharacter Err2200L ErrorCode = "2200L" // NotAnXmlDocument Err2200M ErrorCode = "2200M" // InvalidXmlDocument Err2200N ErrorCode = "2200N" // InvalidXmlContent Err2200S ErrorCode = "2200S" // InvalidXmlComment Err2200T ErrorCode = "2200T" // InvalidXmlProcessingInstruction Err22030 ErrorCode = "22030" // DuplicateJsonObjectKeyValue Err22031 ErrorCode = "22031" // InvalidArgumentForSqlJsonDatetimeFunction Err22032 ErrorCode = "22032" // InvalidJsonText Err22033 ErrorCode = "22033" // InvalidSqlJsonSubscript Err22034 ErrorCode = "22034" // MoreThanOneSqlJsonItem Err22035 ErrorCode = "22035" // NoSqlJsonItem Err22036 ErrorCode = "22036" // NonNumericSqlJsonItem Err22037 ErrorCode = "22037" // NonUniqueKeysInAJsonObject Err22038 ErrorCode = "22038" // SingletonSqlJsonItemRequired Err22039 ErrorCode = "22039" // SqlJsonArrayNotFound Err2203A ErrorCode = "2203A" // SqlJsonMemberNotFound Err2203B ErrorCode = "2203B" // SqlJsonNumberNotFound Err2203C ErrorCode = "2203C" // SqlJsonObjectNotFound Err2203D ErrorCode = "2203D" // TooManyJsonArrayElements Err2203E ErrorCode = "2203E" // TooManyJsonObjectMembers Err2203F ErrorCode = "2203F" // SqlJsonScalarRequired Err2203G ErrorCode = "2203G" // SqlJsonItemCannotBeCastToTargetType Err23000 ErrorCode = "23000" // IntegrityConstraintViolation Err23001 ErrorCode = "23001" // RestrictViolation Err23502 ErrorCode = "23502" // NotNullViolation Err23503 ErrorCode = "23503" // ForeignKeyViolation Err23505 ErrorCode = "23505" // UniqueViolation Err23514 ErrorCode = "23514" // CheckViolation Err23P01 ErrorCode = "23P01" // ExclusionViolation Err24000 ErrorCode = "24000" // InvalidCursorState Err25000 ErrorCode = "25000" // InvalidTransactionState Err25001 ErrorCode = "25001" // ActiveSqlTransaction Err25002 ErrorCode = "25002" // BranchTransactionAlreadyActive Err25008 ErrorCode = "25008" // HeldCursorRequiresSameIsolationLevel Err25003 ErrorCode = "25003" // InappropriateAccessModeForBranchTransaction Err25004 ErrorCode = "25004" // InappropriateIsolationLevelForBranchTransaction Err25005 ErrorCode = "25005" // NoActiveSqlTransactionForBranchTransaction Err25006 ErrorCode = "25006" // ReadOnlySqlTransaction Err25007 ErrorCode = "25007" // SchemaAndDataStatementMixingNotSupported Err25P01 ErrorCode = "25P01" // NoActiveSqlTransaction Err25P02 ErrorCode = "25P02" // InFailedSqlTransaction Err25P03 ErrorCode = "25P03" // IdleInTransactionSessionTimeout Err26000 ErrorCode = "26000" // InvalidSqlStatementName Err27000 ErrorCode = "27000" // TriggeredDataChangeViolation Err28000 ErrorCode = "28000" // InvalidAuthorizationSpecification Err28P01 ErrorCode = "28P01" // InvalidPassword Err2B000 ErrorCode = "2B000" // DependentPrivilegeDescriptorsStillExist Err2BP01 ErrorCode = "2BP01" // DependentObjectsStillExist Err2D000 ErrorCode = "2D000" // InvalidTransactionTermination Err2F000 ErrorCode = "2F000" // SqlRoutineException Err2F005 ErrorCode = "2F005" // FunctionExecutedNoReturnStatement Err2F002 ErrorCode = "2F002" // ModifyingSqlDataNotPermitted Err2F003 ErrorCode = "2F003" // ProhibitedSqlStatementAttempted Err2F004 ErrorCode = "2F004" // ReadingSqlDataNotPermitted Err34000 ErrorCode = "34000" // InvalidCursorName Err38000 ErrorCode = "38000" // ExternalRoutineException Err38001 ErrorCode = "38001" // ContainingSqlNotPermitted Err38002 ErrorCode = "38002" // ModifyingSqlDataNotPermitted Err38003 ErrorCode = "38003" // ProhibitedSqlStatementAttempted Err38004 ErrorCode = "38004" // ReadingSqlDataNotPermitted Err39000 ErrorCode = "39000" // ExternalRoutineInvocationException Err39001 ErrorCode = "39001" // InvalidSqlstateReturned Err39004 ErrorCode = "39004" // NullValueNotAllowed Err39P01 ErrorCode = "39P01" // TriggerProtocolViolated Err39P02 ErrorCode = "39P02" // SrfProtocolViolated Err39P03 ErrorCode = "39P03" // EventTriggerProtocolViolated Err3B000 ErrorCode = "3B000" // SavepointException Err3B001 ErrorCode = "3B001" // InvalidSavepointSpecification Err3D000 ErrorCode = "3D000" // InvalidCatalogName Err3F000 ErrorCode = "3F000" // InvalidSchemaName Err40000 ErrorCode = "40000" // TransactionRollback Err40002 ErrorCode = "40002" // TransactionIntegrityConstraintViolation Err40001 ErrorCode = "40001" // SerializationFailure Err40003 ErrorCode = "40003" // StatementCompletionUnknown Err40P01 ErrorCode = "40P01" // DeadlockDetected Err42000 ErrorCode = "42000" // SyntaxErrorOrAccessRuleViolation Err42601 ErrorCode = "42601" // SyntaxError Err42501 ErrorCode = "42501" // InsufficientPrivilege Err42846 ErrorCode = "42846" // CannotCoerce Err42803 ErrorCode = "42803" // GroupingError Err42P20 ErrorCode = "42P20" // WindowingError Err42P19 ErrorCode = "42P19" // InvalidRecursion Err42830 ErrorCode = "42830" // InvalidForeignKey Err42602 ErrorCode = "42602" // InvalidName Err42622 ErrorCode = "42622" // NameTooLong Err42939 ErrorCode = "42939" // ReservedName Err42804 ErrorCode = "42804" // DatatypeMismatch Err42P18 ErrorCode = "42P18" // IndeterminateDatatype Err42P21 ErrorCode = "42P21" // CollationMismatch Err42P22 ErrorCode = "42P22" // IndeterminateCollation Err42809 ErrorCode = "42809" // WrongObjectType Err428C9 ErrorCode = "428C9" // GeneratedAlways Err42703 ErrorCode = "42703" // UndefinedColumn Err42883 ErrorCode = "42883" // UndefinedFunction Err42P01 ErrorCode = "42P01" // UndefinedTable Err42P02 ErrorCode = "42P02" // UndefinedParameter Err42704 ErrorCode = "42704" // UndefinedObject Err42701 ErrorCode = "42701" // DuplicateColumn Err42P03 ErrorCode = "42P03" // DuplicateCursor Err42P04 ErrorCode = "42P04" // DuplicateDatabase Err42723 ErrorCode = "42723" // DuplicateFunction Err42P05 ErrorCode = "42P05" // DuplicatePreparedStatement Err42P06 ErrorCode = "42P06" // DuplicateSchema Err42P07 ErrorCode = "42P07" // DuplicateTable Err42712 ErrorCode = "42712" // DuplicateAlias Err42710 ErrorCode = "42710" // DuplicateObject Err42702 ErrorCode = "42702" // AmbiguousColumn Err42725 ErrorCode = "42725" // AmbiguousFunction Err42P08 ErrorCode = "42P08" // AmbiguousParameter Err42P09 ErrorCode = "42P09" // AmbiguousAlias Err42P10 ErrorCode = "42P10" // InvalidColumnReference Err42611 ErrorCode = "42611" // InvalidColumnDefinition Err42P11 ErrorCode = "42P11" // InvalidCursorDefinition Err42P12 ErrorCode = "42P12" // InvalidDatabaseDefinition Err42P13 ErrorCode = "42P13" // InvalidFunctionDefinition Err42P14 ErrorCode = "42P14" // InvalidPreparedStatementDefinition Err42P15 ErrorCode = "42P15" // InvalidSchemaDefinition Err42P16 ErrorCode = "42P16" // InvalidTableDefinition Err42P17 ErrorCode = "42P17" // InvalidObjectDefinition Err44000 ErrorCode = "44000" // WithCheckOptionViolation Err53000 ErrorCode = "53000" // InsufficientResources Err53100 ErrorCode = "53100" // DiskFull Err53200 ErrorCode = "53200" // OutOfMemory Err53300 ErrorCode = "53300" // TooManyConnections Err53400 ErrorCode = "53400" // ConfigurationLimitExceeded Err54000 ErrorCode = "54000" // ProgramLimitExceeded Err54001 ErrorCode = "54001" // StatementTooComplex Err54011 ErrorCode = "54011" // TooManyColumns Err54023 ErrorCode = "54023" // TooManyArguments Err55000 ErrorCode = "55000" // ObjectNotInPrerequisiteState Err55006 ErrorCode = "55006" // ObjectInUse Err55P02 ErrorCode = "55P02" // CantChangeRuntimeParam Err55P03 ErrorCode = "55P03" // LockNotAvailable Err55P04 ErrorCode = "55P04" // UnsafeNewEnumValueUsage Err57000 ErrorCode = "57000" // OperatorIntervention Err57014 ErrorCode = "57014" // QueryCanceled Err57P01 ErrorCode = "57P01" // AdminShutdown Err57P02 ErrorCode = "57P02" // CrashShutdown Err57P03 ErrorCode = "57P03" // CannotConnectNow Err57P04 ErrorCode = "57P04" // DatabaseDropped Err57P05 ErrorCode = "57P05" // IdleSessionTimeout Err58000 ErrorCode = "58000" // SystemError Err58030 ErrorCode = "58030" // IoError Err58P01 ErrorCode = "58P01" // UndefinedFile Err58P02 ErrorCode = "58P02" // DuplicateFile Err72000 ErrorCode = "72000" // SnapshotTooOld ErrF0000 ErrorCode = "F0000" // ConfigFileError ErrF0001 ErrorCode = "F0001" // LockFileExists ErrHV000 ErrorCode = "HV000" // FdwError ErrHV005 ErrorCode = "HV005" // FdwColumnNameNotFound ErrHV002 ErrorCode = "HV002" // FdwDynamicParameterValueNeeded ErrHV010 ErrorCode = "HV010" // FdwFunctionSequenceError ErrHV021 ErrorCode = "HV021" // FdwInconsistentDescriptorInformation ErrHV024 ErrorCode = "HV024" // FdwInvalidAttributeValue ErrHV007 ErrorCode = "HV007" // FdwInvalidColumnName ErrHV008 ErrorCode = "HV008" // FdwInvalidColumnNumber ErrHV004 ErrorCode = "HV004" // FdwInvalidDataType ErrHV006 ErrorCode = "HV006" // FdwInvalidDataTypeDescriptors ErrHV091 ErrorCode = "HV091" // FdwInvalidDescriptorFieldIdentifier ErrHV00B ErrorCode = "HV00B" // FdwInvalidHandle ErrHV00C ErrorCode = "HV00C" // FdwInvalidOptionIndex ErrHV00D ErrorCode = "HV00D" // FdwInvalidOptionName ErrHV090 ErrorCode = "HV090" // FdwInvalidStringLengthOrBufferLength ErrHV00A ErrorCode = "HV00A" // FdwInvalidStringFormat ErrHV009 ErrorCode = "HV009" // FdwInvalidUseOfNullPointer ErrHV014 ErrorCode = "HV014" // FdwTooManyHandles ErrHV001 ErrorCode = "HV001" // FdwOutOfMemory ErrHV00P ErrorCode = "HV00P" // FdwNoSchemas ErrHV00J ErrorCode = "HV00J" // FdwOptionNameNotFound ErrHV00K ErrorCode = "HV00K" // FdwReplyHandle ErrHV00Q ErrorCode = "HV00Q" // FdwSchemaNotFound ErrHV00R ErrorCode = "HV00R" // FdwTableNotFound ErrHV00L ErrorCode = "HV00L" // FdwUnableToCreateExecution ErrHV00M ErrorCode = "HV00M" // FdwUnableToCreateReply ErrHV00N ErrorCode = "HV00N" // FdwUnableToEstablishConnection ErrP0000 ErrorCode = "P0000" // PlpgsqlError ErrP0001 ErrorCode = "P0001" // RaiseException ErrP0002 ErrorCode = "P0002" // NoDataFound ErrP0003 ErrorCode = "P0003" // TooManyRows ErrP0004 ErrorCode = "P0004" // AssertFailure ErrXX000 ErrorCode = "XX000" // InternalError ErrXX001 ErrorCode = "XX001" // DataCorrupted ErrXX002 ErrorCode = "XX002" // IndexCorrupted )
type SQLConn ¶
SQLConn is a wrapper around sql.DB that uses pgx driver under the hood.
func NewSQLConn ¶
func NewSQLConn(ctx context.Context, cfg SQLConnConfig) (*SQLConn, error)
NewSQLConn creates and returns a new postgres connection. The function ensures that the connection is established correctly by send a ping request to the database.
Click to show internal directories.
Click to hide internal directories.