/ 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 Unified Diffs Show Whitespace Changes Patch

Changes to src/resolve.c.

264
265
266
267
268
269
270
271
272
273

274


275

276
277
278
279
280
281
282

  /* Start at the inner-most context and move outward until a match is found */
  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.

    */


    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;
      pNC->ncFlags |= NC_UsesLevel;
      break;







|
|
|
>

>
>
|
>







264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286

  /* Start at the inner-most context and move outward until a match is found */
  while( pNC && cnt==0 ){
    ExprList *pEList;
    SrcList *pSrcList = pNC->pSrcList;

#ifndef SQLITE_OMIT_CTE
    /* 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
    ){
      assert( cnt==0 );
      cnt = 1;
      newOp = TK_LEVEL;
      pExpr->iColumn = -1;
      pExpr->affinity = SQLITE_AFF_INTEGER;
      pNC->ncFlags |= NC_UsesLevel;
      break;

Changes to src/sqliteInt.h.

2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
** Allowed values for the NameContext, ncFlags field.
*/
#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_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.
**
** nLimit is set to -1 if there is no LIMIT clause.  nOffset is set to 0.







|







2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
** Allowed values for the NameContext, ncFlags field.
*/
#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    /* 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.
**
** nLimit is set to -1 if there is no LIMIT clause.  nOffset is set to 0.