/ Check-in [d47a6bdd]
Login

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

Overview
Comment:Ensure that there are no bind-parameters or incorrect schema references in the UPSERT portions of an INSERT within a TRIGGER.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d47a6bdda0ce967a7b70bc6eb56278c8b79525622381ff4adcf04525eafc1461
User & Date: drh 2018-04-23 13:28:55
Context
2018-04-23
17:02
In the ".selecttrace" output, include the EXPLAIN QUERY PLAN iSelectId as part of each Select identifier. check-in: 5c6339f9 user: drh tags: trunk
13:28
Ensure that there are no bind-parameters or incorrect schema references in the UPSERT portions of an INSERT within a TRIGGER. check-in: d47a6bdd user: drh tags: trunk
00:25
Fix an unreachable branch associated with stack overflow in the LEMON-generated parser. check-in: e3064ba3 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/attach.c.

   600    600       }
   601    601       if( sqlite3FixExpr(pFix, pStep->pWhere) ){
   602    602         return 1;
   603    603       }
   604    604       if( sqlite3FixExprList(pFix, pStep->pExprList) ){
   605    605         return 1;
   606    606       }
          607  +#ifndef SQLITE_OMIT_UPSERT
          608  +    if( pStep->pUpsert ){
          609  +      Upsert *pUp = pStep->pUpsert;
          610  +      if( sqlite3FixExprList(pFix, pUp->pUpsertTarget)
          611  +       || sqlite3FixExpr(pFix, pUp->pUpsertTargetWhere)
          612  +       || sqlite3FixExprList(pFix, pUp->pUpsertSet)
          613  +       || sqlite3FixExpr(pFix, pUp->pUpsertWhere)
          614  +      ){
          615  +        return 1;
          616  +      }
          617  +    }
          618  +#endif
   607    619       pStep = pStep->pNext;
   608    620     }
   609    621     return 0;
   610    622   }
   611    623   #endif

Changes to src/sqliteInt.h.

  2736   2736   ** The pUpsertSet field is NULL for a ON CONFLICT DO NOTHING.  The
  2737   2737   ** pUpsertWhere is the WHERE clause for the UPDATE and is NULL if the
  2738   2738   ** WHERE clause is omitted.
  2739   2739   */
  2740   2740   struct Upsert {
  2741   2741     ExprList *pUpsertTarget;  /* Optional description of conflicting index */
  2742   2742     Expr *pUpsertTargetWhere; /* WHERE clause for partial index targets */
  2743         -  Index *pUpsertIdx;        /* Constraint that pUpsertTarget identifies */
  2744   2743     ExprList *pUpsertSet;     /* The SET clause from an ON CONFLICT UPDATE */
  2745   2744     Expr *pUpsertWhere;       /* WHERE clause for the ON CONFLICT UPDATE */
  2746   2745     /* The fields above comprise the parse tree for the upsert clause.
  2747   2746     ** The fields below are used to transfer information from the INSERT
  2748   2747     ** processing down into the UPDATE processing while generating code.
  2749   2748     ** Upsert owns the memory allocated above, but not the memory below. */
         2749  +  Index *pUpsertIdx;        /* Constraint that pUpsertTarget identifies */
  2750   2750     SrcList *pUpsertSrc;      /* Table to be updated */
  2751   2751     int regData;              /* First register holding array of VALUES */
  2752   2752     int iDataCur;             /* Index of the data cursor */
  2753   2753     int iIdxCur;              /* Index of the first index cursor */
  2754   2754   };
  2755   2755   
  2756   2756   /*