{"id":"5c57124c15289195","repo":"jackc/pgx","slug":"statement-description-failed-w","errorCode":null,"errorMessage":"statement description failed: %w","messagePattern":"statement description failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"copy_from.go","lineNumber":155,"sourceCode":"\tswitch ct.mode {\n\tcase QueryExecModeExec, QueryExecModeSimpleProtocol:\n\t\t// These modes don't support the binary format. Before the inclusion of the\n\t\t// QueryExecModes, Conn.Prepare was called on every COPY operation to get\n\t\t// the OIDs. These prepared statements were not cached.\n\t\t//\n\t\t// Since that's the same behavior provided by QueryExecModeDescribeExec,\n\t\t// we'll default to that mode.\n\t\tct.mode = QueryExecModeDescribeExec\n\t\tfallthrough\n\tcase QueryExecModeCacheStatement, QueryExecModeCacheDescribe, QueryExecModeDescribeExec:\n\t\tvar err error\n\t\tsd, err = ct.conn.getStatementDescription(\n\t\t\tctx,\n\t\t\tct.mode,\n\t\t\tfmt.Sprintf(\"select %s from %s\", quotedColumnNames, quotedTableName),\n\t\t)\n\t\tif err != nil {\n\t\t\treturn 0, fmt.Errorf(\"statement description failed: %w\", err)\n\t\t}\n\tdefault:\n\t\treturn 0, fmt.Errorf(\"unknown QueryExecMode: %v\", ct.mode)\n\t}\n\n\tr, w := io.Pipe()\n\tdoneChan := make(chan struct{})\n\n\tgo func() {\n\t\tdefer close(doneChan)\n\n\t\t// Purposely NOT using defer w.Close(). See https://github.com/golang/go/issues/24283.\n\t\tbuf := ct.conn.wbuf\n\n\t\tbuf = append(buf, \"PGCOPY\\n\\377\\r\\n\\000\"...)\n\t\tbuf = pgio.AppendInt32(buf, 0)\n\t\tbuf = pgio.AppendInt32(buf, 0)\n","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/copy_from.go#L137-L173","documentation":"Error \"statement description failed: %w\" thrown in jackc/pgx.","triggerScenarios":"Thrown at copy_from.go:155 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}