Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7d57288

Browse files
committed
Fix coredump seen when doing mergejoin between indexed tables,
for example in the regression test database, tryselect * from tenk1 t1, tenk1 t2 where t1.unique1 = t2.unique2;6.5 has this same bug ...
1 parent161be69 commit7d57288

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

‎src/backend/optimizer/util/pathnode.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.49 1999/07/27 03:51:05 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.50 1999/07/30 00:56:17 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -329,11 +329,16 @@ create_index_path(Query *root,
329329

330330
/* Note that we are making a pathnode for a single-scan indexscan;
331331
* therefore, both indexid and indexqual should be single-element
332-
* lists (unless indexqual is empty).
332+
* lists. We initialize indexqual to contain one empty sublist,
333+
* representing a single index traversal with no index restriction
334+
* conditions. If we do have restriction conditions to use, they
335+
* will get inserted below.
333336
*/
337+
Assert(length(index->relids)==1);
334338
pathnode->indexid=index->relids;
339+
pathnode->indexqual=lcons(NIL,NIL);
340+
335341
pathnode->indexkeys=index->indexkeys;
336-
pathnode->indexqual=NIL;
337342

338343
/*
339344
* The index must have an ordering for the path to have (ordering)
@@ -358,14 +363,19 @@ create_index_path(Query *root,
358363

359364
if (is_join_scan||restriction_clauses==NULL)
360365
{
361-
362366
/*
363367
* Indices used for joins or sorting result nodes don't restrict
364368
* the result at all, they simply order it, so compute the scan
365369
* cost accordingly -- use a selectivity of 1.0.
370+
*
371+
* is the statement above really true?what about IndexScan as the
372+
* inner of a join?
373+
*
374+
* I think it's OK --- this routine is only used to make index paths
375+
* for mergejoins and sorts. Index paths used as the inner side of
376+
* a nestloop join do provide restriction, but they are not made
377+
* with this code. See index_innerjoin() in indxpath.c.
366378
*/
367-
/* is the statement above really true?what about IndexScan as the
368-
inner of a join? */
369379
pathnode->path.path_cost=cost_index(lfirsti(index->relids),
370380
index->pages,
371381
1.0,
@@ -378,8 +388,8 @@ create_index_path(Query *root,
378388
else
379389
{
380390
/*
381-
* Compute scan cost for the case when 'index' is used with a
382-
* restriction clause.
391+
* Compute scan cost for the case when 'index' is used with
392+
* restriction clause(s).
383393
*/
384394
List*indexquals;
385395
floatnpages;
@@ -390,14 +400,18 @@ create_index_path(Query *root,
390400
/* expand special operators to indexquals the executor can handle */
391401
indexquals=expand_indexqual_conditions(indexquals);
392402

403+
/* Insert qual list into 1st sublist of pathnode->indexqual;
404+
* we already made the cons cell above, no point in wasting it...
405+
*/
406+
lfirst(pathnode->indexqual)=indexquals;
407+
393408
index_selectivity(root,
394409
lfirsti(rel->relids),
395410
lfirsti(index->relids),
396411
indexquals,
397412
&npages,
398413
&selec);
399414

400-
pathnode->indexqual=lcons(indexquals,NIL);
401415
pathnode->path.path_cost=cost_index(lfirsti(index->relids),
402416
(int)npages,
403417
selec,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp