sqlruntime

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneHookArgs

func CloneHookArgs(args []interface{}) []interface{}

CloneHookArgs creates a shallow copy for hook consumers to avoid mutation races.

func FingerprintSQL

func FingerprintSQL(query string, mode int, keepComments bool) string

FingerprintSQL creates a normalized SQL fingerprint. mode controls literal masking; keepComments controls whether comments are preserved.

func NormalizeFingerprintMode

func NormalizeFingerprintMode(mode int) int

NormalizeFingerprintMode converts unknown mode values to default basic mode.

func NormalizePlaceholderStyle

func NormalizePlaceholderStyle(style int) int

NormalizePlaceholderStyle converts unknown style values to default question style.

func ShouldRunAfterHook

func ShouldRunAfterHook(hasAfterHook bool, slowThreshold, duration time.Duration, err error) bool

ShouldRunAfterHook decides whether after-hook should run.

Types

type State

type State struct {
	// contains filtered or unexported fields
}

State stores runtime SQL behavior toggles in a thread-safe manner.

func (*State) FingerprintCounterEnabled

func (s *State) FingerprintCounterEnabled() bool

FingerprintCounterEnabled reports whether in-memory SQL fingerprint hit counter is enabled.

func (*State) FingerprintCountsSnapshot

func (s *State) FingerprintCountsSnapshot() map[string]uint64

FingerprintCountsSnapshot returns a snapshot copy of fingerprint counters.

func (*State) FingerprintEnabled

func (s *State) FingerprintEnabled() bool

FingerprintEnabled reports whether SQL fingerprint metadata generation is enabled.

func (*State) FingerprintKeepComments

func (s *State) FingerprintKeepComments() bool

FingerprintKeepComments reports whether comments are kept in generated SQL fingerprints.

func (*State) FingerprintMode

func (s *State) FingerprintMode() int

FingerprintMode returns SQL fingerprint mode.

func (*State) Hooks

func (s *State) Hooks() (before, after interface{}, slowThreshold time.Duration)

Hooks returns before/after hooks and slow threshold.

func (*State) IncFingerprintCount

func (s *State) IncFingerprintCount(fingerprint string)

IncFingerprintCount increments hit count for a fingerprint.

func (*State) Options

func (s *State) Options() (before, after interface{}, placeholder int, slowThreshold time.Duration)

Options returns snapshot of current runtime options.

func (*State) PlaceholderStyle

func (s *State) PlaceholderStyle() int

PlaceholderStyle returns placeholder style.

func (*State) ResetFingerprintCounts

func (s *State) ResetFingerprintCounts()

ResetFingerprintCounts clears all fingerprint counters.

func (*State) SetAfterHook

func (s *State) SetAfterHook(after interface{})

SetAfterHook sets after hook.

func (*State) SetBeforeHook

func (s *State) SetBeforeHook(before interface{})

SetBeforeHook sets before hook.

func (*State) SetFingerprintCounterEnabled

func (s *State) SetFingerprintCounterEnabled(enabled bool)

SetFingerprintCounterEnabled toggles in-memory SQL fingerprint hit counter.

func (*State) SetFingerprintEnabled

func (s *State) SetFingerprintEnabled(enabled bool)

SetFingerprintEnabled toggles SQL fingerprint metadata generation for hooks.

func (*State) SetFingerprintKeepComments

func (s *State) SetFingerprintKeepComments(keep bool)

SetFingerprintKeepComments toggles comment preservation in generated SQL fingerprints.

func (*State) SetFingerprintMode

func (s *State) SetFingerprintMode(mode int)

SetFingerprintMode sets SQL fingerprint mode.

func (*State) SetHooks

func (s *State) SetHooks(before, after interface{})

SetHooks sets before/after hooks.

func (*State) SetPlaceholderStyle

func (s *State) SetPlaceholderStyle(style int)

SetPlaceholderStyle sets placeholder style.

func (*State) SetSlowThreshold

func (s *State) SetSlowThreshold(threshold time.Duration)

SetSlowThreshold sets minimum duration for triggering after hook.

func (*State) SlowThreshold

func (s *State) SlowThreshold() time.Duration

SlowThreshold returns current slow threshold.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL