{"id":"0c6fd7d6df167480","repo":"jackc/pgx","slug":"connection-is-not-read-only","errorCode":null,"errorMessage":"connection is not read only","messagePattern":"connection is not read only","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgconn/config.go","lineNumber":1059,"sourceCode":"\t}\n\n\tif string(result[0].Rows[0][0]) == \"on\" {\n\t\treturn errors.New(\"read only connection\")\n\t}\n\n\treturn nil\n}\n\n// ValidateConnectTargetSessionAttrsReadOnly is a ValidateConnectFunc that implements libpq compatible\n// target_session_attrs=read-only.\nfunc ValidateConnectTargetSessionAttrsReadOnly(ctx context.Context, pgConn *PgConn) error {\n\tresult, err := pgConn.Exec(ctx, \"show transaction_read_only\").ReadAll()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif string(result[0].Rows[0][0]) != \"on\" {\n\t\treturn errors.New(\"connection is not read only\")\n\t}\n\n\treturn nil\n}\n\n// ValidateConnectTargetSessionAttrsStandby is a ValidateConnectFunc that implements libpq compatible\n// target_session_attrs=standby.\nfunc ValidateConnectTargetSessionAttrsStandby(ctx context.Context, pgConn *PgConn) error {\n\tresult, err := pgConn.Exec(ctx, \"select pg_is_in_recovery()\").ReadAll()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif string(result[0].Rows[0][0]) != \"t\" {\n\t\treturn errors.New(\"server is not in hot standby mode\")\n\t}\n\n\treturn nil","sourceCodeStart":1041,"sourceCodeEnd":1077,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgconn/config.go#L1041-L1077","documentation":"Error \"connection is not read only\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgconn/config.go:1059 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}