1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Remove the SQLITE_PREPARE_SAFEOPT flag. The name is obsolete and it is at the

wrong level.  Instead use the SF_UpdateFrom flags on the Select object.

FossilOrigin-Name: 78723a9a7e72b42d28fc5645661da17f20cedcf864819b861800ad9340007be1
This commit is contained in:
drh
2022-12-09 18:26:15 +00:00
parent e974e73f69
commit 93f41e22d4
6 changed files with 19 additions and 18 deletions

View File

@@ -6878,7 +6878,7 @@ static int sameSrcAlias(SrcItem *p0, SrcList *pSrc){
** (ii) There is nothing that would prevent the subquery from
** being used as the outer loop if the sqlite3WhereBegin()
** routine nominates it to that position.
** (iii) The SQLITE_PREPARE_SAFEOPT flag is not set
** (iii) The query is not a UPDATE ... FROM
** (2) The subquery is not a CTE that should be materialized because of
** the AS MATERIALIZED keywords
** (3) The subquery is not part of a left operand for a RIGHT JOIN
@@ -6888,7 +6888,8 @@ static int sameSrcAlias(SrcItem *p0, SrcList *pSrc){
static int fromClauseTermCanBeCoroutine(
Parse *pParse, /* Parsing context */
SrcList *pTabList, /* FROM clause */
int i /* Which term of the FROM clause holds the subquery */
int i, /* Which term of the FROM clause holds the subquery */
int selFlags /* Flags on the SELECT statement */
){
SrcItem *pItem = &pTabList->a[i];
if( pItem->fg.isCte && pItem->u2.pCteUse->eM10d==M10d_Yes ) return 0;/* (2) */
@@ -6900,10 +6901,10 @@ static int fromClauseTermCanBeCoroutine(
if( i==0 ){
if( pTabList->nSrc==1 ) return 1; /* (1a) */
if( pTabList->a[1].fg.jointype & JT_CROSS ) return 1; /* (1b) */
if( pParse->prepFlags & SQLITE_PREPARE_SAFEOPT ) return 0; /* (1c-iii) */
if( selFlags & SF_UpdateFrom ) return 0; /* (1c-iii) */
return 1;
}
if( pParse->prepFlags & SQLITE_PREPARE_SAFEOPT ) return 0; /* (1c-iii) */
if( selFlags & SF_UpdateFrom ) return 0; /* (1c-iii) */
while( 1 /*exit-by-break*/ ){
if( pItem->fg.jointype & (JT_OUTER|JT_CROSS) ) return 0; /* (1c-ii) */
if( i==0 ) break;
@@ -7302,7 +7303,7 @@ int sqlite3Select(
/* Generate code to implement the subquery
*/
if( fromClauseTermCanBeCoroutine(pParse, pTabList, i) ){
if( fromClauseTermCanBeCoroutine(pParse, pTabList, i, p->selFlags) ){
/* Implement a co-routine that will return a single row of the result
** set on each invocation.
*/