@@ -250,16 +250,18 @@ recursiveExtract(JsQueryItem *jsq, bool not, bool indirect, PathItem *path)
250250
251251 if (jsq -> type == jqiGreater || jsq -> type == jqiGreaterOrEqual )
252252 {
253+ result -> bounds .leftBound = (JsQueryItem * )palloc (sizeof (JsQueryItem ));
253254 result -> bounds .leftInclusive = (jsq -> type == jqiGreaterOrEqual );
254255 result -> bounds .rightBound = NULL ;
255- result -> bounds .leftBound = ( JsQueryItem * ) palloc ( sizeof ( JsQueryItem )) ;
256+ result -> bounds .rightInclusive = false ;
256257 jsqGetArg (jsq , result -> bounds .leftBound );
257258 }
258259 else
259260 {
261+ result -> bounds .rightBound = (JsQueryItem * )palloc (sizeof (JsQueryItem ));
260262 result -> bounds .rightInclusive = (jsq -> type == jqiLessOrEqual );
261263 result -> bounds .leftBound = NULL ;
262- result -> bounds .rightBound = ( JsQueryItem * ) palloc ( sizeof ( JsQueryItem )) ;
264+ result -> bounds .leftInclusive = false ;
263265 jsqGetArg (jsq , result -> bounds .rightBound );
264266 }
265267 return result ;
@@ -699,12 +701,13 @@ makeEntries(ExtractedNode *node, MakeEntryHandler handler, Pointer extra)
699701 for (i = 0 ; i < node -> args .count ; i ++ )
700702 {
701703 child = node -> args .items [i ];
702- if (!child ) continue ;
703- if (child -> sClass > node -> sClass && !child -> forceIndex )
704- {
705- Assert (node -> type != eOr );
704+ if (!child )
705+ continue ;
706+ /* Skip non-selective AND children */
707+ if (child -> sClass > node -> sClass &&
708+ node -> type == eAnd &&
709+ !child -> forceIndex )
706710 continue ;
707- }
708711 child = makeEntries (child , handler , extra );
709712 if (child )
710713 {
@@ -771,15 +774,15 @@ setSelectivityClass(ExtractedNode *node, CheckEntryHandler checkHandler,
771774 if (!child )
772775 continue ;
773776
777+ setSelectivityClass (child , checkHandler , extra );
778+
774779 if (!isLogicalNodeType (child -> type ))
775780 {
776781 if (child -> hint == jsqNoIndex ||
777782 !checkHandler (child , extra ))
778783 continue ;
779784 }
780785
781- setSelectivityClass (child , checkHandler , extra );
782-
783786 if (child -> forceIndex )
784787 node -> forceIndex = true;
785788
0 commit comments