/ Check-in [c57deced]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a couple comment typos and one overly long line. No functional changes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | level-pseudocolumn
Files: files | file ages | folders
SHA1: c57deced09c67085852eb17d4f6f881416daf24c
User & Date: mistachkin 2014-01-21 01:13:45
Context
2014-01-21
01:13
Fix a couple comment typos and one overly long line. No functional changes. Closed-Leaf check-in: c57deced user: mistachkin tags: level-pseudocolumn
00:19
Add support for the LEVEL pseudo-column in the recursive part of a common table expression. LEVEL has the value of 1 on the first iteration and successively larger integer values of subsequent iterations. It cannot have a table qualifier. Actual columns named "level" can still be accessed by including the table name qualifier. check-in: cc1cb321 user: drh tags: level-pseudocolumn
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/resolve.c.

   264    264   
   265    265     /* Start at the inner-most context and move outward until a match is found */
   266    266     while( pNC && cnt==0 ){
   267    267       ExprList *pEList;
   268    268       SrcList *pSrcList = pNC->pSrcList;
   269    269   
   270    270   #ifndef SQLITE_OMIT_CTE
   271         -    /* The identifier "LEVEL", with a table or database qualifier and within a
   272         -    ** recursive common table expression, resolves to the special LEVEL pseudo-column.
   273         -    ** To access table names called "level", add a table qualifier.
          271  +    /* The identifier "LEVEL", without a table or database qualifier and
          272  +    ** within a recursive common table expression, resolves to the special
          273  +    ** LEVEL pseudo-column.  To access table names called "level", add a
          274  +    ** table qualifier.
   274    275       */
   275         -    if( (pNC->ncFlags&NC_Recursive)!=0 && zTab==0 && sqlite3_stricmp(zCol,"level")==0 ){
          276  +    if( (pNC->ncFlags&NC_Recursive)!=0
          277  +     && zTab==0
          278  +     && sqlite3_stricmp(zCol,"level")==0
          279  +    ){
   276    280         assert( cnt==0 );
   277    281         cnt = 1;
   278    282         newOp = TK_LEVEL;
   279    283         pExpr->iColumn = -1;
   280    284         pExpr->affinity = SQLITE_AFF_INTEGER;
   281    285         pNC->ncFlags |= NC_UsesLevel;
   282    286         break;

Changes to src/sqliteInt.h.

  2103   2103   ** Allowed values for the NameContext, ncFlags field.
  2104   2104   */
  2105   2105   #define NC_AllowAgg  0x01    /* Aggregate functions are allowed here */
  2106   2106   #define NC_HasAgg    0x02    /* One or more aggregate functions seen */
  2107   2107   #define NC_IsCheck   0x04    /* True if resolving names in a CHECK constraint */
  2108   2108   #define NC_InAggFunc 0x08    /* True if analyzing arguments to an agg func */
  2109   2109   #define NC_PartIdx   0x10    /* True if resolving a partial index WHERE */
  2110         -#define NC_Recursive 0x20    /* Resolvingn a recursive CTE definition */
         2110  +#define NC_Recursive 0x20    /* Resolving a recursive CTE definition */
  2111   2111   #define NC_UsesLevel 0x40    /* The LEVEL pseudo-column has been seen */
  2112   2112   
  2113   2113   /*
  2114   2114   ** An instance of the following structure contains all information
  2115   2115   ** needed to generate code for a single SELECT statement.
  2116   2116   **
  2117   2117   ** nLimit is set to -1 if there is no LIMIT clause.  nOffset is set to 0.