{"id":"8328e872bda375d1","repo":"jackc/pgx","slug":"read-only-connection","errorCode":null,"errorMessage":"read only connection","messagePattern":"read only connection","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgconn/config.go","lineNumber":1044,"sourceCode":"\treturn time.Duration(timeout) * time.Second, nil\n}\n\nfunc makeConnectTimeoutDialFunc(timeout time.Duration) DialFunc {\n\td := makeDefaultDialer()\n\td.Timeout = timeout\n\treturn d.DialContext\n}\n\n// ValidateConnectTargetSessionAttrsReadWrite is a ValidateConnectFunc that implements libpq compatible\n// target_session_attrs=read-write.\nfunc ValidateConnectTargetSessionAttrsReadWrite(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(\"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","sourceCodeStart":1026,"sourceCodeEnd":1062,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgconn/config.go#L1026-L1062","documentation":"Error \"read only connection\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgconn/config.go:1044 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}