Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -384,16 +384,32 @@ func handleUserDelete(db *sql.DB, w http.ResponseWriter, r *http.Request, userID
|
||||
return false
|
||||
}
|
||||
|
||||
for _, q := range cleanupQueries {
|
||||
for i, q := range cleanupQueries {
|
||||
sp := fmt.Sprintf("sp_user_cleanup_%d", i)
|
||||
_, _ = tx.Exec("SAVEPOINT " + sp)
|
||||
|
||||
if _, err := tx.Exec(q, userID); err != nil {
|
||||
// rollback the failed statement so tx can continue
|
||||
_, _ = tx.Exec("ROLLBACK TO SAVEPOINT " + sp)
|
||||
|
||||
if isUndefinedTable(err) {
|
||||
log.Printf("⚠️ [UserDetail] cleanup skipped (table missing) user_id=%d query=%s", userID, q)
|
||||
_, _ = tx.Exec("RELEASE SAVEPOINT " + sp)
|
||||
continue
|
||||
}
|
||||
log.Printf("❌ [UserDetail] cleanup failed user_id=%d err=%v query=%s", userID, err, q)
|
||||
if pe, ok := err.(*pq.Error); ok {
|
||||
log.Printf(
|
||||
"❌ [UserDetail] cleanup failed user_id=%d code=%s detail=%s constraint=%s table=%s err=%v query=%s",
|
||||
userID, pe.Code, pe.Detail, pe.Constraint, pe.Table, err, q,
|
||||
)
|
||||
} else {
|
||||
log.Printf("❌ [UserDetail] cleanup failed user_id=%d err=%v query=%s", userID, err, q)
|
||||
}
|
||||
http.Error(w, "Kullanici baglantilari silinemedi", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
_, _ = tx.Exec("RELEASE SAVEPOINT " + sp)
|
||||
}
|
||||
|
||||
if _, err := tx.Exec(`DELETE FROM mk_dfusr WHERE id = $1`, userID); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user