(query string, execErr error, sqlTxActive *atomic.Bool)
| 33 | } |
| 34 | |
| 35 | func trackSQLTransactionState(query string, execErr error, sqlTxActive *atomic.Bool) { |
| 36 | upper := strings.ToUpper(stripLeadingSQLComments(query)) |
| 37 | if len(upper) == 0 { |
| 38 | return |
| 39 | } |
| 40 | if isTransactionStartStmt(upper) { |
| 41 | if execErr == nil { |
| 42 | sqlTxActive.Store(true) |
| 43 | } |
| 44 | return |
| 45 | } |
| 46 | if isTransactionControlStmt(upper) { |
| 47 | if execErr == nil { |
| 48 | sqlTxActive.Store(false) |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | func stripLeadingSQLComments(query string) string { |
| 54 | q := strings.TrimSpace(query) |