update.test 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. # 2001 September 15
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # a legal notice, here is a blessing:
  5. #
  6. # May you do good and not evil.
  7. # May you find forgiveness for yourself and forgive others.
  8. # May you share freely, never taking more than you give.
  9. #
  10. #***********************************************************************
  11. # This file implements regression tests for SQLite library. The
  12. # focus of this file is testing the UPDATE statement.
  13. #
  14. # $Id: update.test,v 1.9 2002/05/21 12:56:44 drh Exp $
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. # Try to update an non-existent table
  18. #
  19. do_test update-1.1 {
  20. set v [catch {execsql {UPDATE test1 SET f2=5 WHERE f1<1}} msg]
  21. lappend v $msg
  22. } {1 {no such table: test1}}
  23. # Try to update a read-only table
  24. #
  25. do_test update-2.1 {
  26. set v [catch \
  27. {execsql {UPDATE sqlite_master SET name='xyz' WHERE name='123'}} msg]
  28. lappend v $msg
  29. } {1 {table sqlite_master may not be modified}}
  30. # Create a table to work with
  31. #
  32. do_test update-3.1 {
  33. execsql {CREATE TABLE test1(f1 int,f2 int)}
  34. for {set i 1} {$i<=10} {incr i} {
  35. set sql "INSERT INTO test1 VALUES($i,[expr {int(pow(2,$i))}])"
  36. execsql $sql
  37. }
  38. execsql {SELECT * FROM test1 ORDER BY f1}
  39. } {1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024}
  40. # Unknown column name in an expression
  41. #
  42. do_test update-3.2 {
  43. set v [catch {execsql {UPDATE test1 SET f1=f3*2 WHERE f2==32}} msg]
  44. lappend v $msg
  45. } {1 {no such column: f3}}
  46. do_test update-3.3 {
  47. set v [catch {execsql {UPDATE test1 SET f1=test2.f1*2 WHERE f2==32}} msg]
  48. lappend v $msg
  49. } {1 {no such column: test2.f1}}
  50. do_test update-3.4 {
  51. set v [catch {execsql {UPDATE test1 SET f3=f1*2 WHERE f2==32}} msg]
  52. lappend v $msg
  53. } {1 {no such column: f3}}
  54. # Actually do some updates
  55. #
  56. do_test update-3.5 {
  57. execsql {UPDATE test1 SET f2=f2*3}
  58. } {}
  59. do_test update-3.6 {
  60. execsql {SELECT * FROM test1 ORDER BY f1}
  61. } {1 6 2 12 3 24 4 48 5 96 6 192 7 384 8 768 9 1536 10 3072}
  62. do_test update-3.7 {
  63. execsql {PRAGMA count_changes=on}
  64. execsql {UPDATE test1 SET f2=f2/3 WHERE f1<=5}
  65. } {5}
  66. do_test update-3.8 {
  67. execsql {SELECT * FROM test1 ORDER BY f1}
  68. } {1 2 2 4 3 8 4 16 5 32 6 192 7 384 8 768 9 1536 10 3072}
  69. do_test update-3.9 {
  70. execsql {UPDATE test1 SET f2=f2/3 WHERE f1>5}
  71. } {5}
  72. do_test update-3.10 {
  73. execsql {SELECT * FROM test1 ORDER BY f1}
  74. } {1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024}
  75. # Swap the values of f1 and f2 for all elements
  76. #
  77. do_test update-3.11 {
  78. execsql {UPDATE test1 SET F2=f1, F1=f2}
  79. } {10}
  80. do_test update-3.12 {
  81. execsql {SELECT * FROM test1 ORDER BY F1}
  82. } {2 1 4 2 8 3 16 4 32 5 64 6 128 7 256 8 512 9 1024 10}
  83. do_test update-3.13 {
  84. execsql {PRAGMA count_changes=off}
  85. execsql {UPDATE test1 SET F2=f1, F1=f2}
  86. } {}
  87. do_test update-3.14 {
  88. execsql {SELECT * FROM test1 ORDER BY F1}
  89. } {1 2 2 4 3 8 4 16 5 32 6 64 7 128 8 256 9 512 10 1024}
  90. # Create duplicate entries and make sure updating still
  91. # works.
  92. #
  93. do_test update-4.0 {
  94. execsql {
  95. DELETE FROM test1 WHERE f1<=5;
  96. INSERT INTO test1(f1,f2) VALUES(8,88);
  97. INSERT INTO test1(f1,f2) VALUES(8,888);
  98. INSERT INTO test1(f1,f2) VALUES(77,128);
  99. INSERT INTO test1(f1,f2) VALUES(777,128);
  100. }
  101. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  102. } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
  103. do_test update-4.1 {
  104. execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8}
  105. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  106. } {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128}
  107. do_test update-4.2 {
  108. execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800}
  109. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  110. } {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128}
  111. do_test update-4.3 {
  112. execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800}
  113. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  114. } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
  115. do_test update-4.4 {
  116. execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128}
  117. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  118. } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128}
  119. do_test update-4.5 {
  120. execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128}
  121. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  122. } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128}
  123. do_test update-4.6 {
  124. execsql {
  125. PRAGMA count_changes=on;
  126. UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128;
  127. }
  128. } {2}
  129. do_test update-4.7 {
  130. execsql {
  131. PRAGMA count_changes=off;
  132. SELECT * FROM test1 ORDER BY f1,f2
  133. }
  134. } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
  135. # Repeat the previous sequence of tests with an index.
  136. #
  137. do_test update-5.0 {
  138. execsql {CREATE INDEX idx1 ON test1(f1)}
  139. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  140. } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
  141. do_test update-5.1 {
  142. execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8}
  143. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  144. } {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128}
  145. do_test update-5.2 {
  146. execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800}
  147. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  148. } {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128}
  149. do_test update-5.3 {
  150. execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800}
  151. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  152. } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
  153. do_test update-5.4 {
  154. execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128}
  155. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  156. } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128}
  157. do_test update-5.4.1 {
  158. execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}
  159. } {78 128}
  160. do_test update-5.4.2 {
  161. execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
  162. } {778 128}
  163. do_test update-5.4.3 {
  164. execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
  165. } {8 88 8 128 8 256 8 888}
  166. do_test update-5.5 {
  167. execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128}
  168. } {}
  169. do_test update-5.5.1 {
  170. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  171. } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128}
  172. do_test update-5.5.2 {
  173. execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}
  174. } {78 128}
  175. do_test update-5.5.3 {
  176. execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
  177. } {}
  178. do_test update-5.5.4 {
  179. execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}
  180. } {777 128}
  181. do_test update-5.5.5 {
  182. execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
  183. } {8 88 8 128 8 256 8 888}
  184. do_test update-5.6 {
  185. execsql {
  186. PRAGMA count_changes=on;
  187. UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128;
  188. }
  189. } {2}
  190. do_test update-5.6.1 {
  191. execsql {
  192. PRAGMA count_changes=off;
  193. SELECT * FROM test1 ORDER BY f1,f2
  194. }
  195. } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
  196. do_test update-5.6.2 {
  197. execsql {SELECT * FROM test1 WHERE f1==77 ORDER BY f1,f2}
  198. } {77 128}
  199. do_test update-5.6.3 {
  200. execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
  201. } {}
  202. do_test update-5.6.4 {
  203. execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}
  204. } {777 128}
  205. do_test update-5.6.5 {
  206. execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
  207. } {8 88 8 256 8 888}
  208. # Repeat the previous sequence of tests with a different index.
  209. #
  210. do_test update-6.0 {
  211. execsql {DROP INDEX idx1}
  212. execsql {CREATE INDEX idx1 ON test1(f2)}
  213. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  214. } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
  215. do_test update-6.1 {
  216. execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8}
  217. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  218. } {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128}
  219. do_test update-6.1.1 {
  220. execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
  221. } {8 89 8 257 8 889}
  222. do_test update-6.1.2 {
  223. execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2}
  224. } {8 89}
  225. do_test update-6.1.3 {
  226. execsql {SELECT * FROM test1 WHERE f1==88 ORDER BY f1,f2}
  227. } {}
  228. do_test update-6.2 {
  229. execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800}
  230. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  231. } {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128}
  232. do_test update-6.3 {
  233. execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800}
  234. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  235. } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
  236. do_test update-6.3.1 {
  237. execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
  238. } {8 88 8 256 8 888}
  239. do_test update-6.3.2 {
  240. execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2}
  241. } {}
  242. do_test update-6.3.3 {
  243. execsql {SELECT * FROM test1 WHERE f2==88 ORDER BY f1,f2}
  244. } {8 88}
  245. do_test update-6.4 {
  246. execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128}
  247. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  248. } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128}
  249. do_test update-6.4.1 {
  250. execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}
  251. } {78 128}
  252. do_test update-6.4.2 {
  253. execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
  254. } {778 128}
  255. do_test update-6.4.3 {
  256. execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
  257. } {8 88 8 128 8 256 8 888}
  258. do_test update-6.5 {
  259. execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128}
  260. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  261. } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128}
  262. do_test update-6.5.1 {
  263. execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}
  264. } {78 128}
  265. do_test update-6.5.2 {
  266. execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
  267. } {}
  268. do_test update-6.5.3 {
  269. execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}
  270. } {777 128}
  271. do_test update-6.5.4 {
  272. execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
  273. } {8 88 8 128 8 256 8 888}
  274. do_test update-6.6 {
  275. execsql {UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128}
  276. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  277. } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
  278. do_test update-6.6.1 {
  279. execsql {SELECT * FROM test1 WHERE f1==77 ORDER BY f1,f2}
  280. } {77 128}
  281. do_test update-6.6.2 {
  282. execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
  283. } {}
  284. do_test update-6.6.3 {
  285. execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}
  286. } {777 128}
  287. do_test update-6.6.4 {
  288. execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
  289. } {8 88 8 256 8 888}
  290. # Repeat the previous sequence of tests with multiple
  291. # indices
  292. #
  293. do_test update-7.0 {
  294. execsql {CREATE INDEX idx2 ON test1(f2)}
  295. execsql {CREATE INDEX idx3 ON test1(f1,f2)}
  296. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  297. } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
  298. do_test update-7.1 {
  299. execsql {UPDATE test1 SET f2=f2+1 WHERE f1==8}
  300. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  301. } {6 64 7 128 8 89 8 257 8 889 9 512 10 1024 77 128 777 128}
  302. do_test update-7.1.1 {
  303. execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
  304. } {8 89 8 257 8 889}
  305. do_test update-7.1.2 {
  306. execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2}
  307. } {8 89}
  308. do_test update-7.1.3 {
  309. execsql {SELECT * FROM test1 WHERE f1==88 ORDER BY f1,f2}
  310. } {}
  311. do_test update-7.2 {
  312. execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2>800}
  313. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  314. } {6 64 7 128 8 89 8 257 8 888 9 512 10 1024 77 128 777 128}
  315. do_test update-7.3 {
  316. # explain {UPDATE test1 SET f2=f2-1 WHERE f1==8 and F2<300}
  317. execsql {UPDATE test1 SET f2=f2-1 WHERE f1==8 and f2<800}
  318. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  319. } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
  320. do_test update-7.3.1 {
  321. execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
  322. } {8 88 8 256 8 888}
  323. do_test update-7.3.2 {
  324. execsql {SELECT * FROM test1 WHERE f2==89 ORDER BY f1,f2}
  325. } {}
  326. do_test update-7.3.3 {
  327. execsql {SELECT * FROM test1 WHERE f2==88 ORDER BY f1,f2}
  328. } {8 88}
  329. do_test update-7.4 {
  330. execsql {UPDATE test1 SET f1=f1+1 WHERE f2==128}
  331. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  332. } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 778 128}
  333. do_test update-7.4.1 {
  334. execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}
  335. } {78 128}
  336. do_test update-7.4.2 {
  337. execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
  338. } {778 128}
  339. do_test update-7.4.3 {
  340. execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
  341. } {8 88 8 128 8 256 8 888}
  342. do_test update-7.5 {
  343. execsql {UPDATE test1 SET f1=f1-1 WHERE f1>100 and f2==128}
  344. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  345. } {6 64 8 88 8 128 8 256 8 888 9 512 10 1024 78 128 777 128}
  346. do_test update-7.5.1 {
  347. execsql {SELECT * FROM test1 WHERE f1==78 ORDER BY f1,f2}
  348. } {78 128}
  349. do_test update-7.5.2 {
  350. execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
  351. } {}
  352. do_test update-7.5.3 {
  353. execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}
  354. } {777 128}
  355. do_test update-7.5.4 {
  356. execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
  357. } {8 88 8 128 8 256 8 888}
  358. do_test update-7.6 {
  359. execsql {UPDATE test1 SET f1=f1-1 WHERE f1<=100 and f2==128}
  360. execsql {SELECT * FROM test1 ORDER BY f1,f2}
  361. } {6 64 7 128 8 88 8 256 8 888 9 512 10 1024 77 128 777 128}
  362. do_test update-7.6.1 {
  363. execsql {SELECT * FROM test1 WHERE f1==77 ORDER BY f1,f2}
  364. } {77 128}
  365. do_test update-7.6.2 {
  366. execsql {SELECT * FROM test1 WHERE f1==778 ORDER BY f1,f2}
  367. } {}
  368. do_test update-7.6.3 {
  369. execsql {SELECT * FROM test1 WHERE f1==777 ORDER BY f1,f2}
  370. } {777 128}
  371. do_test update-7.6.4 {
  372. execsql {SELECT * FROM test1 WHERE f1==8 ORDER BY f1,f2}
  373. } {8 88 8 256 8 888}
  374. # Error messages
  375. #
  376. do_test update-9.1 {
  377. set v [catch {execsql {
  378. UPDATE test1 SET x=11 WHERE f1=1025
  379. }} msg]
  380. lappend v $msg
  381. } {1 {no such column: x}}
  382. do_test update-9.2 {
  383. set v [catch {execsql {
  384. UPDATE test1 SET f1=x(11) WHERE f1=1025
  385. }} msg]
  386. lappend v $msg
  387. } {1 {no such function: x}}
  388. do_test update-9.3 {
  389. set v [catch {execsql {
  390. UPDATE test1 SET f1=11 WHERE x=1025
  391. }} msg]
  392. lappend v $msg
  393. } {1 {no such column: x}}
  394. do_test update-9.4 {
  395. set v [catch {execsql {
  396. UPDATE test1 SET f1=11 WHERE x(f1)=1025
  397. }} msg]
  398. lappend v $msg
  399. } {1 {no such function: x}}
  400. # Try doing updates on a unique column where the value does not
  401. # really change.
  402. #
  403. do_test update-10.1 {
  404. execsql {
  405. DROP TABLE test1;
  406. CREATE TABLE t1(
  407. a integer primary key,
  408. b UNIQUE,
  409. c, d,
  410. e, f,
  411. UNIQUE(c,d)
  412. );
  413. INSERT INTO t1 VALUES(1,2,3,4,5,6);
  414. INSERT INTO t1 VALUES(2,3,4,4,6,7);
  415. SELECT * FROM t1
  416. }
  417. } {1 2 3 4 5 6 2 3 4 4 6 7}
  418. do_test update-10.2 {
  419. catchsql {
  420. UPDATE t1 SET a=1, e=9 WHERE f=6;
  421. SELECT * FROM t1;
  422. }
  423. } {0 {1 2 3 4 9 6 2 3 4 4 6 7}}
  424. do_test update-10.3 {
  425. catchsql {
  426. UPDATE t1 SET a=1, e=10 WHERE f=7;
  427. SELECT * FROM t1;
  428. }
  429. } {1 {constraint failed}}
  430. do_test update-10.4 {
  431. catchsql {
  432. SELECT * FROM t1;
  433. }
  434. } {0 {1 2 3 4 9 6 2 3 4 4 6 7}}
  435. do_test update-10.5 {
  436. catchsql {
  437. UPDATE t1 SET b=2, e=11 WHERE f=6;
  438. SELECT * FROM t1;
  439. }
  440. } {0 {1 2 3 4 11 6 2 3 4 4 6 7}}
  441. do_test update-10.6 {
  442. catchsql {
  443. UPDATE t1 SET b=2, e=12 WHERE f=7;
  444. SELECT * FROM t1;
  445. }
  446. } {1 {constraint failed}}
  447. do_test update-10.7 {
  448. catchsql {
  449. SELECT * FROM t1;
  450. }
  451. } {0 {1 2 3 4 11 6 2 3 4 4 6 7}}
  452. do_test update-10.8 {
  453. catchsql {
  454. UPDATE t1 SET c=3, d=4, e=13 WHERE f=6;
  455. SELECT * FROM t1;
  456. }
  457. } {0 {1 2 3 4 13 6 2 3 4 4 6 7}}
  458. do_test update-10.9 {
  459. catchsql {
  460. UPDATE t1 SET c=3, d=4, e=14 WHERE f=7;
  461. SELECT * FROM t1;
  462. }
  463. } {1 {constraint failed}}
  464. do_test update-10.10 {
  465. catchsql {
  466. SELECT * FROM t1;
  467. }
  468. } {0 {1 2 3 4 13 6 2 3 4 4 6 7}}
  469. finish_test