-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Severity:
Description:
Using CAST operations in SELECT queries that include JOIN operations causes the driver to hang indefinitely after reading all data but before returning results to the application.
Symptoms:
- Query executes successfully in IRIS SQL Prompt
- Driver reads all data from database
- Hangs indefinitely after reading, before returning results
- No error message, timeout, or panic
- Application becomes completely unresponsive
- Must force-kill application
Minimal Reproduction:
package main
import (
"database/sql"
"log"
_ "github.com/caretdev/go-irisnative"
)
func main() {
db, _ := sql.Open("iris", "iris://_SYSTEM:password@localhost:1972/USER")
defer db.Close()
// This query hangs indefinitely
query := `
SELECT
CAST(o.Org_ID AS VARCHAR(36)),
CAST(o.Org_Active AS INTEGER),
ot.Org_Type_Name
FROM GPC.Organization o
LEFT JOIN GPC.Org_Type ot ON o.Org_Org_Type_ID = ot.Org_Type_ID
`
rows, err := db.Query(query) // Hangs here - never returns
if err != nil {
log.Fatal(err)
}
defer rows.Close()
// Never reaches this point
for rows.Next() {
var id string
var active int
var typeName string
rows.Scan(&id, &active, &typeName)
}
}Workaround:
Remove CAST operations from queries with JOINs and scan native IRIS types:
// Query without CAST (works fine)
query := `
SELECT
o.Org_ID, -- No CAST
o.Org_Active, -- No CAST
COALESCE(ot.Org_Type_Name, '')
FROM GPC.Organization o
LEFT JOIN GPC.Org_Type ot ON o.Org_Org_Type_ID = ot.Org_Type_ID
`
rows, err := db.Query(query) // Works fine
// Scan native types directly
var orgID string
var active bool // Scan as bool, NOT int
var typeName string
rows.Scan(&orgID, &active, &typeName)Note: CAST works fine in single-table queries without JOINs.
Impact: High - requires rewriting all queries with JOINs to avoid CAST, complicates type handling.
Metadata
Metadata
Assignees
Labels
No labels