Index: src/resolve.c ================================================================== --- src/resolve.c +++ src/resolve.c @@ -266,15 +266,19 @@ while( pNC && cnt==0 ){ ExprList *pEList; SrcList *pSrcList = pNC->pSrcList; #ifndef SQLITE_OMIT_CTE - /* The identifier "LEVEL", with a table or database qualifier and within a - ** recursive common table expression, resolves to the special LEVEL pseudo-column. - ** To access table names called "level", add a table qualifier. + /* The identifier "LEVEL", without a table or database qualifier and + ** within a recursive common table expression, resolves to the special + ** LEVEL pseudo-column. To access table names called "level", add a + ** table qualifier. */ - if( (pNC->ncFlags&NC_Recursive)!=0 && zTab==0 && sqlite3_stricmp(zCol,"level")==0 ){ + if( (pNC->ncFlags&NC_Recursive)!=0 + && zTab==0 + && sqlite3_stricmp(zCol,"level")==0 + ){ assert( cnt==0 ); cnt = 1; newOp = TK_LEVEL; pExpr->iColumn = -1; pExpr->affinity = SQLITE_AFF_INTEGER; Index: src/sqliteInt.h ================================================================== --- src/sqliteInt.h +++ src/sqliteInt.h @@ -2105,11 +2105,11 @@ #define NC_AllowAgg 0x01 /* Aggregate functions are allowed here */ #define NC_HasAgg 0x02 /* One or more aggregate functions seen */ #define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */ #define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */ #define NC_PartIdx 0x10 /* True if resolving a partial index WHERE */ -#define NC_Recursive 0x20 /* Resolvingn a recursive CTE definition */ +#define NC_Recursive 0x20 /* Resolving a recursive CTE definition */ #define NC_UsesLevel 0x40 /* The LEVEL pseudo-column has been seen */ /* ** An instance of the following structure contains all information ** needed to generate code for a single SELECT statement.