Skip to content

Commit

Permalink
Fix EOF errors and other query failures caused by invalid index in c…
Browse files Browse the repository at this point in the history
…olumnFromVar, called from qualFromBoolExpr. Closes #187
  • Loading branch information
kaidaguerre committed May 20, 2022
1 parent fe9c3b9 commit c05bdfb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion quals.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,17 @@ func qualFromBoolExpr(restriction *C.BoolExpr, node *C.ForeignScanState, cinfos

func columnFromVar(variable *C.Var, cinfos *conversionInfos) string {
var arrayIndex = int(variable.varattno - 1)
if arrayIndex < 0 {
log.Printf("[WARN] columnFromVar failed - index %d, returning empty string", arrayIndex)
return ""
}
ci := cinfos.get(arrayIndex)
if ci == nil {
log.Printf("[WARN] columnFromVar failed - could not get conversion info for index %d", arrayIndex)
log.Printf("[WARN] columnFromVar failed - could not get conversion info for index %d, returning empty string", arrayIndex)
return ""
}
if ci.attrname == nil {
log.Printf("[WARN] columnFromVar failed - conversion info for index %d has no attrname, returning empty string", arrayIndex)
return ""
}

Expand Down

0 comments on commit c05bdfb

Please sign in to comment.