I'm really having a difficult time debugging an issue using the pq.CopyIn pattern. I have used this pattern in a number of projects, and even within this project before without issue. Now when I try to load data it gives me
Extra data after last expected column
I tried digging into the source but I could not find anything helpful about why CopyIn and txn.Exec would return this error. The row which creates the issue seems more deterministic in the absence of txn.Rollback(), but with txn.Rollback() on error then it's totally random which row creates the issues.
If anyone has any insights on this error, ideas for debugging, or anything else I would appreciate all help here because I feel as though I am at a dead end on debugging this.
Version
pg version: v1.8.0
Code snippet
stmt, err := txn.Prepare(pq.CopyIn("DB_TABLE", "col_1", "col_2", "col_3", "col_4", "col_5", "col_6", "col_7", "col_8"))
if err != nil {
return err
}
for i, v := range rows {
if i > 0 {
_, err := stmt.Exec(inquiryId, v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7])
//fmt.Println(stmt)
if err != nil {
fmt.Printf("%v, size: %v\n", v, len(v))
txn.Rollback()
return err
}
}
}
Errorpq: extra data after last expected columnUpdate:
Syntax error solved this problem
I'm really having a difficult time debugging an issue using the pq.CopyIn pattern. I have used this pattern in a number of projects, and even within this project before without issue. Now when I try to load data it gives me
Extra data after last expected column
I tried digging into the source but I could not find anything helpful about why CopyIn and txn.Exec would return this error. The row which creates the issue seems more deterministic in the absence of txn.Rollback(), but with txn.Rollback() on error then it's totally random which row creates the issues. If anyone has any insights on this error, ideas for debugging, or anything else I would appreciate all help here because I feel as though I am at a dead end on debugging this. Version pg version: v1.8.0 Code snippetError
pq: extra data after last expected column
Update: Syntax error solved this problem