fix: version 2.9.2 (#4405)

This commit is contained in:
hailaz
2025-09-01 15:33:50 +08:00
committed by GitHub
parent f08897a114
commit 502d158bc0
33 changed files with 67 additions and 74 deletions

View File

@ -716,6 +716,13 @@ const (
linkPatternDescription = `type:username:password@protocol(host:port)/dbname?param1=value1&...&paramN=valueN`
)
// Context key types to avoid collisions
type ctxKey string
const (
ctxKeyWrappedByGetCtxTimeout ctxKey = "WrappedByGetCtxTimeout"
)
type ctxTimeoutType int
const (

View File

@ -76,7 +76,7 @@ func (c *Core) GetCtxTimeout(ctx context.Context, timeoutType ctxTimeoutType) (c
if ctx == nil {
ctx = c.db.GetCtx()
} else {
ctx = context.WithValue(ctx, "WrappedByGetCtxTimeout", nil)
ctx = context.WithValue(ctx, ctxKeyWrappedByGetCtxTimeout, nil)
}
var config = c.db.GetConfig()
switch timeoutType {

View File

@ -57,10 +57,13 @@ type TxOptions struct {
ReadOnly bool
}
// Context key types for transaction to avoid collisions
type transactionCtxKey string
const (
transactionPointerPrefix = "transaction"
contextTransactionKeyPrefix = "TransactionObjectForGroup_"
transactionIdForLoggerCtx = "TransactionId"
transactionPointerPrefix = "transaction"
contextTransactionKeyPrefix = "TransactionObjectForGroup_"
transactionIdForLoggerCtx transactionCtxKey = "TransactionId"
)
var transactionIdGenerator = gtype.NewUint64()
@ -286,7 +289,7 @@ func TXFromCtx(ctx context.Context, group string) TX {
return nil
}
// transactionKeyForContext forms and returns a string for storing transaction object of certain database group into context.
func transactionKeyForContext(group string) string {
return contextTransactionKeyPrefix + group
// transactionKeyForContext forms and returns a key for storing transaction object of certain database group into context.
func transactionKeyForContext(group string) transactionCtxKey {
return transactionCtxKey(contextTransactionKeyPrefix + group)
}