Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
FromContext retrieves a SQL statement from the context chain that matches the given query. It performs a recursive search through the context chain until it finds a matching statement or reaches the end of the chain.
Note: It prevents infinite recursion by checking for self-referential contexts.
func Query ¶
Query extracts the SQL query string from a *sql.Stmt using unsafe pointer arithmetic.
How it works: 1. sql.Stmt struct memory layout (only relevant fields):
First field (*DB): 8 bytes (on 64-bit systems)
Second field (query string): 16 bytes <- we want this
2. To get the query string, we:
a. Start at the beginning of the struct (sql.Stmt) b. Skip the first field (8 bytes) to reach query string c. Read the string value
Note: This implementation relies on the internal structure of sql.Stmt and may break if the struct layout changes in future Go versions.
Types ¶
This section is empty.