{"id":"7f0521229c7ee3e4","repo":"jackc/pgx","slug":"rewrite-query-failed-w","errorCode":null,"errorMessage":"rewrite query failed: %w","messagePattern":"rewrite query failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"conn.go","lineNumber":515,"sourceCode":"\noptionLoop:\n\tfor len(arguments) > 0 {\n\t\tswitch arg := arguments[0].(type) {\n\t\tcase QueryExecMode:\n\t\t\tmode = arg\n\t\t\targuments = arguments[1:]\n\t\tcase QueryRewriter:\n\t\t\tqueryRewriter = arg\n\t\t\targuments = arguments[1:]\n\t\tdefault:\n\t\t\tbreak optionLoop\n\t\t}\n\t}\n\n\tif queryRewriter != nil {\n\t\tsql, arguments, err = queryRewriter.RewriteQuery(ctx, c, sql, arguments)\n\t\tif err != nil {\n\t\t\treturn pgconn.CommandTag{}, fmt.Errorf(\"rewrite query failed: %w\", err)\n\t\t}\n\t}\n\n\t// Always use simple protocol when there are no arguments.\n\tif len(arguments) == 0 {\n\t\tmode = QueryExecModeSimpleProtocol\n\t}\n\n\tdefer func() {\n\t\tif err != nil {\n\t\t\tif sc := c.statementCache; sc != nil {\n\t\t\t\tsc.Invalidate(sql)\n\t\t\t}\n\n\t\t\tif sc := c.descriptionCache; sc != nil {\n\t\t\t\tsc.Invalidate(sql)\n\t\t\t}\n\t\t}","sourceCodeStart":497,"sourceCodeEnd":533,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/conn.go#L497-L533","documentation":"Error \"rewrite query failed: %w\" thrown in jackc/pgx.","triggerScenarios":"Thrown at conn.go:515 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}