{
  "id": "go/database-sql-rows-iteration-error-after-close",
  "signature": "error: sql: Rows are closed",
  "signature_zh": "错误：sql：结果集已关闭",
  "regex": "error:\\ sql:\\ Rows\\ are\\ closed",
  "domain": "go",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Attempting to iterate over database/sql Rows after they have been closed, typically due to premature defer row.Close() or double iteration.",
  "root_cause_type": "generic",
  "root_cause_zh": "在结果集关闭后尝试迭代，通常由于过早调用 defer row.Close() 或重复迭代。",
  "versions": [
    {
      "version": "1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Calling rows.Close() at beginning of function",
      "why_fails": "Deferring Close before iteration closes rows prematurely, causing 'Rows are closed' error on Next().",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Defer rows.Close() after checking error and before iteration, but ensure iteration completes before close",
      "success_rate": 0.95,
      "how": "rows, err := db.QueryContext(ctx, query)\nif err != nil { return err }\ndefer rows.Close()\nfor rows.Next() { /* process */ }\nif err = rows.Err(); err != nil { return err }",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}