{"record":{"id":"2246ad5bb36cf334","repo":"jackc/pgx","slug":"d-is-less-than-minimum-value-for-int4-2246ad","errorCode":null,"errorMessage":"%d is less than minimum value for Int4","messagePattern":"(.+?) is less than minimum value for Int4","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/zeronull/int.go","lineNumber":83,"sourceCode":"\t\treturn nil, nil\n\t}\n\treturn int64(src), nil\n}\n\ntype Int4 int32\n\n// SkipUnderlyingTypePlan implements the [pgtype.SkipUnderlyingTypePlanner] interface.\nfunc (Int4) SkipUnderlyingTypePlan() {}\n\n// ScanInt64 implements the [pgtype.Int64Scanner] interface.\nfunc (dst *Int4) ScanInt64(n pgtype.Int8) error {\n\tif !n.Valid {\n\t\t*dst = 0\n\t\treturn nil\n\t}\n\n\tif n.Int64 < math.MinInt32 {\n\t\treturn fmt.Errorf(\"%d is less than minimum value for Int4\", n.Int64)\n\t}\n\tif n.Int64 > math.MaxInt32 {\n\t\treturn fmt.Errorf(\"%d is greater than maximum value for Int4\", n.Int64)\n\t}\n\t*dst = Int4(n.Int64)\n\n\treturn nil\n}\n\n// Int64Value implements the [pgtype.Int64Valuer] interface.\nfunc (src Int4) Int64Value() (pgtype.Int8, error) {\n\tif src == 0 {\n\t\treturn pgtype.Int8{}, nil\n\t}\n\treturn pgtype.Int8{Int64: int64(src), Valid: true}, nil\n}\n\n// Scan implements the [database/sql.Scanner] interface.","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/zeronull/int.go#L65-L101","documentation":"ScanInt64 on zero-null Int4 fires when the incoming int64 is below math.MinInt32 and would wrap when stored in the int32-based type. The database value lies outside the range of the Go type and PostgreSQL integer.","triggerScenarios":"Thrown at pgtype/zeronull/int.go:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Switch the Go type to zero-null Int8 or plain int64","Alter the column to bigint","Clamp or reject out-of-range values in the query or schema"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}