{"record":{"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":"CopyFrom failed to obtain the statement description (column list and OIDs) for the generated 'select ... from ...' query used to set up the COPY operation. The wrapped error carries the underlying cause from getStatementDescription.","triggerScenarios":"Thrown at copy_from.go:155 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Unwrap the error to find the underlying prepare/describe failure (permissions, syntax, missing table)","Verify the table and column names passed to CopyFrom are correct and quoted properly","Check the connecting role has SELECT access on the target table"],"exampleFix":null,"handlingStrategy":"try-catch","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"}