diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index 81c9338..9550bd1 100644
*** a/src/backend/parser/parse_expr.c
--- b/src/backend/parser/parse_expr.c
*************** transformAExprOf(ParseState *pstate, A_E
*** 1088,1094 ****
  static Node *
  transformAExprIn(ParseState *pstate, A_Expr *a)
  {
! 	Node	   *result = NULL;
  	Node	   *lexpr;
  	List	   *rexprs;
  	List	   *rvars;
--- 1088,1095 ----
  static Node *
  transformAExprIn(ParseState *pstate, A_Expr *a)
  {
! 	Node	   *result;
! 	List	   *cmpexprs = NIL;
  	Node	   *lexpr;
  	List	   *rexprs;
  	List	   *rvars;
*************** transformAExprIn(ParseState *pstate, A_E
*** 1166,1171 ****
--- 1167,1173 ----
  			 */
  			List	   *aexprs;
  			ArrayExpr  *newa;
+ 			Node	   *cmp;
  
  			aexprs = NIL;
  			foreach(l, rnonvars)
*************** transformAExprIn(ParseState *pstate, A_E
*** 1185,1196 ****
  			newa->multidims = false;
  			newa->location = -1;
  
! 			result = (Node *) make_scalar_array_op(pstate,
! 												   a->name,
! 												   useOr,
! 												   lexpr,
! 												   (Node *) newa,
! 												   a->location);
  
  			/* Consider only the Vars (if any) in the loop below */
  			rexprs = rvars;
--- 1187,1202 ----
  			newa->multidims = false;
  			newa->location = -1;
  
! 			cmp = (Node *) make_scalar_array_op(pstate,
! 												a->name,
! 												useOr,
! 												lexpr,
! 												(Node *) newa,
! 												a->location);
! 
! 			/* cmp certainly yields boolean, no need to check it */
! 
! 			cmpexprs = lappend(cmpexprs, cmp);
  
  			/* Consider only the Vars (if any) in the loop below */
  			rexprs = rvars;
*************** transformAExprIn(ParseState *pstate, A_E
*** 1198,1204 ****
  	}
  
  	/*
! 	 * Must do it the hard way, ie, with a boolean expression tree.
  	 */
  	foreach(l, rexprs)
  	{
--- 1204,1210 ----
  	}
  
  	/*
! 	 * Any remaining righthand exprs need to be compared individually.
  	 */
  	foreach(l, rexprs)
  	{
*************** transformAExprIn(ParseState *pstate, A_E
*** 1226,1239 ****
  		}
  
  		cmp = coerce_to_boolean(pstate, cmp, "IN");
! 		if (result == NULL)
! 			result = cmp;
! 		else
! 			result = (Node *) makeBoolExpr(useOr ? OR_EXPR : AND_EXPR,
! 										   list_make2(result, cmp),
! 										   a->location);
  	}
  
  	return result;
  }
  
--- 1232,1253 ----
  		}
  
  		cmp = coerce_to_boolean(pstate, cmp, "IN");
! 
! 		cmpexprs = lappend(cmpexprs, cmp);
  	}
  
+ 	/*
+ 	 * If we have more than one comparison expression, AND or OR them together
+ 	 */
+ 	if (cmpexprs == NIL)
+ 		result = NULL;			/* can this happen? is it right if so? */
+ 	else if (list_length(cmpexprs) == 1)
+ 		result = (Node *) linitial(cmpexprs);
+ 	else
+ 		result = (Node *) makeBoolExpr(useOr ? OR_EXPR : AND_EXPR,
+ 									   cmpexprs,
+ 									   a->location);
+ 
  	return result;
  }
  
