mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	OR clause index fix
This commit is contained in:
		@@ -8,7 +8,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * IDENTIFICATION
 | 
					 * IDENTIFICATION
 | 
				
			||||||
 *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.31 1998/08/19 02:02:11 momjian Exp $
 | 
					 *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.32 1998/08/31 07:19:54 momjian Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *-------------------------------------------------------------------------
 | 
					 *-------------------------------------------------------------------------
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -340,10 +340,10 @@ match_index_orclause(RelOptInfo *rel,
 | 
				
			|||||||
								   index) &&
 | 
													   index) &&
 | 
				
			||||||
			  IsA(get_rightop((Expr *) clause), Const)) ||
 | 
								  IsA(get_rightop((Expr *) clause), Const)) ||
 | 
				
			||||||
			 (match_index_to_operand(indexkey,
 | 
								 (match_index_to_operand(indexkey,
 | 
				
			||||||
								   (Expr *) get_leftop((Expr *) clause),
 | 
													   (Expr *) get_rightop((Expr *) clause),
 | 
				
			||||||
								   rel,
 | 
													   rel,
 | 
				
			||||||
								   index) &&
 | 
													   index) &&
 | 
				
			||||||
			 IsA(get_rightop((Expr *) clause), Const))))
 | 
								 IsA(get_leftop((Expr *) clause), Const))))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			lfirst(matching_indices) = lcons(index, lfirst(matching_indices));
 | 
								lfirst(matching_indices) = lcons(index, lfirst(matching_indices));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * IDENTIFICATION
 | 
					 * IDENTIFICATION
 | 
				
			||||||
 *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.8 1998/08/01 22:12:13 momjian Exp $
 | 
					 *	  $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.9 1998/08/31 07:19:55 momjian Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *-------------------------------------------------------------------------
 | 
					 *-------------------------------------------------------------------------
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -84,6 +84,7 @@ create_or_index_paths(Query *root,
 | 
				
			|||||||
					break;
 | 
										break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								/* do they all have indexes? */
 | 
				
			||||||
			if (index_flag)
 | 
								if (index_flag)
 | 
				
			||||||
			{					/* used to be a lisp every function */
 | 
								{					/* used to be a lisp every function */
 | 
				
			||||||
				IndexPath  *pathnode = makeNode(IndexPath);
 | 
									IndexPath  *pathnode = makeNode(IndexPath);
 | 
				
			||||||
@@ -215,6 +216,11 @@ best_or_subclause_index(Query *root,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	List *ilist;
 | 
						List *ilist;
 | 
				
			||||||
	bool first_run = true;
 | 
						bool first_run = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* if we don't match anything, return zeros */
 | 
				
			||||||
 | 
						*retIndexid = 0;
 | 
				
			||||||
 | 
						*retCost = 0.0;
 | 
				
			||||||
 | 
						*retSelec = 0.0;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	foreach (ilist, indices)
 | 
						foreach (ilist, indices)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@@ -268,12 +274,5 @@ best_or_subclause_index(Query *root,
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* we didn't get any indexes, so zero return values */
 | 
					 | 
				
			||||||
	if (first_run)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		*retIndexid = 0;
 | 
					 | 
				
			||||||
		*retCost = 0.0;
 | 
					 | 
				
			||||||
		*retSelec = 0.0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return;
 | 
						return;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * IDENTIFICATION
 | 
					 * IDENTIFICATION
 | 
				
			||||||
 *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.20 1998/08/10 02:26:29 momjian Exp $
 | 
					 *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.21 1998/08/31 07:19:56 momjian Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * HISTORY
 | 
					 * HISTORY
 | 
				
			||||||
 *	  AUTHOR			DATE			MAJOR EVENT
 | 
					 *	  AUTHOR			DATE			MAJOR EVENT
 | 
				
			||||||
@@ -198,9 +198,8 @@ make_funcclause(Func *func, List *funcargs)
 | 
				
			|||||||
bool
 | 
					bool
 | 
				
			||||||
or_clause(Node *clause)
 | 
					or_clause(Node *clause)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return
 | 
						return clause != NULL &&
 | 
				
			||||||
	(clause != NULL &&
 | 
							   nodeTag(clause) == T_Expr && ((Expr *) clause)->opType == OR_EXPR);
 | 
				
			||||||
	 nodeTag(clause) == T_Expr && ((Expr *) clause)->opType == OR_EXPR);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user