diff --git a/goextVersion.go b/goextVersion.go index f111e21..489442d 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.519" +const GoextVersion = "0.0.520" -const GoextVersionTimestamp = "2024-10-05T00:58:15+0200" +const GoextVersionTimestamp = "2024-10-05T01:02:25+0200" diff --git a/sq/database.go b/sq/database.go index ed0e067..677b89e 100644 --- a/sq/database.go +++ b/sq/database.go @@ -61,7 +61,7 @@ func (db *database) Exec(ctx context.Context, sqlstr string, prep PP) (sql.Resul t0 := time.Now() - preMeta := PreExecMeta{} + preMeta := PreExecMeta{Context: ctx, TransactionConstructorContext: nil} for _, v := range db.lstr { err := v.PreExec(ctx, nil, &sqlstr, &prep, preMeta) if err != nil { @@ -73,7 +73,7 @@ func (db *database) Exec(ctx context.Context, sqlstr string, prep PP) (sql.Resul res, err := db.db.NamedExecContext(ctx, sqlstr, prep) - postMeta := PostExecMeta{Init: t0, Start: t1, End: time.Now()} + postMeta := PostExecMeta{Context: ctx, TransactionConstructorContext: nil, Init: t0, Start: t1, End: time.Now()} for _, v := range db.lstr { v.PostExec(nil, origsql, sqlstr, prep, postMeta) } @@ -90,7 +90,7 @@ func (db *database) Query(ctx context.Context, sqlstr string, prep PP) (*sqlx.Ro t0 := time.Now() - preMeta := PreQueryMeta{} + preMeta := PreQueryMeta{Context: ctx, TransactionConstructorContext: nil} for _, v := range db.lstr { err := v.PreQuery(ctx, nil, &sqlstr, &prep, preMeta) if err != nil { @@ -102,7 +102,7 @@ func (db *database) Query(ctx context.Context, sqlstr string, prep PP) (*sqlx.Ro rows, err := sqlx.NamedQueryContext(ctx, db.db, sqlstr, prep) - postMeta := PostQueryMeta{Init: t0, Start: t1, End: time.Now()} + postMeta := PostQueryMeta{Context: ctx, TransactionConstructorContext: nil, Init: t0, Start: t1, End: time.Now()} for _, v := range db.lstr { v.PostQuery(nil, origsql, sqlstr, prep, postMeta) } @@ -118,7 +118,7 @@ func (db *database) Ping(ctx context.Context) error { t0 := time.Now() - preMeta := PrePingMeta{} + preMeta := PrePingMeta{Context: ctx} for _, v := range db.lstr { err := v.PrePing(ctx, preMeta) if err != nil { @@ -130,7 +130,7 @@ func (db *database) Ping(ctx context.Context) error { err := db.db.PingContext(ctx) - postMeta := PostPingMeta{Init: t0, Start: t1, End: time.Now()} + postMeta := PostPingMeta{Context: ctx, Init: t0, Start: t1, End: time.Now()} for _, v := range db.lstr { v.PostPing(err, postMeta) } @@ -151,7 +151,7 @@ func (db *database) BeginTransaction(ctx context.Context, iso sql.IsolationLevel db.txctr += 1 // with overflow ! db.lock.Unlock() - preMeta := PreTxBeginMeta{} + preMeta := PreTxBeginMeta{Context: ctx} for _, v := range db.lstr { err := v.PreTxBegin(ctx, txid, preMeta) if err != nil { @@ -163,7 +163,7 @@ func (db *database) BeginTransaction(ctx context.Context, iso sql.IsolationLevel xtx, err := db.db.BeginTxx(ctx, &sql.TxOptions{Isolation: iso}) - postMeta := PostTxBeginMeta{Init: t0, Start: t1, End: time.Now()} + postMeta := PostTxBeginMeta{Context: ctx, Init: t0, Start: t1, End: time.Now()} for _, v := range db.lstr { v.PostTxBegin(txid, err, postMeta) } diff --git a/sq/listener.go b/sq/listener.go index e89a668..f1d7f54 100644 --- a/sq/listener.go +++ b/sq/listener.go @@ -6,9 +6,11 @@ import ( ) type PrePingMeta struct { + Context context.Context } type PreTxBeginMeta struct { + Context context.Context ConstructorContext context.Context } @@ -21,22 +23,27 @@ type PreTxRollbackMeta struct { } type PreQueryMeta struct { + Context context.Context + TransactionConstructorContext context.Context } type PreExecMeta struct { + Context context.Context + TransactionConstructorContext context.Context } type PostPingMeta struct { - Init time.Time - Start time.Time - End time.Time + Context context.Context + Init time.Time + Start time.Time + End time.Time } type PostTxBeginMeta struct { - ConstructorContext context.Context - Init time.Time - Start time.Time - End time.Time + Context context.Context + Init time.Time + Start time.Time + End time.Time } type PostTxCommitMeta struct { @@ -58,15 +65,19 @@ type PostTxRollbackMeta struct { } type PostQueryMeta struct { - Init time.Time - Start time.Time - End time.Time + Context context.Context + TransactionConstructorContext context.Context + Init time.Time + Start time.Time + End time.Time } type PostExecMeta struct { - Init time.Time - Start time.Time - End time.Time + Context context.Context + TransactionConstructorContext context.Context + Init time.Time + Start time.Time + End time.Time } type Listener interface { diff --git a/sq/transaction.go b/sq/transaction.go index d643ccf..5c1954a 100644 --- a/sq/transaction.go +++ b/sq/transaction.go @@ -109,7 +109,7 @@ func (tx *transaction) Exec(ctx context.Context, sqlstr string, prep PP) (sql.Re t0 := time.Now() - preMeta := PreExecMeta{} + preMeta := PreExecMeta{Context: ctx, TransactionConstructorContext: tx.constructorContext} for _, v := range tx.db.lstr { err := v.PreExec(ctx, langext.Ptr(tx.id), &sqlstr, &prep, preMeta) if err != nil { @@ -126,7 +126,7 @@ func (tx *transaction) Exec(ctx context.Context, sqlstr string, prep PP) (sql.Re tx.status = TxStatusActive } - postMeta := PostExecMeta{Init: t0, Start: t1, End: time.Now()} + postMeta := PostExecMeta{Context: ctx, TransactionConstructorContext: tx.constructorContext, Init: t0, Start: t1, End: time.Now()} for _, v := range tx.db.lstr { v.PostExec(langext.Ptr(tx.id), origsql, sqlstr, prep, postMeta) } @@ -142,7 +142,7 @@ func (tx *transaction) Query(ctx context.Context, sqlstr string, prep PP) (*sqlx t0 := time.Now() - preMeta := PreQueryMeta{} + preMeta := PreQueryMeta{Context: ctx, TransactionConstructorContext: tx.constructorContext} for _, v := range tx.db.lstr { err := v.PreQuery(ctx, langext.Ptr(tx.id), &sqlstr, &prep, preMeta) if err != nil { @@ -159,7 +159,7 @@ func (tx *transaction) Query(ctx context.Context, sqlstr string, prep PP) (*sqlx tx.status = TxStatusActive } - postMeta := PostQueryMeta{Init: t0, Start: t1, End: time.Now()} + postMeta := PostQueryMeta{Context: ctx, TransactionConstructorContext: tx.constructorContext, Init: t0, Start: t1, End: time.Now()} for _, v := range tx.db.lstr { v.PostQuery(langext.Ptr(tx.id), origsql, sqlstr, prep, postMeta) }