SQLite

Check-in [a7acc7878b]
Login

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

Overview
Comment:Correctly handle empty function argument lists on table-valued functions.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a7acc7878b8bb8e27a0da67b2dbb7bd51df4859b
User & Date: drh 2015-08-20 20:13:37.543
Context
2015-08-20
20:21
Fix stray variable declaration for C89. (check-in: 17eb7f18cb user: mistachkin tags: trunk)
20:13
Correctly handle empty function argument lists on table-valued functions. (check-in: a7acc7878b user: drh tags: trunk)
19:55
Add support for table-valued functions in the FROM clause implemented as virtual tables. (check-in: 9b718b06b1 user: drh tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/build.c.
3798
3799
3800
3801
3802
3803
3804
3805

3806
3807
3808
3809
3810
3811
3812
3798
3799
3800
3801
3802
3803
3804

3805
3806
3807
3808
3809
3810
3811
3812







-
+







}

/*
** Add the list of function arguments to the SrcList entry for a
** table-valued-function.
*/
void sqlite3SrcListFuncArgs(Parse *pParse, SrcList *p, ExprList *pList){
  if( p && ALWAYS(p->nSrc>0) ){
  if( p && ALWAYS(p->nSrc>0) && pList ){
    struct SrcList_item *pItem = &p->a[p->nSrc-1];
    assert( pItem->fg.notIndexed==0 );
    assert( pItem->fg.isIndexedBy==0 );
    assert( pItem->fg.isTabFunc==0 );
    pItem->u1.pFuncArg = pList;
    pItem->fg.isTabFunc = 1;
  }
Changes to src/resolve.c.
1447
1448
1449
1450
1451
1452
1453

1454
1455
1456




1457
1458
1459
1460
1461
1462
1463
1447
1448
1449
1450
1451
1452
1453
1454



1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465







+
-
-
-
+
+
+
+







** just like sqlite3ResolveExprNames() except that it works for an expression
** list rather than a single expression.
*/
int sqlite3ResolveExprListNames( 
  NameContext *pNC,       /* Namespace to resolve expressions in. */
  ExprList *pList         /* The expression list to be analyzed. */
){
  if( pList ){
  int i;
  for(i=0; i<pList->nExpr; i++){
    if( sqlite3ResolveExprNames(pNC, pList->a[i].pExpr) ) return WRC_Abort;
    int i;
    for(i=0; i<pList->nExpr; i++){
      if( sqlite3ResolveExprNames(pNC, pList->a[i].pExpr) ) return WRC_Abort;
    }
  }
  return WRC_Continue;
}

/*
** Resolve all names in all expressions of a SELECT and in all
** decendents of the SELECT, including compounds off of p->pPrior,
Changes to test/tabfunc01.test.
56
57
58
59
60
61
62





63
64
56
57
58
59
60
61
62
63
64
65
66
67
68
69







+
+
+
+
+


} {7 30 6 25 5 20 4 15 3 10 2 5 1 0}

do_execsql_test tabfunc01-2.1 {
  CREATE TABLE t1(x);
  INSERT INTO t1(x) VALUES(2),(3);
  SELECT *, '|' FROM t1, generate_series(1,x) ORDER BY 1, 2
} {2 1 | 2 2 | 3 1 | 3 2 | 3 3 |}

do_execsql_test tabfunc01-2.2 {
  SELECT * FROM generate_series() LIMIT 5;
} {0 1 2 3 4}


finish_test