/ Check-in [ba1b441b]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Add the ability to have a table-valued function on the RHS of an IN operator.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | prototype-int-array
Files: files | file ages | folders
SHA1: ba1b441b6003808810667d749635fe6b2e8c6165
User & Date: drh 2016-06-29 06:19:19
Context
2016-07-02
20:51
Merge the alternative table-valued function RHS of IN operator implementation from trunk. check-in: 507fdbfb user: drh tags: prototype-int-array
2016-06-29
06:19
Add the ability to have a table-valued function on the RHS of an IN operator. check-in: ba1b441b user: drh tags: prototype-int-array
05:08
Another test case for the intarray($PTR,$N) virtual table. check-in: 06e1fab7 user: drh tags: prototype-int-array
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/parse.y.

1133
1134
1135
1136
1137
1138
1139









1140
1141
1142
1143
1144
1145
1146
    sqlite3PExprAddSelect(pParse, A.pExpr, Y);
    exprNot(pParse, N, &A);
    A.zEnd = &E.z[E.n];
  }
  expr(A) ::= expr(A) in_op(N) nm(Y) dbnm(Z). [IN] {
    SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&Y,&Z);
    Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);









    A.pExpr = sqlite3PExpr(pParse, TK_IN, A.pExpr, 0, 0);
    sqlite3PExprAddSelect(pParse, A.pExpr, pSelect);
    exprNot(pParse, N, &A);
    A.zEnd = Z.z ? &Z.z[Z.n] : &Y.z[Y.n];
  }
  expr(A) ::= EXISTS(B) LP select(Y) RP(E). {
    Expr *p;







>
>
>
>
>
>
>
>
>







1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
    sqlite3PExprAddSelect(pParse, A.pExpr, Y);
    exprNot(pParse, N, &A);
    A.zEnd = &E.z[E.n];
  }
  expr(A) ::= expr(A) in_op(N) nm(Y) dbnm(Z). [IN] {
    SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&Y,&Z);
    Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
    A.pExpr = sqlite3PExpr(pParse, TK_IN, A.pExpr, 0, 0);
    sqlite3PExprAddSelect(pParse, A.pExpr, pSelect);
    exprNot(pParse, N, &A);
    A.zEnd = Z.z ? &Z.z[Z.n] : &Y.z[Y.n];
  }
  expr(A) ::= expr(A) in_op(N) nm(Y) dbnm(Z) LP exprlist(E) RP. [IN] {
    SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&Y,&Z);
    Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
    sqlite3SrcListFuncArgs(pParse, pSrc, E);
    A.pExpr = sqlite3PExpr(pParse, TK_IN, A.pExpr, 0, 0);
    sqlite3PExprAddSelect(pParse, A.pExpr, pSelect);
    exprNot(pParse, N, &A);
    A.zEnd = Z.z ? &Z.z[Z.n] : &Y.z[Y.n];
  }
  expr(A) ::= EXISTS(B) LP select(Y) RP(E). {
    Expr *p;

Changes to test/tabfunc01.test.

173
174
175
176
177
178
179
















180
181
182
183
  sqlite3_bind_intarray $VM 1 11 22 33 44 55
  sqlite3_step $VM
} SQLITE_ROW
do_test tabfunc01-661 {
  sqlite3_column_int $VM 0
} 11
sqlite3_finalize $VM

















catch {sqlite3_bind_intarray}

finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
  sqlite3_bind_intarray $VM 1 11 22 33 44 55
  sqlite3_step $VM
} SQLITE_ROW
do_test tabfunc01-661 {
  sqlite3_column_int $VM 0
} 11
sqlite3_finalize $VM

do_test tabfunc01-670 {
  set TAIL {}
  set VM [sqlite3_prepare db {
     SELECT length(y) FROM t6 WHERE x IN intarray(?1,3);
  } -1 TAIL]
  string trim $TAIL
} {}
do_test tabfunc01-671 {
  sqlite3_bind_intarray $VM 1 11 22 33 44 55
  sqlite3_step $VM
} SQLITE_ROW
do_test tabfunc01-672 {
  sqlite3_column_int $VM 0
} 11
sqlite3_finalize $VM

catch {sqlite3_bind_intarray}

finish_test