Naming the join columns in the result set of a natural join does not result
in an "ambiguous column name" error. Ticket #1217. (CVS 2494)
FossilOrigin-Name: 265fb6079c0a4b7a93f063939436db494ff1d56c
diff --git a/src/expr.c b/src/expr.c
index e6ca219..44664d2 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
-** $Id: expr.c,v 1.202 2005/05/24 20:19:59 drh Exp $
+** $Id: expr.c,v 1.203 2005/06/06 16:59:24 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -825,6 +825,12 @@
pExpr->iColumn = j==pTab->iPKey ? -1 : j;
pExpr->affinity = pTab->aCol[j].affinity;
pExpr->pColl = pTab->aCol[j].pColl;
+ if( pItem->jointype & JT_NATURAL ){
+ /* If this match occurred in the left table of a natural join,
+ ** then skip the right table to avoid a duplicate match */
+ pItem++;
+ i++;
+ }
break;
}
}