Skip to content

Commit c05bdfb

Browse files
committed
Fix EOF errors and other query failures caused by invalid index in columnFromVar, called from qualFromBoolExpr. Closes #187
1 parent fe9c3b9 commit c05bdfb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: quals.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,17 @@ func qualFromBoolExpr(restriction *C.BoolExpr, node *C.ForeignScanState, cinfos
283283

284284
func columnFromVar(variable *C.Var, cinfos *conversionInfos) string {
285285
var arrayIndex = int(variable.varattno - 1)
286+
if arrayIndex < 0 {
287+
log.Printf("[WARN] columnFromVar failed - index %d, returning empty string", arrayIndex)
288+
return ""
289+
}
286290
ci := cinfos.get(arrayIndex)
287291
if ci == nil {
288-
log.Printf("[WARN] columnFromVar failed - could not get conversion info for index %d", arrayIndex)
292+
log.Printf("[WARN] columnFromVar failed - could not get conversion info for index %d, returning empty string", arrayIndex)
293+
return ""
294+
}
295+
if ci.attrname == nil {
296+
log.Printf("[WARN] columnFromVar failed - conversion info for index %d has no attrname, returning empty string", arrayIndex)
289297
return ""
290298
}
291299

0 commit comments

Comments
 (0)