SQLite

Check-in [cc6cd7531f]
Login

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

Overview
Comment:Fix a problem with ALTER TABLE and vector assignments in UPDATE statements within triggers.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cc6cd7531fee39b4c2a9f522f1089c1d79254a9e25acae59468322031f94c25a
User & Date: dan 2019-01-15 20:51:35.919
Context
2019-01-16
11:38
Fix a memory leak that could occur in fts3 when handling a corrupt database. (check-in: 65cebb06a0 user: dan tags: trunk)
2019-01-15
20:51
Fix a problem with ALTER TABLE and vector assignments in UPDATE statements within triggers. (check-in: cc6cd7531f user: dan tags: trunk)
18:14
Handle SQL NULL values without crashing in the fts5 snippet() and highlight() functions. (check-in: a5e9cc794f user: dan tags: trunk)
Changes
Side-by-Side Diff Show Whitespace Changes Patch
Changes to src/expr.c.
461
462
463
464
465
466
467

468
469
470
471
472
473
474
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475







+







      pRet->iColumn = iField;
      pRet->pLeft = pVector;
    }
    assert( pRet==0 || pRet->iTable==0 );
  }else{
    if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;
    pRet = sqlite3ExprDup(pParse->db, pVector, 0);
    sqlite3RenameTokenRemap(pParse, pRet, pVector);
  }
  return pRet;
}

/*
** If expression pExpr is of type TK_SELECT, generate code to evaluate
** it. Return the register in which the result is stored (or, if the 
1664
1665
1666
1667
1668
1669
1670



1671
1672
1673
1674
1675
1676
1677
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681







+
+
+








    /* Remember the size of the LHS in iTable so that we can check that
    ** the RHS and LHS sizes match during code generation. */
    pFirst->iTable = pColumns->nId;
  }

vector_append_error:
  if( IN_RENAME_OBJECT ){
    sqlite3RenameExprUnmap(pParse, pExpr);
  }
  sqlite3ExprDelete(db, pExpr);
  sqlite3IdListDelete(db, pColumns);
  return pList;
}

/*
** Set the sort order for the last element on the given ExprList.
Changes to test/altertab2.test.
137
138
139
140
141
142
143




































144
145
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


  set expect [string map {col1 newname} $expect]

  do_execsql_test 3.$tn.4 {
    ALTER TABLE log_entry RENAME col1 TO newname;
    SELECT sql FROM sqlite_master;
  } $expect
}

#-------------------------------------------------------------------------
reset_db
do_execsql_test 4.0 {
  CREATE TABLE t1(a,b,c,d,e,f);
  CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN new.a NOT NULL BEGIN
    UPDATE t1 SET (c,d)=(a,b);
  END;
}

do_execsql_test 4.1 {
  ALTER TABLE t1 RENAME TO t1x;
  SELECT sql FROM sqlite_master WHERE type = 'trigger';
} {
{CREATE TRIGGER r1 AFTER INSERT ON "t1x" WHEN new.a NOT NULL BEGIN
    UPDATE "t1x" SET (c,d)=(a,b);
  END}
}

do_execsql_test 4.2 {
  ALTER TABLE t1x RENAME a TO aaa;
  SELECT sql FROM sqlite_master WHERE type = 'trigger';
} {
{CREATE TRIGGER r1 AFTER INSERT ON "t1x" WHEN new.aaa NOT NULL BEGIN
    UPDATE "t1x" SET (c,d)=(aaa,b);
  END}
}

do_execsql_test 4.3 {
  ALTER TABLE t1x RENAME d TO ddd;
  SELECT sql FROM sqlite_master WHERE type = 'trigger';
} {
{CREATE TRIGGER r1 AFTER INSERT ON "t1x" WHEN new.aaa NOT NULL BEGIN
    UPDATE "t1x" SET (c,ddd)=(aaa,b);
  END}
}

finish_test