/ Hex Artifact Content
Login

Artifact 92a80e4afc172c24f662a10a612d188fb272de4a9bd19e017927c95f737de6d7:


0000: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00  SQLite format 3.
0010: 20 00 01 01 00 40 20 20 00 00 00 09 00 00 00 da   ....@  ........
0020: 00 00 00 00 00 00 00 00 00 00 00 05 00 00 00 04  ................
0030: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00  ................
0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09  ................
0060: 00 2e 20 98 0d 00 00 00 03 1e 74 00 1f 77 1e db  .. .......t..w..
0070: 1e 74 00 00 00 00 00 00 00 00 00 00 00 00 00 00  .t..............
0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
01a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
01b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
01c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
01d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
01e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
01f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0220: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0230: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0270: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0290: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
02a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
02b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
02c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
02d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
02e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
02f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
03a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
03b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
03c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
03d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
03e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
03f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
04a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
04b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
04c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
04d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
04e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
04f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0550: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
05a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
05b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
05c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
05d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
05e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
05f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
06a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
06b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
06c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
06d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
06e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
06f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0730: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0750: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0770: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0790: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0810: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0820: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0830: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0890: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
08a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
08b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
08c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
08d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
08e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
08f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0910: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0920: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0930: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0940: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0950: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0960: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0970: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0990: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
09a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
09b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
09c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
09d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
09e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
09f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0a10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0a20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0a30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0a40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0a50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0a60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0a70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0a90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0aa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0ab0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0ac0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0ad0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0ae0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0af0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0b10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0b20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0b30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0b40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0b50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0b60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0b70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0b90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0ba0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0bb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0bc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0be0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0bf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0c20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0c30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0c40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0c50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0c60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0c70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0c80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0c90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0ca0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0cb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0cc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0cd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0ce0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0cf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0d10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0d20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0d30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0d40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0d50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0d60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0d70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0d80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0d90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0da0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0db0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0dc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0dd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0de0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0df0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0e10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0e20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0e30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0e40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0e50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0e60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0e70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0e90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0ea0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0eb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0ec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0ed0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0ee0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0ef0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0f10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0f20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0f30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0f40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0f50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0f60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0f70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0f90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0fa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
11a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
11b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
11c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
11d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
11e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
11f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1220: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1230: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1270: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1290: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
13a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
13b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
13c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
13d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
13e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
13f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
14a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
14b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
14c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
14d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
14e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
14f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1550: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
15a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
15b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
15c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
15d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
15e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
15f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
16a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
16b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
16c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
16d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
16e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
16f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1730: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1750: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1770: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1790: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
17a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
17b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
17c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
17d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
17e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
17f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1810: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1820: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1830: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1890: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1910: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1920: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1930: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1940: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1950: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1960: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1970: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1990: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
19a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
19b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
19c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
19d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
19e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
19f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1a10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1a20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1a30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1a40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1a50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1a60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1a70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1a90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1aa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1ab0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1ac0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1ad0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1ae0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1af0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1b10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1b20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1b30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1b40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1b50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1b60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1b70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1b90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1ba0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1bb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1bc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1be0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1bf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1ca0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1cb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1cc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1cd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1ce0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1cf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1d10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1d20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1d30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1d40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1d50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1d60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1d70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1d80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1d90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1da0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1db0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1dc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1dd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1de0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1df0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e70: 00 00 00 00 65 03 07 17 19 19 01 81 25 74 61 62  ....e.......%tab
1e80: 6c 65 72 65 61 64 6d 65 72 65 61 64 6d 65 04 43  lereadmereadme.C
1e90: 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 61 64  REATE TABLE read
1ea0: 6d 65 28 0a 20 20 6d 73 67 20 54 45 58 54 20 2d  me(.  msg TEXT -
1eb0: 2d 20 48 75 6d 61 6e 2d 72 65 61 64 61 62 6c 65  - Human-readable
1ec0: 20 64 65 73 63 72 69 70 74 69 6f 6e 20 6f 66 20   description of 
1ed0: 74 68 69 73 20 66 69 6c 65 0a 29 81 19 02 07 17  this file.).....
1ee0: 15 15 01 82 15 74 61 62 6c 65 78 73 71 6c 78 73  .....tablexsqlxs
1ef0: 71 6c 03 43 52 45 41 54 45 20 54 41 42 4c 45 20  ql.CREATE TABLE 
1f00: 78 73 71 6c 28 0a 20 20 73 71 6c 69 64 20 49 4e  xsql(.  sqlid IN
1f10: 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
1f20: 59 2c 20 20 20 2d 2d 20 53 51 4c 20 73 63 72 69  Y,   -- SQL scri
1f30: 70 74 20 69 64 0a 20 20 73 71 6c 74 65 78 74 20  pt id.  sqltext 
1f40: 54 45 58 54 20 20 20 20 20 20 20 20 20 20 20 20  TEXT            
1f50: 20 20 20 20 20 2d 2d 20 54 65 78 74 20 6f 66 20       -- Text of 
1f60: 53 51 4c 20 73 74 61 74 65 6d 65 6e 74 73 20 74  SQL statements t
1f70: 6f 20 72 75 6e 0a 29 81 06 01 07 17 11 11 01 81  o run.).........
1f80: 77 74 61 62 6c 65 64 62 64 62 02 43 52 45 41 54  wtabledbdb.CREAT
1f90: 45 20 54 41 42 4c 45 20 64 62 28 0a 20 20 64 62  E TABLE db(.  db
1fa0: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41  id INTEGER PRIMA
1fb0: 52 59 20 4b 45 59 2c 20 2d 2d 20 64 61 74 61 62  RY KEY, -- datab
1fc0: 61 73 65 20 69 64 0a 20 20 64 62 63 6f 6e 74 65  ase id.  dbconte
1fd0: 6e 74 20 42 4c 4f 42 20 20 20 20 20 20 20 20 20  nt BLOB         
1fe0: 20 20 20 2d 2d 20 64 61 74 61 62 61 73 65 20 64     -- database d
1ff0: 69 73 6b 20 66 69 6c 65 20 69 6d 61 67 65 0a 29  isk file image.)
2000: 0d 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00  ..... ..........
2010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
21a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
21b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
21c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
21d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
21e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
21f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2220: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2230: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2270: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2290: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
23a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
23b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
23c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
23d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
23e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
23f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2550: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
25a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
25b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
25c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
25d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
25e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
25f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2730: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2750: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2770: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2790: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
27a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
27b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
27c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
27d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
27e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
27f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2810: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2820: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2830: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2890: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2910: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2920: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2930: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2940: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2950: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2960: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2970: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2990: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
29a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
29b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
29c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
29d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
29e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
29f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2aa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2ab0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2ac0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2ad0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2ae0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2af0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2b10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2b20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2b30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2b40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2b50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2b60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2b70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2b90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2ba0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2bb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2bc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2be0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2bf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2ca0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2cb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2cc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2cd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2ce0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2cf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2d10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2d20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2d30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2d40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2d50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2d60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2d70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2d80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2d90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2da0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2db0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2dc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2dd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2de0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2df0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2ea0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2eb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2ec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2ed0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2ee0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2ef0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2f10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2f20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2f30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2f40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2f50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2f60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2f70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2f90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2fa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
31a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
31b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
31c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
31d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
31e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
31f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3220: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3230: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3270: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3290: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
33a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
33b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
33c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
33d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
33e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
33f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3550: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
35a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
35b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
35c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
35d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
35e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
35f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
36a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
36b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
36c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
36d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
36e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
36f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3730: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3750: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3770: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3790: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
37a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
37b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
37c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
37d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
37e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
37f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3810: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3820: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3830: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3890: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3910: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3920: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3930: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3940: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3950: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3960: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3970: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3990: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
39a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
39b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
39c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
39d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
39e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
39f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3a10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3a20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3a30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3a40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3a50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3a60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3a70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3a90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3aa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3ab0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3ac0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3ad0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3ae0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3af0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3b10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3b20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3b30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3b40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3b50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3b60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3b70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3b90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3ba0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3bb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3bc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3be0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3bf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3c20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3c30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3c40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3c50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3c60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3c70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3c80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3c90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3ca0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3cb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3cc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3cd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3ce0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3cf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3d10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3d20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3d30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3d40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3d50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3d60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3d70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3d80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3d90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3da0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3db0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3dc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3dd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3de0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3df0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3e10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3e20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3e30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3e40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3e50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3e60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3e70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3e90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3ea0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3eb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3ec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3ed0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3ee0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3ef0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3f10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3f20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3f30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3f40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3f50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3f60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3f70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3f90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3fa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
3ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
4000: 05 00 00 00 d5 1b 0b 00 00 00 00 da 1f fb 1f f6  ................
4010: 1f f1 1f ec 1f e7 1f e2 1f dd 1f d8 1f d3 1f cd  ................
4020: 1f c7 1f c1 1f bb 1f b5 1f af 1f a9 1f a3 1f 9d  ................
4030: 1f 97 1f 91 1f 8b 1f 85 1f 7f 1f 79 1f 73 1f 6d  ...........y.s.m
4040: 1f 67 1f 61 1f 5b 1f 55 1f 4f 1f 49 1f 43 1f 3d  .g.a.[.U.O.I.C.=
4050: 1f 37 1f 31 1f 2b 1f 25 1f 1f 1f 19 1f 13 1f 0d  .7.1.+.%........
4060: 1f 07 1f 01 1e fb 1e f5 1e ef 1e e9 1e e3 1e dd  ................
4070: 1e d7 1e d1 1e cb 1e c5 1e bf 1e b9 1e b3 1e ad  ................
4080: 1e a7 1e a1 1e 9b 1e 95 1e 8f 1e 89 1e 83 1e 7d  ...............}
4090: 1e 77 1e 71 1e 6b 1e 65 1e 5f 1e 59 1e 53 1e 4d  .w.q.k.e._.Y.S.M
40a0: 1e 47 1e 41 1e 3b 1e 35 1e 2f 1e 29 1e 23 1e 1d  .G.A.;.5./.).#..
40b0: 1e 17 1e 11 1e 0b 1e 05 1d ff 1d f9 1d f3 1d ed  ................
40c0: 1d e7 1d e1 1d db 1d d5 1d cf 1d c9 1d c3 1d bd  ................
40d0: 1d b7 1d b1 1d ab 1d a5 1d 9f 1d 99 1d 93 1d 8d  ................
40e0: 1d 87 1d 81 1d 7b 1d 75 1d 6f 1d 69 1d 63 1d 5d  .....{.u.o.i.c.]
40f0: 1d 57 1d 51 1d 4b 1d 45 1d 3f 1d 39 1d 33 1d 2d  .W.Q.K.E.?.9.3.-
4100: 1d 27 1d 21 1d 1b 1d 15 1d 0f 1d 09 1d 03 1c fd  .'.!............
4110: 1c f7 1c f1 1c eb 1c e5 1c df 1c d9 1c d3 1c cd  ................
4120: 1c c7 1c c1 1c bb 1c b5 1c af 1c a9 1c a3 1c 9d  ................
4130: 1c 97 1c 91 1c 8b 1c 85 1c 7f 1c 79 1c 73 1c 6d  ...........y.s.m
4140: 1c 67 1c 61 1c 5b 1c 55 1c 4f 1c 49 1c 43 1c 3d  .g.a.[.U.O.I.C.=
4150: 1c 37 1c 31 1c 2b 1c 25 1c 1f 1c 19 1c 13 1c 0d  .7.1.+.%........
4160: 1c 07 1c 01 1b fb 1b f5 1b ef 1b e9 1b e3 1b dd  ................
4170: 1b d7 1b d1 1b cb 1b c5 1b bf 1b b9 1b b3 1b ad  ................
4180: 1b a7 1b a1 1b 9b 1b 95 1b 8f 1b 89 1b 83 1b 7d  ...............}
4190: 1b 77 1b 71 1b 6b 1b 65 1b 5f 1b 59 1b 53 1b 4d  .w.q.k.e._.Y.S.M
41a0: 1b 47 1b 41 1b 3b 1b 35 1b 2f 1b 29 1b 23 1b 1d  .G.A.;.5./.).#..
41b0: 1b 17 1b 11 1b 0b 4e 53 45 52 54 20 4f 4e 20 74  ......NSERT ON t
41c0: 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
41d0: 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
41e0: 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27  ,y)     VALUES('
41f0: 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
4200: 69 6e 74 66 28 27 25 71 2c 25 64 2c 25 64 27 2c  intf('%q,%d,%d',
4210: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
4220: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
4230: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
4240: 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e  BEFORE UPDATE ON
4250: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
4260: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
4270: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
4280: 4c 55 45 53 28 20 72 65 70 6c 61 63 65 28 31 2c  LUES( replace(1,
4290: 31 2c 31 29 2c 70 72 69 6e 74 66 28 27 25 64 2c  1,1),printf('%d,
42a0: 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
42b0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
42c0: 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
42d0: 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
42e0: 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
42f0: 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
4300: 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55  IGGER r4 AFTER U
4310: 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
4320: 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
4330: 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
4340: 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
4350: 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ter-update',prin
4360: 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
4370: 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
4380: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
4390: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
43a0: 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
43b0: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
43c0: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e  c));.  END;.  IN
43d0: 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
43e0: 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20  ) VALUES(1,2);. 
43f0: 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
4400: 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
4410: 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
4420: 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
4430: 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
4440: 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31  ATE SET c=t1.c+1
4450: 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
4460: 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45  M record;.  DELE
4470: 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
4480: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
4490: 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
44a0: 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
44b0: 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
44c0: 45 54 20 63 3d 63 3b 31 20 57 48 45 52 45 20 63  ET c=c;1 WHERE c
44d0: 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  <0;.  SELECT * F
44e0: 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 51 0d 04  ROM record;..Q..
44f0: 00 91 27 20 20 43 52 45 41 54 45 20 54 41 42 4c  ..'  CREATE TABL
4500: 45 20 74 31 28 61 20 20 63 68 61 72 28 31 29 50  E t1(a  char(1)P
4510: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
4520: 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  t, c DEFAULT 0);
4530: 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
4540: 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79  record(x TEXT, y
4550: 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45   TEXT);.  CREATE
4560: 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f   TRIGGER r1 BEFO
4570: 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  RE INSERT ON t1 
4580: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
4590: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
45a0: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
45b0: 28 27 62 73 65 72 74 27 2c 70 72 69 6e 74 66 28  ('bsert',printf(
45c0: 27 25 63 ac 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%c.%d,%d',new.a
45d0: 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
45e0: 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
45f0: 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
4600: 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
4610: 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
4620: 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
4630: 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
4640: 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
4650: 28 27 25 71 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%q,%d,%d',new.
4660: 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
4670: 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
4680: 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
4690: 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
46a0: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
46b0: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
46c0: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
46d0: 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
46e0: 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
46f0: 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
4700: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
4710: 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
4720: 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
4730: 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
4740: 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
4750: 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
4760: 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
4770: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
4780: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
4790: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
47a0: 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
47b0: 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
47c0: 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
47d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
47e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
47f0: 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
4800: 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
4810: 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
4820: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
4830: 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
4840: 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
4850: 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
4860: 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
4870: 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
4880: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
4890: 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
48a0: 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
48b0: 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
48c0: 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
48d0: 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
48e0: 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
48f0: 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
4900: 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
4910: 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
4920: 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
4930: 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
4940: 88 49 0c 04 00 91 17 20 20 43 52 45 41 54 45 20  .I.....  CREATE 
4950: 54 41 42 4c 45 20 74 31 28 61 20 20 63 68 61 72  TABLE t1(a  char
4960: 28 31 29 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  (1)PRIMARY KEY, 
4970: 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
4980: 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41   0);.  CREATE TA
4990: 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58  BLE record(x TEX
49a0: 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52  T, y TEXT);.  CR
49b0: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20  EATE TRIGGER r1 
49c0: 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e  BEFORE INSERT ON
49d0: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
49e0: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
49f0: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
4a00: 4c 55 45 53 28 27 62 73 65 72 74 27 2c 70 72 69  LUES('bsert',pri
4a10: 6e 74 66 28 20 67 6c 6f 62 28 31 2c 31 29 2c 6e  ntf( glob(1,1),n
4a20: 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
4a30: 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
4a40: 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
4a50: 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74  FTER INSERT ON t
4a60: 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
4a70: 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
4a80: 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27  ,y)     VALUES('
4a90: 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
4aa0: 69 6e 74 66 28 27 25 71 2c 25 64 2c 25 64 27 2c  intf('%q,%d,%d',
4ab0: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
4ac0: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
4ad0: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
4ae0: 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e  BEFORE UPDATE ON
4af0: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
4b00: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
4b10: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
4b20: 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64  LUES('before-upd
4b30: 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
4b40: 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
4b50: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
4b60: 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
4b70: 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
4b80: 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
4b90: 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
4ba0: 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55  IGGER r4 AFTER U
4bb0: 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
4bc0: 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
4bd0: 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
4be0: 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
4bf0: 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ter-update',prin
4c00: 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
4c10: 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
4c20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
4c30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
4c40: 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
4c50: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
4c60: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e  c));.  END;.  IN
4c70: 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
4c80: 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20  ) VALUES(1,2);. 
4c90: 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
4ca0: 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
4cb0: 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
4cc0: 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
4cd0: 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
4ce0: 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31  ATE SET c=t1.c+1
4cf0: 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
4d00: 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45  M record;.  DELE
4d10: 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
4d20: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
4d30: 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
4d40: 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
4d50: 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
4d60: 45 54 20 63 3d 63 3b 31 20 57 48 45 52 45 20 63  ET c=c;1 WHERE c
4d70: 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  <0;.  SELECT * F
4d80: 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 59 0b 04  ROM record;..Y..
4d90: 00 91 37 20 20 43 52 45 41 54 45 20 54 41 42 4c  ..7  CREATE TABL
4da0: 45 20 74 31 28 61 20 20 63 68 61 72 28 31 29 50  E t1(a  char(1)P
4db0: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
4dc0: 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  t, c DEFAULT 0);
4dd0: 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
4de0: 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79  record(x TEXT, y
4df0: 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45   TEXT);.  CREATE
4e00: 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f   TRIGGER r1 BEFO
4e10: 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  RE INSERT ON t1 
4e20: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
4e30: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
4e40: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
4e50: 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27  ('before-insert'
4e60: 2c 70 72 69 6e 74 66 28 27 25 67 2c 25 64 2c 25  ,printf('%g,%d,%
4e70: 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
4e80: 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
4e90: 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
4ea0: 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r2 AFTER INSERT 
4eb0: 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
4ec0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
4ed0: 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55  rd(x,y)     VALU
4ee0: 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74  ES('after-insert
4ef0: 27 2c 70 72 69 6e 74 66 28 27 25 67 2c 25 64 2c  ',printf('%g,%d,
4f00: 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
4f10: 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
4f20: 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
4f30: 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54   r3 BEFORE UPDAT
4f40: 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
4f50: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
4f60: 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
4f70: 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
4f80: 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
4f90: 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
4fa0: 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
4fb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
4fc0: 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f     old.a,old.b,o
4fd0: 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ld.c,new.a,new.b
4fe0: 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
4ff0: 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
5000: 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54  R r4 AFTER UPDAT
5010: 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
5020: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
5030: 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
5040: 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
5050: 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
5060: 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
5070: 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
5080: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
5090: 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
50a0: 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
50b0: 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
50c0: 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54  .  END;.  INSERT
50d0: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
50e0: 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c  LUES(1,2);.  DEL
50f0: 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  ETE FROM record;
5100: 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
5110: 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
5120: 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49  2).    ON CONFLI
5130: 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20  CT(a) DO UPDATE 
5140: 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20  SET c=t1.c+1;.  
5150: 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
5160: 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46  cord;.  DELETE F
5170: 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e  ROM record;.  IN
5180: 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
5190: 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20  ) VALUES(1,2).  
51a0: 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
51b0: 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
51c0: 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a  =c+1 WHERE c<0;.
51d0: 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
51e0: 72 65 63 6f 72 64 3b 0a 82 0d 0a 04 00 84 1f 20  record;........ 
51f0: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
5200: 28 20 61 2c 62 61 2c 49 4e 54 45 47 45 52 20 50  ( a,ba,INTEGER P
5210: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 2c 49 4e  RIMARY KEY, b,IN
5220: 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T, c DEFAULT 0);
5230: 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
5240: 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
5250: 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
5260: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
5270: 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
5280: 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
5290: 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
52a0: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
52b0: 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
52c0: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
52d0: 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
52e0: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 2a 20 46  LECT DISTINCT* F
52f0: 52 4f 4d 20 74 31 3b 0a 82 0d 09 04 00 84 1f 20  ROM t1;........ 
5300: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
5310: 28 20 61 2c 62 61 20 61 2c 62 45 47 45 52 20 50  ( a,ba a,bEGER P
5320: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e  RIMARY KEY, b IN
5330: 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T, c DEFAULT 0);
5340: 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
5350: 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
5360: 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
5370: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
5380: 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
5390: 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
53a0: 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
53b0: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
53c0: 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
53d0: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
53e0: 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
53f0: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 2a 20 46  LECT DISTINCT* F
5400: 52 4f 4d 20 74 31 3b 0a 82 0d 08 04 00 84 1f 20  ROM t1;........ 
5410: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
5420: 28 20 61 2c 62 61 20 49 4e 54 45 47 45 52 20 50  ( a,ba INTEGER P
5430: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 2c 49 4e  RIMARY KEY, b,IN
5440: 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T, c DEFAULT 0);
5450: 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
5460: 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
5470: 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
5480: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
5490: 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
54a0: 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
54b0: 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
54c0: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
54d0: 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
54e0: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
54f0: 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
5500: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 2a 20 46  LECT DISTINCT* F
5510: 52 4f 4d 20 74 31 3b 0a 82 0d 07 04 00 84 1f 20  ROM t1;........ 
5520: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
5530: 28 20 61 2c 62 61 20 49 4e 54 45 47 45 52 20 50  ( a,ba INTEGER P
5540: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 2c 49 2c  RIMARY KEY, b,I,
5550: 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T, c DEFAULT 0);
5560: 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
5570: 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
5580: 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
5590: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
55a0: 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
55b0: 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
55c0: 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
55d0: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
55e0: 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
55f0: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
5600: 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
5610: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 2a 20 46  LECT DISTINCT* F
5620: 52 4f 4d 20 74 31 3b 0a 82 0d 06 04 00 84 1f 20  ROM t1;........ 
5630: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
5640: 28 20 61 2c 62 61 20 49 4e 54 45 47 45 52 20 50  ( a,ba INTEGER P
5650: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e  RIMARY KEY, b IN
5660: 54 ac 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T. c DEFAULT 0);
5670: 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
5680: 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
5690: 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
56a0: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
56b0: 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
56c0: 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
56d0: 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
56e0: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
56f0: 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
5700: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
5710: 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
5720: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 2a 20 46  LECT DISTINCT* F
5730: 52 4f 4d 20 74 31 3b 0a 82 0d 05 04 00 84 1f 20  ROM t1;........ 
5740: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
5750: 28 20 61 2c 62 61 20 49 4e 54 45 47 45 52 20 50  ( a,ba INTEGER P
5760: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e  RIMARY KEY, b IN
5770: 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T, c DEFAULT 0);
5780: 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
5790: 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
57a0: 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
57b0: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
57c0: 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
57d0: 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
57e0: 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
57f0: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
5800: 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
5810: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
5820: 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
5830: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 2a 20 46  LECT DISTINCT* F
5840: 52 4f 4d 20 74 31 3b 0a 82 0d 04 04 00 84 1f 20  ROM t1;........ 
5850: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
5860: 28 20 61 2c 62 61 20 49 4e 54 45 47 45 52 20 44  ( a,ba INTEGER D
5870: 45 46 41 55 4c 54 20 4b 45 59 2c 20 62 2c 49 4e  EFAULT KEY, b,IN
5880: 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T, c DEFAULT 0);
5890: 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
58a0: 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
58b0: 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
58c0: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
58d0: 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
58e0: 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
58f0: 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
5900: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
5910: 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
5920: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
5930: 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
5940: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 2a 20 46  LECT DISTINCT* F
5950: 52 4f 4d 20 74 31 3b 0a 88 59 03 04 00 91 37 20  ROM t1;..Y....7 
5960: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
5970: 28 20 61 2c 62 54 45 47 45 52 20 50 52 49 4d 41  ( a,bTEGER PRIMA
5980: 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63  RY KEY, b int, c
5990: 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43   DEFAULT 0);.  C
59a0: 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f  REATE TABLE reco
59b0: 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58  rd(x TEXT, y TEX
59c0: 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  T);.  CREATE TRI
59d0: 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49  GGER r1 BEFORE I
59e0: 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
59f0: 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
5a00: 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
5a10: 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
5a20: 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69  fore-insert',pri
5a30: 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
5a40: 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
5a50: 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
5a60: 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
5a70: 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74  FTER INSERT ON t
5a80: 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
5a90: 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
5aa0: 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27  ,y)     VALUES('
5ab0: 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
5ac0: 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c  intf('%d,%d,%d',
5ad0: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
5ae0: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
5af0: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
5b00: 42 45 46 4f 52 45 20 55 50 44 41 00 00 00 d9 9e  BEFORE UPDA.....
5b10: 1d 00 00 00 d8 9d 6f 00 00 00 d7 9d 4b 00 00 00  ......o.....K...
5b20: d6 9d 20 00 00 00 d5 9c 73 00 00 00 d4 9c 3d 00  .. .....s.....=.
5b30: 00 00 d3 9c 1b 00 00 00 d2 9b 78 00 00 00 d1 9b  ..........x.....
5b40: 4a 00 00 00 d0 9b 25 00 00 00 cf 9a 7f 00 00 00  J.....%.........
5b50: ce 9a 59 00 00 00 cd 9a 33 00 00 00 cc 9a 0a 00  ..Y.....3.......
5b60: 00 00 cb 99 64 00 00 00 ca 99 37 00 00 00 c9 99  ....d.....7.....
5b70: 11 00 00 00 c8 98 67 00 00 00 c7 98 3b 00 00 00  ......g.....;...
5b80: c6 98 22 00 00 00 c5 98 0e 00 00 00 c4 97 7a 00  .."...........z.
5b90: 00 00 c3 97 62 00 00 00 c2 97 4f 00 00 00 c1 97  ....b.....O.....
5ba0: 3c 00 00 00 c0 97 21 00 00 00 bf 97 07 00 00 00  <.....!.........
5bb0: be 96 6c 00 00 00 bd 96 50 00 00 00 bc 96 35 00  ..l.....P.....5.
5bc0: 00 00 bb 96 1d 00 00 00 ba 96 07 00 00 00 b9 95  ................
5bd0: 6b 00 00 00 b8 95 4e 00 00 00 b7 95 33 00 00 00  k.....N.....3...
5be0: b6 95 19 00 00 00 b5 95 05 00 00 00 b4 94 66 00  ..............f.
5bf0: 00 00 b3 94 44 00 00 00 b2 94 25 00 00 00 b1 94  ....D.....%.....
5c00: 06 00 00 00 b0 93 68 00 00 00 af 93 49 00 00 00  ......h.....I...
5c10: ae 93 2a 00 00 00 ad 93 08 00 00 00 ac 92 6a 00  ..*...........j.
5c20: 00 00 ab 92 4c 00 00 00 aa 92 25 00 00 00 a9 91  ....L.....%.....
5c30: 75 00 00 00 a8 91 4a 00 00 00 a7 91 2f 00 00 00  u.....J...../...
5c40: a6 91 18 00 00 00 a5 91 05 00 00 00 a4 90 6f 00  ..............o.
5c50: 00 00 a3 90 58 00 00 00 a2 90 40 00 00 00 a1 90  ....X.....@.....
5c60: 29 00 00 00 a0 90 16 00 00 00 9f 90 0b 00 00 00  )...............
5c70: 9e 90 00 00 00 00 9d 8f 75 00 00 00 9c 8f 6a 00  ........u.....j.
5c80: 00 00 9b 8f 5f 00 00 00 9a 8f 54 00 00 00 99 8f  ...._.....T.....
5c90: 48 00 00 00 98 8f 3d 00 00 00 97 8f 32 00 00 00  H.....=.....2...
5ca0: 96 8f 27 00 00 00 95 8f 1c 00 00 00 94 8f 11 00  ..'.............
5cb0: 00 00 93 8f 04 00 00 00 92 8e 76 00 00 00 91 8e  ..........v.....
5cc0: 68 00 00 00 90 8e 5c 00 00 00 8f 8e 50 00 00 00  h.....\.....P...
5cd0: 8e 8e 45 00 00 00 8d 8e 3a 00 00 00 8c 8e 2f 00  ..E.....:...../.
5ce0: 00 00 8b 8e 24 00 00 00 8a 8e 18 00 00 00 89 8e  ....$...........
5cf0: 0c 00 00 00 88 8e 00 00 00 00 87 8d 75 00 00 00  ............u...
5d00: 86 8d 6a 00 00 00 85 8d 5f 00 00 00 84 8d 54 00  ..j....._.....T.
5d10: 00 00 83 8d 49 00 00 00 82 8d 3e 00 00 00 81 8d  ....I.....>.....
5d20: 33 00 00 00 80 8d 28 00 00 00 7f 8d 1d 00 00 00  3.....(.........
5d30: 7e 8d 12 00 00 00 7d 8d 07 00 00 00 7c 8c 7c 00  ~.....}.....|.|.
5d40: 00 00 7b 8c 71 00 00 00 7a 8c 66 00 00 00 79 8c  ..{.q...z.f...y.
5d50: 5b 00 00 00 78 8c 50 00 00 00 77 8c 44 00 00 00  [...x.P...w.D...
5d60: 76 8c 38 00 00 00 75 8c 2d 00 00 00 74 8c 22 00  v.8...u.-...t.".
5d70: 00 00 73 8c 17 00 00 00 72 8c 0c 00 00 00 71 8c  ..s.....r.....q.
5d80: 01 00 00 00 70 8b 76 00 00 00 6f 8b 6b 00 00 00  ....p.v...o.k...
5d90: 6e 8b 60 00 00 00 6d 8b 55 00 00 00 6c 8b 4a 00  n.`...m.U...l.J.
5da0: 00 00 6b 8b 3f 00 00 00 6a 8b 34 00 00 00 69 8b  ..k.?...j.4...i.
5db0: 29 00 00 00 68 8b 1e 00 00 00 67 8b 13 00 00 00  )...h.....g.....
5dc0: 66 8b 07 00 00 00 65 8a 7a 00 00 00 64 8a 6d 00  f.....e.z...d.m.
5dd0: 00 00 63 8a 60 00 00 00 62 8a 54 00 00 00 61 8a  ..c.`...b.T...a.
5de0: 48 00 00 00 60 8a 3c 00 00 00 5f 8a 2e 00 00 00  H...`.<..._.....
5df0: 5e 8a 22 00 00 00 5d 8a 0c 00 00 00 5c 89 5e 00  ^."...].....\.^.
5e00: 00 00 5b 89 34 00 00 00 5a 89 0c 00 00 00 59 88  ..[.4...Z.....Y.
5e10: 60 00 00 00 58 88 2f 00 00 00 57 88 04 00 00 00  `...X./...W.....
5e20: 56 87 54 00 00 00 55 87 19 00 00 00 54 86 60 00  V.T...U.....T.`.
5e30: 00 00 53 86 4b 00 00 00 52 86 37 00 00 00 51 86  ..S.K...R.7...Q.
5e40: 2c 00 00 00 50 86 20 00 00 00 4f 86 10 00 00 00  ,...P. ...O.....
5e50: 4e 86 05 00 00 00 4d 85 74 00 00 00 4c 85 5d 00  N.....M.t...L.].
5e60: 00 00 4b 85 47 00 00 00 4a 85 2d 00 00 00 49 85  ..K.G...J.-...I.
5e70: 14 00 00 00 48 84 7a 00 00 00 47 84 61 00 00 00  ....H.z...G.a...
5e80: 46 84 47 00 00 00 45 84 2a 00 00 00 44 84 0d 00  F.G...E.*...D...
5e90: 00 00 43 83 74 00 00 00 42 83 6d 00 00 00 41 83  ..C.t...B.m...A.
5ea0: 66 00 00 00 40 83 5f 00 00 00 3f 83 58 00 00 00  f...@._...?.X...
5eb0: 3e 83 51 00 00 00 3d 83 4a 00 00 00 3c 83 43 00  >.Q...=.J...<.C.
5ec0: 00 00 3b 83 3c 00 00 00 3a 83 35 00 00 00 39 83  ..;.<...:.5...9.
5ed0: 2e 00 00 00 38 83 27 00 00 00 37 83 20 00 00 00  ....8.'...7. ...
5ee0: 36 83 19 00 00 00 35 83 12 00 00 00 34 83 0b 00  6.....5.....4...
5ef0: 00 00 33 83 04 00 00 00 32 82 7d 00 00 00 31 82  ..3.....2.}...1.
5f00: 76 00 00 00 30 82 6f 00 00 00 2f 82 68 00 00 00  v...0.o.../.h...
5f10: 2e 82 61 00 00 00 2d 82 5a 00 00 00 2c 82 53 00  ..a...-.Z...,.S.
5f20: 00 00 2b 82 4c 00 00 00 2a 82 45 00 00 00 29 82  ..+.L...*.E...).
5f30: 3e 00 00 00 28 82 37 00 00 00 27 82 30 00 00 00  >...(.7...'.0...
5f40: 26 82 29 00 00 00 25 82 22 00 00 00 24 82 1b 00  &.)...%."...$...
5f50: 00 00 23 82 14 00 00 00 22 82 0d 00 00 00 21 82  ..#.....".....!.
5f60: 06 00 00 00 20 81 7f 00 00 00 1f 81 78 00 00 00  .... .......x...
5f70: 1e 81 71 00 00 00 1d 81 6a 00 00 00 1c 81 63 00  ..q.....j.....c.
5f80: 00 00 1b 81 5c 00 00 00 1a 81 55 00 00 00 19 81  ....\.....U.....
5f90: 4e 00 00 00 18 81 47 00 00 00 17 81 40 00 00 00  N.....G.....@...
5fa0: 16 81 39 00 00 00 15 81 32 00 00 00 14 81 2b 00  ..9.....2.....+.
5fb0: 00 00 13 81 24 00 00 00 12 81 1d 00 00 00 11 81  ....$...........
5fc0: 16 00 00 00 10 81 0f 00 00 00 0f 81 08 00 00 00  ................
5fd0: 0e 81 01 00 00 00 0d 79 00 00 00 0c 5d 00 00 00  .......y....]...
5fe0: 0b 40 00 00 00 0a 31 00 00 00 09 2a 00 00 00 08  .@....1....*....
5ff0: 23 00 00 00 07 1c 00 00 00 06 15 00 00 00 05 0e  #...............
6000: 0d 00 00 00 01 1f e7 00 1f e7 00 00 00 00 00 00  ................
6010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
60a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
60b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
60c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
60d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
60e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
60f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
61a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
61b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
61c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
61d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
61e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
61f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6220: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6230: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6270: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6290: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
62a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
62b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
62c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
62d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
62e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
62f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
63a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
63b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
63c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
63d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
63e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
63f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
64a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
64b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
64c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
64d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
64e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
64f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6550: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
65a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
65b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
65c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
65d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
65e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
65f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
66a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
66b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
66c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
66d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
66e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
66f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6730: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6750: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6770: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6790: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
67a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
67b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
67c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
67d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
67e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
67f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6810: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6820: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6830: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6890: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
68a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
68b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
68c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
68d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
68e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
68f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6910: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6920: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6930: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6940: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6950: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6960: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6970: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6990: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
69a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
69b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
69c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
69d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
69e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
69f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6a10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6a20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6a30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6a40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6a50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6a60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6a70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6a90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6aa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6ab0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6ac0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6ad0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6ae0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6af0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6b10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6b20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6b30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6b40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6b50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6b60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6b70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6b90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6ba0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6bb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6bc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6be0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6bf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6c20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6c30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6c40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6c50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6c60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6c70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6c80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6c90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6ca0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6cb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6cc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6cd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6ce0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6cf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6d10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6d20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6d30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6d40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6d50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6d60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6d70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6d80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6d90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6da0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6db0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6dc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6dd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6de0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6df0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6e10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6e20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6e30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6e40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6e50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6e60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6e70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6e90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6ea0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6eb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6ec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6ed0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6ee0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6ef0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6f10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6f20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6f30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6f40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6f50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6f60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6f70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6f90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6fa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
6ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
70a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
70b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
70c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
70d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
70e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
70f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
71a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
71b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
71c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
71d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
71e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
71f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7220: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7230: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7270: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7290: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
72a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
72b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
72c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
72d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
72e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
72f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
73a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
73b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
73c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
73d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
73e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
73f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
74a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
74b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
74c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
74d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
74e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
74f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7550: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
75a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
75b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
75c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
75d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
75e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
75f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
76a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
76b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
76c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
76d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
76e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
76f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7730: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7750: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7770: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7790: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
77a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
77b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
77c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
77d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
77e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
77f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7810: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7820: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7830: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7890: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
78a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
78b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
78c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
78d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
78e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
78f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7910: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7920: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7930: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7940: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7950: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7960: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7970: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7990: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
79a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
79b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
79c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
79d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
79e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
79f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7a10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7a20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7a30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7a40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7a50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7a60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7a70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7a90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7aa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7ab0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7ac0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7ad0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7ae0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7af0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7b10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7b20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7b30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7b40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7b50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7b60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7b70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7b90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7ba0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7bb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7bc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7be0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7bf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7c20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7c30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7c40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7c50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7c60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7c70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7c80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7c90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7ca0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7cb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7cc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7cd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7ce0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7cf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7d10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7d20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7d30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7d40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7d50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7d60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7d70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7d80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7d90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7da0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7db0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7dc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7dd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7de0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7df0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7e10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7e20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7e30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7e40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7e50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7e60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7e70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7e90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7ea0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7eb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7ec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7ed0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7ee0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7ef0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7f10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7f20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7f30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7f40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7f50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7f60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7f70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7f90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7fa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
7fe0: 00 00 00 00 00 00 00 17 01 02 37 54 65 73 74 20  ..........7Test 
7ff0: 63 61 73 65 73 20 66 6f 72 20 55 50 53 45 52 54  cases for UPSERT
8000: 0d 00 00 00 0e 00 a0 00 1f 50 1d b4 19 58 18 48  .........P...X.H
8010: 17 38 16 28 15 18 14 08 12 f8 11 e8 0d 8c 09 40  .8.(...........@
8020: 04 ec 00 a0 00 00 00 00 00 00 00 00 00 00 00 00  ................
8030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
8040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
8050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
8060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
8070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
8080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
8090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
80a0: 88 49 0e 04 00 91 17 20 20 43 52 45 41 54 45 20  .I.....  CREATE 
80b0: 54 41 42 4c 45 20 74 31 28 61 20 20 63 68 61 72  TABLE t1(a  char
80c0: 28 31 29 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  (1)PRIMARY KEY, 
80d0: 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
80e0: 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41   0);.  CREATE TA
80f0: 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58  BLE record(x TEX
8100: 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52  T, y TEXT);.  CR
8110: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20  EATE TRIGGER r1 
8120: 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e  BEFORE INSERT ON
8130: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
8140: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
8150: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
8160: 4c 55 45 53 28 27 62 73 65 72 74 27 2c 70 72 69  LUES('bsert',pri
8170: 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
8180: 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
8190: 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
81a0: 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
81b0: 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74  FTER INSERT ON t
81c0: 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
81d0: 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
81e0: 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27  ,y)     VALUES('
81f0: 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
8200: 69 6e 74 66 28 27 25 71 2c 25 64 2c 25 64 27 2c  intf('%q,%d,%d',
8210: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
8220: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
8230: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
8240: 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e  BEFORE UPDATE ON
8250: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
8260: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
8270: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
8280: 4c 55 45 53 28 20 72 65 70 6c 61 63 65 28 31 2c  LUES( replace(1,
8290: 31 2c 31 29 2c 70 72 69 6e 74 66 28 27 25 64 2c  1,1),printf('%d,
82a0: 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
82b0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
82c0: 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
82d0: 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
82e0: 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
82f0: 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
8300: 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55  IGGER r4 AFTER U
8310: 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
8320: 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
8330: 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
8340: 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
8350: 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ter-update',prin
8360: 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
8370: 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
8380: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
8390: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
83a0: 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
83b0: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
83c0: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e  c));.  END;.  IN
83d0: 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
83e0: 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20  ) VALUES(1,2);. 
83f0: 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
8400: 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
8410: 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
8420: 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
8430: 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
8440: 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31  ATE SET c=t1.c+1
8450: 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
8460: 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45  M record;.  DELE
8470: 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
8480: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
8490: 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
84a0: 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
84b0: 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
84c0: 45 54 20 63 3d 63 3b 31 20 57 48 45 52 45 20 63  ET c=c;1 WHERE c
84d0: 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  <0;.  SELECT * F
84e0: 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 51 0d 04  ROM record;..Q..
84f0: 00 91 27 20 20 43 52 45 41 54 45 20 54 41 42 4c  ..'  CREATE TABL
8500: 45 20 74 31 28 61 20 20 63 68 61 72 28 31 29 50  E t1(a  char(1)P
8510: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
8520: 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  t, c DEFAULT 0);
8530: 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
8540: 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79  record(x TEXT, y
8550: 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45   TEXT);.  CREATE
8560: 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f   TRIGGER r1 BEFO
8570: 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  RE INSERT ON t1 
8580: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
8590: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
85a0: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
85b0: 28 27 62 73 65 72 74 27 2c 70 72 69 6e 74 66 28  ('bsert',printf(
85c0: 27 25 63 ac 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%c.%d,%d',new.a
85d0: 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
85e0: 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
85f0: 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
8600: 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
8610: 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
8620: 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
8630: 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
8640: 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
8650: 28 27 25 71 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%q,%d,%d',new.
8660: 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
8670: 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
8680: 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
8690: 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
86a0: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
86b0: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
86c0: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
86d0: 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
86e0: 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
86f0: 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
8700: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
8710: 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
8720: 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
8730: 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
8740: 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
8750: 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
8760: 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
8770: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
8780: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
8790: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
87a0: 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
87b0: 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
87c0: 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
87d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
87e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
87f0: 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
8800: 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
8810: 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
8820: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
8830: 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
8840: 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
8850: 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
8860: 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
8870: 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
8880: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
8890: 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
88a0: 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
88b0: 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
88c0: 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
88d0: 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
88e0: 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
88f0: 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
8900: 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
8910: 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
8920: 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
8930: 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
8940: 88 49 0c 04 00 91 17 20 20 43 52 45 41 54 45 20  .I.....  CREATE 
8950: 54 41 42 4c 45 20 74 31 28 61 20 20 63 68 61 72  TABLE t1(a  char
8960: 28 31 29 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  (1)PRIMARY KEY, 
8970: 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
8980: 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41   0);.  CREATE TA
8990: 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58  BLE record(x TEX
89a0: 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52  T, y TEXT);.  CR
89b0: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20  EATE TRIGGER r1 
89c0: 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e  BEFORE INSERT ON
89d0: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
89e0: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
89f0: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
8a00: 4c 55 45 53 28 27 62 73 65 72 74 27 2c 70 72 69  LUES('bsert',pri
8a10: 6e 74 66 28 20 67 6c 6f 62 28 31 2c 31 29 2c 6e  ntf( glob(1,1),n
8a20: 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
8a30: 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
8a40: 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
8a50: 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74  FTER INSERT ON t
8a60: 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
8a70: 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
8a80: 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27  ,y)     VALUES('
8a90: 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
8aa0: 69 6e 74 66 28 27 25 71 2c 25 64 2c 25 64 27 2c  intf('%q,%d,%d',
8ab0: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
8ac0: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
8ad0: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
8ae0: 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e  BEFORE UPDATE ON
8af0: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
8b00: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
8b10: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
8b20: 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64  LUES('before-upd
8b30: 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
8b40: 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
8b50: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
8b60: 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
8b70: 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
8b80: 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
8b90: 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
8ba0: 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55  IGGER r4 AFTER U
8bb0: 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
8bc0: 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
8bd0: 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
8be0: 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
8bf0: 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ter-update',prin
8c00: 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
8c10: 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
8c20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
8c30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
8c40: 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
8c50: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
8c60: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e  c));.  END;.  IN
8c70: 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
8c80: 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20  ) VALUES(1,2);. 
8c90: 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
8ca0: 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
8cb0: 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
8cc0: 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
8cd0: 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
8ce0: 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31  ATE SET c=t1.c+1
8cf0: 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
8d00: 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45  M record;.  DELE
8d10: 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
8d20: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
8d30: 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
8d40: 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
8d50: 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
8d60: 45 54 20 63 3d 63 3b 31 20 57 48 45 52 45 20 63  ET c=c;1 WHERE c
8d70: 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  <0;.  SELECT * F
8d80: 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 59 0b 04  ROM record;..Y..
8d90: 00 91 37 20 20 43 52 45 41 54 45 20 54 41 42 4c  ..7  CREATE TABL
8da0: 45 20 74 31 28 61 20 20 63 68 61 72 28 31 29 50  E t1(a  char(1)P
8db0: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
8dc0: 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  t, c DEFAULT 0);
8dd0: 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
8de0: 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79  record(x TEXT, y
8df0: 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45   TEXT);.  CREATE
8e00: 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f   TRIGGER r1 BEFO
8e10: 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  RE INSERT ON t1 
8e20: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
8e30: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
8e40: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
8e50: 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27  ('before-insert'
8e60: 2c 70 72 69 6e 74 66 28 27 25 67 2c 25 64 2c 25  ,printf('%g,%d,%
8e70: 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
8e80: 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
8e90: 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
8ea0: 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r2 AFTER INSERT 
8eb0: 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
8ec0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
8ed0: 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55  rd(x,y)     VALU
8ee0: 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74  ES('after-insert
8ef0: 27 2c 70 72 69 6e 74 66 28 27 25 67 2c 25 64 2c  ',printf('%g,%d,
8f00: 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
8f10: 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
8f20: 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
8f30: 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54   r3 BEFORE UPDAT
8f40: 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
8f50: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
8f60: 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
8f70: 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
8f80: 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
8f90: 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
8fa0: 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
8fb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
8fc0: 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f     old.a,old.b,o
8fd0: 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ld.c,new.a,new.b
8fe0: 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
8ff0: 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
9000: 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54  R r4 AFTER UPDAT
9010: 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
9020: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
9030: 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
9040: 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
9050: 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
9060: 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
9070: 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
9080: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
9090: 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
90a0: 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
90b0: 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
90c0: 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54  .  END;.  INSERT
90d0: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
90e0: 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c  LUES(1,2);.  DEL
90f0: 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  ETE FROM record;
9100: 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
9110: 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
9120: 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49  2).    ON CONFLI
9130: 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20  CT(a) DO UPDATE 
9140: 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20  SET c=t1.c+1;.  
9150: 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
9160: 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46  cord;.  DELETE F
9170: 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e  ROM record;.  IN
9180: 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
9190: 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20  ) VALUES(1,2).  
91a0: 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
91b0: 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
91c0: 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a  =c+1 WHERE c<0;.
91d0: 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
91e0: 72 65 63 6f 72 64 3b 0a 82 0d 0a 04 00 84 1f 20  record;........ 
91f0: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
9200: 28 20 61 2c 62 61 2c 49 4e 54 45 47 45 52 20 50  ( a,ba,INTEGER P
9210: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 2c 49 4e  RIMARY KEY, b,IN
9220: 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T, c DEFAULT 0);
9230: 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
9240: 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
9250: 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
9260: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
9270: 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
9280: 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
9290: 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
92a0: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
92b0: 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
92c0: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
92d0: 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
92e0: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 2a 20 46  LECT DISTINCT* F
92f0: 52 4f 4d 20 74 31 3b 0a 82 0d 09 04 00 84 1f 20  ROM t1;........ 
9300: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
9310: 28 20 61 2c 62 61 20 61 2c 62 45 47 45 52 20 50  ( a,ba a,bEGER P
9320: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e  RIMARY KEY, b IN
9330: 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T, c DEFAULT 0);
9340: 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
9350: 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
9360: 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
9370: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
9380: 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
9390: 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
93a0: 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
93b0: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
93c0: 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
93d0: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
93e0: 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
93f0: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 2a 20 46  LECT DISTINCT* F
9400: 52 4f 4d 20 74 31 3b 0a 82 0d 08 04 00 84 1f 20  ROM t1;........ 
9410: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
9420: 28 20 61 2c 62 61 20 49 4e 54 45 47 45 52 20 50  ( a,ba INTEGER P
9430: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 2c 49 4e  RIMARY KEY, b,IN
9440: 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T, c DEFAULT 0);
9450: 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
9460: 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
9470: 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
9480: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
9490: 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
94a0: 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
94b0: 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
94c0: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
94d0: 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
94e0: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
94f0: 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
9500: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 2a 20 46  LECT DISTINCT* F
9510: 52 4f 4d 20 74 31 3b 0a 82 0d 07 04 00 84 1f 20  ROM t1;........ 
9520: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
9530: 28 20 61 2c 62 61 20 49 4e 54 45 47 45 52 20 50  ( a,ba INTEGER P
9540: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 2c 49 2c  RIMARY KEY, b,I,
9550: 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T, c DEFAULT 0);
9560: 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
9570: 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
9580: 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
9590: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
95a0: 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
95b0: 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
95c0: 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
95d0: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
95e0: 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
95f0: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
9600: 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
9610: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 2a 20 46  LECT DISTINCT* F
9620: 52 4f 4d 20 74 31 3b 0a 82 0d 06 04 00 84 1f 20  ROM t1;........ 
9630: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
9640: 28 20 61 2c 62 61 20 49 4e 54 45 47 45 52 20 50  ( a,ba INTEGER P
9650: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e  RIMARY KEY, b IN
9660: 54 ac 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T. c DEFAULT 0);
9670: 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
9680: 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
9690: 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
96a0: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
96b0: 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
96c0: 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
96d0: 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
96e0: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
96f0: 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
9700: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
9710: 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
9720: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 2a 20 46  LECT DISTINCT* F
9730: 52 4f 4d 20 74 31 3b 0a 82 0d 05 04 00 84 1f 20  ROM t1;........ 
9740: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
9750: 28 20 61 2c 62 61 20 49 4e 54 45 47 45 52 20 50  ( a,ba INTEGER P
9760: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e  RIMARY KEY, b IN
9770: 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T, c DEFAULT 0);
9780: 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
9790: 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
97a0: 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
97b0: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
97c0: 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
97d0: 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
97e0: 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
97f0: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
9800: 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
9810: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
9820: 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
9830: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 2a 20 46  LECT DISTINCT* F
9840: 52 4f 4d 20 74 31 3b 0a 82 0d 04 04 00 84 1f 20  ROM t1;........ 
9850: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
9860: 28 20 61 2c 62 61 20 49 4e 54 45 47 45 52 20 44  ( a,ba INTEGER D
9870: 45 46 41 55 4c 54 20 4b 45 59 2c 20 62 2c 49 4e  EFAULT KEY, b,IN
9880: 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T, c DEFAULT 0);
9890: 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
98a0: 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
98b0: 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
98c0: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
98d0: 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
98e0: 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
98f0: 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
9900: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
9910: 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
9920: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
9930: 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
9940: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 2a 20 46  LECT DISTINCT* F
9950: 52 4f 4d 20 74 31 3b 0a 88 59 03 04 00 91 37 20  ROM t1;..Y....7 
9960: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
9970: 28 20 61 2c 62 54 45 47 45 52 20 50 52 49 4d 41  ( a,bTEGER PRIMA
9980: 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63  RY KEY, b int, c
9990: 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43   DEFAULT 0);.  C
99a0: 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f  REATE TABLE reco
99b0: 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58  rd(x TEXT, y TEX
99c0: 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  T);.  CREATE TRI
99d0: 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49  GGER r1 BEFORE I
99e0: 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
99f0: 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
9a00: 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
9a10: 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
9a20: 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69  fore-insert',pri
9a30: 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
9a40: 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
9a50: 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
9a60: 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
9a70: 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74  FTER INSERT ON t
9a80: 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
9a90: 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
9aa0: 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27  ,y)     VALUES('
9ab0: 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
9ac0: 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c  intf('%d,%d,%d',
9ad0: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
9ae0: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
9af0: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
9b00: 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e  BEFORE UPDATE ON
9b10: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
9b20: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
9b30: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
9b40: 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64  LUES('before-upd
9b50: 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
9b60: 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
9b70: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
9b80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
9b90: 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
9ba0: 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
9bb0: 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
9bc0: 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34  REATE TRIGGER r4
9bd0: 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e   AFTER UPDATE ON
9be0: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
9bf0: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
9c00: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
9c10: 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61  LUES('after-upda
9c20: 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
9c30: 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
9c40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
9c50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
9c60: 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
9c70: 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
9c80: 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
9c90: 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ND;.  INSERT INT
9ca0: 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
9cb0: 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20  (1,2);.  DELETE 
9cc0: 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
9cd0: 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
9ce0: 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
9cf0: 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
9d00: 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
9d10: 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45  c=t1.c+1;.  SELE
9d20: 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64  CT * FROM record
9d30: 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
9d40: 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
9d50: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
9d60: 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e  LUES(1,2).    ON
9d70: 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
9d80: 55 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31  UPDATE SET c=c+1
9d90: 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45   WHERE c<0;.  SE
9da0: 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
9db0: 72 64 3b 0a 83 19 02 04 00 86 37 20 20 43 52 45  rd;.......7  CRE
9dc0: 41 54 45 20 54 41 42 4c 45 20 65 78 63 6c 75 64  ATE TABLE exclud
9dd0: 65 64 28 61 20 49 4e 54 2c 20 62 20 49 4e 54 2c  ed(a INT, b INT,
9de0: 20 63 20 49 4e 54 20 44 45 46 41 55 4c 54 20 30   c INT DEFAULT 0
9df0: 29 3b 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51  );.  CREATE UNIQ
9e00: 55 45 20 49 4e 44 45 58 20 65 78 63 6c 75 64 65  UE INDEX exclude
9e10: 64 61 62 20 4f 4e 20 65 78 63 6c 75 64 65 64 28  dab ON excluded(
9e20: 61 2c 62 29 3b 0a 20 20 49 4e 53 45 52 54 20 49  a,b);.  INSERT I
9e30: 4e 54 4f 20 65 78 63 6c 75 64 65 64 28 61 2c 62  NTO excluded(a,b
9e40: 29 20 56 41 4c 55 45 53 28 31 2c 32 29 2c 28 31  ) VALUES(1,2),(1
9e50: 2c 32 29 2c 28 33 2c 34 29 2c 28 31 2c 32 29 2c  ,2),(3,4),(1,2),
9e60: 28 35 2c 36 29 2c 28 33 2c 34 29 0a 20 20 20 20  (5,6),(3,4).    
9e70: 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 62 2c 61 29  ON CONFLICT(b,a)
9e80: 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
9e90: 3d 65 78 63 6c 75 64 65 64 2e 63 2b 31 3b 0a 20  =excluded.c+1;. 
9ea0: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 65 78 63   INSERT INTO exc
9eb0: 6c 75 64 65 64 20 41 53 20 62 61 73 65 28 61 2c  luded AS base(a,
9ec0: 62 2c 63 29 20 56 41 4c 55 45 53 28 31 2c 32 2c  b,c) VALUES(1,2,
9ed0: 38 29 2c 28 31 2c 32 2c 33 29 0a 20 20 20 20 4f  8),(1,2,3).    O
9ee0: 4e 20 43 4f 4e 46 4c 49 43 54 28 62 2c 61 29 20  N CONFLICT(b,a) 
9ef0: 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d  DO UPDATE SET c=
9f00: 65 78 63 6c 75 64 65 64 2e 63 2b 31 20 57 48 45  excluded.c+1 WHE
9f10: 52 45 20 62 61 73 65 2e 63 3c 65 78 63 6c 75 64  RE base.c<exclud
9f20: 65 64 2e 63 3b 0a 20 20 53 45 4c 45 43 54 20 2a  ed.c;.  SELECT *
9f30: 2c 20 27 78 27 20 46 52 4f 4d 20 65 78 63 6c 75  , 'x' FROM exclu
9f40: 64 65 64 20 4f 52 44 45 52 20 42 59 20 61 3b 0a  ded ORDER BY a;.
9f50: 81 2d 01 04 00 82 5f 00 52 45 41 54 45 20 54 41  .-...._.REATE TA
9f60: 42 4c 45 20 74 31 28 0a 20 20 61 20 49 4e 54 2c  BLE t1(.  a INT,
9f70: 0a 20 20 62 20 49 4e 54 20 55 4e 49 51 55 45 2c  .  b INT UNIQUE,
9f80: 0a 20 20 63 20 49 4e 54 20 44 45 46 41 55 4c 54  .  c INT DEFAULT
9f90: 20 30 2c 0a 20 20 50 52 49 4d 41 52 59 20 4b 45   0,.  PRIMARY KE
9fa0: 59 28 61 2c 62 29 0a 29 20 57 49 54 48 4f 55 54  Y(a,b).) WITHOUT
9fb0: 20 52 4f 57 49 44 3b 0a 49 4e 53 45 52 54 20 49   ROWID;.INSERT I
9fc0: 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
9fd0: 45 53 28 31 2c 32 29 2c 28 33 2c 34 29 2c 28 31  ES(1,2),(3,4),(1
9fe0: 2c 32 29 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61  ,2)ON CONFLICT(a
9ff0: 2c 62 29 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a  ,b) DO NOTHING;.
a000: 0d 00 00 00 07 01 c9 00 1b a5 17 51 13 01 0e b5  ...........Q....
a010: 0a 69 06 1d 01 c9 00 00 00 00 00 00 00 00 00 00  .i..............
a020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a0a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a0b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a0c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a0d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a0e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a0f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a1a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a1b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
a1c0: 00 00 00 00 00 00 00 00 00 88 51 15 04 00 91 27  ..........Q....'
a1d0: 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
a1e0: 31 28 61 20 20 63 68 61 72 28 31 29 50 52 49 4d  1(a  char(1)PRIM
a1f0: 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20  ARY KEY, b int, 
a200: 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20  c DEFAULT 0);.  
a210: 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63  CREATE TABLE rec
a220: 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45  ord(x TEXT, y TE
a230: 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52  XT);.  CREATE TR
a240: 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20  IGGER r1 BEFORE 
a250: 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
a260: 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
a270: 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
a280: 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
a290: 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64  sert',printf('%d
a2a0: 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65  ,%d,%d',new.a,ne
a2b0: 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
a2c0: 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
a2d0: 47 47 45 52 20 72 32 a0 41 46 54 45 52 20 49 4e  GGER r2.AFTER IN
a2e0: 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
a2f0: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
a300: 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20   record(x,y)    
a310: 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69   VALUES('after-i
a320: 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25  nsert',printf('%
a330: 71 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e  q,%d,%d',new.a,n
a340: 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
a350: 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
a360: 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20  IGGER r3 BEFORE 
a370: 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
a380: 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
a390: 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
a3a0: 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
a3b0: 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72  efore-update',pr
a3c0: 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
a3d0: 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
a3e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
a3f0: 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
a400: 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
a410: 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
a420: 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
a430: 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20  RIGGER r4 AFTER 
a440: 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
a450: 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
a460: 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
a470: 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61         VALUES('a
a480: 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69  fter-update',pri
a490: 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
a4a0: 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
a4b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
a4c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
a4d0: 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
a4e0: 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
a4f0: 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49  .c));.  END;.  I
a500: 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
a510: 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a  b) VALUES(1,2);.
a520: 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
a530: 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
a540: 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
a550: 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43  ES(1,2).    ON C
a560: 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50  ONFLICT(a) DO UP
a570: 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b  DATE SET c=t1.c+
a580: 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52  1;.  SELECT * FR
a590: 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c  OM record;.  DEL
a5a0: 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  ETE FROM record;
a5b0: 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
a5c0: 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
a5d0: 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49  2).    ON CONFLI
a5e0: 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20  CT(a) DO UPDATE 
a5f0: 53 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20  SET c=c+1 WHERE 
a600: 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20  c<0;.  SELECT * 
a610: 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 49 14  FROM record;..I.
a620: 04 00 91 17 20 20 43 52 45 41 54 45 20 54 41 42  ....  CREATE TAB
a630: 4c 45 20 74 31 28 61 20 20 63 68 61 72 28 31 29  LE t1(a  char(1)
a640: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
a650: 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29  nt, c DEFAULT 0)
a660: 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ;.  CREATE TABLE
a670: 20 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20   record(x TEXT, 
a680: 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54  y TEXT);.  CREAT
a690: 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46  E TRIGGER r1 BEF
a6a0: 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  ORE INSERT ON t1
a6b0: 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
a6c0: 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
a6d0: 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
a6e0: 53 28 27 62 73 65 72 74 27 2c 70 72 69 6e 74 66  S('bsert',printf
a6f0: 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%d,%d,%d',new.
a700: 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
a710: 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
a720: 20 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45   TRIGGER r2 AFTE
a730: 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  R INSERT ON t1 B
a740: 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
a750: 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
a760: 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74       VALUES('aft
a770: 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74  er-insert',print
a780: 66 28 27 25 71 2c 25 64 2c 25 64 27 2c 6e 65 77  f('%q,%d,%d',new
a790: 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
a7a0: 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
a7b0: 45 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46  E TRIGGER r3 BEF
a7c0: 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31  ORE UPDATE ON t1
a7d0: 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
a7e0: 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
a7f0: 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
a800: 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65  S('before-update
a810: 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
a820: 25 64 2f 25 64 2c 25 64 2c 25 64 27 3c 0a 20 20  %d/%d,%d,%d'<.  
a830: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
a840: 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
a850: 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
a860: 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
a870: 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
a880: 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41  ER r4 AFTER UPDA
a890: 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
a8a0: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
a8b0: 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
a8c0: 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
a8d0: 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
a8e0: 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
a8f0: 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
a900: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
a910: 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
a920: 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
a930: 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
a940: 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52  ;.  END;.  INSER
a950: 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
a960: 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45  ALUES(1,2);.  DE
a970: 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
a980: 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
a990: 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
a9a0: 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,2).    ON CONFL
a9b0: 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
a9c0: 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20   SET c=t1.c+1;. 
a9d0: 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
a9e0: 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20  ecord;.  DELETE 
a9f0: 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
aa00: 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
aa10: 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
aa20: 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
aa30: 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
aa40: 63 3d 63 3b 31 20 57 48 45 52 45 20 63 3c 30 3b  c=c;1 WHERE c<0;
aa50: 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
aa60: 20 72 65 63 6f 72 64 3b 0a 88 49 13 04 00 91 17   record;..I.....
aa70: 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
aa80: 31 28 61 20 20 63 68 61 72 28 31 29 50 52 49 4d  1(a  char(1)PRIM
aa90: 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20  ARY KEY, b int, 
aaa0: 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20  c DEFAULT 0);.  
aab0: 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63  CREATE TABLE rec
aac0: 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45  ord(x TEXT, y TE
aad0: 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52  XT);.  CREATE TR
aae0: 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20  IGGER r1 BEFORE 
aaf0: 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
ab00: 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
ab10: 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
ab20: 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
ab30: 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64  sert',printf('%d
ab40: 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65  ,%d,%d',new.a,ne
ab50: 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
ab60: 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
ab70: 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49 4e  GGER r2 AFTER IN
ab80: 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
ab90: 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
aba0: 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20   record(x,y)    
abb0: 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69   VALUES('after-i
abc0: 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25  nsert',printf('%
abd0: 71 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e  q,%d,%d',new.a,n
abe0: 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
abf0: 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
ac00: 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20  IGGER r3 BEFORE 
ac10: 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
ac20: 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
ac30: 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
ac40: 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
ac50: 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72  efore-update',pr
ac60: 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
ac70: 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
ac80: 20 20 20 20 6a 73 6f 6e 5f 61 72 72 61 79 28 31      json_array(1
ac90: 2c 31 2c 31 29 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e  ,1,1),old.b,old.
aca0: 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  c,new.a,new.b,ne
acb0: 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
acc0: 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
acd0: 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f  4 AFTER UPDATE O
ace0: 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
acf0: 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
ad00: 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
ad10: 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64  ALUES('after-upd
ad20: 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
ad30: 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
ad40: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
ad50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
ad60: 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
ad70: 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
ad80: 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
ad90: 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  END;.  INSERT IN
ada0: 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
adb0: 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45  S(1,2);.  DELETE
adc0: 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
add0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
ade0: 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
adf0: 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
ae00: 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
ae10: 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c   c=t1.c+1;.  SEL
ae20: 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
ae30: 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  d;.  DELETE FROM
ae40: 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
ae50: 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
ae60: 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
ae70: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
ae80: 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63 3b   UPDATE SET c=c;
ae90: 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53  1 WHERE c<0;.  S
aea0: 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63  ELECT * FROM rec
aeb0: 6f 72 64 3b 0a 88 49 12 04 00 91 17 20 20 43 52  ord;..I.....  CR
aec0: 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20  EATE TABLE t1(a 
aed0: 20 63 68 61 72 28 31 29 50 52 49 4d 41 52 59 20   char(1)PRIMARY 
aee0: 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45  KEY, b int, c DE
aef0: 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41  FAULT 0);.  CREA
af00: 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28  TE TABLE record(
af10: 78 20 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b  x TEXT, y TEXT);
af20: 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
af30: 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45  R r1 BEFORE INSE
af40: 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  RT ON t1 BEGIN. 
af50: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
af60: 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
af70: 20 20 20 56 41 4c 55 45 53 28 27 62 73 65 72 74     VALUES('bsert
af80: 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
af90: 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
afa0: 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
afb0: 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
afc0: 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54   r2 AFTER INSERT
afd0: 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
afe0: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
aff0: 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c  ord(x,y)     VAL
b000: 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72  UES('after-inser
b010: 74 27 2c 70 72 69 6e 74 66 28 27 25 71 2c 25 64  t',printf('%q,%d
b020: 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
b030: 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
b040: 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
b050: 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41  R r3 BEFORE UPDA
b060: 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
b070: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
b080: 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
b090: 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
b0a0: 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  e-update',printf
b0b0: 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
b0c0: 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
b0d0: 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e              old.
b0e0: 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65  a,old.b,old.c,ne
b0f0: 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
b100: 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
b110: 54 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46  TE TRIGGER r4 AF
b120: 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31  TER UPDATE ON t1
b130: 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
b140: 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
b150: 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
b160: 53 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27  S('after-update'
b170: 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
b180: 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
b190: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
b1a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 70 72 69               pri
b1b0: 6e 74 66 28 31 2c 31 29 2c 6f 6c 64 2e 62 2c 6f  ntf(1,1),old.b,o
b1c0: 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ld.c,new.a,new.b
b1d0: 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
b1e0: 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
b1f0: 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
b200: 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  2);.  DELETE FRO
b210: 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
b220: 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
b230: 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
b240: 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
b250: 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74  O UPDATE SET c=t
b260: 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20  1.c+1;.  SELECT 
b270: 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  * FROM record;. 
b280: 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
b290: 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
b2a0: 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
b2b0: 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
b2c0: 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
b2d0: 41 54 45 20 53 45 54 20 63 3d 63 3b 31 20 57 48  ATE SET c=c;1 WH
b2e0: 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43  ERE c<0;.  SELEC
b2f0: 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
b300: 0a 88 4d 11 04 00 91 1f 20 20 43 52 45 41 54 45  ..M.....  CREATE
b310: 20 54 41 42 4c 45 20 74 31 28 61 20 20 63 68 61   TABLE t1(a  cha
b320: 72 28 31 29 50 52 49 4d 41 52 59 20 4b 45 59 2c  r(1)PRIMARY KEY,
b330: 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c   b int, c DEFAUL
b340: 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54  T 0);.  CREATE T
b350: 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45  ABLE record(x TE
b360: 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43  XT, y TEXT);.  C
b370: 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31  REATE TRIGGER r1
b380: 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f   BEFORE INSERT O
b390: 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
b3a0: 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
b3b0: 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
b3c0: 41 4c 55 45 53 28 27 62 73 65 72 74 27 2c 70 72  ALUES('bsert',pr
b3d0: 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c  intf('%d,%d,%d',
b3e0: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
b3f0: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
b400: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20  EATE TRIGGER r2 
b410: 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20  AFTER INSERT ON 
b420: 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
b430: 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
b440: 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28  x,y)     VALUES(
b450: 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70  'after-insert',p
b460: 72 69 6e 74 66 28 27 25 71 2c 25 64 2c 25 64 27  rintf('%q,%d,%d'
b470: 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
b480: 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
b490: 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33  REATE TRIGGER r3
b4a0: 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f   BEFORE UPDATE O
b4b0: 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
b4c0: 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
b4d0: 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
b4e0: 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70  ALUES('before-up
b4f0: 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
b500: 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
b510: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
b520: 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
b530: 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
b540: 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
b550: 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
b560: 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20  RIGGER r4 AFTER 
b570: 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
b580: 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
b590: 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
b5a0: 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61         VALUES('a
b5b0: 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69  fter-update',pri
b5c0: 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
b5d0: 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
b5e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
b5f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
b600: 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
b610: 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
b620: 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49  .c));.  END;.  I
b630: 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
b640: 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a  b) VALUES(1,2);.
b650: 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
b660: 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
b670: 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
b680: 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43  ES(1,2).    ON C
b690: 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50  ONFLICT(a) DO UP
b6a0: 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 20  DATE SET c=t1.c 
b6b0: 7c 7c 20 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20  || +1;.  SELECT 
b6c0: 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  * FROM record;. 
b6d0: 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
b6e0: 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
b6f0: 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
b700: 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
b710: 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
b720: 41 54 45 20 53 45 54 20 63 3d 63 3b 31 20 57 48  ATE SET c=c;1 WH
b730: 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43  ERE c<0;.  SELEC
b740: 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
b750: 0a 88 51 10 04 00 91 27 20 20 43 52 45 41 54 45  ..Q....'  CREATE
b760: 20 54 41 42 4c 45 20 74 31 28 61 20 20 63 68 61   TABLE t1(a  cha
b770: 72 28 31 29 50 52 49 4d 41 52 59 20 4b 45 59 2c  r(1)PRIMARY KEY,
b780: 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c   b int, c DEFAUL
b790: 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54  T 0);.  CREATE T
b7a0: 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45  ABLE record(x TE
b7b0: 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43  XT, y TEXT);.  C
b7c0: 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31  REATE TRIGGER r1
b7d0: 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f   BEFORE INSERT O
b7e0: 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
b7f0: 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
b800: 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
b810: 41 4c 55 45 53 28 27 62 73 65 72 74 27 2c 70 72  ALUES('bsert',pr
b820: 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c  intf('%d,%d,%d',
b830: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
b840: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
b850: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20  EATE TRIGGER r2 
b860: 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20  AFTER INSERT ON 
b870: 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
b880: 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
b890: 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28  x,y)     VALUES(
b8a0: 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70  'after-insert',p
b8b0: 72 69 6e 74 66 28 27 25 71 2c 25 64 2c 25 64 27  rintf('%q,%d,%d'
b8c0: 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
b8d0: 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
b8e0: 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33  REATE TRIGGER r3
b8f0: 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f   BEFORE UPDATE O
b900: 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
b910: 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
b920: 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
b930: 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70  ALUES('before-up
b940: 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
b950: 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
b960: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
b970: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
b980: 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e  old.a,old.b,old.
b990: 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  c,new.a,new.b,ne
b9a0: 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
b9b0: 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
b9c0: 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f  4 AFTER UPDATE O
b9d0: 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
b9e0: 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
b9f0: 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
ba00: 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64  ALUES('after-upd
ba10: 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
ba20: 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
ba30: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
ba40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
ba50: 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
ba60: 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
ba70: 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
ba80: 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  END;.  INSERT IN
ba90: 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
baa0: 53 28 39 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45  S(9,2);.  DELETE
bab0: 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
bac0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
bad0: 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
bae0: 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
baf0: 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
bb00: 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c   c=t1.c+1;.  SEL
bb10: 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
bb20: 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  d;.  DELETE FROM
bb30: 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
bb40: 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
bb50: 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
bb60: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
bb70: 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b   UPDATE SET c=c+
bb80: 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53  1 WHERE c<0;.  S
bb90: 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63  ELECT * FROM rec
bba0: 6f 72 64 3b 0a 88 58 0f 04 00 91 35 20 20 43 52  ord;..X....5  CR
bbb0: 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20  EATE TABLE t1(a 
bbc0: 20 63 68 61 72 28 31 29 50 52 49 4d 41 52 59 20   char(1)PRIMARY 
bbd0: 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45  KEY, b int, c DE
bbe0: 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41  FAULT 0);.  CREA
bbf0: 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28  TE TABLE record(
bc00: 78 20 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b  x TEXT, y TEXT);
bc10: 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
bc20: 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45  R r1 BEFORE INSE
bc30: 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  RT ON t1 BEGIN. 
bc40: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
bc50: 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
bc60: 20 20 20 56 41 4c 55 45 53 28 27 62 73 65 72 74     VALUES('bsert
bc70: 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
bc80: 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
bc90: 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
bca0: 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
bcb0: 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54   r2 AFTER INSERT
bcc0: 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
bcd0: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
bce0: 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c  ord(x,y)     VAL
bcf0: 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72  UES('after-inser
bd00: 74 27 2c 70 72 69 6e 74 66 28 27 25 71 2c 25 64  t',printf('%q,%d
bd10: 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
bd20: 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
bd30: 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
bd40: 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41  R r3 BEFORE UPDA
bd50: 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
bd60: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
bd70: 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
bd80: 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
bd90: 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  e-update',printf
bda0: 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
bdb0: 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
bdc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
bdd0: 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
bde0: 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
bdf0: 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
be00: 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
be10: 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41  ER r4 AFTER UPDA
be20: 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
be30: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
be40: 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
be50: 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
be60: 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
be70: 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
be80: 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
be90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
bea0: 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
beb0: 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
bec0: 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
bed0: 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52  ;.  END;.  INSER
bee0: 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
bef0: 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45  ALUES(1,2);.  DE
bf00: 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
bf10: 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
bf20: 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
bf30: 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,2).    ON CONFL
bf40: 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
bf50: 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20   SET c=t1.c+1;. 
bf60: 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
bf70: 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20  ecord;.  DELETE 
bf80: 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
bf90: 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
bfa0: 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
bfb0: 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
bfc0: 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
bfd0: 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b  c=c+1 WHERE c<0;
bfe0: 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
bff0: 20 72 65 63 6f 72 64 3b 41 4e 41 4c 59 5a 45 0a   record;ANALYZE.
c000: 0d 00 00 00 07 01 d1 00 1b ac 17 60 13 14 0e c0  ...........`....
c010: 0a 6c 06 1d 01 d1 00 00 00 00 00 00 00 00 00 00  .l..............
c020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c0a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c0b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c0c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c0d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c0e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c0f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c1a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c1b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c1c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
c1d0: 00 88 49 1c 04 00 91 17 20 20 43 52 45 41 54 45  ..I.....  CREATE
c1e0: 20 54 41 42 4c 45 20 74 31 28 61 20 43 48 45 43   TABLE t1(a CHEC
c1f0: 4b 28 30 29 50 52 49 4d 41 52 59 20 4b 45 59 2c  K(0)PRIMARY KEY,
c200: 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c   b int, c DEFAUL
c210: 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54  T 0);.  CREATE T
c220: 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45  ABLE record(x TE
c230: 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43  XT, y TEXT);.  C
c240: 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31  REATE TRIGGER r1
c250: 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f   BEFORE INSERT O
c260: 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
c270: 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
c280: 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
c290: 41 4c 55 45 53 28 27 62 73 65 72 74 27 2c 70 72  ALUES('bsert',pr
c2a0: 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c  intf('%d,%d,%d',
c2b0: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
c2c0: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
c2d0: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20  EATE TRIGGER r2 
c2e0: 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20  AFTER INSERT ON 
c2f0: 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
c300: 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
c310: 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28  x,y)     VALUES(
c320: 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70  'after-insert',p
c330: 72 69 6e 74 66 28 27 25 71 2c 25 64 2c 25 64 27  rintf('%q,%d,%d'
c340: 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
c350: 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
c360: 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33  REATE TRIGGER r3
c370: 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f   BEFORE UPDATE O
c380: 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
c390: 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
c3a0: 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
c3b0: 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70  ALUES('before-up
c3c0: 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
c3d0: 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
c3e0: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
c3f0: 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
c400: 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
c410: 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
c420: 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
c430: 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20  RIGGER r4 AFTER 
c440: 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
c450: 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
c460: 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
c470: 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61         VALUES('a
c480: 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69  fter-update',pri
c490: 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
c4a0: 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
c4b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
c4c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
c4d0: 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
c4e0: 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
c4f0: 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49  .c));.  END;.  I
c500: 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
c510: 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a  b) VALUES(1,2);.
c520: 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
c530: 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
c540: 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
c550: 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43  ES(1,2).    ON C
c560: 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50  ONFLICT(a) DO UP
c570: 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b  DATE SET c=t1.c+
c580: 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52  1;.  SELECT * FR
c590: 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c  OM record;.  DEL
c5a0: 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  ETE FROM record;
c5b0: 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
c5c0: 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
c5d0: 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49  2).    ON CONFLI
c5e0: 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20  CT(a) DO UPDATE 
c5f0: 53 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20  SET c=c+1 WHERE 
c600: 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20  c<0;.  SELECT * 
c610: 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 4c 1b  FROM record;..L.
c620: 04 00 91 1d 20 20 43 52 45 41 54 45 20 54 41 42  ....  CREATE TAB
c630: 4c 45 20 74 31 28 61 20 43 48 45 43 4b 28 20 2d  LE t1(a CHECK( -
c640: 31 31 29 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  11)PRIMARY KEY, 
c650: 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
c660: 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41   0);.  CREATE TA
c670: 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58  BLE record(x TEX
c680: 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52  T, y TEXT);.  CR
c690: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20  EATE TRIGGER r1 
c6a0: 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e  BEFORE INSERT ON
c6b0: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
c6c0: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
c6d0: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
c6e0: 4c 55 45 53 28 27 62 73 65 72 74 27 2c 70 72 69  LUES('bsert',pri
c6f0: 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
c700: 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
c710: 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
c720: 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
c730: 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74  FTER INSERT ON t
c740: 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
c750: 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
c760: 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27  ,y)     VALUES('
c770: 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
c780: 69 6e 74 66 28 27 25 71 2c 25 64 2c 25 64 27 2c  intf('%q,%d,%d',
c790: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
c7a0: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
c7b0: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
c7c0: 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e  BEFORE UPDATE ON
c7d0: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
c7e0: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
c7f0: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
c800: 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64  LUES('before-upd
c810: 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
c820: 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
c830: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
c840: 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
c850: 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
c860: 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
c870: 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
c880: 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55  IGGER r4 AFTER U
c890: 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
c8a0: 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
c8b0: 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
c8c0: 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
c8d0: 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ter-update',prin
c8e0: 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
c8f0: 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
c900: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
c910: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
c920: 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
c930: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
c940: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e  c));.  END;.  IN
c950: 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
c960: 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20  ) VALUES(1,2);. 
c970: 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
c980: 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
c990: 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
c9a0: 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
c9b0: 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
c9c0: 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31  ATE SET c=t1.c+1
c9d0: 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
c9e0: 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45  M record;.  DELE
c9f0: 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
ca00: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
ca10: 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
ca20: 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
ca30: 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
ca40: 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63  ET c=c+1 WHERE c
ca50: 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  <0;.  SELECT * F
ca60: 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 51 1a 04  ROM record;..Q..
ca70: 00 91 27 20 20 43 52 45 41 54 45 20 54 41 42 4c  ..'  CREATE TABL
ca80: 45 20 74 31 28 61 20 20 63 68 61 72 28 31 29 50  E t1(a  char(1)P
ca90: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
caa0: 74 2c 20 63 20 63 68 61 72 28 31 29 20 44 45 46  t, c char(1) DEF
cab0: 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54  AULT 0);.  CREAT
cac0: 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78  E TABLE record(x
cad0: 20 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a   TEXT, y TEXT);.
cae0: 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
caf0: 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52   r1 BEFORE INSER
cb00: 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
cb10: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
cb20: 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
cb30: 20 20 56 41 4c 55 45 53 28 27 62 73 65 72 74 27    VALUES('bsert'
cb40: 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
cb50: 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
cb60: 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
cb70: 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
cb80: 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r2 AFTER INSERT 
cb90: 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
cba0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
cbb0: 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55  rd(x,y)     VALU
cbc0: 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74  ES('after-insert
cbd0: 27 2c 70 72 69 6e 74 66 28 27 25 71 2c 25 64 2c  ',printf('%q,%d,
cbe0: 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
cbf0: 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
cc00: 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
cc10: 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54   r3 BEFORE UPDAT
cc20: 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
cc30: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
cc40: 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
cc50: 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
cc60: 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
cc70: 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
cc80: 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
cc90: 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
cca0: 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
ccb0: 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
ccc0: 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
ccd0: 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
cce0: 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
ccf0: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
cd00: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
cd10: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
cd20: 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
cd30: 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
cd40: 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
cd50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
cd60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
cd70: 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
cd80: 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
cd90: 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
cda0: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
cdb0: 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
cdc0: 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
cdd0: 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
cde0: 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
cdf0: 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
ce00: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
ce10: 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
ce20: 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
ce30: 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
ce40: 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
ce50: 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
ce60: 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
ce70: 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
ce80: 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
ce90: 54 45 20 53 45 54 20 63 3d 63 3b 31 20 57 48 45  TE SET c=c;1 WHE
cea0: 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
ceb0: 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
cec0: 88 51 19 04 00 91 27 20 20 43 52 45 41 54 45 20  .Q....'  CREATE 
ced0: 54 41 42 4c 45 20 74 31 28 61 20 20 63 68 61 72  TABLE t1(a  char
cee0: 28 31 29 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  (1)PRIMARY KEY, 
cef0: 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
cf00: 2e 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41  .0);.  CREATE TA
cf10: 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58  BLE record(x TEX
cf20: 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52  T, y TEXT);.  CR
cf30: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20  EATE TRIGGER r1 
cf40: 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e  BEFORE INSERT ON
cf50: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
cf60: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
cf70: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
cf80: 4c 55 45 53 28 27 62 73 65 72 74 27 2c 70 72 69  LUES('bsert',pri
cf90: 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
cfa0: 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
cfb0: 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
cfc0: 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
cfd0: 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74  FTER INSERT ON t
cfe0: 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
cff0: 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
d000: 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27  ,y)     VALUES('
d010: 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
d020: 69 6e 74 66 28 27 25 71 2c 25 64 2c 25 64 27 2c  intf('%q,%d,%d',
d030: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
d040: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
d050: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
d060: 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e  BEFORE UPDATE ON
d070: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
d080: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
d090: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
d0a0: 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64  LUES('before-upd
d0b0: 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
d0c0: 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
d0d0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
d0e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
d0f0: 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
d100: 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
d110: 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
d120: 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34  REATE TRIGGER r4
d130: 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e   AFTER UPDATE ON
d140: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
d150: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
d160: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
d170: 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61  LUES('after-upda
d180: 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
d190: 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
d1a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
d1b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
d1c0: 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
d1d0: 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
d1e0: 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
d1f0: 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ND;.  INSERT INT
d200: 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
d210: 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20  (1,2);.  DELETE 
d220: 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
d230: 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
d240: 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
d250: 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
d260: 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
d270: 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45  c=t1.c+1;.  SELE
d280: 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64  CT * FROM record
d290: 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
d2a0: 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
d2b0: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
d2c0: 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e  LUES(1,2).    ON
d2d0: 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
d2e0: 55 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31  UPDATE SET c=c+1
d2f0: 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45   WHERE c<0;.  SE
d300: 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
d310: 72 64 3b 0a 88 49 18 04 00 91 17 20 20 43 52 45  rd;..I.....  CRE
d320: 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 20  ATE TABLE t1(a  
d330: 63 68 61 72 28 31 29 50 52 49 4d 41 52 59 20 4b  char(1)PRIMARY K
d340: 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46  EY, b int, c DEF
d350: 41 55 4c 54 20 b0 29 3b 0a 20 20 43 52 45 41 54  AULT .);.  CREAT
d360: 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78  E TABLE record(x
d370: 20 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a   TEXT, y TEXT);.
d380: 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
d390: 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52   r1 BEFORE INSER
d3a0: 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
d3b0: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
d3c0: 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
d3d0: 20 20 56 41 4c 55 45 53 28 27 62 73 65 72 74 27    VALUES('bsert'
d3e0: 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
d3f0: 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
d400: 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
d410: 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
d420: 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r2 AFTER INSERT 
d430: 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
d440: 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
d450: 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55  rd(x,y)     VALU
d460: 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74  ES('after-insert
d470: 27 2c 70 72 69 6e 74 66 28 27 25 71 2c 25 64 2c  ',printf('%q,%d,
d480: 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
d490: 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
d4a0: 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
d4b0: 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54   r3 BEFORE UPDAT
d4c0: 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
d4d0: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
d4e0: 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
d4f0: 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
d500: 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
d510: 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
d520: 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
d530: 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
d540: 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
d550: 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
d560: 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
d570: 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
d580: 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
d590: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
d5a0: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
d5b0: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
d5c0: 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
d5d0: 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
d5e0: 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
d5f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
d600: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
d610: 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
d620: 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
d630: 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
d640: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
d650: 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
d660: 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
d670: 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
d680: 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
d690: 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
d6a0: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
d6b0: 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
d6c0: 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
d6d0: 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
d6e0: 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
d6f0: 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
d700: 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
d710: 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
d720: 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
d730: 54 45 20 53 45 54 20 63 3d 63 3b 31 20 57 48 45  TE SET c=c;1 WHE
d740: 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
d750: 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
d760: 88 49 17 04 00 91 17 20 20 43 52 45 41 54 45 20  .I.....  CREATE 
d770: 54 41 42 4c 45 20 74 31 28 61 20 20 63 68 61 72  TABLE t1(a  char
d780: 28 31 29 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  (1)PRIMARY KEY, 
d790: 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
d7a0: 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41   0);.  CREATE TA
d7b0: 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58  BLE record(x TEX
d7c0: 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52  T, y TEXT);.  CR
d7d0: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20  EATE TRIGGER r1 
d7e0: 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e  BEFORE INSERT ON
d7f0: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
d800: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
d810: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
d820: 4c 55 45 53 28 27 62 73 65 72 74 27 2c 70 72 69  LUES('bsert',pri
d830: 6e 74 66 28 27 25 7a 2c 25 64 2c 25 64 27 2c 6e  ntf('%z,%d,%d',n
d840: 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
d850: 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
d860: 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
d870: 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74  FTER INSERT ON t
d880: 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
d890: 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
d8a0: 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27  ,y)     VALUES('
d8b0: 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
d8c0: 69 6e 74 66 28 27 25 71 2c 25 64 2c 25 64 27 2c  intf('%q,%d,%d',
d8d0: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
d8e0: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
d8f0: 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
d900: 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e  BEFORE UPDATE ON
d910: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
d920: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
d930: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
d940: 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64  LUES('before-upd
d950: 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
d960: 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
d970: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
d980: 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
d990: 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
d9a0: 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
d9b0: 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
d9c0: 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55  IGGER r4 AFTER U
d9d0: 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
d9e0: 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
d9f0: 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
da00: 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
da10: 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ter-update',prin
da20: 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
da30: 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
da40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
da50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
da60: 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
da70: 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
da80: 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e  c));.  END;.  IN
da90: 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
daa0: 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20  ) VALUES(1,2);. 
dab0: 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
dac0: 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
dad0: 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
dae0: 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
daf0: 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
db00: 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31  ATE SET c=t1.c+1
db10: 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
db20: 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45  M record;.  DELE
db30: 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
db40: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
db50: 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
db60: 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
db70: 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
db80: 45 54 20 63 3d 63 3b 31 20 57 48 45 52 45 20 63  ET c=c;1 WHERE c
db90: 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  <0;.  SELECT * F
dba0: 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 51 16 04  ROM record;..Q..
dbb0: 00 91 27 20 20 43 52 45 41 54 45 20 54 41 42 4c  ..'  CREATE TABL
dbc0: 45 20 74 31 28 61 20 20 63 68 61 72 28 31 29 50  E t1(a  char(1)P
dbd0: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
dbe0: 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  t, c DEFAULT 0);
dbf0: 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
dc00: 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79  record(x TEXT, y
dc10: 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45   TEXT);.  CREATE
dc20: 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f   TRIGGER r1 BEFO
dc30: 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  RE INSERT ON t1 
dc40: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
dc50: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
dc60: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
dc70: 28 27 62 73 65 72 74 27 2c 70 72 69 6e 74 66 28  ('bsert',printf(
dc80: 27 25 71 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%q,%d,%d',new.a
dc90: 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
dca0: 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
dcb0: 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
dcc0: 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
dcd0: 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
dce0: 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
dcf0: 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
dd00: 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
dd10: 28 27 25 71 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%q,%d,%d',new.
dd20: 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
dd30: 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
dd40: 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
dd50: 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
dd60: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
dd70: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
dd80: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
dd90: 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
dda0: 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
ddb0: 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
ddc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
ddd0: 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
dde0: 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
ddf0: 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
de00: 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
de10: 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
de20: 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
de30: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
de40: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
de50: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
de60: 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
de70: 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
de80: 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
de90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
dea0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
deb0: 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
dec0: 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
ded0: 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
dee0: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
def0: 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
df00: 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
df10: 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
df20: 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
df30: 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
df40: 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
df50: 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
df60: 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
df70: 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
df80: 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
df90: 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
dfa0: 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
dfb0: 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
dfc0: 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
dfd0: 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
dfe0: 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
dff0: 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
e000: 0d 00 00 00 07 01 dc 00 1b ae 17 62 13 16 0e ca  ...........b....
e010: 0a 74 06 28 01 dc 00 00 00 00 00 00 00 00 00 00  .t.(............
e020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e0a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e0b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e0c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e0d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e0e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e0f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e1a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e1b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e1c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
e1d0: 00 00 00 00 00 00 00 00 00 00 00 00 88 49 23 04  .............I#.
e1e0: 00 91 17 20 20 43 52 45 41 54 45 20 54 41 42 4c  ...  CREATE TABL
e1f0: 45 20 74 31 28 61 20 43 48 45 43 4b 28 b1 29 50  E t1(a CHECK(.)P
e200: 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
e210: 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  t, c DEFAULT 0);
e220: 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
e230: 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79  record(x TEXT, y
e240: 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45   TEXT);.  CREATE
e250: 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f   TRIGGER r1 BEFO
e260: 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  RE INSERT ON t1 
e270: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
e280: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
e290: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
e2a0: 28 27 62 73 65 72 74 27 2c 70 72 69 6e 74 66 28  ('bsert',printf(
e2b0: 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
e2c0: 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
e2d0: 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
e2e0: 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
e2f0: 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
e300: 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
e310: 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
e320: 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
e330: 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
e340: 28 27 25 71 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%q,%d,%d',new.
e350: 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
e360: 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
e370: 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
e380: 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
e390: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
e3a0: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
e3b0: 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
e3c0: 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
e3d0: 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
e3e0: 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
e3f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
e400: 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f     old.a,old.b,o
e410: 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ld.c,new.a,new.b
e420: 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
e430: 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
e440: 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54  R r4 AFTER UPDAT
e450: 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
e460: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
e470: 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
e480: 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
e490: 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
e4a0: 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
e4b0: 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
e4c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
e4d0: 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
e4e0: 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
e4f0: 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
e500: 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54  .  END;.  INSERT
e510: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
e520: 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c  LUES(1,2);.  DEL
e530: 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  ETE FROM record;
e540: 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
e550: 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
e560: 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49  2).    ON CONFLI
e570: 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20  CT(a) DO UPDATE 
e580: 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20  SET c=t1.c+1;.  
e590: 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
e5a0: 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46  cord;.  DELETE F
e5b0: 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e  ROM record;.  IN
e5c0: 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
e5d0: 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20  ) VALUES(1,2).  
e5e0: 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
e5f0: 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
e600: 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a  =c+1 WHERE c<0;.
e610: 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
e620: 72 65 63 6f 72 64 3b 0a 88 49 22 04 00 91 17 20  record;..I".... 
e630: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
e640: 28 61 20 43 48 45 43 4b 28 41 29 50 52 49 4d 41  (a CHECK(A)PRIMA
e650: 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63  RY KEY, b int, c
e660: 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43   DEFAULT 0);.  C
e670: 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f  REATE TABLE reco
e680: 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58  rd(x TEXT, y TEX
e690: 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  T);.  CREATE TRI
e6a0: 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49  GGER r1 BEFORE I
e6b0: 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
e6c0: 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
e6d0: 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
e6e0: 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 73        VALUES('bs
e6f0: 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ert',printf('%d,
e700: 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77  %d,%d',new.a,new
e710: 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
e720: 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
e730: 47 45 52 20 72 32 20 41 46 54 45 52 20 49 4e 53  GER r2 AFTER INS
e740: 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ERT ON t1 BEGIN.
e750: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
e760: 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20  record(x,y)     
e770: 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e  VALUES('after-in
e780: 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 71  sert',printf('%q
e790: 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65  ,%d,%d',new.a,ne
e7a0: 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
e7b0: 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
e7c0: 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20 55  GGER r3 BEFORE U
e7d0: 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
e7e0: 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
e7f0: 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
e800: 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
e810: 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69  fore-update',pri
e820: 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
e830: 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
e840: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
e850: 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
e860: 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
e870: 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
e880: 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34  REATE TRIGGER r4
e890: 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e   AFTER UPDATE ON
e8a0: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
e8b0: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
e8c0: 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
e8d0: 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61  LUES('after-upda
e8e0: 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
e8f0: 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
e900: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
e910: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
e920: 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
e930: 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
e940: 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
e950: 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ND;.  INSERT INT
e960: 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
e970: 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20  (1,2);.  DELETE 
e980: 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
e990: 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
e9a0: 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
e9b0: 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
e9c0: 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
e9d0: 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45  c=t1.c+1;.  SELE
e9e0: 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64  CT * FROM record
e9f0: 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
ea00: 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
ea10: 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
ea20: 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e  LUES(1,2).    ON
ea30: 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
ea40: 55 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31  UPDATE SET c=c+1
ea50: 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45   WHERE c<0;.  SE
ea60: 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
ea70: 72 64 3b 0a 88 53 21 04 00 91 2b 20 20 43 52 45  rd;..S!...+  CRE
ea80: 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 43  ATE TABLE t1(a C
ea90: 48 45 43 4b 28 32 30 30 31 2d 30 31 2d 30 31 31  HECK(2001-01-011
eaa0: 29 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20  )PRIMARY KEY, b 
eab0: 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30  int, c DEFAULT 0
eac0: 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c  );.  CREATE TABL
ead0: 45 20 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c  E record(x TEXT,
eae0: 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41   y TEXT);.  CREA
eaf0: 54 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45  TE TRIGGER r1 BE
eb00: 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74  FORE INSERT ON t
eb10: 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
eb20: 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
eb30: 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
eb40: 45 53 28 27 62 73 65 72 74 27 2c 70 72 69 6e 74  ES('bsert',print
eb50: 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77  f('%d,%d,%d',new
eb60: 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
eb70: 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
eb80: 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46 54  E TRIGGER r2 AFT
eb90: 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  ER INSERT ON t1 
eba0: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
ebb0: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
ebc0: 29 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66  )     VALUES('af
ebd0: 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ter-insert',prin
ebe0: 74 66 28 27 25 71 2c 25 64 2c 25 64 27 2c 6e 65  tf('%q,%d,%d',ne
ebf0: 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
ec00: 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
ec10: 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42 45  TE TRIGGER r3 BE
ec20: 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74  FORE UPDATE ON t
ec30: 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
ec40: 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
ec50: 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
ec60: 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74  ES('before-updat
ec70: 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
ec80: 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
ec90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
eca0: 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
ecb0: 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
ecc0: 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
ecd0: 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
ece0: 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44  GER r4 AFTER UPD
ecf0: 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
ed00: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
ed10: 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
ed20: 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
ed30: 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  r-update',printf
ed40: 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
ed50: 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
ed60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
ed70: 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e              old.
ed80: 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65  a,old.b,old.c,ne
ed90: 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
eda0: 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45  );.  END;.  INSE
edb0: 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
edc0: 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44  VALUES(1,2);.  D
edd0: 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
ede0: 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
edf0: 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
ee00: 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46  1,2).    ON CONF
ee10: 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54  LICT(a) DO UPDAT
ee20: 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a  E SET c=t1.c+1;.
ee30: 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
ee40: 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45  record;.  DELETE
ee50: 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
ee60: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
ee70: 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
ee80: 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
ee90: 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
eea0: 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30   c=c+1 WHERE c<0
eeb0: 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
eec0: 4d 20 72 65 63 6f 72 64 3b 0a 88 49 20 04 00 91  M record;..I ...
eed0: 17 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
eee0: 74 31 28 61 20 43 48 45 43 4b 28 31 29 50 52 49  t1(a CHECK(1)PRI
eef0: 4d 41 52 59 20 4b 45 59 2c 20 62 2c 69 6e 74 2c  MARY KEY, b,int,
ef00: 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20   c DEFAULT 0);. 
ef10: 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65   CREATE TABLE re
ef20: 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54  cord(x TEXT, y T
ef30: 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54  EXT);.  CREATE T
ef40: 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45  RIGGER r1 BEFORE
ef50: 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
ef60: 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
ef70: 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
ef80: 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
ef90: 62 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25  bsert',printf('%
efa0: 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e  d,%d,%d',new.a,n
efb0: 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
efc0: 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
efd0: 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49  IGGER r2 AFTER I
efe0: 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
eff0: 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
f000: 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20  O record(x,y)   
f010: 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
f020: 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
f030: 25 71 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c  %q,%d,%d',new.a,
f040: 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
f050: 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
f060: 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45  RIGGER r3 BEFORE
f070: 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
f080: 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
f090: 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
f0a0: 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
f0b0: 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70  before-update',p
f0c0: 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
f0d0: 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
f0e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
f0f0: 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
f100: 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
f110: 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
f120: 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
f130: 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20  r4 AFTER UPDATE 
f140: 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
f150: 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
f160: 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
f170: 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70  VALUES('after-up
f180: 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
f190: 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
f1a0: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
f1b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
f1c0: 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
f1d0: 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
f1e0: 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
f1f0: 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49   END;.  INSERT I
f200: 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
f210: 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54  ES(1,2);.  DELET
f220: 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
f230: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
f240: 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
f250: 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
f260: 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
f270: 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45  T c=t1.c+1;.  SE
f280: 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
f290: 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  rd;.  DELETE FRO
f2a0: 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
f2b0: 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
f2c0: 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
f2d0: 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
f2e0: 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63  O UPDATE SET c=c
f2f0: 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20  +1 WHERE c<0;.  
f300: 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
f310: 63 6f 72 64 3b 0a 88 49 1f 04 00 91 17 20 20 43  cord;..I.....  C
f320: 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 61  REATE TABLE t1(a
f330: 20 43 48 45 43 4b 28 31 29 50 52 49 4d 41 52 59   CHECK(1)PRIMARY
f340: 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44   KEY, b int, c D
f350: 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45  EFAULT 0);.  CRE
f360: 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64  ATE TABLE record
f370: 28 78 20 54 45 58 54 2c 20 79 20 54 45 58 54 29  (x TEXT, y TEXT)
f380: 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
f390: 45 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53  ER r1 BEFORE INS
f3a0: 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ERT ON t1 BEGIN.
f3b0: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
f3c0: 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
f3d0: 20 20 20 20 56 41 4c 55 45 53 28 27 62 73 65 72      VALUES('bser
f3e0: 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  t',printf('%d,%d
f3f0: 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
f400: 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
f410: 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
f420: 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52  R r2 AFTER INSER
f430: 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
f440: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
f450: 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41  cord(x,y)     VA
f460: 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65  LUES('after-inse
f470: 72 74 27 2c 70 72 69 6e 74 66 28 27 25 71 2c 25  rt',printf('%q,%
f480: 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e  d,%d',new.a,new.
f490: 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
f4a0: 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
f4b0: 45 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44  ER r3 BEFORE UPD
f4c0: 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
f4d0: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
f4e0: f2 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  .ecord(x,y).    
f4f0: 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f      VALUES('befo
f500: 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74  re-update',print
f510: 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25  f('%d,%d,%d/%d,%
f520: 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20  d,%d',.         
f530: 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64               old
f540: 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e  .a,old.b,old.c,n
f550: 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
f560: 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
f570: 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20 41  ATE TRIGGER r4 A
f580: 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74  FTER UPDATE ON t
f590: 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
f5a0: 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
f5b0: 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
f5c0: 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74 65  ES('after-update
f5d0: 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
f5e0: 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20  %d/%d,%d,%d',.  
f5f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
f600: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
f610: 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
f620: 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
f630: 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
f640: 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
f650: 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
f660: 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  ,2);.  DELETE FR
f670: 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
f680: 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
f690: 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20   VALUES(1,2).   
f6a0: 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20   ON CONFLICT(a) 
f6b0: 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d  DO UPDATE SET c=
f6c0: 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54  t1.c+1;.  SELECT
f6d0: 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
f6e0: 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
f6f0: 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
f700: 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
f710: 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43  ES(1,2).    ON C
f720: 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50  ONFLICT(a) DO UP
f730: 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57  DATE SET c=c+1 W
f740: 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45  HERE c<0;.  SELE
f750: 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64  CT * FROM record
f760: 3b 0a 88 49 1e 04 00 91 17 20 20 43 52 45 41 54  ;..I.....  CREAT
f770: 45 20 54 41 42 4c 45 20 74 31 28 61 20 43 48 45  E TABLE t1(a CHE
f780: 43 4b 28 31 29 50 52 49 4d 41 52 59 20 4b 45 59  CK(1)PRIMARY KEY
f790: 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55  , b int, c DEFAU
f7a0: 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20  LT 0);.  CREATE 
f7b0: 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54  TABLE record(x T
f7c0: 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20  EXT, y TEXT);.  
f7d0: 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
f7e0: 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20  1 BEFORE INSERT 
f7f0: 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
f800: 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
f810: 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
f820: 56 41 4c 55 45 53 28 27 62 73 65 72 74 27 2c 70  VALUES('bsert',p
f830: 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27  rintf('%d,%d,%d'
f840: 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
f850: 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
f860: 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32  REATE TRIGGER r2
f870: 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e   AFTER INSERT ON
f880: 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
f890: 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
f8a0: 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53  (x,y)     VALUES
f8b0: 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c  ('after-insert',
f8c0: 70 72 69 6e 74 66 28 27 25 71 2c 25 64 2c 25 64  printf('%q,%d,%d
f8d0: 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ',new.a,new.b,ne
f8e0: 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
f8f0: 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
f900: 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20  3 BEFORE UPDATE 
f910: 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
f920: 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
f930: 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
f940: 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75  VALUES('before-u
f950: 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
f960: 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
f970: 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
f980: 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
f990: 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
f9a0: 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
f9b0: 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
f9c0: 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52  TRIGGER r4 AFTER
f9d0: 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
f9e0: 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
f9f0: 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
fa00: 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
fa10: 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72  after-update',pr
fa20: 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
fa30: 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
fa40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
fa50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
fa60: 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e  old.a,old.b,old.
fa70: 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  c,new.a,new.b,ne
fa80: 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
fa90: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
faa0: 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b  ,b) VALUES(1,2);
fab0: 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
fac0: 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
fad0: 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
fae0: 55 45 53 28 31 2c 32 29 8a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
faf0: 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
fb00: 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63  PDATE SET c=t1.c
fb10: 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  +1;.  SELECT * F
fb20: 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45  ROM record;.  DE
fb30: 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
fb40: 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
fb50: 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
fb60: 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,2).    ON CONFL
fb70: 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
fb80: 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45   SET c=c+1 WHERE
fb90: 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a   c<0;.  SELECT *
fba0: 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 4f   FROM record;..O
fbb0: 1d 04 00 91 23 20 20 43 52 45 41 54 45 20 54 41  ....#  CREATE TA
fbc0: 42 4c 45 20 74 31 28 61 20 43 48 45 43 4b 28 31  BLE t1(a CHECK(1
fbd0: 29 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20  )PRIMARY KEY, b 
fbe0: 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30  int, c DEFAULT 0
fbf0: 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c  );.  CREATE TABL
fc00: 45 20 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c  E record(x TEXT,
fc10: 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41   y TEXT);.  CREA
fc20: 54 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45  TE TRIGGER r1 BE
fc30: 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74  FORE INSERT ON t
fc40: 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
fc50: 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
fc60: 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
fc70: 45 53 28 27 62 73 65 72 74 27 2c 70 72 69 6e 74  ES('bsert',print
fc80: 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77  f('%d,%d,%d',new
fc90: 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
fca0: 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
fcb0: 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46 54  E TRIGGER r2 AFT
fcc0: 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  ER INSERT ON t1 
fcd0: 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
fce0: 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
fcf0: 29 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66  )     VALUES('af
fd00: 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ter-insert',prin
fd10: 74 66 28 27 25 71 2c 25 64 2c 25 64 27 2c 6e 65  tf('%q,%d,%d',ne
fd20: 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
fd30: 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
fd40: 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42 45  TE TRIGGER r3 BE
fd50: 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74  FORE UPDATE ON t
fd60: 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
fd70: 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
fd80: 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
fd90: 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74  ES('before-updat
fda0: 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
fdb0: 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
fdc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
fdd0: 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
fde0: 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
fdf0: 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
fe00: 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
fe10: 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44  GER r4 AFTER UPD
fe20: 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
fe30: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
fe40: 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
fe50: 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
fe60: 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  r-update',printf
fe70: 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
fe80: 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
fe90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
fea0: 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e              old.
feb0: 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65  a,old.b,old.c,ne
fec0: 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
fed0: 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45  );.  END;.  INSE
fee0: 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
fef0: 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44  VALUES(1,2);.  D
ff00: 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
ff10: 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
ff20: 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
ff30: 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46  1,2).    ON CONF
ff40: 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54  LICT(a) DO UPDAT
ff50: 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a  E SET c=t1.c+1;.
ff60: 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
ff70: 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45  record;.  DELETE
ff80: 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
ff90: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
ffa0: 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
ffb0: 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
ffc0: 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
ffd0: 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30   c=c+1 WHERE c<0
ffe0: 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
fff0: 4d 20 72 65 63 6f 72 64 3b 56 41 43 55 55 4d 0a  M record;VACUUM.
10000 0d 00 00 00 07 02 ff 00 1b a9 17 90 13 70 0f 4a  .............p.J
10010 0b 31 07 18 02 ff 00 00 00 00 00 00 00 00 00 00  .1..............
10020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
100a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
100b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
100c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
100d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
100e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
100f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
101a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
101b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
101c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
101d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
101e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
101f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10200 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10210 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10220 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10230 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10250 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10260 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10270 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10280 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
10290 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
102a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
102b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
102c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
102d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
102e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
102f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 88  ................
10300 16 2a 04 00 90 31 20 20 43 52 45 41 54 45 20 54  .*...1  CREATE T
10310 41 42 4c 45 20 74 31 28 61 20 49 4e 54 20 50 52  ABLE t1(a INT PR
10320 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74  IMARY KEY, b int
10330 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 20 57  , c DEFAULT 0) W
10340 49 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20 20  ITHOUT ROWID;.  
10350 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
10360 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20  1 BEFORE INSERT 
10370 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
10380 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
10390 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
103a0 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69  VALUES('before-i
103b0 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25  nsert',printf('%
103c0 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e  d,%d,%d',new.a,n
103d0 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
103e0 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
103f0 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49  IGGER r2 AFTER I
10400 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
10410 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
10420 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
10430 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
10440 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ter-insert',prin
10450 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65  tf('%d,%d,%d',ne
10460 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
10470 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
10480 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42 45  TE TRIGGER r3 BE
10490 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74  FORE UPDATE ON t
104a0 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
104b0 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
104c0 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
104d0 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74  ES('before-updat
104e0 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
104f0 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
10500 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
10510 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
10520 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
10530 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
10540 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
10550 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
10560 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44  GER r4 AFTER UPD
10570 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
10580 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
10590 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
105a0 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
105b0 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  r-update',printf
105c0 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
105d0 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
105e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
105f0 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e              old.
10600 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65  a,old.b,old.c,ne
10610 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
10620 29 3b 0a 20 2f 2a 20 2a 2f 0a 20 20 49 4e 53 45  );. /* */.  INSE
10630 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
10640 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44  VALUES(1,2);.  D
10650 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
10660 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
10670 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
10680 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46  1,2).    ON CONF
10690 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54  LICT(a) DO UPDAT
106a0 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a  E SET c=t1.c+1;.
106b0 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
106c0 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
106d0 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
106e0 45 53 28 31 2c 32 29 20 4f 4e 20 43 4f 4e 46 4c  ES(1,2) ON CONFL
106f0 49 43 54 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a  ICT DO NOTHING;.
10700 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
10710 61 2c 62 6f 72 64 3b 0a 88 16 29 04 00 90 31 20  a,bord;...)...1 
10720 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
10730 28 61 20 49 4e 54 20 50 52 49 4d 41 52 59 20 4b  (a INT PRIMARY K
10740 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46  EY, b int, c DEF
10750 41 55 4c 54 20 30 29 20 57 49 54 48 4f 55 54 20  AULT 0) WITHOUT 
10760 52 4f 57 49 44 3b 0a 20 20 43 52 45 41 54 45 20  ROWID;.  CREATE 
10770 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52  TRIGGER r1 BEFOR
10780 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  E INSERT ON t1 B
10790 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
107a0 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
107b0 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
107c0 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c  'before-insert',
107d0 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
107e0 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ',new.a,new.b,ne
107f0 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
10800 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
10810 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f  2 AFTER INSERT O
10820 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
10830 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
10840 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
10850 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73  ALUES('after-ins
10860 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ert',printf('%d,
10870 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77  %d,%d',new.a,new
10880 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
10890 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
108a0 47 45 52 20 72 33 20 42 45 46 4f 52 45 20 55 50  GER r3 BEFORE UP
108b0 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e  DATE ON t1 BEGIN
108c0 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
108d0 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
108e0 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
108f0 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ore-update',prin
10900 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
10910 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
10920 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
10930 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
10940 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
10950 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
10960 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
10970 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20  EATE TRIGGER r4 
10980 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20  AFTER UPDATE ON 
10990 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
109a0 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
109b0 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
109c0 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74  UES('after-updat
109d0 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
109e0 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
109f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
10a00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
10a10 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
10a20 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
10a30 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
10a40 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  D;.  INSERT INTO
10a50 20 74 31 28 62 2c 62 29 20 56 41 4c 55 45 53 28   t1(b,b) VALUES(
10a60 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46  1,2);.  DELETE F
10a70 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e  ROM record;.  IN
10a80 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
10a90 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20  ) VALUES(1,2).  
10aa0 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
10ab0 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
10ac0 3d 74 31 2e 63 2b 31 3b 0a 20 20 44 45 4c 45 54  =t1.c+1;.  DELET
10ad0 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
10ae0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
10af0 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
10b00 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 20 44 4f 20   ON CONFLICT DO 
10b10 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45 4c 45 43  NOTHING;.  SELEC
10b20 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
10b30 0a 88 16 28 04 00 90 31 20 20 43 52 45 41 54 45  ...(...1  CREATE
10b40 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 20   TABLE t1(a INT 
10b50 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
10b60 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29  nt, c DEFAULT 0)
10b70 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a   WITHOUT ROWID;.
10b80 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
10b90 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52   r1 BEFORE INSER
10ba0 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
10bb0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
10bc0 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
10bd0 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
10be0 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
10bf0 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
10c00 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
10c10 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
10c20 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
10c30 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
10c40 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
10c50 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
10c60 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
10c70 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
10c80 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c  intf('%d,%d,%d',
10c90 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
10ca0 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
10cb0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
10cc0 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e  BEFORE INSERT ON
10cd0 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
10ce0 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
10cf0 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
10d00 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64  LUES('before-upd
10d10 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
10d20 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
10d30 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
10d40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
10d50 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
10d60 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
10d70 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
10d80 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
10d90 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55  IGGER r4 AFTER U
10da0 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
10db0 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
10dc0 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
10dd0 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
10de0 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ter-update',prin
10df0 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
10e00 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
10e10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
10e20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
10e30 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
10e40 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
10e50 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e  c));.  END;.  IN
10e60 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
10e70 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20  ) VALUES(1,2);. 
10e80 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
10e90 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
10ea0 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
10eb0 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
10ec0 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
10ed0 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31  ATE SET c=t1.c+1
10ee0 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
10ef0 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
10f00 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
10f10 4c 55 45 53 28 31 2c 32 29 20 4f 4e 20 43 4f 4e  LUES(1,2) ON CON
10f20 46 4c 49 43 54 20 44 4f 20 4e 4f 54 48 49 4e 47  FLICT DO NOTHING
10f30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
10f40 4d 20 72 65 63 6f 72 64 3b 0a 88 23 27 04 00 90  M record;..#'...
10f50 4b 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  K  CREATE TABLE 
10f60 74 31 28 61 20 49 4e 54 20 50 52 49 4d 41 52 59  t1(a INT PRIMARY
10f70 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44   KEY, b int, c D
10f80 45 46 41 55 4c 54 20 30 29 20 57 49 54 48 4f 55  EFAULT 0) WITHOU
10f90 54 20 52 4f 57 49 44 3b 0a 20 20 43 52 45 41 54  T ROWID;.  CREAT
10fa0 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46  E TRIGGER r1 BEF
10fb0 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  ORE INSERT ON t1
10fc0 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
10fd0 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
10fe0 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
10ff0 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74  S('before-insert
11000 27 20 67 6c 6f 62 28 31 2c 31 29 2c 70 72 69 6e  ' glob(1,1),prin
11010 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65  tf('%d,%d,%d',ne
11020 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
11030 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
11040 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46  TE TRIGGER r2 AF
11050 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  TER INSERT ON t1
11060 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
11070 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
11080 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
11090 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27  S('after-insert'
110a0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
110b0 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
110c0 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
110d0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
110e0 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45  r3 BEFORE UPDATE
110f0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
11100 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
11110 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
11120 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
11130 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
11140 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
11150 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
11160 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
11170 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
11180 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
11190 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
111a0 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
111b0 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45   TRIGGER r4 AFTE
111c0 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  R UPDATE ON t1 B
111d0 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
111e0 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
111f0 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
11200 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70  'after-update',p
11210 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
11220 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
11230 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
11240 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
11250 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
11260 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
11270 65 77 2e 63 29 29 3b 0a 20 2f 2a 20 2a 2f 0a 20  ew.c));. /* */. 
11280 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
11290 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
112a0 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
112b0 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
112c0 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
112d0 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e  LUES(1,2).    ON
112e0 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
112f0 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e  UPDATE SET c=t1.
11300 63 2b 31 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  c+1;.  DELETE FR
11310 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
11320 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
11330 20 56 41 4c 55 45 53 28 31 2c 32 29 20 4f 4e 20   VALUES(1,2) ON 
11340 43 4f 4e 46 4c 49 43 54 20 44 4f 20 4e 4f 54 48  CONFLICT DO NOTH
11350 49 4e 47 3b 0a 20 20 53 45 4c 45 43 54 20 2a 57  ING;.  SELECT *W
11360 48 45 52 45 20 72 65 63 6f 72 64 3b 45 4e 44 0a  HERE record;END.
11370 88 1d 26 04 00 90 3f 20 20 43 52 45 41 54 45 20  ..&...?  CREATE 
11380 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 20 50  TABLE t1(a INT P
11390 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
113a0 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 20  t, c DEFAULT 0) 
113b0 57 49 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20  WITHOUT ROWID;. 
113c0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
113d0 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54  r1 BEFORE INSERT
113e0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
113f0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
11400 6f 72 64 28 20 61 2c 62 78 2c 79 29 0a 20 20 20  ord( a,bx,y).   
11410 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
11420 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ore-insert',prin
11430 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65  tf('%d,%d,%d',ne
11440 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
11450 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
11460 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46  TE TRIGGER r2 AF
11470 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  TER INSERT ON t1
11480 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
11490 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
114a0 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
114b0 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27  S('after-insert'
114c0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
114d0 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
114e0 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
114f0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
11500 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45  r3 BEFORE UPDATE
11510 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
11520 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
11530 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
11540 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
11550 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
11560 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
11570 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
11580 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
11590 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
115a0 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
115b0 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
115c0 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
115d0 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45   TRIGGER r4 AFTE
115e0 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  R UPDATE ON t1 B
115f0 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
11600 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
11610 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
11620 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70  'after-update',p
11630 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
11640 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
11650 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
11660 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
11670 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
11680 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
11690 65 77 2e 63 29 29 3b 0a 20 2f 2a 20 2a 2f 0a 20  ew.c));. /* */. 
116a0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
116b0 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
116c0 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
116d0 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
116e0 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
116f0 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e  LUES(1,2).    ON
11700 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
11710 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e  UPDATE SET c=t1.
11720 63 2b 31 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  c+1;.  DELETE FR
11730 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
11740 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
11750 20 56 41 4c 55 45 53 28 31 2c 32 29 20 4f 4e 20   VALUES(1,2) ON 
11760 43 4f 4e 46 4c 49 43 54 20 44 4f 20 4e 4f 54 48  CONFLICT DO NOTH
11770 49 4e 47 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20  ING;.  SELECT * 
11780 46 52 4f 4d 20 72 65 63 6f 72 64 3b 45 4e 44 0a  FROM record;END.
11790 88 16 25 04 00 90 31 20 20 43 52 45 41 54 45 20  ..%...1  CREATE 
117a0 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 20 50  TABLE t1(a INT P
117b0 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 55 4e  RIMARY KEY, b UN
117c0 49 51 55 45 20 44 45 46 41 55 4c 54 20 30 29 20  IQUE DEFAULT 0) 
117d0 57 49 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20  WITHOUT ROWID;. 
117e0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
117f0 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54  r1 BEFORE INSERT
11800 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 57   ON t1 BEGIN.  W
11810 49 54 48 20 63 28 78 29 20 41 53 20 28 76 61 6c  ITH c(x) AS (val
11820 75 65 73 28 31 29 29 20 0a 20 20 20 20 20 20 20  ues(1)) .       
11830 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
11840 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
11850 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c  %d,%d,%d',new.a,
11860 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
11870 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
11880 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20  RIGGER r2 AFTER 
11890 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
118a0 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
118b0 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
118c0 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61         VALUES('a
118d0 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69  fter-insert',pri
118e0 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
118f0 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
11900 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
11910 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42  ATE TRIGGER r3 B
11920 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20  EFORE UPDATE ON 
11930 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
11940 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
11950 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
11960 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61  UES('before-upda
11970 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
11980 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
11990 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
119a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
119b0 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
119c0 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
119d0 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
119e0 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
119f0 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50  GGER r4 AFTER UP
11a00 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e  DATE ON t1 BEGIN
11a10 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
11a20 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
11a30 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74       VALUES('aft
11a40 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74  er-update',print
11a50 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25  f('%d,%d,%d/%d,%
11a60 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20  d,%d',.         
11a70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
11a80 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64               old
11a90 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e  .a,old.b,old.c,n
11aa0 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
11ab0 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53  ));.  END;.  INS
11ac0 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
11ad0 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20   VALUES(1,2);.  
11ae0 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
11af0 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
11b00 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
11b10 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
11b20 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
11b30 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b  TE SET c=t1.c+1;
11b40 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
11b50 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
11b60 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
11b70 55 45 53 28 31 2c 32 29 20 4f 4e 20 43 4f 4e 46  UES(1,2) ON CONF
11b80 4c 49 43 54 20 44 4f 20 4e 4f 54 48 49 4e 47 3b  LICT DO NOTHING;
11b90 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
11ba0 20 72 65 63 6f 72 64 3b 0a 88 54 24 04 00 91 2d   record;..T$...-
11bb0 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
11bc0 31 28 61 20 45 58 43 4c 55 53 49 56 45 49 4e 54  1(a EXCLUSIVEINT
11bd0 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59  EGER PRIMARY KEY
11be0 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55  , b int, c DEFAU
11bf0 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20  LT 0);.  CREATE 
11c00 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54  TABLE record(x T
11c10 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20  EXT, y TEXT);.  
11c20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
11c30 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20  1 BEFORE INSERT 
11c40 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
11c50 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
11c60 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
11c70 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69  VALUES('before-i
11c80 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25  nsert',printf('%
11c90 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e  d,%d,%d',new.a,n
11ca0 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
11cb0 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
11cc0 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49  IGGER r2 AFTER I
11cd0 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
11ce0 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
11cf0 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20  O record(x,y)   
11d00 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
11d10 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
11d20 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c  %d,%d,%d',new.a,
11d30 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
11d40 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
11d50 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45  RIGGER r3 BEFORE
11d60 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
11d70 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
11d80 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
11d90 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
11da0 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70  before-update',p
11db0 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
11dc0 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
11dd0 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
11de0 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
11df0 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
11e00 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
11e10 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52  TRIGGER r4 AFTER
11e20 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
11e30 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
11e40 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
11e50 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
11e60 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72  after-update',pr
11e70 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
11e80 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
11e90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
11ea0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
11eb0 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e  old.a,old.b,old.
11ec0 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  c,new.a,new.b,ne
11ed0 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
11ee0 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 63  INSERT INTO t1(c
11ef0 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b  ,b) VALUES(1,2);
11f00 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
11f10 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
11f20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
11f30 55 45 53 28 31 2c 32 29 0a 4f 4e 20 43 4f 4e 46  UES(1,2).ON CONF
11f40 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54  LICT(a) DO UPDAT
11f50 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a  E SET c=t1.c+1;.
11f60 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
11f70 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45  record;.  DELETE
11f80 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
11f90 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
11fa0 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
11fb0 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
11fc0 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
11fd0 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30   c=c+1 WHERE c<0
11fe0 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
11ff0 4d 20 72 65 63 6f 72 64 3b 56 41 43 55 55 4d 0a  M record;VACUUM.
12000 0d 00 00 00 07 03 27 00 1b dc 17 b1 13 95 0f 79  ......'........y
12010 0b 60 07 47 03 27 00 00 00 00 00 00 00 00 00 00  .`.G.'..........
12020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
120a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
120b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
120c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
120d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
120e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
120f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
121a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
121b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
121c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
121d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
121e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
121f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12200 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12210 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12220 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12230 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12250 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12260 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12270 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12280 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12290 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
122a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
122b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
122c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
122d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
122e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
122f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12300 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12310 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
12320 00 00 00 00 00 00 00 88 1d 31 04 00 90 3f 20 20  .........1...?  
12330 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
12340 61 20 49 4e 54 20 50 52 49 4d 41 52 59 20 4b 45  a INT PRIMARY KE
12350 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41  Y, b int, c DEFA
12360 55 4c 54 20 30 29 20 57 49 54 48 4f 55 54 20 52  ULT 0) WITHOUT R
12370 4f 57 49 44 3b 0a 20 20 43 52 45 41 54 45 20 54  OWID;.  CREATE T
12380 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45  RIGGER r1 BEFORE
12390 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
123a0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
123b0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
123c0 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
123d0 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70  before-insert',p
123e0 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27  rintf('%d,%d,%d'
123f0 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
12400 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
12410 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32  REATE TRIGGER r2
12420 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e   AFTER INSERT ON
12430 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
12440 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
12450 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
12460 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65  LUES('after-inse
12470 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  rt',printf('%d,%
12480 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e  d,%d',new.a,new.
12490 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
124a0 3b 45 58 50 4c 41 49 4e 0a 20 20 43 52 45 41 54  ;EXPLAIN.  CREAT
124b0 45 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46  E TRIGGER r3 BEF
124c0 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31  ORE UPDATE ON t1
124d0 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
124e0 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
124f0 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
12500 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65  S('before-update
12510 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
12520 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20  %d/%d,%d,%d',.  
12530 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
12540 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
12550 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
12560 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
12570 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
12580 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
12590 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41  ER r4 AFTER UPDA
125a0 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
125b0 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
125c0 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
125d0 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
125e0 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
125f0 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
12600 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
12610 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
12620 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
12630 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
12640 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
12650 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52  ;.  END;.  INSER
12660 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
12670 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45  ALUES(1,2);.  DE
12680 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
12690 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
126a0 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
126b0 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,2).    ON CONFL
126c0 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
126d0 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20   SET c=t1.c+1;. 
126e0 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
126f0 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
12700 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
12710 53 28 31 2c 32 29 20 4f 4e 20 43 4f 4e 46 4c 49  S(1,2) ON CONFLI
12720 43 54 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20  CT DO NOTHING;. 
12730 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
12740 65 63 6f 72 64 3b 0a 88 16 30 04 00 90 31 20 20  ecord;...0...1  
12750 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
12760 61 20 49 4e 54 20 50 52 49 4d 41 52 59 20 4b 45  a INT PRIMARY KE
12770 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41  Y, b int, c DEFA
12780 55 4c 54 20 30 29 20 57 49 54 48 4f 55 54 20 52  ULT 0) WITHOUT R
12790 4f 57 49 44 3b 0a 20 20 43 52 45 41 54 45 20 54  OWID;.  CREATE T
127a0 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45  RIGGER r1 BEFORE
127b0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
127c0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
127d0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
127e0 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
127f0 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70  before-insert',p
12800 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27  rintf('%d,%d,%d'
12810 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
12820 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
12830 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32  REATE TRIGGER r2
12840 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e   AFTER INSERT ON
12850 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
12860 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
12870 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
12880 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65  LUES('after-inse
12890 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  rt',printf('%d,%
128a0 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e  d,%d',new.a,new.
128b0 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
128c0 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
128d0 45 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44  ER r3 BEFORE UPD
128e0 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
128f0 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
12900 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
12910 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f      VALUES('befo
12920 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74  re-update',print
12930 66 2a 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25  f*'%d,%d,%d/%d,%
12940 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20  d,%d',.         
12950 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
12960 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64               old
12970 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e  .a,old.b,old.c,n
12980 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
12990 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
129a0 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20 41  ATE TRIGGER r4 A
129b0 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74  FTER UPDATE ON t
129c0 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
129d0 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
129e0 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
129f0 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74 65  ES('after-update
12a00 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
12a10 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20  %d/%d,%d,%d',.  
12a20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
12a30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
12a40 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
12a50 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
12a60 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
12a70 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
12a80 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
12a90 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  ,2);.  DELETE FR
12aa0 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
12ab0 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
12ac0 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20   VALUES(1,2).   
12ad0 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20   ON CONFLICT(a) 
12ae0 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d  DO UPDATE SET c=
12af0 74 31 2e 63 2b 31 3b 0a 20 20 44 45 4c 45 54 45  t1.c+1;.  DELETE
12b00 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
12b10 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
12b20 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 20  ,b) VALUES(1,2) 
12b30 4f 4e 20 43 4f 4e 46 4c 49 43 54 20 44 4f 20 4e  ON CONFLICT DO N
12b40 4f 54 48 49 4e 47 3b 0a 20 20 53 45 4c 45 43 54  OTHING;.  SELECT
12b50 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
12b60 88 16 2f 04 00 90 31 20 20 43 52 45 41 54 45 20  ../...1  CREATE 
12b70 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 20 50  TABLE t1(a INT P
12b80 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
12b90 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 20  t, c DEFAULT 0) 
12ba0 57 49 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20  WITHOUT ROWID;. 
12bb0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
12bc0 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54  r1 BEFORE INSERT
12bd0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
12be0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
12bf0 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
12c00 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
12c10 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
12c20 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c  %d,%d,%d',new.a,
12c30 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
12c40 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
12c50 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20  RIGGER r2 AFTER 
12c60 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
12c70 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
12c80 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
12c90 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61         VALUES('a
12ca0 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69  fter-insert',pri
12cb0 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
12cc0 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
12cd0 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
12ce0 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42  ATE TRIGGER r3 B
12cf0 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20  EFORE UPDATE ON 
12d00 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
12d10 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
12d20 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
12d30 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61  UES('before-upda
12d40 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
12d50 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
12d60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
12d70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
12d80 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
12d90 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
12da0 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
12db0 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
12dc0 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50  GGER r4 AFTER UP
12dd0 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e  DATE ON t1 BEGIN
12de0 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
12df0 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
12e00 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74       VALUES('aft
12e10 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74  er-update',print
12e20 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25  f('%d,%d,%d/%d,%
12e30 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20  d,%d',.         
12e40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
12e50 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64               old
12e60 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e  .a,old.b,old.c,n
12e70 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
12e80 29 29 3b 0a 20 2f 2a 20 2a 2f 0a 20 20 49 4e 53  ));. /* */.  INS
12e90 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
12ea0 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20   VALUES(1,2);.  
12eb0 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
12ec0 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
12ed0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
12ee0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
12ef0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
12f00 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b  TE SET c=t1.c+1;
12f10 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
12f20 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
12f30 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
12f40 55 45 53 28 31 2c 32 29 20 4f 4e 20 43 4f 4e 46  UES(1,2) ON CONF
12f50 4c 49 43 54 20 44 4f 20 4e 4f 54 48 49 4e 47 3b  LICT DO NOTHING;
12f60 0a 20 20 53 45 4c 45 43 54 20 2a a0 46 52 4f 4d  .  SELECT *.FROM
12f70 20 72 65 63 6f 72 64 3b 0a 88 19 2e 04 00 90 37   record;.......7
12f80 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
12f90 31 28 61 20 49 4e 54 20 50 52 49 4d 41 52 59 20  1(a INT PRIMARY 
12fa0 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45  KEY, b int, c DE
12fb0 46 41 55 4c 54 20 30 29 20 57 49 54 48 4f 55 54  FAULT 0) WITHOUT
12fc0 20 52 4f 57 49 44 3b 0a 20 20 43 52 45 41 54 45   ROWID;.  CREATE
12fd0 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f   TRIGGER r1 BEFO
12fe0 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  RE INSERT ON t1 
12ff0 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
13000 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
13010 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
13020 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27  ('before-insert'
13030 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
13040 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
13050 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
13060 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
13070 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r2 AFTER INSERT 
13080 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
13090 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
130a0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
130b0 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e  VALUES('after-in
130c0 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64  sert',printf('%d
130d0 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65  ,%d,%d',new.a,ne
130e0 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
130f0 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
13100 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20 55  GGER r3 BEFORE U
13110 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
13120 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
13130 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
13140 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
13150 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69  fore-update',pri
13160 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
13170 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
13180 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
13190 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
131a0 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
131b0 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
131c0 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
131d0 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34  REATE TRIGGER r4
131e0 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e   AFTER UPDATE ON
131f0 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
13200 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
13210 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
13220 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61  LUES('after-upda
13230 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
13240 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
13250 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
13260 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
13270 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
13280 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
13290 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 2f 2a  w.b,new.c));. /*
132a0 20 2a 2f 0a 20 20 49 4e 53 45 52 54 20 49 4e 54   */.  INSERT INT
132b0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
132c0 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20  (1,2);.  DELETE 
132d0 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
132e0 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
132f0 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
13300 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
13310 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
13320 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 44 45 4c 45  c=t1.c+1;.  DELE
13330 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
13340 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
13350 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
13360 29 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 20 44 4f  ) ON CONFLICT DO
13370 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45 4c 45   NOTHING;.  SELE
13380 43 54 20 2a 57 48 45 52 45 20 72 65 63 6f 72 64  CT *WHERE record
13390 3b 45 4e 44 2a 88 19 2d 04 00 90 37 20 20 43 52  ;END*..-...7  CR
133a0 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20  EATE TABLE t1(a 
133b0 49 4e 54 20 50 52 49 4d 41 52 59 20 4b 45 59 2c  INT PRIMARY KEY,
133c0 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c   b int, c DEFAUL
133d0 54 20 30 29 20 57 49 54 48 4f 55 54 20 52 4f 57  T 0) WITHOUT ROW
133e0 49 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ID;.  CREATE TRI
133f0 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49  GGER r1 BEFORE I
13400 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
13410 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
13420 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
13430 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
13440 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69  fore-insert',pri
13450 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
13460 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
13470 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
13480 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
13490 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74  FTER INSERT ON t
134a0 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
134b0 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
134c0 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
134d0 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74  ES('after-insert
134e0 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
134f0 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
13500 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
13510 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
13520 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54   r3 BEFORE UPDAT
13530 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
13540 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
13550 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
13560 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
13570 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
13580 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
13590 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
135a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
135b0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
135c0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
135d0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
135e0 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
135f0 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
13600 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
13610 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
13620 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
13630 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
13640 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
13650 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
13660 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
13670 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
13680 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
13690 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
136a0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
136b0 6e 65 77 2e 63 29 29 3b 0a 20 2f 2a 20 2a 2f 0a  new.c));. /* */.
136c0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
136d0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
136e0 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
136f0 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
13700 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
13710 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
13720 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
13730 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
13740 2e 63 2b 31 3b 0a 20 20 44 45 4c 45 54 45 20 46  .c+1;.  DELETE F
13750 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e  ROM record;.  IN
13760 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
13770 29 20 56 41 4c 55 45 53 28 31 2c 32 29 20 4f 4e  ) VALUES(1,2) ON
13780 20 43 4f 4e 46 4c 49 43 54 20 44 4f 20 4e 4f 54   CONFLICT DO NOT
13790 48 49 4e 47 3b 0a 20 20 53 45 4c 45 43 54 20 2a  HING;.  SELECT *
137a0 20 46 52 4f 4d 20 72 65 63 6f 0a 64 3b 45 4e 44   FROM reco.d;END
137b0 0a 88 28 2c 04 00 90 55 20 20 43 52 45 41 54 45  ..(,...U  CREATE
137c0 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 20   TABLE t1(a INT 
137d0 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
137e0 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29  nt, c DEFAULT 0)
137f0 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a   WITHOUT ROWID;.
13800 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
13810 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52   r1 BEFORE INSER
13820 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
13830 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
13840 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
13850 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
13860 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
13870 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
13880 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
13890 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
138a0 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
138b0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
138c0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
138d0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
138e0 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
138f0 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
13900 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c  intf('%d,%d,%d',
13910 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
13920 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
13930 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
13940 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e  BEFORE UPDATE ON
13950 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
13960 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
13970 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
13980 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64  LUES('before-upd
13990 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
139a0 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
139b0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
139c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
139d0 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
139e0 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
139f0 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
13a00 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
13a10 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55  IGGER r4 AFTER U
13a20 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
13a30 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
13a40 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
13a50 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
13a60 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ter-update',prin
13a70 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
13a80 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
13a90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
13aa0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
13ab0 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
13ac0 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
13ad0 63 29 29 3b 0a 20 2f 2a 20 2a 2f 0a 20 20 49 4e  c));. /* */.  IN
13ae0 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
13af0 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20  ) VALUES(1,2);. 
13b00 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
13b10 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
13b20 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
13b30 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
13b40 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
13b50 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31  ATE SET c=t1.c+1
13b60 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
13b70 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
13b80 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
13b90 4c 55 45 53 28 31 2c 32 29 20 4f 4e 20 43 4f 4e  LUES(1,2) ON CON
13ba0 46 4c 49 43 54 20 44 4f 20 4e 4f 54 48 49 4e 47  FLICT DO NOTHING
13bb0 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
13bc0 4d 20 72 61 6e 64 6f 6d 28 29 48 41 56 49 4e 47  M random()HAVING
13bd0 20 72 65 63 6f 72 64 3b 45 4e 44 0a 88 21 2b 04   record;END..!+.
13be0 00 90 47 20 20 43 52 45 41 54 45 20 54 41 42 4c  ..G  CREATE TABL
13bf0 45 20 74 31 28 61 20 49 4e 54 20 50 52 49 4d 41  E t1(a INT PRIMA
13c00 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63  RY KEY, b int, c
13c10 20 44 45 46 41 55 4c 54 20 30 29 20 57 49 54 48   DEFAULT 0) WITH
13c20 4f 55 54 20 52 4f 57 49 44 3b 0a 20 20 43 52 45  OUT ROWID;.  CRE
13c30 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20 42  ATE TRIGGER r1 B
13c40 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20  EFORE INSERT ON 
13c50 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
13c60 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
13c70 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
13c80 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65  UES('before-inse
13c90 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  rt',printf('%d,%
13ca0 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e  d,%d',new.a,new.
13cb0 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
13cc0 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
13cd0 45 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45  ER r2 AFTER INSE
13ce0 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  RT ON t1 BEGIN. 
13cf0 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
13d00 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
13d10 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
13d20 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
13d30 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
13d40 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
13d50 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
13d60 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52  TRIGGER r3 BEFOR
13d70 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  E UPDATE ON t1 B
13d80 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
13d90 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
13da0 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
13db0 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c  'before-update',
13dc0 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
13dd0 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
13de0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
13df0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
13e00 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
13e10 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
13e20 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
13e30 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
13e40 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45   r4 AFTER UPDATE
13e50 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
13e60 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
13e70 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
13e80 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75   VALUES('after-u
13e90 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
13ea0 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
13eb0 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
13ec0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
13ed0 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
13ee0 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
13ef0 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
13f00 20 2f 2a 20 2a 2f 0a 20 20 49 4e 53 45 52 54 20   /* */.  INSERT 
13f10 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
13f20 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45  UES(1,2);.  DELE
13f30 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
13f40 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
13f50 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
13f60 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
13f70 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
13f80 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 44  ET c=t1.c+1;.  D
13f90 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
13fa0 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
13fb0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
13fc0 31 2c 32 29 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  1,2) ON CONFLICT
13fd0 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53   DO NOTHING;.  S
13fe0 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 20 22  ELECT * FROM r "
13ff0 61 22 2c 22 62 22 65 63 6f 72 64 3b 45 4e 44 0a  a","b"ecord;END.
14000 0d 00 00 00 0f 00 cd 00 1b e4 17 cb 13 b2 0f 99  ................
14010 0b 77 0a d0 09 b9 08 9f 07 85 06 6e 05 57 04 2e  .w.........n.W..
14020 03 09 01 e4 00 cd 00 00 00 00 00 00 00 00 00 00  ................
14030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
14040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
14050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
14060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
14070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
14080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
14090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
140a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
140b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
140c0 00 00 00 00 00 00 00 00 00 00 00 00 00 82 14 40  ...............@
140d0 04 00 84 2d 20 20 43 52 45 41 54 45 20 54 41 42  ...-  CREATE TAB
140e0 4c 45 20 74 31 28 61 20 49 4e 54 20 50 52 49 4d  LE t1(a INT PRIM
140f0 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20  ARY KEY, b int, 
14100 63 20 44 45 46 41 55 4c 54 20 30 29 20 57 49 54  c DEFAULT 0) WIT
14110 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20 20 49 4e  HOUT ROWID;.  IN
14120 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
14130 29 20 56 41 4c 55 45 53 28 31 2c 32 29 2c 28 33  ) VALUES(1,2),(3
14140 2c 34 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ,4);.  INSERT IN
14150 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
14160 53 28 31 2c 38 29 2c 28 32 2c 31 31 29 2c 28 33  S(1,8),(2,11),(3
14170 2c 31 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,1).    ON CONFL
14180 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
14190 20 53 45 54 20 62 3d 65 78 63 6c 75 64 65 64 2e   SET b=excluded.
141a0 62 2c 20 63 3d 63 2b 20 61 66 66 69 6e 69 74 79  b, c=c+ affinity
141b0 28 41 29 3c 65 78 63 6c 75 64 65 64 2e 62 3b 0a  (A)<excluded.b;.
141c0 20 20 53 45 4c 45 43 54 20 2a 2c 20 27 78 27 20    SELECT *, 'x' 
141d0 46 52 4f 4d 20 74 31 20 4f 52 44 45 52 20 42 59  FROM t1 ORDER BY
141e0 20 61 3b 0a 82 22 3f 04 00 84 49 20 20 43 52 45   a;.."?...I  CRE
141f0 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49  ATE TABLE t1(a I
14200 4e 54 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  NT PRIMARY KEY, 
14210 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
14220 20 30 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49   0) WITHOUT ROWI
14230 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  D;.  INSERT INTO
14240 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
14250 31 2c 32 29 2c 28 33 2c 34 29 3b 0a 20 20 49 4e  1,2),(3,4);.  IN
14260 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
14270 29 20 56 41 4c 55 45 53 28 31 2c 38 29 2c 28 32  ) VALUES(1,8),(2
14280 2c 31 31 29 2c 28 33 2c 31 29 0a 20 20 20 20 4f  ,11),(3,1).    O
14290 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
142a0 20 55 50 44 41 54 45 20 53 45 54 20 62 3d 65 78   UPDATE SET b=ex
142b0 63 6c 75 64 65 64 2e 62 20 7c 20 72 61 6e 64 6f  cluded.b | rando
142c0 6d 62 6c 6f 62 28 31 29 7c 4e 4f 54 20 6e 75 6c  mblob(1)|NOT nul
142d0 6c 69 66 28 31 2c 31 29 3c 65 78 63 6c 75 64 65  lif(1,1)<exclude
142e0 64 2e 62 3b 0a 20 20 53 45 4c 45 43 54 20 2a 2c  d.b;.  SELECT *,
142f0 20 27 78 27 20 46 52 4f 4d 20 74 31 20 4f 52 44   'x' FROM t1 ORD
14300 45 52 20 42 59 20 61 3b 0a 82 22 3e 04 00 84 49  ER BY a;..">...I
14310 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
14320 31 28 61 20 49 4e 54 20 50 52 49 4d 41 52 59 20  1(a INT PRIMARY 
14330 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45  KEY, b int, c DE
14340 46 41 55 4c 54 20 30 29 20 57 49 54 48 4f 55 54  FAULT 0) WITHOUT
14350 20 52 4f 57 49 44 3b 0a 20 20 49 4e 53 45 52 54   ROWID;.  INSERT
14360 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
14370 4c 55 45 53 28 31 2c 32 29 2c 28 33 2c 34 29 3b  LUES(1,2),(3,4);
14380 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
14390 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
143a0 38 29 2c 28 32 2c 31 31 29 2c 28 33 2c 31 29 0a  8),(2,11),(3,1).
143b0 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
143c0 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
143d0 20 62 3d 65 78 63 6c 75 64 65 64 2e 62 20 7c 20   b=excluded.b | 
143e0 72 61 6e 64 6f 6d 62 6c 6f 62 28 31 29 7c 20 63  randomblob(1)| c
143f0 2b 20 6e 75 6c 6c 69 66 28 31 2c 31 29 3c 65 78  + nullif(1,1)<ex
14400 63 6c 75 64 65 64 2e 62 3b 0a 20 20 53 45 4c 45  cluded.b;.  SELE
14410 43 54 20 2a 2c 20 27 78 27 20 46 52 4f 4d 20 74  CT *, 'x' FROM t
14420 31 20 4f 52 44 45 52 20 42 59 20 61 3b 0a 82 26  1 ORDER BY a;..&
14430 3d 04 00 84 51 20 20 43 52 45 41 54 45 20 54 41  =...Q  CREATE TA
14440 42 4c 45 20 74 31 28 61 20 49 4e 54 20 50 52 49  BLE t1(a INT PRI
14450 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c  MARY KEY, b int,
14460 20 63 20 44 45 46 41 55 4c 54 20 30 29 20 57 49   c DEFAULT 0) WI
14470 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20 20 49  THOUT ROWID;.  I
14480 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
14490 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 2c 28  b) VALUES(1,2),(
144a0 33 2c 34 29 3b 0a 20 20 49 4e 53 45 52 54 20 49  3,4);.  INSERT I
144b0 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
144c0 45 53 28 31 2c 38 29 2c 28 32 2c 31 31 29 2c 28  ES(1,8),(2,11),(
144d0 33 2c 31 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46  3,1).    ON CONF
144e0 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54  LICT(a) DO UPDAT
144f0 45 20 53 45 54 20 62 3d 65 78 63 6c 75 64 65 64  E SET b=excluded
14500 2e 62 20 7c 20 72 61 6e 64 6f 6d 62 6c 6f 62 28  .b | randomblob(
14510 31 29 7c 20 63 20 7c 7c 20 2b 20 6e 75 6c 6c 69  1)| c || + nulli
14520 66 28 31 2c 31 29 3c 65 78 63 6c 75 64 65 64 2e  f(1,1)<excluded.
14530 62 3b 0a 20 20 53 45 4c 45 43 54 20 2a 2c 20 27  b;.  SELECT *, '
14540 78 27 20 46 52 4f 4d 20 74 31 20 4f 52 44 45 52  x' FROM t1 ORDER
14550 20 42 59 20 61 3b 0a 82 14 3c 04 00 84 2d 20 20   BY a;...<...-  
14560 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
14570 61 20 49 4e 54 20 50 52 49 4d 41 52 59 20 4b 45  a INT PRIMARY KE
14580 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41  Y, b int, c DEFA
14590 55 4c 54 20 30 29 20 57 49 54 48 4f 55 54 20 52  ULT 0) WITHOUT R
145a0 4f 57 49 44 3b 0a 20 20 49 4e 53 45 52 54 20 49  OWID;.  INSERT I
145b0 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
145c0 45 53 28 31 2c 32 29 2c 28 33 2c 34 29 3b 0a 20  ES(1,2),(3,4);. 
145d0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
145e0 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 38 29  a,b) VALUES(1,8)
145f0 2c 28 32 2c 31 31 29 2c 28 33 2c 31 29 0a 20 20  ,(2,11),(3,1).  
14600 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
14610 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 62   DO UPDATE SET b
14620 3d 65 78 63 6c 75 64 65 64 2e 62 20 47 4c 4f 42  =excluded.b GLOB
14630 2b 20 6e 75 6c 6c 69 66 28 31 2c 31 29 3c 65 78  + nullif(1,1)<ex
14640 63 6c 75 64 65 64 2e 62 3b 0a 20 20 53 45 4c 45  cluded.b;.  SELE
14650 43 54 20 2a 2c 20 27 78 27 20 46 52 4f 4d 20 74  CT *, 'x' FROM t
14660 31 20 4f 52 44 45 52 20 42 59 20 61 3b 0a 82 14  1 ORDER BY a;...
14670 3b 04 00 84 2d 20 20 43 52 45 41 54 45 20 54 41  ;...-  CREATE TA
14680 42 4c 45 20 74 31 28 61 20 49 4e 54 20 50 52 49  BLE t1(a INT PRI
14690 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c  MARY KEY, b int,
146a0 20 63 20 44 45 46 41 55 4c 54 20 30 29 20 57 49   c DEFAULT 0) WI
146b0 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20 20 49  THOUT ROWID;.  I
146c0 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
146d0 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 2c 28  b) VALUES(1,2),(
146e0 33 2c 34 29 3b 0a 20 20 49 4e 53 45 52 54 20 49  3,4);.  INSERT I
146f0 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
14700 45 53 28 31 2c 38 29 2c 28 32 2c 31 31 29 2c 28  ES(1,8),(2,11),(
14710 33 2c 31 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46  3,1).    ON CONF
14720 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54  LICT(a) DO UPDAT
14730 45 20 53 45 54 20 61 3d 65 78 63 6c 75 64 65 64  E SET a=excluded
14740 2e 62 2c 20 63 3d 63 2b 20 6e 75 6c 6c 69 66 28  .b, c=c+ nullif(
14750 31 2c 31 29 3c 65 78 63 6c 75 64 65 64 2e 62 3b  1,1)<excluded.b;
14760 0a 20 20 53 45 4c 45 43 54 20 2a 2c 20 27 78 27  .  SELECT *, 'x'
14770 20 46 52 4f 4d 20 74 31 20 4f 52 44 45 52 20 42   FROM t1 ORDER B
14780 59 20 61 3b 0a 82 17 3a 04 00 84 33 20 20 43 52  Y a;...:...3  CR
14790 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20  EATE TABLE t1(a 
147a0 49 4e 54 20 50 52 49 4d 41 52 59 20 4b 45 59 2c  INT PRIMARY KEY,
147b0 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c   b int, c DEFAUL
147c0 54 20 30 29 20 57 49 54 48 4f 55 54 20 52 4f 57  T 0) WITHOUT ROW
147d0 49 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ID;.  INSERT INT
147e0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
147f0 28 31 2c 32 29 2c 28 33 2c 34 29 3b 0a 20 20 49  (1,2),(3,4);.  I
14800 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
14810 62 29 20 56 41 4c 55 45 53 28 31 2c 38 29 2c 28  b) VALUES(1,8),(
14820 32 20 2d 31 2c 31 31 29 2c 28 33 2c 31 29 0a 20  2 -1,11),(3,1). 
14830 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
14840 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
14850 62 3d 65 78 63 6c 75 64 65 64 2e 62 2c 20 63 3d  b=excluded.b, c=
14860 63 2b 24 6e 75 6c 6c 69 66 28 31 2c 31 29 3c 65  c+$nullif(1,1)<e
14870 78 63 6c 75 64 65 64 2e 62 3b 0a 20 20 53 45 4c  xcluded.b;.  SEL
14880 45 43 54 20 2a 2c 20 27 78 27 20 46 52 4f 4d 20  ECT *, 'x' FROM 
14890 74 31 20 4f 52 44 45 52 20 42 59 20 61 3b 0a 82  t1 ORDER BY a;..
148a0 17 39 04 00 84 33 20 20 43 52 45 41 54 45 20 54  .9...3  CREATE T
148b0 41 42 4c 45 20 74 31 28 61 20 49 4e 54 20 50 52  ABLE t1(a INT PR
148c0 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74  IMARY KEY, b int
148d0 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 20 57  , c DEFAULT 0) W
148e0 49 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20 20  ITHOUT ROWID;.  
148f0 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
14900 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 2c  ,b) VALUES(1,2),
14910 28 33 2c 34 29 3b 0a 20 20 49 4e 53 45 52 54 20  (3,4);.  INSERT 
14920 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
14930 55 45 53 28 31 2c 38 29 2c 28 32 20 2d 31 2c 31  UES(1,8),(2 -1,1
14940 31 29 2c 28 33 2c 31 29 0a 20 20 20 20 4f 4e 20  1),(3,1).    ON 
14950 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
14960 50 44 41 54 45 20 53 45 54 20 62 3d 65 78 63 6c  PDATE SET b=excl
14970 75 64 65 64 2e 62 2c 20 63 3d 61 2b 20 6e 75 6c  uded.b, c=a+ nul
14980 6c 69 66 28 31 2c 31 29 3c 65 78 63 6c 75 64 65  lif(1,1)<exclude
14990 64 2e 62 3b 0a 20 20 53 45 4c 45 43 54 20 2a 2c  d.b;.  SELECT *,
149a0 20 27 78 27 20 46 52 4f 4d 20 74 31 20 4f 52 44   'x' FROM t1 ORD
149b0 45 52 20 42 59 20 61 3b 0a 82 14 38 04 00 84 2d  ER BY a;...8...-
149c0 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
149d0 31 28 61 20 49 4e 54 20 50 52 49 4d 41 52 59 20  1(a INT PRIMARY 
149e0 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45  KEY, b int, c DE
149f0 46 41 55 4c 54 20 30 29 20 57 49 54 48 4f 55 54  FAULT 0) WITHOUT
14a00 20 52 4f 57 49 44 3b 0a 20 20 49 4e 53 45 52 54   ROWID;.  INSERT
14a10 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
14a20 4c 55 45 53 28 31 2c 32 29 2c 28 33 2c 34 29 3b  LUES(1,2),(3,4);
14a30 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
14a40 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
14a50 32 29 2c 28 32 2c 31 31 29 2c 28 33 2c 31 29 0a  2),(2,11),(3,1).
14a60 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
14a70 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
14a80 20 61 3d 65 78 63 6c 75 64 65 64 2e 62 2c 20 63   a=excluded.b, c
14a90 3d 63 2b 20 6e 75 6c 6c 69 66 28 31 2c 31 29 3c  =c+ nullif(1,1)<
14aa0 65 78 63 6c 75 64 65 64 2e 62 3b 0a 20 20 53 45  excluded.b;.  SE
14ab0 4c 45 43 54 20 2a 2c 20 27 78 27 20 46 52 4f 4d  LECT *, 'x' FROM
14ac0 20 74 31 20 4f 52 44 45 52 20 42 59 20 61 3b 0a   t1 ORDER BY a;.
14ad0 81 24 37 04 00 82 4d 20 20 43 52 45 41 54 45 20  .$7...M  CREATE 
14ae0 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 20 50  TABLE t1(a INT P
14af0 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
14b00 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 20  t, c DEFAULT 0) 
14b10 57 49 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20  WITHOUT ROWID;. 
14b20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
14b30 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
14b40 2c 28 33 2c 34 29 3b 0a 20 20 49 4e 53 45 52 54  ,(3,4);.  INSERT
14b50 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 53 45   INTO t1(a,b) SE
14b60 4c 45 43 54 28 31 2c 38 29 2c 28 32 2c 31 31 29  LECT(1,8),(2,11)
14b70 2c 20 2a 2c 31 29 0a 88 1f 36 04 00 90 43 20 20  , *,1)...6...C  
14b80 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
14b90 61 20 49 4e 54 20 50 52 49 4d 41 52 59 20 4b 45  a INT PRIMARY KE
14ba0 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41  Y, b int, c DEFA
14bb0 55 4c 54 20 30 29 20 57 49 54 48 4f 55 54 20 52  ULT 0) WITHOUT R
14bc0 4f 57 49 44 3b 0a 20 20 43 52 45 41 54 45 20 54  OWID;.  CREATE T
14bd0 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45  RIGGER r1 BEFORE
14be0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
14bf0 47 49 4e 0a 20 20 57 49 54 48 20 63 28 78 29 20  GIN.  WITH c(x) 
14c00 41 53 20 28 76 61 6c 75 65 73 28 31 29 55 4e 49  AS (values(1)UNI
14c10 4f 4e 20 41 4c 4c 20 20 56 41 4c 55 45 53 28 27  ON ALL  VALUES('
14c20 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70  before-insert',p
14c30 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27  rintf('%d,%d,%d'
14c40 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
14c50 2e 63 29 29 55 4e 49 4f 4e 20 41 4c 4c 3b 0a 20  .c))UNION ALL;. 
14c60 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
14c70 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20  RIGGER r2 AFTER 
14c80 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
14c90 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
14ca0 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
14cb0 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61         VALUES('a
14cc0 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69  fter-insert',pri
14cd0 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
14ce0 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
14cf0 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
14d00 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42  ATE TRIGGER r3 B
14d10 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20  EFORE UPDATE ON 
14d20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
14d30 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
14d40 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
14d50 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61  UES('before-upda
14d60 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
14d70 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
14d80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
14d90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
14da0 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
14db0 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
14dc0 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
14dd0 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
14de0 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50  GGER r4 AFTER UP
14df0 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e  DATE ON t1 BEGIN
14e00 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
14e10 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
14e20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74       VALUES('aft
14e30 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74  er-update',print
14e40 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25  f('%d,%d,%d/%d,%
14e50 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20  d,%d',.         
14e60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
14e70 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64               old
14e80 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e  .a,old.b,old.c,n
14e90 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
14ea0 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53  ));.  END;.  INS
14eb0 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
14ec0 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20   VALUES(1,2);.  
14ed0 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
14ee0 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
14ef0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
14f00 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
14f10 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
14f20 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b  TE SET c=t1.c+1;
14f30 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
14f40 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
14f50 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
14f60 55 45 53 28 31 2c 32 29 20 4f 4e 20 43 4f 4e 46  UES(1,2) ON CONF
14f70 4c 49 43 54 20 44 4f 20 4e 4f 54 48 49 4e 47 3b  LICT DO NOTHING;
14f80 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
14f90 20 72 65 63 6f 72 64 3b 0a 88 16 35 04 00 90 31   record;...5...1
14fa0 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
14fb0 31 28 61 20 49 4e 54 20 50 52 49 4d 41 52 59 20  1(a INT PRIMARY 
14fc0 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45  KEY, b int, c DE
14fd0 46 41 55 4c 54 20 30 29 20 57 49 54 48 4f 55 54  FAULT 0) WITHOUT
14fe0 20 52 4f 57 49 44 3b 0a 20 20 43 52 45 41 54 45   ROWID;.  CREATE
14ff0 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f   TRIGGER r1 BEFO
15000 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  RE INSERT ON t1 
15010 42 45 47 49 4e 0a 20 20 57 49 54 48 20 63 28 78  BEGIN.  WITH c(x
15020 29 20 41 53 20 28 76 61 6c 75 65 73 28 31 29 55  ) AS (values(1)U
15030 4e 49 4f 4e 20 41 4c 4c 20 20 56 41 4c 55 45 53  NION ALL  VALUES
15040 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27  ('before-insert'
15050 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
15060 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
15070 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
15080 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
15090 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r2 AFTER INSERT 
150a0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
150b0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
150c0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
150d0 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e  VALUES('after-in
150e0 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64  sert',printf('%d
150f0 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65  ,%d,%d',new.a,ne
15100 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
15110 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
15120 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20 55  GGER r3 BEFORE U
15130 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
15140 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
15150 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
15160 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
15170 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69  fore-update',pri
15180 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
15190 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
151a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
151b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
151c0 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
151d0 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
151e0 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
151f0 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34  REATE TRIGGER r4
15200 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e   AFTER UPDATE ON
15210 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
15220 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
15230 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
15240 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61  LUES('after-upda
15250 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
15260 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
15270 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
15280 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
15290 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
152a0 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
152b0 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
152c0 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ND;.  INSERT INT
152d0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
152e0 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20  (1,2);.  DELETE 
152f0 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
15300 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
15310 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
15320 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
15330 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
15340 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 44 45 4c 45  c=t1.c+1;.  DELE
15350 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
15360 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
15370 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
15380 29 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 20 44 4f  ) ON CONFLICT DO
15390 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45 4c 45   NOTHING;.  SELE
153a0 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64  CT * FROM record
153b0 3b 0a 88 16 34 04 00 90 31 20 20 43 52 45 41 54  ;...4...1  CREAT
153c0 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54  E TABLE t1(a INT
153d0 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20   PRIMARY KEY, b 
153e0 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30  int, c DEFAULT 0
153f0 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 3b  ) WITHOUT ROWID;
15400 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
15410 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45  R r1 BEFORE INSE
15420 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  RT ON t1 BEGIN. 
15430 20 57 49 54 48 20 63 28 78 29 20 41 53 20 28 76   WITH c(x) AS (v
15440 61 6c 75 65 73 28 31 29 29 20 0a 20 20 20 20 20  alues(1)) .     
15450 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
15460 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  e-insert',printf
15470 28 27 25 64 2c 25 64 2c 25 64 27 2c 20 69 6e 73  ('%d,%d,%d', ins
15480 74 72 28 31 2c 31 29 2c 6e 65 77 2e 63 29 29 3b  tr(1,1),new.c));
15490 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
154a0 20 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45   TRIGGER r2 AFTE
154b0 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  R INSERT ON t1 B
154c0 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
154d0 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
154e0 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
154f0 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70  'after-insert',p
15500 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27  rintf('%d,%d,%d'
15510 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
15520 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
15530 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33  REATE TRIGGER r3
15540 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f   BEFORE UPDATE O
15550 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
15560 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
15570 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
15580 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70  ALUES('before-up
15590 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
155a0 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
155b0 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
155c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
155d0 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
155e0 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
155f0 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
15600 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
15610 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20  RIGGER r4 AFTER 
15620 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
15630 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
15640 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
15650 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61         VALUES('a
15660 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69  fter-update',pri
15670 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
15680 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
15690 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
156a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
156b0 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
156c0 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
156d0 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49  .c));.  END;.  I
156e0 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
156f0 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a  b) VALUES(1,2);.
15700 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
15710 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
15720 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
15730 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43  ES(1,2).    ON C
15740 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50  ONFLICT(a) DO UP
15750 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b  DATE SET c=t1.c+
15760 31 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  1;.  DELETE FROM
15770 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
15780 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
15790 41 4c 55 45 53 28 31 2c 32 29 20 4f 4e 20 43 4f  ALUES(1,2) ON CO
157a0 4e 46 4c 49 43 54 20 44 4f 20 4e 4f 54 48 49 4e  NFLICT DO NOTHIN
157b0 47 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52  G;.  SELECT * FR
157c0 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 16 33 04 00  OM record;...3..
157d0 90 31 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  .1  CREATE TABLE
157e0 20 74 31 28 61 20 49 4e 54 20 50 52 49 4d 41 52   t1(a INT PRIMAR
157f0 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20  Y KEY, b int, c 
15800 44 45 46 41 55 4c 54 20 30 29 20 57 49 54 48 4f  DEFAULT 0) WITHO
15810 55 54 20 52 4f 57 49 44 3b 0a 20 20 43 52 45 41  UT ROWID;.  CREA
15820 54 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45  TE TRIGGER r1 BE
15830 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74  FORE INSERT ON t
15840 31 20 42 45 47 49 4e 0a 20 20 57 49 54 48 20 63  1 BEGIN.  WITH c
15850 28 78 29 20 41 53 20 28 76 61 6c 75 65 73 28 31  (x) AS (values(1
15860 29 29 20 0a 20 20 20 20 20 20 20 20 56 41 4c 55  )) .        VALU
15870 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72  ES('before-inser
15880 74 27 2c 70 72 69 6e 74 66 28 20 73 71 6c 69 74  t',printf( sqlit
15890 65 5f 63 6f 6d 70 69 6c 65 6f 70 74 69 6f 6e 5f  e_compileoption_
158a0 67 65 74 28 31 29 29 29 3b 0a 20 20 45 4e 44 3b  get(1)));.  END;
158b0 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
158c0 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52  R r2 AFTER INSER
158d0 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
158e0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
158f0 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
15900 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
15910 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
15920 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c  %d,%d,%d',new.a,
15930 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
15940 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
15950 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45  RIGGER r3 BEFORE
15960 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
15970 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
15980 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
15990 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
159a0 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70  before-update',p
159b0 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
159c0 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
159d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
159e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
159f0 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
15a00 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
15a10 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
15a20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
15a30 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20  r4 AFTER UPDATE 
15a40 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
15a50 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
15a60 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
15a70 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70  VALUES('after-up
15a80 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
15a90 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
15aa0 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
15ab0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
15ac0 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
15ad0 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
15ae0 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
15af0 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49   END;.  INSERT I
15b00 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
15b10 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54  ES(1,2);.  DELET
15b20 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
15b30 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
15b40 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
15b50 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
15b60 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
15b70 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 44 45  T c=t1.c+1;.  DE
15b80 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
15b90 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
15ba0 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
15bb0 2c 32 29 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 20  ,2) ON CONFLICT 
15bc0 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
15bd0 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
15be0 72 64 3b 0a 88 19 32 04 00 90 37 20 20 43 52 45  rd;...2...7  CRE
15bf0 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49  ATE TABLE t1(a I
15c00 4e 54 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  NT PRIMARY KEY, 
15c10 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
15c20 20 30 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49   0) WITHOUT ROWI
15c30 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
15c40 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e  GER r1 BEFORE IN
15c50 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
15c60 0a 20 20 20 20 57 49 54 48 20 63 28 78 29 20 41  .    WITH c(x) A
15c70 53 20 28 76 61 6c 75 65 73 28 31 29 29 20 20 20  S (values(1))   
15c80 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
15c90 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ore-insert',prin
15ca0 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65  tf('%d,%d,%d',ne
15cb0 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
15cc0 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
15cd0 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46  TE TRIGGER r2 AF
15ce0 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  TER INSERT ON t1
15cf0 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
15d00 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
15d10 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
15d20 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27  S('after-insert'
15d30 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
15d40 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
15d50 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
15d60 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
15d70 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45  r3 BEFORE UPDATE
15d80 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
15d90 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
15da0 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
15db0 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
15dc0 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
15dd0 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
15de0 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
15df0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
15e00 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
15e10 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
15e20 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
15e30 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
15e40 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45   TRIGGER r4 AFTE
15e50 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  R UPDATE ON t1 B
15e60 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
15e70 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
15e80 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
15e90 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70  'after-update',p
15ea0 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
15eb0 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
15ec0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
15ed0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
15ee0 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
15ef0 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
15f00 65 77 2e 63 29 29 3b 0a 20 2f 2a 20 2a 2f 0a 20  ew.c));. /* */. 
15f10 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
15f20 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
15f30 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
15f40 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
15f50 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
15f60 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e  LUES(1,2).    ON
15f70 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
15f80 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e  UPDATE SET c=t1.
15f90 63 2b 31 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  c+1;.  DELETE FR
15fa0 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
15fb0 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
15fc0 20 56 41 4c 55 45 53 28 31 2c 32 29 20 4f 4e 20   VALUES(1,2) ON 
15fd0 43 4f 4e 46 4c 49 43 54 20 44 4f 20 4e 4f 54 48  CONFLICT DO NOTH
15fe0 49 4e 47 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20  ING;.  SELECT * 
15ff0 46 52 4f 4d 20 72 65 63 6f 72 64 3b 45 4e 44 0a  FROM record;END.
16000 0d 00 00 00 1d 01 00 00 1e e9 1d d2 1c b3 1b 95  ................
16010 1a 7e 19 67 18 44 17 2d 16 0f 14 f8 13 cf 12 b0  .~.g.D.-........
16020 11 99 10 74 0f 5d 0e 46 0d 28 0c 11 0a fa 09 f7  ...t.].F.(......
16030 09 6b 08 67 07 63 06 4b 05 33 04 2b 03 19 02 0e  .k.g.c.K.3.+....
16040 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
16050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
16060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
16070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
16080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
16090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
160a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
160b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
160c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
160d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
160e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
160f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
16100 82 0b 5d 04 00 84 1b 20 20 43 52 45 41 54 45 20  ..]....  CREATE 
16110 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47  TABLE t1(a INTEG
16120 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  ER PRIMARY KEY, 
16130 62 20 49 4e 54 2c 20 63 20 44 45 46 41 55 4c 54  b INT, c DEFAULT
16140 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 55 4e   0);.  CREATE UN
16150 49 51 55 45 20 49 4e 44 45 58 20 74 31 78 31 20  IQUE INDEX t1x1 
16160 4f 4e 20 74 31 28 61 2b 62 29 3b 0a 20 20 49 4e  ON t1(a+b);.  IN
16170 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
16180 29 20 56 41 4c 55 45 53 28 37 2c 38 29 20 4f 4e  ) VALUES(7,8) ON
16190 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20 44   CONFLICT(a+b) D
161a0 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 49 4e 53  O NOTHING;.  INS
161b0 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
161c0 20 56 41 4c 55 45 53 28 38 2c 37 29 2c 28 39 2c   VALUES(8,7),(9,
161d0 36 29 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61  6) ON CONFLICT(a
161e0 2b 62 29 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a  +b) DO NOTHING;.
161f0 20 20 53 45 4c 45 43 54 20 32 30 30 31 2d 30 31    SELECT 2001-01
16200 2d 30 31 32 20 46 52 4f 4d 20 74 31 3b 0a 82 08  -012 FROM t1;...
16210 5c 04 00 84 15 20 20 43 52 45 41 54 45 20 54 41  \....  CREATE TA
16220 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52  BLE t1(a INTEGER
16230 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20   PRIMARY KEY, b 
16240 49 4e 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30  INT, c DEFAULT 0
16250 29 3b 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51  );.  CREATE UNIQ
16260 55 45 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e  UE INDEX t1x1 ON
16270 20 74 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45   t1(a+b);.  INSE
16280 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
16290 56 41 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43  VALUES(7,8) ON C
162a0 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20  ONFLICT(a+b) DO 
162b0 4e 4f 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52  NOTHING;.  INSER
162c0 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
162d0 41 4c 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29  ALUES(8,7),(9,6)
162e0 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62   ON CONFLICT(a+b
162f0 29 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20  ) DO NOTHING;.  
16300 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 74 31  SELECT * FROM t1
16310 3b 52 45 49 4e 44 45 58 0a 82 0f 5b 04 00 84 23  ;REINDEX...[...#
16320 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
16330 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d  1(a INTEGER PRIM
16340 41 52 59 20 4b 45 59 2c 20 62 20 49 4e 54 2c 20  ARY KEY, b INT, 
16350 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20  c DEFAULT 0);.  
16360 43 52 45 41 54 45 20 55 4e 49 51 55 45 20 49 4e  CREATE UNIQUE IN
16370 44 45 58 20 74 31 78 31 20 4f 4e 20 74 31 28 61  DEX t1x1 ON t1(a
16380 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  +b);.  INSERT IN
16390 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
163a0 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e 46 4c 49  S(7,8) ON CONFLI
163b0 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54 48 49  CT(a+b) DO NOTHI
163c0 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  NG;.  INSERT INT
163d0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
163e0 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f 4e 20 43  (8,7),(9,6) ON C
163f0 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20  ONFLICT(a+b) DO 
16400 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45 4c 45 43  NOTHING;.  SELEC
16410 54 20 20 32 30 30 31 2d 30 31 2d 30 31 31 3d 31  T  2001-01-011=1
16420 32 20 46 52 4f 4d 20 74 31 3b 0a 82 05 5a 04 00  2 FROM t1;...Z..
16430 84 0f 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ..  CREATE TABLE
16440 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
16450 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e 54  IMARY KEY, b INT
16460 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a  , c DEFAULT 0);.
16470 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45 20    CREATE UNIQUE 
16480 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74 31  INDEX t1x1 ON t1
16490 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54 20  (a+b);.  INSERT 
164a0 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
164b0 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e 46  UES(7,8) ON CONF
164c0 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54  LICT(a+b) DO NOT
164d0 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20 49  HING;.  INSERT I
164e0 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
164f0 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f 4e  ES(8,7),(9,6) ON
16500 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20 44   CONFLICT(a+b) D
16510 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45 4c  O NOTHING;.  SEL
16520 45 43 54 20 20 31 3d 31 32 20 46 52 4f 4d 20 74  ECT  1=12 FROM t
16530 31 3b 0a 82 15 59 04 00 84 2f 20 20 43 52 45 41  1;...Y.../  CREA
16540 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
16550 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
16560 59 2c 20 62 20 49 4e 54 2c 20 63 20 44 45 46 41  Y, b INT, c DEFA
16570 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45  ULT 0);.  CREATE
16580 20 55 4e 49 51 55 45 20 49 4e 44 45 58 20 74 31   UNIQUE INDEX t1
16590 78 31 20 4f 4e 20 74 31 28 61 2b 62 29 3b 0a 20  x1 ON t1(a+b);. 
165a0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
165b0 61 2c 62 29 20 56 41 4c 55 45 53 28 32 30 30 31  a,b) VALUES(2001
165c0 32 30 30 31 2d 30 31 2d 30 31 2d 30 31 2d 30 31  2001-01-01-01-01
165d0 37 2c 38 29 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  7,8) ON CONFLICT
165e0 28 61 2b 62 29 20 44 4f 20 4e 4f 54 48 49 4e 47  (a+b) DO NOTHING
165f0 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
16600 74 31 28 63 2c 62 29 20 56 41 4c 55 45 53 28 38  t1(c,b) VALUES(8
16610 2c 37 29 2c 28 39 2c 36 29 20 4f 4e 20 43 4f 4e  ,7),(9,6) ON CON
16620 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
16630 54 48 49 4e 47 3b 0a 20 20 53 45 4c 45 43 54 20  THING;.  SELECT 
16640 2a 20 46 52 4f 4d 20 74 31 3b 0a 82 15 58 04 00  * FROM t1;...X..
16650 84 2f 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ./  CREATE TABLE
16660 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
16670 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e 54  IMARY KEY, b INT
16680 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a  , c DEFAULT 0);.
16690 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45 20    CREATE UNIQUE 
166a0 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74 31  INDEX t1x1 ON t1
166b0 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54 20  (a+b);.  INSERT 
166c0 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
166d0 55 45 53 28 32 30 30 31 2d 30 31 2d 30 31 37 2c  UES(2001-01-017,
166e0 38 29 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61  8) ON CONFLICT(a
166f0 2b 62 29 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a  +b) DO NOTHING;.
16700 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
16710 28 61 2c 62 29 20 56 41 4c 55 45 53 28 38 32 30  (a,b) VALUES(820
16720 30 31 2d 30 31 2d 30 31 2c 37 29 2c 28 39 2c 36  01-01-01,7),(9,6
16730 29 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b  ) ON CONFLICT(a+
16740 62 29 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20  b) DO NOTHING;. 
16750 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 74   SELECT * FROM t
16760 31 3b 0a 82 01 57 04 00 84 07 20 20 43 52 45 41  1;...W....  CREA
16770 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
16780 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
16790 59 2c 20 62 20 49 4e 54 2c 20 63 20 44 45 46 41  Y, b INT, c DEFA
167a0 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45  ULT 0);.  CREATE
167b0 20 55 4e 49 51 55 45 20 49 4e 44 45 58 20 74 31   UNIQUE INDEX t1
167c0 78 31 20 4f 4e 20 74 31 28 20 2b 62 29 3b 0a 20  x1 ON t1( +b);. 
167d0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
167e0 61 2c 62 29 20 56 41 4c 55 45 53 28 37 2c 38 29  a,b) VALUES(7,8)
167f0 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 20 2f 2a 20   ON CONFLICT /* 
16800 2a 2f 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20  */DO NOTHING;.  
16810 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
16820 2c 62 29 20 56 41 4c 55 45 53 28 38 2c 37 29 2c  ,b) VALUES(8,7),
16830 28 39 2c 36 29 20 4f 4e 20 43 4f 4e 46 4c 49 43  (9,6) ON CONFLIC
16840 54 20 2f 2a 20 2a 2f 44 4f 20 4e 4f 54 48 49 4e  T /* */DO NOTHIN
16850 47 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52  G;.  SELECT * FR
16860 4f 4d 20 74 31 3b 0a 82 01 56 04 00 84 07 20 20  OM t1;...V....  
16870 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
16880 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52  a INTEGER PRIMAR
16890 59 20 4b 45 59 2c 20 62 20 49 4e 54 2c 20 63 20  Y KEY, b INT, c 
168a0 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52  DEFAULT 0);.  CR
168b0 45 41 54 45 20 20 2f 2a 20 2a 2f 20 49 4e 44 45  EATE  /* */ INDE
168c0 58 20 74 31 78 31 20 4f 4e 20 74 31 28 61 2b 62  X t1x1 ON t1(a+b
168d0 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  );.  INSERT INTO
168e0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
168f0 37 2c 38 29 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  7,8) ON CONFLICT
16900 20 2f 2a 20 2a 2f 44 4f 20 4e 4f 54 48 49 4e 47   /* */DO NOTHING
16910 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
16920 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 38  t1(a,b) VALUES(8
16930 2c 37 29 2c 28 39 2c 36 29 20 4f 4e 20 43 4f 4e  ,7),(9,6) ON CON
16940 46 4c 49 43 54 20 2f 2a 20 2a 2f 44 4f 20 4e 4f  FLICT /* */DO NO
16950 54 48 49 4e 47 3b 0a 20 20 53 45 4c 45 43 54 20  THING;.  SELECT 
16960 2a 20 46 52 4f 4d 20 74 31 3b 0a 81 09 55 04 00  * FROM t1;...U..
16970 82 17 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ..  CREATE TABLE
16980 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
16990 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e 54  IMARY KEY, b INT
169a0 2c 20 63 20 44 45 46 41 55 4c 54 20 27 61 27 0a  , c DEFAULT 'a'.
169b0 20 20 43 52 45 41 54 45 20 55 45 20 49 4e 4f 20    CREATE UE INO 
169c0 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 38  t1(a,b) VALUES(8
169d0 2c 37 29 2c 28 39 2c 36 29 20 4f 4e 20 43 4f 4e  ,7),(9,6) ON CON
169e0 46 4c 49 43 54 28 61 2b 63 29 20 44 4f 20 4e 4f  FLICT(a+c) DO NO
169f0 54 48 49 4e 47 3b 0a 82 00 54 04 00 84 05 20 20  THING;...T....  
16a00 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
16a10 61 20 49 4e 54 45 47 45 4b 45 59 2c 20 62 20 69  a INTEGEKEY, b i
16a20 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29  nt, c DEFAULT 0)
16a30 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
16a40 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
16a50 2c 32 29 64 28 33 2c 34 29 3b 0a 20 20 49 4e 53  ,2)d(3,4);.  INS
16a60 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
16a70 20 56 41 4c 55 45 53 28 31 2c 38 29 2c 28 32 2c   VALUES(1,8),(2,
16a80 31 31 29 2c 28 33 2c 31 29 0a 20 20 20 20 4f 4e  11),(3,1).    ON
16a90 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
16aa0 55 50 44 41 54 45 20 53 45 54 20 62 3d 65 78 63  UPDATE SET b=exc
16ab0 6c 75 64 65 64 2e 62 2c 20 63 3d 63 2b 31 20 57  luded.b, c=c+1 W
16ac0 48 45 52 45 20 74 31 2e 62 3c 65 78 63 6c 75 64  HERE t1.b<exclud
16ad0 65 64 2e 62 3b 0a 20 20 53 45 4c 45 43 54 20 2a  ed.b;.  SELECT *
16ae0 2c 20 27 78 27 20 46 52 4f 4d 20 74 31 20 4f 52  , 'x' FROM t1 OR
16af0 44 45 52 20 42 59 20 61 3b 0a 82 14 53 04 00 84  DER BY a;...S...
16b00 2d 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  -  CREATE TABLE 
16b10 74 31 28 61 20 49 4e 54 20 50 52 49 4d 41 52 59  t1(a INT PRIMARY
16b20 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44   KEY, b int, c D
16b30 45 46 41 55 4c 54 20 30 29 20 57 49 54 48 4f 55  EFAULT 0) WITHOU
16b40 54 20 52 4f 57 49 44 3b 0a 20 52 45 50 4c 41 43  T ROWID;. REPLAC
16b50 45 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  E INTO t1(a,b) V
16b60 41 4c 55 45 53 28 31 2c 32 29 2c 28 33 2c 34 29  ALUES(1,2),(3,4)
16b70 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
16b80 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
16b90 2c 38 29 2c 28 32 2c 31 31 29 2c 28 33 2c 31 29  ,8),(2,11),(3,1)
16ba0 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
16bb0 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
16bc0 54 20 62 3d 65 78 63 6c 75 64 65 64 2e 62 2c 20  T b=excluded.b, 
16bd0 63 3d 63 2b 31 20 57 48 45 52 45 20 74 31 2e 62  c=c+1 WHERE t1.b
16be0 3c 65 78 63 6c 75 64 65 64 2e 62 3b 0a 20 20 53  <excluded.b;.  S
16bf0 45 4c 45 43 54 20 2a 2c 20 27 78 27 20 46 52 4f  ELECT *, 'x' FRO
16c00 4d 20 74 31 20 4f 52 44 45 52 20 42 59 20 61 3b  M t1 ORDER BY a;
16c10 0a 82 14 52 04 00 84 2d 20 20 43 52 45 41 54 45  ...R...-  CREATE
16c20 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 20   TABLE t1(a INT 
16c30 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
16c40 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29  nt, c DEFAULT 0)
16c50 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a   WITHOUT ROWID;.
16c60 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
16c70 28 61 2c 62 29 20 56 41 4c 55 45 53 28 39 2c 32  (a,b) VALUES(9,2
16c80 29 2c 28 33 2c 34 29 3b 0a 20 20 49 4e 53 45 52  ),(3,4);.  INSER
16c90 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
16ca0 41 4c 55 45 53 28 31 2c 38 29 2c 28 32 2c 31 31  ALUES(1,8),(2,11
16cb0 29 2c 28 33 2c 31 29 0a 20 20 20 20 4f 4e 20 43  ),(3,1).    ON C
16cc0 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50  ONFLICT(a) DO UP
16cd0 44 41 54 45 20 53 45 54 20 62 3d 65 78 63 6c 75  DATE SET b=exclu
16ce0 64 65 64 2e 62 2c 20 63 3d 63 2b 31 20 57 48 45  ded.b, c=c+1 WHE
16cf0 52 45 20 74 31 2e 62 3c 65 78 63 6c 75 64 65 64  RE t1.b<excluded
16d00 2e 62 3b 0a 20 20 53 45 4c 45 43 54 20 2a 2c 20  .b;.  SELECT *, 
16d10 27 78 27 20 46 52 4f 4d 20 74 31 20 4f 52 44 45  'x' FROM t1 ORDE
16d20 52 20 42 59 20 61 2c 3f 82 1b 51 04 00 84 3b 20  R BY a,?..Q...; 
16d30 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
16d40 28 61 20 49 4e 54 20 50 52 49 4d 41 52 59 20 4b  (a INT PRIMARY K
16d50 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46  EY, b int, c DEF
16d60 41 55 4c 54 20 30 29 20 57 49 54 48 4f 55 54 20  AULT 0) WITHOUT 
16d70 52 4f 57 49 44 3b 0a 20 20 49 4e 53 45 52 54 20  ROWID;.  INSERT 
16d80 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
16d90 55 45 53 28 31 2c 32 29 2c 28 33 2c 34 29 3b 45  UES(1,2),(3,4);E
16da0 58 50 4c 41 49 4e 0a 20 20 49 4e 53 45 52 54 20  XPLAIN.  INSERT 
16db0 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
16dc0 55 45 53 28 31 2c 38 29 2c 28 32 2c 31 31 29 2c  UES(1,8),(2,11),
16dd0 28 33 2c 31 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (3,1).    ON CON
16de0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
16df0 54 45 20 53 45 54 20 62 3d 65 78 63 6c 75 64 65  TE SET b=exclude
16e00 64 2e 62 2c 20 63 3d 63 2b 31 20 57 48 45 52 45  d.b, c=c+1 WHERE
16e10 20 74 31 2e 62 3c 65 78 63 6c 75 64 65 64 2e 62   t1.b<excluded.b
16e20 3b 0a 20 20 53 45 4c 45 43 54 20 2a 2c 20 27 78  ;.  SELECT *, 'x
16e30 27 20 46 52 4f 4d 20 74 31 20 4f 52 44 45 52 20  ' FROM t1 ORDER 
16e40 42 59 20 61 3b 0a 82 14 50 04 00 84 2d 20 20 43  BY a;...P...-  C
16e50 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 61  REATE TABLE t1(a
16e60 20 49 4e 54 20 50 52 49 4d 41 52 59 20 4b 45 59   INT PRIMARY KEY
16e70 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55  , b int, c DEFAU
16e80 4c 54 20 30 29 20 57 49 54 48 4f 55 54 20 52 4f  LT 0) WITHOUT RO
16e90 57 49 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  WID;.  INSERT IN
16ea0 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
16eb0 53 28 31 2c 32 29 2c 28 33 2c 34 29 3b 0a 20 20  S(1,2),(3,4);.  
16ec0 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
16ed0 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 38 29 2c  ,b) VALUES(1,8),
16ee0 28 33 2c 31 31 29 2c 28 33 2c 31 29 0a 20 20 20  (3,11),(3,1).   
16ef0 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20   ON CONFLICT(a) 
16f00 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 62 3d  DO UPDATE SET b=
16f10 65 78 63 6c 75 64 65 64 2e 62 2c 20 63 3d 63 2b  excluded.b, c=c+
16f20 20 64 61 74 65 28 41 2c 31 2c 31 29 3c 65 78 63   date(A,1,1)<exc
16f30 6c 75 64 65 64 2e 62 3b 0a 20 20 53 45 4c 45 43  luded.b;.  SELEC
16f40 54 20 2a 2c 20 27 78 27 20 46 52 4f 4d 20 74 31  T *, 'x' FROM t1
16f50 20 4f 52 44 45 52 20 42 59 20 61 3b 0a 82 14 4f   ORDER BY a;...O
16f60 04 00 84 2d 20 20 43 52 45 41 54 45 20 54 41 42  ...-  CREATE TAB
16f70 4c 45 20 74 31 28 61 20 49 4e 54 20 50 52 49 4d  LE t1(a INT PRIM
16f80 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20  ARY KEY, b int, 
16f90 63 20 44 45 46 41 55 4c 54 20 30 29 20 57 49 54  c DEFAULT 0) WIT
16fa0 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20 20 49 4e  HOUT ROWID;.  IN
16fb0 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
16fc0 29 20 56 41 4c 55 45 53 28 31 2c 32 29 2c 28 33  ) VALUES(1,2),(3
16fd0 2c 34 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ,4);.  INSERT IN
16fe0 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
16ff0 53 28 31 2c 38 29 2c 28 33 2c 31 31 29 2c 28 33  S(1,8),(3,11),(3
17000 2c 31 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,1).    ON CONFL
17010 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
17020 20 53 45 54 20 62 3d 65 78 63 6c 75 64 65 64 2e   SET b=excluded.
17030 62 20 7c 7c 20 63 2b 20 6e 75 6c 6c 69 66 28 31  b || c+ nullif(1
17040 2c 31 29 3c 65 78 63 6c 75 64 65 64 2e 62 3b 0a  ,1)<excluded.b;.
17050 20 20 53 45 4c 45 43 54 20 2a 2c 20 27 78 27 20    SELECT *, 'x' 
17060 46 52 4f 4d 20 74 31 20 4f 52 44 45 52 20 42 59  FROM t1 ORDER BY
17070 20 61 3b 0a 82 22 4e 04 00 84 49 20 20 43 52 45   a;.."N...I  CRE
17080 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49  ATE TABLE t1(a I
17090 4e 54 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  NT PRIMARY KEY, 
170a0 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
170b0 20 30 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49   0) WITHOUT ROWI
170c0 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  D;.  INSERT INTO
170d0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
170e0 31 2c 32 29 2c 28 33 2c 34 29 3b 0a 20 20 49 4e  1,2),(3,4);.  IN
170f0 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
17100 29 20 56 41 4c 55 45 53 28 31 2c 38 29 2c 28 33  ) VALUES(1,8),(3
17110 2c 31 31 29 2c 28 33 2c 31 29 0a 20 20 20 20 4f  ,11),(3,1).    O
17120 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
17130 20 55 50 44 41 54 45 20 53 45 54 20 62 3d 65 78   UPDATE SET b=ex
17140 63 6c 75 64 65 64 2e 62 20 7c 20 72 61 6e 64 6f  cluded.b | rando
17150 6d 62 6c 6f 62 28 31 29 7c 20 63 2b 20 6e 75 6c  mblob(1)| c+ nul
17160 6c 69 66 28 31 2c 31 29 3c 65 78 63 6c 75 64 65  lif(1,1)<exclude
17170 64 2e 62 3b 0a 20 20 53 45 4c 45 43 54 20 2a 2c  d.b;.  SELECT *,
17180 20 27 78 27 20 46 52 4f 4d 20 74 31 20 4f 52 44   'x' FROM t1 ORD
17190 45 52 20 42 59 20 61 3b 0a 82 14 4d 04 00 84 2d  ER BY a;...M...-
171a0 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
171b0 31 28 61 20 49 4e 54 20 50 52 49 4d 41 52 59 20  1(a INT PRIMARY 
171c0 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45  KEY, b int, c DE
171d0 46 41 55 4c 54 20 30 29 20 57 49 54 48 4f 55 54  FAULT 0) WITHOUT
171e0 20 52 4f 57 49 44 3b 0a 20 20 49 4e 53 45 52 54   ROWID;.  INSERT
171f0 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
17200 4c 55 45 53 28 31 2c 32 29 2c 28 33 2c 34 29 3b  LUES(1,2),(3,4);
17210 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
17220 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
17230 38 29 2c 28 33 2c 31 31 29 2c 28 33 2c 31 29 0a  8),(3,11),(3,1).
17240 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
17250 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
17260 20 62 3d 65 78 63 6c 75 64 65 64 2e 62 20 47 4c   b=excluded.b GL
17270 4f 42 2b 20 6e 75 6c 6c 69 66 28 31 2c 31 29 3c  OB+ nullif(1,1)<
17280 65 78 63 6c 75 64 65 64 2e 62 3b 0a 20 20 53 45  excluded.b;.  SE
17290 4c 45 43 54 20 2a 2c 20 27 78 27 20 46 52 4f 4d  LECT *, 'x' FROM
172a0 20 74 31 20 4f 52 44 45 52 20 42 59 20 61 3b 0a   t1 ORDER BY a;.
172b0 82 1c 4c 04 00 84 3d 20 20 43 52 45 41 54 45 20  ..L...=  CREATE 
172c0 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 20 50  TABLE t1(a INT P
172d0 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
172e0 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 20  t, c DEFAULT 0) 
172f0 57 49 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20  WITHOUT ROWID;. 
17300 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
17310 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
17320 2c 28 33 2c 34 29 3b 0a 20 20 49 4e 53 45 52 54  ,(3,4);.  INSERT
17330 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
17340 4c 55 45 53 28 31 2c 38 29 2c 28 32 2c 31 31 29  LUES(1,8),(2,11)
17350 2c 28 33 2c 31 29 0a 20 20 20 20 4f 4e 20 43 4f  ,(3,1).    ON CO
17360 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
17370 41 54 45 20 53 45 54 20 62 3d 65 78 63 6c 75 64  ATE SET b=exclud
17380 65 64 2e 62 2c 20 63 3d 63 2b 31 20 57 48 45 52  ed.b, c=c+1 WHER
17390 45 20 74 31 2e 62 3c 65 78 63 6c 75 64 65 64 2e  E t1.b<excluded.
173a0 62 3b 0a 20 20 53 45 4c 45 43 54 20 44 49 53 54  b;.  SELECT DIST
173b0 49 4e 43 54 3f 2c 20 27 78 27 20 46 52 4f 4d 20  INCT?, 'x' FROM 
173c0 74 31 20 4f 52 44 45 52 20 42 59 20 61 3b 0a 82  t1 ORDER BY a;..
173d0 26 4b 04 00 84 51 20 20 43 52 45 41 54 45 20 54  &K...Q  CREATE T
173e0 41 42 4c 45 20 74 31 28 61 20 49 4e 54 20 50 52  ABLE t1(a INT PR
173f0 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74  IMARY KEY, b int
17400 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 20 57  , c DEFAULT 0) W
17410 49 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20 20  ITHOUT ROWID;.  
17420 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
17430 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 2c  ,b) VALUES(1,2),
17440 28 33 2c 34 29 3b 0a 20 20 49 4e 53 45 52 54 20  (3,4);.  INSERT 
17450 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
17460 55 45 53 28 31 2c 38 29 2c 28 32 2c 31 31 29 2c  UES(1,8),(2,11),
17470 28 33 2c 31 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (3,1).    ON CON
17480 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
17490 54 45 20 53 45 54 20 62 3d 65 78 63 6c 75 64 65  TE SET b=exclude
174a0 64 2e 62 2c 20 63 3d 63 2b 31 20 57 48 45 52 45  d.b, c=c+1 WHERE
174b0 20 74 31 2e 62 3c 65 78 63 6c 75 64 65 64 2e 62   t1.b<excluded.b
174c0 3b 0a 20 20 53 45 4c 45 43 54 20 2a 2c 20 6a 73  ;.  SELECT *, js
174d0 6f 6e 5f 61 72 72 61 79 28 41 2c 31 2c 31 29 20  on_array(A,1,1) 
174e0 27 78 27 20 46 52 4f 4d 20 74 31 20 4f 52 44 45  'x' FROM t1 ORDE
174f0 52 20 42 59 20 61 3b 0a 82 14 4a 04 00 84 2d 20  R BY a;...J...- 
17500 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
17510 28 61 20 49 4e 54 20 50 52 49 4d 41 52 59 20 4b  (a INT PRIMARY K
17520 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46  EY, b int, c DEF
17530 41 55 4c 54 20 30 29 20 57 49 54 48 4f 55 54 20  AULT 0) WITHOUT 
17540 52 4f 57 49 44 3b 0a 20 20 49 4e 53 45 52 54 20  ROWID;.  INSERT 
17550 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
17560 55 45 53 28 31 2c 32 29 2c 28 33 2c 34 29 3b 0a  UES(1,2),(3,4);.
17570 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
17580 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 38  (a,b) VALUES(1,8
17590 29 2c 28 32 2c 31 31 29 2c 28 33 2c 31 29 0a 20  ),(2,11),(3,1). 
175a0 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
175b0 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
175c0 62 3d 65 78 63 6c 75 64 65 64 2e 62 2c 20 63 3d  b=excluded.b, c=
175d0 63 2b 31 20 57 48 45 52 45 20 74 31 2e 62 3c 65  c+1 WHERE t1.b<e
175e0 78 63 6c 75 64 65 64 2e 62 3b 0a 20 20 53 45 4c  xcluded.b;.  SEL
175f0 45 43 54 20 2a 2c 20 61 2c 62 20 46 52 4f 4d 20  ECT *, a,b FROM 
17600 74 31 20 47 52 4f 55 50 20 42 59 20 61 2c 62 82  t1 GROUP BY a,b.
17610 1b 49 04 00 84 3b 20 20 43 52 45 41 54 45 20 54  .I...;  CREATE T
17620 41 42 4c 45 20 74 31 28 61 20 49 4e 54 20 50 52  ABLE t1(a INT PR
17630 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74  IMARY KEY, b int
17640 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 20 57  , c DEFAULT 0) W
17650 49 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20 20  ITHOUT ROWID;.  
17660 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
17670 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 2c  ,b) VALUES(1,2),
17680 28 33 2c 34 29 3b 0a 20 20 49 4e 53 45 52 54 20  (3,4);.  INSERT 
17690 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
176a0 55 45 53 28 31 2c 38 29 2c 28 32 2c 31 31 29 2c  UES(1,8),(2,11),
176b0 28 33 2c 31 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (3,1).    ON CON
176c0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
176d0 54 45 20 53 45 54 20 62 3d 65 78 63 6c 75 64 65  TE SET b=exclude
176e0 64 2e 62 2c 20 63 3d 63 2b 31 20 57 48 45 52 45  d.b, c=c+1 WHERE
176f0 20 74 31 2e 62 3c 65 78 63 6c 75 64 65 64 2e 62   t1.b<excluded.b
17700 3b 0a 20 20 53 45 4c 45 43 54 20 2a 2c 20 27 78  ;.  SELECT *, 'x
17710 27 20 46 52 4f 4d 20 74 31 20 4f 52 44 45 52 20  ' FROM t1 ORDER 
17720 42 59 20 61 3b 52 45 49 4e 44 45 58 0a 82 14 48  BY a;REINDEX...H
17730 04 00 84 2d 20 20 43 52 45 41 54 45 20 54 41 42  ...-  CREATE TAB
17740 4c 45 20 74 31 28 61 20 49 4e 54 20 50 52 49 4d  LE t1(a INT PRIM
17750 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20  ARY KEY, b int, 
17760 63 20 44 45 46 41 55 4c 54 20 30 29 20 57 49 54  c DEFAULT 0) WIT
17770 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20 20 49 4e  HOUT ROWID;.  IN
17780 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
17790 29 20 56 41 4c 55 45 53 28 31 2c 32 29 2c 28 33  ) VALUES(1,2),(3
177a0 2c 34 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ,4);.  INSERT IN
177b0 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
177c0 53 28 31 2c 38 29 2c 28 32 2c 31 31 29 2c 28 33  S(1,8),(2,11),(3
177d0 2c 31 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,1).    ON CONFL
177e0 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
177f0 20 53 45 54 20 62 3d 65 78 63 6c 75 64 65 64 2e   SET b=excluded.
17800 62 2c 20 63 3d 63 2b 31 20 57 48 45 52 45 20 74  b, c=c+1 WHERE t
17810 31 2e 62 3c 65 78 63 6c 75 64 65 64 2e 62 3b 0a  1.b<excluded.b;.
17820 20 20 53 45 4c 45 43 54 20 2a 2c 20 27 78 27 20    SELECT *, 'x' 
17830 46 52 4f 4d 20 74 31 20 4f 52 44 45 52 20 42 59  FROM t1 ORDER BY
17840 20 61 2c 62 82 20 47 04 00 84 45 20 20 43 52 45   a,b. G...E  CRE
17850 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49  ATE TABLE t1(a I
17860 4e 54 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  NT PRIMARY KEY, 
17870 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
17880 20 30 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49   0) WITHOUT ROWI
17890 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  D;.  INSERT INTO
178a0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
178b0 31 2c 32 29 2c 28 33 2c 34 29 3b 0a 20 20 49 4e  1,2),(3,4);.  IN
178c0 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
178d0 29 20 56 41 4c 55 45 53 28 31 2c 38 29 2c 28 32  ) VALUES(1,8),(2
178e0 2c 31 31 29 2c 28 33 2c 31 29 0a 20 20 20 20 4f  ,11),(3,1).    O
178f0 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
17900 20 55 50 44 41 54 45 20 53 45 54 20 62 3d 65 78   UPDATE SET b=ex
17910 63 6c 75 64 65 64 2e 62 2c 20 63 3d 63 2b 31 20  cluded.b, c=c+1 
17920 57 48 45 52 45 20 74 31 2e 62 3c 65 78 63 6c 75  WHERE t1.b<exclu
17930 64 65 64 2e 62 3b 0a 20 20 53 45 4c 45 43 54 20  ded.b;.  SELECT 
17940 2a 2c 20 27 78 27 20 46 52 4f 4d 20 74 31 20 4f  *, 'x' FROM t1 O
17950 52 44 45 52 20 42 59 20 61 2c 20 61 2c 20 22 61  RDER BY a, a, "a
17960 22 2c 22 62 22 62 62 82 14 46 04 00 84 2d 20 20  ","b"bb..F...-  
17970 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
17980 61 20 49 4e 54 20 50 52 49 4d 41 52 59 20 4b 45  a INT PRIMARY KE
17990 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41  Y, b int, c DEFA
179a0 55 4c 54 20 30 29 20 57 49 54 48 4f 55 54 20 52  ULT 0) WITHOUT R
179b0 4f 57 49 44 3b 0a 20 20 49 4e 53 45 52 54 20 49  OWID;.  INSERT I
179c0 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
179d0 45 53 28 31 2c 32 29 2c 28 33 2c 34 29 3b 0a 20  ES(1,2),(3,4);. 
179e0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
179f0 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 38 29  a,b) VALUES(1,8)
17a00 2c 28 32 2c 31 31 29 2c 28 33 2c 31 29 0a 20 20  ,(2,11),(3,1).  
17a10 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
17a20 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 62   DO UPDATE SET b
17a30 3d 65 78 63 6c 75 64 65 64 2e 62 2c 20 63 3d 63  =excluded.b, c=c
17a40 2b 31 20 57 48 45 52 45 20 74 31 2e 62 3c 65 78  +1 WHERE t1.b<ex
17a50 63 6c 75 64 65 64 2e 62 3b 0a 20 20 53 45 4c 45  cluded.b;.  SELE
17a60 43 54 20 2a 2c 20 27 78 27 20 46 52 4f 4d 20 74  CT *, 'x' FROM t
17a70 31 20 47 52 4f 55 50 20 42 59 40 61 2c 62 82 14  1 GROUP BY@a,b..
17a80 45 04 00 84 2d 20 20 43 52 45 41 54 45 20 54 41  E...-  CREATE TA
17a90 42 4c 45 20 74 31 28 61 20 49 4e 54 20 50 52 49  BLE t1(a INT PRI
17aa0 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c  MARY KEY, b int,
17ab0 20 63 20 44 45 46 41 55 4c 54 20 30 29 20 57 49   c DEFAULT 0) WI
17ac0 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a 20 20 49  THOUT ROWID;.  I
17ad0 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
17ae0 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 2c 28  b) VALUES(1,2),(
17af0 33 2c 34 29 3b 0a 20 20 49 4e 53 45 52 54 20 49  3,4);.  INSERT I
17b00 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
17b10 45 53 28 31 2c 38 29 2c 28 32 2c 31 31 29 2c 28  ES(1,8),(2,11),(
17b20 33 2c 31 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46  3,1).    ON CONF
17b30 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54  LICT(a) DO UPDAT
17b40 45 20 53 45 54 20 62 3d 65 78 63 6c 75 64 65 64  E SET b=excluded
17b50 2e 62 2c 20 63 3d 63 2b 31 20 57 48 45 52 45 20  .b, c=c+1 WHERE 
17b60 74 31 2e 62 3c 65 78 63 6c 75 64 65 64 2e 62 3b  t1.b<excluded.b;
17b70 0a 20 20 53 45 4c 45 43 54 20 2a 2c 20 27 78 27  .  SELECT *, 'x'
17b80 20 46 52 4f 4d 20 74 31 20 47 52 4f 55 50 20 42   FROM t1 GROUP B
17b90 59 20 61 3c 62 82 1b 44 04 00 84 3b 20 20 43 52  Y a<b..D...;  CR
17ba0 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20  EATE TABLE t1(a 
17bb0 49 4e 54 20 50 52 49 4d 41 52 59 20 4b 45 59 2c  INT PRIMARY KEY,
17bc0 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c   b int, c DEFAUL
17bd0 54 20 30 29 20 57 49 54 48 4f 55 54 20 52 4f 57  T 0) WITHOUT ROW
17be0 49 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ID;.  INSERT INT
17bf0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
17c00 28 31 2c 32 29 2c 28 33 2c 34 29 3b 0a 20 20 49  (1,2),(3,4);.  I
17c10 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
17c20 62 29 20 56 41 4c 55 45 53 28 31 2c 38 29 2c 28  b) VALUES(1,8),(
17c30 32 2c 31 31 29 2c 28 33 2c 31 29 0a 20 20 20 20  2,11),(3,1).    
17c40 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
17c50 4f 20 55 50 44 41 54 45 20 53 45 54 20 62 3d 65  O UPDATE SET b=e
17c60 78 63 6c 75 64 65 64 2e 62 2c 20 63 3d 63 2b 31  xcluded.b, c=c+1
17c70 20 57 48 45 52 45 20 74 31 2e 62 3c 65 78 63 6c   WHERE t1.b<excl
17c80 75 64 65 64 2e 62 3b 0a 20 20 53 45 4c 45 43 54  uded.b;.  SELECT
17c90 20 2a 2c 20 27 78 27 20 46 52 4f 4d 20 74 31 20   *, 'x' FROM t1 
17ca0 47 52 4f 55 50 20 42 59 20 61 2c 20 61 76 67 28  GROUP BY a, avg(
17cb0 31 29 62 82 1c 43 04 00 84 3d 20 20 43 52 45 41  1)b..C...=  CREA
17cc0 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
17cd0 54 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62  T PRIMARY KEY, b
17ce0 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20   int, c DEFAULT 
17cf0 30 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44  0) WITHOUT ROWID
17d00 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
17d10 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
17d20 2c 32 29 2c 28 33 2c 34 29 3b 0a 20 20 49 4e 53  ,2),(3,4);.  INS
17d30 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
17d40 20 56 41 4c 55 45 53 28 31 2c 38 29 2c 28 32 2c   VALUES(1,8),(2,
17d50 31 31 29 2c 28 33 2c 31 29 0a 20 20 20 20 4f 4e  11),(3,1).    ON
17d60 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
17d70 55 50 44 41 54 45 20 53 45 54 20 62 3d 65 78 63  UPDATE SET b=exc
17d80 6c 75 64 65 64 2e 62 2c 20 63 3d 63 2b 31 20 57  luded.b, c=c+1 W
17d90 48 45 52 45 20 74 31 2e 62 3c 65 78 63 6c 75 64  HERE t1.b<exclud
17da0 65 64 2e 62 3b 0a 20 20 53 45 4c 45 43 54 20 2a  ed.b;.  SELECT *
17db0 2c 20 27 78 27 20 46 52 4f 4d 20 74 31 20 47 52  , 'x' FROM t1 GR
17dc0 4f 55 50 20 42 59 20 61 2c 20 22 61 22 2c 22 62  OUP BY a, "a","b
17dd0 22 62 82 14 42 04 00 84 2d 20 20 43 52 45 41 54  "b..B...-  CREAT
17de0 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54  E TABLE t1(a INT
17df0 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20   PRIMARY KEY, b 
17e00 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30  int, c DEFAULT 0
17e10 29 20 57 49 54 48 4f 55 54 20 52 4f 57 49 44 3b  ) WITHOUT ROWID;
17e20 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
17e30 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
17e40 32 29 2c 28 33 2c 34 29 3b 0a 20 20 49 4e 53 45  2),(3,4);.  INSE
17e50 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
17e60 56 41 4c 55 45 53 28 31 2c 38 29 2c 28 32 2c 31  VALUES(1,8),(2,1
17e70 31 29 2c 28 33 2c 31 29 0a 20 20 20 20 4f 4e 20  1),(3,1).    ON 
17e80 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
17e90 50 44 41 54 45 20 53 45 54 20 62 3d 65 78 63 6c  PDATE SET b=excl
17ea0 75 64 65 64 2e 62 2c 20 63 3d 63 2b 20 64 61 74  uded.b, c=c+ dat
17eb0 65 28 41 2c 3f 2c 31 29 3c 65 78 63 6c 75 64 65  e(A,?,1)<exclude
17ec0 64 2e 62 3b 0a 20 20 53 45 4c 45 43 54 20 2a 2c  d.b;.  SELECT *,
17ed0 20 27 78 27 20 46 52 4f 4d 20 74 31 20 4f 52 44   'x' FROM t1 ORD
17ee0 45 52 20 42 59 20 61 3b 0a 82 14 41 04 00 84 2d  ER BY a;...A...-
17ef0 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
17f00 31 28 61 20 49 4e 54 20 50 52 49 4d 41 52 59 20  1(a INT PRIMARY 
17f10 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45  KEY, b int, c DE
17f20 46 41 55 4c 54 20 30 29 20 57 49 54 48 4f 55 54  FAULT 0) WITHOUT
17f30 20 52 4f 57 49 44 3b 0a 20 20 49 4e 53 45 52 54   ROWID;.  INSERT
17f40 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
17f50 4c 55 45 53 28 31 2c 32 29 2c 28 33 2c 34 29 3b  LUES(1,2),(3,4);
17f60 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
17f70 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
17f80 38 29 2c 28 32 2c 31 31 29 2c 28 33 2c 31 29 0a  8),(2,11),(3,1).
17f90 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
17fa0 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
17fb0 20 62 3d 65 78 63 6c 75 64 65 64 2e 62 2c 20 63   b=excluded.b, c
17fc0 3d 63 2b 20 64 61 74 65 28 41 2c 31 2c 31 29 3c  =c+ date(A,1,1)<
17fd0 65 78 63 6c 75 64 65 64 2e 62 3b 0a 20 20 53 45  excluded.b;.  SE
17fe0 4c 45 43 54 20 2a 2c 20 27 78 27 20 46 52 4f 4d  LECT *, 'x' FROM
17ff0 20 74 31 20 4f 52 44 45 52 20 42 59 20 61 3b 0a   t1 ORDER BY a;.
18000 0d 00 00 00 1c 04 9c 00 1e fc 1d f8 1c f4 1b de  ................
18010 1a da 19 ea 18 df 17 d1 16 d3 15 bb 14 b7 13 9f  ................
18020 12 8b 11 df 10 db 0f d7 0e d3 0e 47 0d 0d 0c 03  ...........G....
18030 0a f8 0a 3c 09 38 08 34 07 30 06 54 05 78 04 9c  ...<.8.4.0.T.x..
18040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
180a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
180b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
180c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
180d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
180e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
180f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
181a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
181b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
181c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
181d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
181e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
181f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18200 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18210 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18220 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18230 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18250 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18260 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18270 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18280 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18290 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
182a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
182b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
182c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
182d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
182e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
182f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18300 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18310 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18320 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18330 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18340 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18350 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18360 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18370 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18380 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18390 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
183a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
183b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
183c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
183d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
183e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
183f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18400 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18410 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18420 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18430 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18440 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18450 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18460 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18470 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18480 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
18490 00 00 00 00 00 00 00 00 00 00 00 00 81 59 79 04  .............Yy.
184a0 00 83 37 20 20 43 52 45 41 54 45 20 54 41 42 4c  ..7  CREATE TABL
184b0 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50  E t1(a INTEGER P
184c0 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
184d0 74 2c 20 58 63 20 44 45 46 41 55 4c 54 20 30 29  t, Xc DEFAULT 0)
184e0 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
184f0 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
18500 2c 32 29 2c 28 33 2c 34 29 3b 0a 20 20 57 49 54  ,2),(3,4);.  WIT
18510 48 20 6e 78 28 61 2c 62 29 20 41 53 20 28 56 41  H nx(a,b) AS (VA
18520 4c 55 45 53 28 31 2c 38 29 2c 28 32 2c 31 31 29  LUES(1,8),(2,11)
18530 2c 28 33 2c 31 29 2c 28 32 2c 31 35 29 2c 28 31  ,(3,1),(2,15),(1
18540 2c 34 29 2c 28 31 2c 39 39 29 29 0a 20 20 53 45  ,4),(1,99)).  SE
18550 4c 45 43 54 20 61 2c 20 62 20 46 52 4f 4d 20 6e  LECT a, b FROM n
18560 78 20 57 48 45 52 45 20 74 72 75 65 0a 20 20 20  x WHERE true.   
18570 20 4f 4e 20 43 4f 4e 0a 81 59 78 04 00 83 37 20   ON CON..Yx...7 
18580 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
18590 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41  (a INTEGER PRIMA
185a0 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 58  RY KEY, b int, X
185b0 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20  c DEFAULT 0);.  
185c0 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
185d0 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 2c  ,b) VALUES(1,2),
185e0 28 33 2c 34 29 3b 0a 20 20 57 49 54 48 20 6e 78  (3,4);.  WITH nx
185f0 28 61 2c 62 29 20 41 53 20 28 56 41 4c 55 45 53  (a,b) AS (VALUES
18600 28 31 2c 38 29 2c 28 32 2c 31 31 29 2c 28 33 2c  (1,8),(2,11),(3,
18610 31 29 2c 28 32 2c 31 35 29 2c 28 31 2c 34 29 2c  1),(2,15),(1,4),
18620 28 31 2c 39 39 29 29 0a 20 20 53 45 4c 45 43 54  (1,99)).  SELECT
18630 20 61 0c 20 62 20 46 52 4f 4d 20 6e 78 20 57 48   a. b FROM nx WH
18640 45 52 45 20 74 72 75 65 0a 20 20 20 20 4f 4e 20  ERE true.    ON 
18650 43 4f 4e 0a 81 59 77 04 00 83 37 20 20 43 52 45  CON..Yw...7  CRE
18660 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49  ATE TABLE t1(a I
18670 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b  NTEGER PRIMARY K
18680 45 59 2c 20 62 20 69 6e 74 2c 20 58 63 20 44 45  EY, b int, Xc DE
18690 46 41 55 4c 54 20 30 29 3b 0a 20 20 49 4e 53 45  FAULT 0);.  INSE
186a0 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
186b0 56 41 4c 55 45 53 28 31 2c 32 29 2c 28 33 2c 34  VALUES(1,2),(3,4
186c0 29 3b 0a 20 20 57 49 54 48 20 6e 78 28 61 2c 62  );.  WITH nx(a,b
186d0 29 20 41 53 20 28 56 41 4c 55 45 53 28 31 2c 38  ) AS (VALUES(1,8
186e0 29 2c 28 32 2c 31 31 29 2c 28 33 2c 31 29 2c 28  ),(2,11),(3,1),(
186f0 32 2c 31 35 29 2c 28 31 2c 34 29 2c 28 31 2c 39  2,15),(1,4),(1,9
18700 39 29 29 0a 20 20 53 45 4c 45 43 54 20 2a 2c 20  9)).  SELECT *, 
18710 62 20 46 52 4f 4d 20 6e 78 20 57 48 45 52 45 20  b FROM nx WHERE 
18720 74 72 75 65 0a 20 20 20 20 4f 4e 20 43 4f 4e 0a  true.    ON CON.
18730 82 01 76 04 00 84 07 20 20 43 52 45 41 54 45 20  ..v....  CREATE 
18740 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47  TABLE t1(a INTEG
18750 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  ER PRIMARY KEY, 
18760 62 20 63 68 61 72 28 31 29 44 45 46 41 55 4c 54  b char(1)DEFAULT
18770 2e 30 29 3b 0a 20 20 43 52 45 41 54 45 20 55 4e  .0);.  CREATE UN
18780 49 51 55 45 20 49 4e 44 45 58 20 74 31 78 31 20  IQUE INDEX t1x1 
18790 4f 4e 20 74 31 28 61 2b 62 29 3b 0a 20 52 45 50  ON t1(a+b);. REP
187a0 4c 41 43 45 20 49 4e 54 4f 20 74 31 28 61 2c 62  LACE INTO t1(a,b
187b0 29 20 56 41 4c 55 45 53 28 37 2c 38 29 20 4f 4e  ) VALUES(7,8) ON
187c0 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20 44   CONFLICT(a+b) D
187d0 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 49 4e 53  O NOTHING;.  INS
187e0 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
187f0 20 56 41 4c 55 45 53 28 38 2c 37 29 2c 28 39 2c   VALUES(8,7),(9,
18800 36 29 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61  6) ON CONFLICT(a
18810 2b 62 29 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a  +b) DO NOTHING;.
18820 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
18830 74 31 3b 0a 82 01 75 04 00 84 07 20 20 43 52 45  t1;...u....  CRE
18840 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49  ATE TABLE t1(a I
18850 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b  NTEGER PRIMARY K
18860 45 59 2c 20 62 20 63 68 61 72 28 31 29 44 45 46  EY, b char(1)DEF
18870 41 55 4c 54 20 b0 29 3b 0a 20 20 43 52 45 41 54  AULT .);.  CREAT
18880 45 20 55 4e 49 51 55 45 20 49 4e 44 45 58 20 74  E UNIQUE INDEX t
18890 31 78 31 20 4f 4e 20 74 31 28 61 2b 62 29 3b 0a  1x1 ON t1(a+b);.
188a0 20 52 45 50 4c 41 43 45 20 49 4e 54 4f 20 74 31   REPLACE INTO t1
188b0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 37 2c 38  (a,b) VALUES(7,8
188c0 29 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b  ) ON CONFLICT(a+
188d0 62 29 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20  b) DO NOTHING;. 
188e0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
188f0 61 2c 62 29 20 56 41 4c 55 45 53 28 38 2c 37 29  a,b) VALUES(8,7)
18900 2c 28 39 2c 36 29 20 4f 4e 20 43 4f 4e 46 4c 49  ,(9,6) ON CONFLI
18910 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54 48 49  CT(a+b) DO NOTHI
18920 4e 47 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  NG;.  SELECT * F
18930 52 4f 4d 20 74 31 3b 0a 82 01 74 04 00 84 07 20  ROM t1;...t.... 
18940 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
18950 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41  (a INTEGER PRIMA
18960 52 59 20 4b 45 59 2c 20 62 20 63 68 61 72 28 31  RY KEY, b char(1
18970 29 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43  )DEFAULT 0);.  C
18980 52 45 41 54 45 20 55 4e 49 51 55 45 20 49 4e 44  REATE UNIQUE IND
18990 45 58 20 74 31 78 31 20 4f 4e 20 74 31 28 61 2b  EX t1x1 ON t1(a+
189a0 62 29 3b 0a 20 52 45 50 4c 41 43 45 20 49 4e 54  b);. REPLACE INT
189b0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
189c0 28 37 2c 38 29 20 4f 4e 20 43 4f 4e 46 4c 49 43  (7,8) ON CONFLIC
189d0 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54 48 49 4e  T(a+b) DO NOTHIN
189e0 47 3b 0a 20 52 45 50 4c 41 43 45 20 49 4e 54 4f  G;. REPLACE INTO
189f0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
18a00 38 2c 37 29 2c 28 39 2c 36 29 20 4f 4e 20 43 4f  8,7),(9,6) ON CO
18a10 4e 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e  NFLICT(a+b) DO N
18a20 4f 54 48 49 4e 47 3b 0a 20 20 53 45 4c 45 43 54  OTHING;.  SELECT
18a30 20 2a 20 46 52 4f 4d 20 74 31 3b 0a 81 39 73 04   * FROM t1;..9s.
18a40 00 82 77 20 20 43 52 45 41 54 45 20 54 41 42 4c  ..w  CREATE TABL
18a50 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50  E t1(a INTEGER P
18a60 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 63 68  RIMARY KEY, b ch
18a70 61 72 28 31 29 44 45 46 41 55 4c 54 20 30 29 3b  ar(1)DEFAULT 0);
18a80 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
18a90 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
18aa0 31 28 61 2b 62 29 3b 0a 20 52 45 50 4c 41 43 45  1(a+b);. REPLACE
18ab0 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
18ac0 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
18ad0 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
18ae0 54 48 49 4e 47 3b 0a 20 52 45 49 4e 44 45 58 20  THING;. REINDEX 
18af0 49 4e 54 4f 20 74 31 0a 82 08 72 04 00 84 15 20  INTO t1...r.... 
18b00 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
18b10 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41  (a INTEGER PRIMA
18b20 52 59 20 4b 45 59 2c 20 62 20 63 68 61 72 28 31  RY KEY, b char(1
18b30 29 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43  )DEFAULT 0);.  C
18b40 52 45 41 54 45 20 55 4e 49 51 55 45 20 49 4e 44  REATE UNIQUE IND
18b50 45 58 20 74 31 78 31 20 4f 4e 20 74 31 28 61 2b  EX t1x1 ON t1(a+
18b60 62 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  b);.  INSERT INT
18b70 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
18b80 28 37 2c 38 29 20 4f 4e 20 43 4f 4e 46 4c 49 43  (7,8) ON CONFLIC
18b90 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54 48 49 4e  T(a+b) DO NOTHIN
18ba0 47 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  G;.  INSERT INTO
18bb0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
18bc0 38 2c 37 29 2c 28 39 2c 36 29 20 4f 4e 20 43 4f  8,7),(9,6) ON CO
18bd0 4e 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e  NFLICT(a+b) DO N
18be0 4f 54 48 49 4e 47 3b 45 58 50 4c 41 49 4e 0a 20  OTHING;EXPLAIN. 
18bf0 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 74   SELECT * FROM t
18c00 31 3b 0a 82 07 71 04 00 84 13 20 20 43 52 45 41  1;...q....  CREA
18c10 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
18c20 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
18c30 59 2c 20 62 20 63 68 61 72 28 31 29 44 45 46 41  Y, b char(1)DEFA
18c40 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45  ULT 0);.  CREATE
18c50 20 55 4e 49 51 55 45 20 49 4e 44 45 58 20 74 31   UNIQUE INDEX t1
18c60 78 31 20 4f 4e 20 74 31 28 61 2b 62 29 3b 0a 20  x1 ON t1(a+b);. 
18c70 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
18c80 61 2c 62 29 20 56 41 4c 55 45 53 28 37 2c 38 29  a,b) VALUES(7,8)
18c90 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62   ON CONFLICT(a+b
18ca0 29 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20  ) DO NOTHING;.  
18cb0 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
18cc0 2c 62 29 20 56 41 4c 55 45 53 28 38 2c 37 29 2c  ,b) VALUES(8,7),
18cd0 28 39 2c 36 29 20 4f 4e 20 43 4f 4e 46 4c 49 43  (9,6) ON CONFLIC
18ce0 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54 48 49 4e  T(a+b) DO NOTHIN
18cf0 47 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52  G;.  SELECT * FR
18d00 4f 4d 20 74 31 3b 56 41 43 55 55 4d 0a 82 37 70  OM t1;VACUUM..7p
18d10 04 00 84 73 20 20 43 52 45 41 54 45 20 54 41 42  ...s  CREATE TAB
18d20 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20  LE t1(a INTEGER 
18d30 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 55  PRIMARY KEY, b U
18d40 4e 49 51 55 45 20 44 45 46 41 55 4c 54 20 30 29  NIQUE DEFAULT 0)
18d50 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
18d60 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
18d70 2c 32 29 2c 28 33 2c 34 29 3b 0a 20 20 57 49 54  ,2),(3,4);.  WIT
18d80 48 20 6e 78 28 61 2c 62 29 20 41 53 20 28 56 41  H nx(a,b) AS (VA
18d90 4c 55 45 53 28 31 2c 38 29 2c 28 32 2c 31 31 29  LUES(1,8),(2,11)
18da0 2c 28 20 6a 73 6f 6e 5f 67 72 6f 75 70 5f 61 72  ,( json_group_ar
18db0 72 61 79 28 31 29 2c 39 39 29 29 0a 20 20 49 4e  ray(1),99)).  IN
18dc0 53 45 52 54 20 49 4e 54 4f 20 6d 61 69 6e 2e 74  SERT INTO main.t
18dd0 31 20 41 53 20 74 32 28 61 2c 62 29 20 53 45 4c  1 AS t2(a,b) SEL
18de0 45 43 54 20 61 2c 20 62 20 46 52 4f 4d 20 6e 78  ECT a, b FROM nx
18df0 20 57 48 45 52 45 20 74 72 75 65 0a 20 20 20 20   WHERE true.    
18e00 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 3f 29 20 44  ON CONFLICT(?) D
18e10 4f 20 55 50 44 41 54 45 20 53 45 54 20 62 3d 65  O UPDATE SET b=e
18e20 78 63 6c 75 64 65 64 2e 62 2c 20 63 3d 74 32 2e  xcluded.b, c=t2.
18e30 63 2b 31 20 57 48 45 52 45 20 74 32 2e 62 3c 65  c+1 WHERE t2.b<e
18e40 64 65 64 2e 61 3b 0a 81 09 6f 04 00 82 17 20 20  ded.a;...o....  
18e50 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
18e60 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52  a INTEGER PRIMAR
18e70 59 20 4b 45 59 2c 20 62 20 49 4e 54 ac 20 63 20  Y KEY, b INT. c 
18e80 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52  DEFAULT 0);.  CR
18e90 45 41 54 45 20 55 4e 49 51 55 45 20 49 4e 44 45  EATE UNIQUE INDE
18ea0 58 20 74 31 78 31 20 4f 4e 20 74 31 28 61 29 62  X t1x1 ON t1(a)b
18eb0 29 3b 0a 20 20 49 4e 4f 54 48 49 4e 47 3b 0a 20  );.  INOTHING;. 
18ec0 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 74   SELECT * FROM t
18ed0 31 3b 0a 82 01 6e 04 00 84 07 20 20 43 52 45 41  1;...n....  CREA
18ee0 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
18ef0 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
18f00 59 2c 20 62 20 49 4e 54 2c 20 63 20 44 45 46 41  Y, b INT, c DEFA
18f10 55 4c 54 2e 30 29 3b 0a 20 20 43 52 45 41 54 45  ULT.0);.  CREATE
18f20 20 55 4e 49 51 55 45 20 49 4e 44 45 58 20 74 31   UNIQUE INDEX t1
18f30 78 31 20 4f 4e 20 74 31 28 61 2b 62 29 3b 0a 20  x1 ON t1(a+b);. 
18f40 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
18f50 61 2c 62 29 20 56 41 4c 55 45 53 28 37 2c 38 29  a,b) VALUES(7,8)
18f60 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62   ON CONFLICT(a+b
18f70 29 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20  ) DO NOTHING;.  
18f80 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
18f90 2c 62 29 20 56 41 4c 55 45 53 28 38 2c 37 29 2c  ,b) VALUES(8,7),
18fa0 28 39 2c 36 29 20 4f 4e 20 43 4f 4e 46 4c 49 43  (9,6) ON CONFLIC
18fb0 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54 48 49 4e  T(a+b) DO NOTHIN
18fc0 47 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52  G;.  SELECT * FR
18fd0 4f 4d 20 74 31 3b 0a 82 01 6d 04 00 84 07 20 20  OM t1;...m....  
18fe0 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
18ff0 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52  a INTEGER PRIMAR
19000 59 20 4b 45 59 2c 20 62 20 49 4e 54 2c 20 63 20  Y KEY, b INT, c 
19010 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52  DEFAULT 0);.  CR
19020 45 41 54 45 20 55 4e 49 51 55 45 20 49 4e 44 45  EATE UNIQUE INDE
19030 58 20 74 31 78 31 20 4f 4e 20 74 31 28 63 2b 62  X t1x1 ON t1(c+b
19040 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  );.  INSERT INTO
19050 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
19060 37 2c 38 29 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  7,8) ON CONFLICT
19070 28 61 2b 62 29 20 44 4f 20 4e 4f 54 48 49 4e 47  (a+b) DO NOTHING
19080 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
19090 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 38  t1(a,b) VALUES(8
190a0 2c 37 29 2c 28 39 2c 36 29 20 4f 4e 20 43 4f 4e  ,7),(9,6) ON CON
190b0 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
190c0 54 48 49 4e 47 3b 0a 20 20 53 45 4c 45 43 54 20  THING;.  SELECT 
190d0 2a 20 46 52 4f 4d 20 74 31 3b 0a 82 01 6c 04 00  * FROM t1;...l..
190e0 84 07 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ..  CREATE TABLE
190f0 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
19100 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e 54  IMARY KEY, b INT
19110 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a  , c DEFAULT 0);.
19120 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45 20    CREATE UNIQUE 
19130 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74 31  INDEX t1x1 ON t1
19140 28 61 2c 62 29 3b 0a 20 20 49 4e 53 45 52 54 20  (a,b);.  INSERT 
19150 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
19160 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e 46  UES(7,8) ON CONF
19170 4c 49 43 54 20 2f 2a 20 2a 2f 44 4f 20 4e 4f 54  LICT /* */DO NOT
19180 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20 49  HING;.  INSERT I
19190 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
191a0 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f 4e  ES(8,7),(9,6) ON
191b0 20 43 4f 4e 46 4c 49 43 54 20 2f 2a 20 2a 2f 44   CONFLICT /* */D
191c0 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45 4c  O NOTHING;.  SEL
191d0 45 43 54 20 2a 20 46 52 4f 4d 20 74 31 3b 0a 81  ECT * FROM t1;..
191e0 29 6b 04 00 82 57 20 20 43 52 45 41 54 45 20 54  )k...W  CREATE T
191f0 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45  ABLE t1(a INTEGE
19200 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62  R PRIMARY KEY, b
19210 20 49 4e 54 2c 20 63 20 44 45 46 41 55 4c 54 20   INT, c DEFAULT 
19220 30 29 3b 0a 20 20 43 52 45 41 54 45 20 55 4e 49  0);.  CREATE UNI
19230 51 55 45 20 49 4e 44 45 58 20 74 31 78 31 20 4f  QUE INDEX t1x1 O
19240 4e 20 74 31 28 61 2c 61 29 3b 0a 20 52 45 49 4e  N t1(a,a);. REIN
19250 44 45 58 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  DEX INTO t1(a,b)
19260 20 56 41 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20   VALUES(7,8) ON 
19270 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20 44 4f  CONFLICT(a+b) DO
19280 20 4e 4f 54 48 49 4e 47 3b 0a 0a 82 11 6a 04 00   NOTHING;....j..
19290 84 27 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  .'  CREATE TABLE
192a0 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
192b0 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e 54  IMARY KEY, b INT
192c0 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a  , c DEFAULT 0);.
192d0 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45 20    CREATE UNIQUE 
192e0 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74 31  INDEX t1x1 ON t1
192f0 28 61 2b 7e 7e 7e 7e 7e 7e 7e 7e 7e 7e 7e 7e 7e  (a+~~~~~~~~~~~~~
19300 7e 7e 7e 62 29 3b 0a 20 20 49 4e 53 45 52 54 20  ~~~b);.  INSERT 
19310 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
19320 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e 46  UES(7,8) ON CONF
19330 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54  LICT(a+b) DO NOT
19340 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20 49  HING;.  INSERT I
19350 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
19360 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f 4e  ES(8,7),(9,6) ON
19370 20 2d 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20 44   -ONFLICT(a+b) D
19380 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45 4c  O NOTHING;.  SEL
19390 45 43 54 20 40 31 46 52 4f 20 5b 61 5d 3b 0a 82  ECT @1FRO [a];..
193a0 15 69 04 00 84 2f 20 20 43 52 45 41 54 45 20 54  .i.../  CREATE T
193b0 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45  ABLE t1(a INTEGE
193c0 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62  R PRIMARY KEY, b
193d0 20 49 4e 54 2c 20 63 20 44 45 46 41 55 4c 54 20   INT, c DEFAULT 
193e0 30 29 3b 0a 20 20 43 52 45 41 54 45 20 55 4e 49  0);.  CREATE UNI
193f0 51 55 45 20 49 4e 44 45 58 20 74 31 78 31 20 4f  QUE INDEX t1x1 O
19400 4e 20 74 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53  N t1(a+b);.  INS
19410 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
19420 20 56 41 4c 55 45 53 28 3a 30 30 31 32 30 30 31   VALUES(:0012001
19430 2d 30 31 2d 30 31 2d 30 31 2d 30 31 37 2c 38 29  -01-01-01-017,8)
19440 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62   ON CONFLICT(a+b
19450 29 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20  ) DO NOTHING;.  
19460 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
19470 2c 62 29 20 56 41 4c 55 45 53 28 38 2c 37 29 2c  ,b) VALUES(8,7),
19480 28 39 2c 36 29 20 4f 4e 20 43 4f 4e 46 4c 49 43  (9,6) ON CONFLIC
19490 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54 48 49 4e  T(a+b) DO NOTHIN
194a0 47 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52  G;.  SELECT * FR
194b0 4f 4d 20 74 31 3b 0a 82 01 68 04 00 84 07 20 20  OM t1;...h....  
194c0 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
194d0 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52  a INTEGER PRIMAR
194e0 59 20 4b 45 59 2c 20 62 20 49 4e 54 2c 20 63 20  Y KEY, b INT, c 
194f0 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52  DEFAULT 0);.  CR
19500 45 41 54 45 20 55 4e 49 51 55 45 20 49 4e 44 45  EATE UNIQUE INDE
19510 58 20 74 31 78 31 20 4f 4e 20 74 31 28 61 2b 62  X t1x1 ON t1(a+b
19520 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  );.  INSERT INTO
19530 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
19540 37 32 30 30 31 32 30 30 31 2d 30 31 2d 30 31 2d  720012001-01-01-
19550 30 31 2d 30 31 2c 38 29 20 4f 4e 20 43 4f 4e 46  01-01,8) ON CONF
19560 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54  LICT(a+b) DO NOT
19570 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20 49  HING;.  INSERT I
19580 4e 54 4f 20 74 31 28 62 2c 62 29 20 56 41 4c 55  NTO t1(b,b) VALU
19590 45 53 28 39 2c 37 29 2c 28 39 2c 36 29 20 4f 4e  ES(9,7),(9,6) ON
195a0 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20 44   CONFLICT(a+b) D
195b0 4f 20 4e 4f 54 48 49 4e 47 3b 0a 82 15 67 04 00  O NOTHING;...g..
195c0 84 2f 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ./  CREATE TABLE
195d0 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
195e0 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e 54  IMARY KEY, b INT
195f0 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a  , c DEFAULT 0);.
19600 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45 20    CREATE UNIQUE 
19610 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74 31  INDEX t1x1 ON t1
19620 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54 20  (a+b);.  INSERT 
19630 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
19640 55 45 53 28 37 32 30 30 31 32 30 30 31 2d 30 31  UES(720012001-01
19650 2d 30 31 2d 30 31 2d 30 31 2c 38 29 20 4f 4e 20  -01-01-01,8) ON 
19660 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20 44 4f  CONFLICT(a+b) DO
19670 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45   NOTHING;.  INSE
19680 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
19690 56 41 4c 55 45 53 28 38 2c 37 29 2c 28 39 2c 36  VALUES(8,7),(9,6
196a0 29 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b  ) ON CONFLICT(a+
196b0 62 29 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20  b) DO NOTHING;. 
196c0 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 74   SELECT * FROM t
196d0 31 3b 0a 81 7b 66 04 00 83 7b 20 20 43 52 45 41  1;..{f...{  CREA
196e0 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
196f0 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
19700 59 2c 20 62 20 49 4e 54 2c 20 63 20 44 45 46 41  Y, b INT, c DEFA
19710 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45  ULT 0);.  CREATE
19720 20 55 4e 49 51 55 45 20 49 4e 44 45 58 20 74 31   UNIQUE INDEX t1
19730 78 31 20 4f 4e 20 74 31 28 61 2b 62 29 3b 0a 20  x1 ON t1(a+b);. 
19740 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
19750 61 2c 62 29 20 56 41 4c 55 45 53 28 37 32 30 30  a,b) VALUES(7200
19760 31 2d 30 31 2d 30 31 2c 38 29 20 4f 4e 20 43 4f  1-01-01,8) ON CO
19770 4e 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e  NFLICT(a+b) DO N
19780 4f 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54  OTHING;.  INSERT
19790 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
197a0 4c 55 45 53 28 39 2c 37 29 2c 28 39 2c 36 29 20  LUES(9,7),(9,6) 
197b0 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29  ON CONFLICT(a+b)
197c0 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 31 3b   DO NOTHING;. 1;
197d0 0a 82 0b 65 04 00 84 1b 20 20 43 52 45 41 54 45  ...e....  CREATE
197e0 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45   TABLE t1(a INTE
197f0 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c  GER PRIMARY KEY,
19800 20 62 20 49 4e 54 2c 20 63 20 44 45 46 41 55 4c   b INT, c DEFAUL
19810 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 55  T 0);.  CREATE U
19820 4e 49 51 55 45 20 49 4e 44 45 58 20 74 31 78 31  NIQUE INDEX t1x1
19830 20 4f 4e 20 74 31 28 61 2b 62 29 3b 0a 20 20 49   ON t1(a+b);.  I
19840 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
19850 62 29 20 56 41 4c 55 45 53 28 37 32 30 30 31 2d  b) VALUES(72001-
19860 30 31 2d 30 31 2c 38 29 20 4f 4e 20 43 4f 4e 46  01-01,8) ON CONF
19870 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54  LICT(a+b) DO NOT
19880 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20 49  HING;.  INSERT I
19890 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
198a0 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f 4e  ES(8,7),(9,6) ON
198b0 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20 44   CONFLICT(a+b) D
198c0 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45 4c  O NOTHING;.  SEL
198d0 45 43 54 20 2a 20 46 52 4f 4d 20 74 31 3b 0a 82  ECT * FROM t1;..
198e0 08 64 04 00 84 15 20 20 43 52 45 41 54 45 20 54  .d....  CREATE T
198f0 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45  ABLE t1(a INTEGE
19900 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62  R PRIMARY KEY, b
19910 20 49 4e 54 2c 20 63 20 44 45 46 41 55 4c 54 20   INT, c DEFAULT 
19920 30 29 3b 0a 20 20 43 52 45 41 54 45 20 55 4e 49  0);.  CREATE UNI
19930 51 55 45 20 49 4e 44 45 58 20 74 31 78 31 20 4f  QUE INDEX t1x1 O
19940 4e 20 74 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53  N t1(a+b);.  INS
19950 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
19960 20 56 41 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20   VALUES(7,8) ON 
19970 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20 44 4f  CONFLICT(a+b) DO
19980 20 4e 4f 54 48 49 4e 47 3b 45 58 50 4c 41 49 4e   NOTHING;EXPLAIN
19990 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
199a0 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 38 2c  1(a,b) VALUES(8,
199b0 37 29 2c 28 39 2c 36 29 20 4f 4e 20 43 4f 4e 46  7),(9,6) ON CONF
199c0 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54  LICT(a+b) DO NOT
199d0 48 49 4e 47 3b 0a 20 20 53 45 4c 45 43 54 20 32  HING;.  SELECT 2
199e0 20 46 52 4f 4d 20 74 31 3b 0a 81 6d 63 04 00 83   FROM t1;..mc...
199f0 5f 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  _  CREATE TABLE 
19a00 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49  t1(a INTEGER PRI
19a10 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e 54 2c  MARY KEY, b INT,
19a20 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20   c DEFAULT 0);. 
19a30 20 43 52 45 41 54 45 20 55 4e 49 51 55 45 20 49   CREATE UNIQUE I
19a40 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74 31 28  NDEX t1x1 ON t1(
19a50 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54 20 49  a+b);.  INSERT I
19a60 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
19a70 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e 46 4c  ES(7,8) ON CONFL
19a80 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54 48  ICT(a+b) DO NOTH
19a90 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ING;.  INSERT IN
19aa0 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
19ab0 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f 4e 20  S(8,7),(9,6) ON 
19ac0 43 4f 4e 46 4c 49 43 54 28 61 2b 63 29 20 44 4f  CONFLICT(a+c) DO
19ad0 20 4e 4f 54 48 49 4e 47 3b 0a 82 01 62 04 00 84   NOTHING;...b...
19ae0 07 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
19af0 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49  t1(a INTEGER PRI
19b00 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e 54 2c  MARY KEY, b INT,
19b10 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20   c DEFAULT 0);. 
19b20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45 20 49   CREATE UNIQUE I
19b30 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74 31 28  NDEX t1x1 ON t1(
19b40 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54 20 49  a+b);.  INSERT I
19b50 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
19b60 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e 46 4c  ES(7,8) ON CONFL
19b70 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54 48  ICT(a+b) DO NOTH
19b80 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ING;.  INSERT IN
19b90 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
19ba0 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f 4e 20  S(8,7),(9,6) ON 
19bb0 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20 44 4f  CONFLICT(a+b) DO
19bc0 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45 4c 45   NOTHING;.  SELE
19bd0 43 54 23 80 31 46 52 4f 4d 20 74 31 3b 0a 82 13  CT#.1FROM t1;...
19be0 61 04 00 84 2b 20 20 43 52 45 41 54 45 20 54 41  a...+  CREATE TA
19bf0 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52  BLE t1(a INTEGER
19c00 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20   PRIMARY KEY, b 
19c10 49 4e 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30  INT, c DEFAULT 0
19c20 29 3b 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51  );.  CREATE UNIQ
19c30 55 45 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e  UE INDEX t1x1 ON
19c40 20 74 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45   t1(a+b);.  INSE
19c50 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
19c60 56 41 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43  VALUES(7,8) ON C
19c70 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20  ONFLICT(a+b) DO 
19c80 4e 4f 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52  NOTHING;.  INSER
19c90 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
19ca0 41 4c 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29  ALUES(8,7),(9,6)
19cb0 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62   ON CONFLICT(a+b
19cc0 29 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20  ) DO NOTHING;.  
19cd0 53 45 4c 45 43 54 20 44 49 53 54 49 4e 43 54 3f  SELECT DISTINCT?
19ce0 20 67 6c 6f 62 28 31 2c 31 29 20 46 52 4f 4d 20   glob(1,1) FROM 
19cf0 74 31 3b 0a 82 01 60 04 00 84 07 20 20 43 52 45  t1;...`....  CRE
19d00 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49  ATE TABLE t1(a I
19d10 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b  NTEGER PRIMARY K
19d20 45 59 2c 20 62 20 49 4e 54 2c 20 63 20 44 45 46  EY, b INT, c DEF
19d30 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54  AULT 0);.  CREAT
19d40 45 20 55 4e 49 51 55 45 20 49 4e 44 45 58 20 74  E UNIQUE INDEX t
19d50 31 78 31 20 4f 4e 20 74 31 28 61 2b 62 29 3b 0a  1x1 ON t1(a+b);.
19d60 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
19d70 28 61 2c 62 29 20 56 41 4c 55 45 53 28 37 2c 38  (a,b) VALUES(7,8
19d80 29 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b  ) ON CONFLICT(a+
19d90 62 29 20 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20  b) DO NOTHING;. 
19da0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
19db0 61 2c 62 29 20 56 41 4c 55 45 53 28 38 2c 37 29  a,b) VALUES(8,7)
19dc0 2c 28 39 2c 36 29 20 4f 4e 20 43 4f 4e 46 4c 49  ,(9,6) ON CONFLI
19dd0 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54 48 49  CT(a+b) DO NOTHI
19de0 4e 47 3b 0a 20 20 53 45 4c 45 43 54 20 41 20 46  NG;.  SELECT A F
19df0 52 4f 4d 20 74 31 3b 0a 82 01 5f 04 00 84 07 20  ROM t1;..._.... 
19e00 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
19e10 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41  (a INTEGER PRIMA
19e20 52 59 20 4b 45 59 2c 20 62 20 49 4e 54 2c 20 63  RY KEY, b INT, c
19e30 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43   DEFAULT 0);.  C
19e40 52 45 41 54 45 20 55 4e 49 51 55 45 20 49 4e 44  REATE UNIQUE IND
19e50 45 58 20 74 31 78 31 20 4f 4e 20 74 31 28 61 2b  EX t1x1 ON t1(a+
19e60 62 29 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  b);.  INSERT INT
19e70 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
19e80 28 37 2c 38 29 20 4f 4e 20 43 4f 4e 46 4c 49 43  (7,8) ON CONFLIC
19e90 54 28 61 2b 62 29 20 44 4f 20 4e 4f 54 48 49 4e  T(a+b) DO NOTHIN
19ea0 47 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  G;.  INSERT INTO
19eb0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
19ec0 38 2c 37 29 2c 28 39 2c 36 29 20 4f 4e 20 43 4f  8,7),(9,6) ON CO
19ed0 4e 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e  NFLICT(a+b) DO N
19ee0 4f 54 48 49 4e 47 3b 0a 20 20 53 45 4c 45 43 54  OTHING;.  SELECT
19ef0 20 40 31 46 52 4f 4d 00 74 31 3b 0a 82 01 5e 04   @1FROM.t1;...^.
19f00 00 84 07 20 20 43 52 45 41 54 45 20 54 41 42 4c  ...  CREATE TABL
19f10 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50  E t1(a INTEGER P
19f20 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 49 4e  RIMARY KEY, b IN
19f30 54 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  T, c DEFAULT 0);
19f40 0a 20 20 43 52 45 41 54 45 20 55 4e 49 51 55 45  .  CREATE UNIQUE
19f50 20 49 4e 44 45 58 20 74 31 78 31 20 4f 4e 20 74   INDEX t1x1 ON t
19f60 31 28 61 2b 62 29 3b 0a 20 20 49 4e 53 45 52 54  1(a+b);.  INSERT
19f70 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
19f80 4c 55 45 53 28 37 2c 38 29 20 4f 4e 20 43 4f 4e  LUES(7,8) ON CON
19f90 46 4c 49 43 54 28 61 2b 62 29 20 44 4f 20 4e 4f  FLICT(a+b) DO NO
19fa0 54 48 49 4e 47 3b 0a 20 20 49 4e 53 45 52 54 20  THING;.  INSERT 
19fb0 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
19fc0 55 45 53 28 38 2c 37 29 2c 28 39 2c 36 29 20 4f  UES(8,7),(9,6) O
19fd0 4e 20 43 4f 4e 46 4c 49 43 54 28 61 2b 62 29 20  N CONFLICT(a+b) 
19fe0 44 4f 20 4e 4f 54 48 49 4e 47 3b 0a 20 20 53 45  DO NOTHING;.  SE
19ff0 4c 45 43 54 20 40 31 46 52 4f 20 5b 61 5d 3b 0a  LECT @1FRO [a];.
1a000 0d 00 00 00 08 00 57 00 1b 9d 1a 2e 15 da 11 8d  ......W.........
1a010 0d 40 08 f3 04 a5 00 57 00 00 00 00 00 00 00 00  .@.....W........
1a020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1a030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1a040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1a050 00 00 00 00 00 00 00 88 4a 81 01 04 00 91 19 20  ........J...... 
1a060 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
1a070 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41  (a INTEGER PRIMA
1a080 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63  RY KEY, b int, c
1a090 20 44 45 46 41 55 4c 54 20 27 61 27 27 62 27 20   DEFAULT 'a''b' 
1a0a0 20 2c 20 56 29 3b 0a 2c 20 79 20 54 45 58 54 29   , V);., y TEXT)
1a0b0 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
1a0c0 45 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53  ER r1 BEFORE INS
1a0d0 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ERT ON t1 BEGIN.
1a0e0 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
1a0f0 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
1a100 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f      VALUES('befo
1a110 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74  re-insert',print
1a120 66 28 53 28 27 27 25 64 2c 25 64 2c 25 64 27 2c  f(S(''%d,%d,%d',
1a130 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
1a140 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
1a150 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20  EATE TRIGGER r2 
1a160 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20  AFTER INSERT ON 
1a170 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
1a180 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 50 28  ERT INTO recorP(
1a190 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28  x,y)     VALUES(
1a1a0 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70  'after-insert',p
1a1b0 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27  rintf('%d,%d,%d'
1a1c0 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
1a1d0 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
1a1e0 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33  REATE TRIGGER r3
1a1f0 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f   BEFORE UPDATE O
1a200 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
1a210 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
1a220 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
1a230 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70  ALUES('before-up
1a240 40 00 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  @.te',printf('%d
1a250 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
1a260 2c 0a 20 20 20 20 20 20 20 20 41 20 20 20 20 20  ,.        A     
1a270 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1a280 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e  old.a,old.b,old.
1a290 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  c,new.a,new.b,ne
1a2a0 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
1a2b0 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
1a2c0 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f  4 AFTER UPDATE O
1a2d0 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
1a2e0 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
1a2f0 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
1a300 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64  ALUES('after-upd
1a310 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
1a320 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
1a330 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
1a340 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1a350 20 20 20 20 20 20 20 6f 6c 66 2e 61 2c 6f 6c 64         olf.a,old
1a360 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
1a370 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
1a380 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  END;.  INSERT IN
1a390 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
1a3a0 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45  S(1,2);.  DELETE
1a3b0 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
1a3c0 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
1a3d0 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
1a3e0 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
1a3f0 61 0f 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a. DO UPDATE SET
1a400 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c   c=t1.c+1;.  SEL
1a410 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
1a420 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  d;.  DELETE FROM
1a430 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
1a440 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
1a450 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
1a460 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
1a470 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b   UPDATE SET c=c+
1a480 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53  1 WHERE c<0;.  S
1a490 45 60 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63  E`ECT * FROM rec
1a4a0 6f 72 64 3b 0a 88 4a 81 00 04 00 91 19 20 20 43  ord;..J......  C
1a4b0 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 61  REATE TABLE t1(a
1a4c0 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59   INTEGER PRIMARY
1a4d0 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44   KEY, b int, c D
1a4e0 45 46 41 55 4c 54 20 27 61 27 27 62 27 20 20 20  EFAULT 'a''b'   
1a4f0 2c 56 29 3b 0a 2c 20 79 20 54 45 58 54 29 3b 0a  ,V);., y TEXT);.
1a500 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
1a510 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52   r1 BEFORE INSER
1a520 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
1a530 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
1a540 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
1a550 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
1a560 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
1a570 53 28 27 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65  S(''%d,%d,%d',ne
1a580 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
1a590 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
1a5a0 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46  TE TRIGGER r2 AF
1a5b0 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  TER INSERT ON t1
1a5c0 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
1a5d0 54 20 49 4e 54 4f 20 72 65 63 6f 72 50 28 78 2c  T INTO recorP(x,
1a5e0 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27 61  y)     VALUES('a
1a5f0 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69  fter-insert',pri
1a600 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
1a610 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
1a620 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
1a630 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42  ATE TRIGGER r3 B
1a640 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20  EFORE UPDATE ON 
1a650 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
1a660 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
1a670 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
1a680 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 40 00  UES('before-up@.
1a690 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
1a6a0 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
1a6b0 20 20 20 20 20 20 20 20 41 20 20 20 20 20 20 20          A       
1a6c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
1a6d0 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
1a6e0 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
1a6f0 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
1a700 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20  EATE TRIGGER r4 
1a710 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20  AFTER UPDATE ON 
1a720 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
1a730 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
1a740 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
1a750 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74  UES('after-updat
1a760 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
1a770 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
1a780 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1a790 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1a7a0 20 20 20 20 20 6f 6c 66 2e 61 2c 6f 6c 64 2e 62       olf.a,old.b
1a7b0 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
1a7c0 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
1a7d0 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  D;.  INSERT INTO
1a7e0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
1a7f0 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46  1,2);.  DELETE F
1a800 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e  ROM record;.  IN
1a810 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
1a820 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20  ) VALUES(1,2).  
1a830 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 0f    ON CONFLICT(a.
1a840 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
1a850 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43  =t1.c+1;.  SELEC
1a860 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
1a870 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
1a880 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
1a890 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
1a8a0 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
1a8b0 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
1a8c0 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20  PDATE SET c=c+1 
1a8d0 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 60  WHERE c<0;.  SE`
1a8e0 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
1a8f0 64 3b 0a 88 4a 7f 04 00 91 19 20 20 43 52 45 41  d;..J.....  CREA
1a900 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
1a910 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
1a920 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41  Y, b int, c DEFA
1a930 55 4c 54 20 27 61 27 27 62 27 20 20 20 20 56 29  ULT 'a''b'    V)
1a940 3b 0a 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43  ;., y TEXT);.  C
1a950 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31  REATE TRIGGER r1
1a960 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f   BEFORE INSERT O
1a970 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
1a980 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
1a990 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
1a9a0 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e  ALUES('before-in
1a9b0 73 65 72 74 27 2c 70 72 69 6e 74 66 28 53 28 27  sert',printf(S('
1a9c0 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
1a9d0 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
1a9e0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
1a9f0 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
1aa00 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
1aa10 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
1aa20 4e 54 4f 20 72 65 63 6f 72 50 28 78 2c 79 29 20  NTO recorP(x,y) 
1aa30 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
1aa40 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
1aa50 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%d,%d,%d',new.
1aa60 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
1aa70 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
1aa80 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
1aa90 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
1aaa0 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
1aab0 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
1aac0 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
1aad0 28 27 62 65 66 6f 72 65 2d 75 70 40 00 74 65 27  ('before-up@.te'
1aae0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
1aaf0 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
1ab00 20 20 20 20 20 41 20 20 20 20 20 20 20 20 20 20       A          
1ab10 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
1ab20 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
1ab30 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
1ab40 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
1ab50 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
1ab60 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
1ab70 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
1ab80 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
1ab90 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
1aba0 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
1abb0 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
1abc0 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
1abd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1abe0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1abf0 20 20 6f 6c 66 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    olf.a,old.b,ol
1ac00 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
1ac10 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
1ac20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
1ac30 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
1ac40 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
1ac50 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
1ac60 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
1ac70 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
1ac80 4e 20 43 4f 4e 46 4c 49 43 54 28 61 0f 20 44 4f  N CONFLICT(a. DO
1ac90 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
1aca0 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
1acb0 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
1acc0 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
1acd0 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
1ace0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
1acf0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
1ad00 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
1ad10 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
1ad20 52 45 20 63 3c 30 3b 0a 20 20 53 45 60 45 43 54  RE c<0;.  SE`ECT
1ad30 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
1ad40 88 4a 7e 04 00 91 19 20 20 43 52 45 41 54 45 20  .J~....  CREATE 
1ad50 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47  TABLE t1(a INTEG
1ad60 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  ER PRIMARY KEY, 
1ad70 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
1ad80 20 27 61 27 20 20 20 20 20 20 2c 56 29 3b 0a 2c   'a'      ,V);.,
1ad90 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41   y TEXT);.  CREA
1ada0 54 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45  TE TRIGGER r1 BE
1adb0 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74  FORE INSERT ON t
1adc0 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
1add0 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
1ade0 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
1adf0 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72  ES('before-inser
1ae00 74 27 2c 70 72 69 6e 74 66 28 53 28 27 27 25 64  t',printf(S(''%d
1ae10 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65  ,%d,%d',new.a,ne
1ae20 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
1ae30 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
1ae40 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49 4e  GGER r2 AFTER IN
1ae50 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
1ae60 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
1ae70 20 72 65 63 6f 72 50 28 78 2c 79 29 20 20 20 20   recorP(x,y)    
1ae80 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69   VALUES('after-i
1ae90 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25  nsert',printf('%
1aea0 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e  d,%d,%d',new.a,n
1aeb0 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
1aec0 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
1aed0 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20  IGGER r3 BEFORE 
1aee0 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
1aef0 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
1af00 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
1af10 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
1af20 65 66 6f 72 65 2d 75 70 40 00 74 65 27 2c 70 72  efore-up@.te',pr
1af30 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
1af40 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
1af50 20 20 41 20 20 20 20 20 20 20 20 20 20 20 20 20    A             
1af60 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
1af70 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
1af80 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
1af90 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
1afa0 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20  RIGGER r4 AFTER 
1afb0 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
1afc0 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
1afd0 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
1afe0 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61         VALUES('a
1aff0 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69  fter-update',pri
1b000 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
1b010 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
1b020 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1b030 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
1b040 6c 66 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  lf.a,old.b,old.c
1b050 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
1b060 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49  .c));.  END;.  I
1b070 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
1b080 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a  b) VALUES(1,2);.
1b090 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
1b0a0 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
1b0b0 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
1b0c0 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43  ES(1,2).    ON C
1b0d0 4f 4e 46 4c 49 43 54 28 61 0f 20 44 4f 20 55 50  ONFLICT(a. DO UP
1b0e0 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b  DATE SET c=t1.c+
1b0f0 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52  1;.  SELECT * FR
1b100 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c  OM record;.  DEL
1b110 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  ETE FROM record;
1b120 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
1b130 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
1b140 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49  2).    ON CONFLI
1b150 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20  CT(a) DO UPDATE 
1b160 53 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20  SET c=c+1 WHERE 
1b170 63 3c 30 3b 0a 20 20 53 45 60 45 43 54 20 2a 20  c<0;.  SE`ECT * 
1b180 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 4a 7d  FROM record;..J}
1b190 04 00 91 19 20 20 43 52 45 41 54 45 20 54 41 42  ....  CREATE TAB
1b1a0 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20  LE t1(a INTEGER 
1b1b0 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
1b1c0 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 27 61  nt, c DEFAULT 'a
1b1d0 27 20 20 20 20 20 20 20 56 29 3b 0a 2c 20 79 20  '       V);., y 
1b1e0 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20  TEXT);.  CREATE 
1b1f0 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52  TRIGGER r1 BEFOR
1b200 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  E INSERT ON t1 B
1b210 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
1b220 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
1b230 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
1b240 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c  'before-insert',
1b250 70 72 69 6e 74 66 28 53 28 27 27 25 64 2c 25 64  printf(S(''%d,%d
1b260 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
1b270 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
1b280 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
1b290 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52  R r2 AFTER INSER
1b2a0 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
1b2b0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
1b2c0 63 6f 72 50 28 78 2c 79 29 20 20 20 20 20 56 41  corP(x,y)     VA
1b2d0 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65  LUES('after-inse
1b2e0 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  rt',printf('%d,%
1b2f0 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e  d,%d',new.a,new.
1b300 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
1b310 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
1b320 45 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44  ER r3 BEFORE UPD
1b330 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
1b340 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
1b350 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
1b360 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f      VALUES('befo
1b370 72 65 2d 75 70 40 00 74 65 27 2c 70 72 69 6e 74  re-up@.te',print
1b380 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25  f('%d,%d,%d/%d,%
1b390 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 41  d,%d',.        A
1b3a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1b3b0 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
1b3c0 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
1b3d0 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
1b3e0 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
1b3f0 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44  GER r4 AFTER UPD
1b400 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
1b410 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
1b420 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
1b430 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
1b440 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  r-update',printf
1b450 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
1b460 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
1b470 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1b480 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 66 2e              olf.
1b490 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65  a,old.b,old.c,ne
1b4a0 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
1b4b0 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45  );.  END;.  INSE
1b4c0 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
1b4d0 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44  VALUES(1,2);.  D
1b4e0 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
1b4f0 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
1b500 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
1b510 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46  1,2).    ON CONF
1b520 4c 49 43 54 28 61 0f 20 44 4f 20 55 50 44 41 54  LICT(a. DO UPDAT
1b530 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a  E SET c=t1.c+1;.
1b540 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
1b550 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45  record;.  DELETE
1b560 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
1b570 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
1b580 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
1b590 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
1b5a0 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
1b5b0 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30   c=c+1 WHERE c<0
1b5c0 3b 0a 20 20 53 45 60 45 43 54 20 2a 20 46 52 4f  ;.  SE`ECT * FRO
1b5d0 4d 20 72 65 63 6f 72 64 3b 0a 88 51 7c 04 00 91  M record;..Q|...
1b5e0 27 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  '  CREATE TABLE 
1b5f0 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49  t1(a INTEGER PRI
1b600 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c  MARY KEY, b int,
1b610 20 63 20 44 45 46 41 55 4c 54 20 27 20 61 62 73   c DEFAULT ' abs
1b620 28 31 29 61 27 27 62 27 20 20 20 20 56 29 3b 0a  (1)a''b'    V);.
1b630 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45  , y TEXT);.  CRE
1b640 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20 42  ATE TRIGGER r1 B
1b650 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20  EFORE INSERT ON 
1b660 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
1b670 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
1b680 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
1b690 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65  UES('before-inse
1b6a0 72 74 27 2c 70 72 69 6e 74 66 28 53 28 27 27 25  rt',printf(S(''%
1b6b0 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e  d,%d,%d',new.a,n
1b6c0 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
1b6d0 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
1b6e0 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49  IGGER r2 AFTER I
1b6f0 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
1b700 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
1b710 4f 20 72 65 63 6f 72 50 28 78 2c 79 29 20 20 20  O recorP(x,y)   
1b720 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
1b730 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
1b740 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c  %d,%d,%d',new.a,
1b750 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
1b760 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
1b770 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45  RIGGER r3 BEFORE
1b780 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
1b790 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
1b7a0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
1b7b0 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
1b7c0 62 65 66 6f 72 65 2d 75 70 40 00 74 65 27 2c 70  before-up@.te',p
1b7d0 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
1b7e0 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
1b7f0 20 20 20 41 20 20 20 20 20 20 20 20 20 20 20 20     A            
1b800 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
1b810 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
1b820 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
1b830 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
1b840 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52  TRIGGER r4 AFTER
1b850 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
1b860 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
1b870 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
1b880 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
1b890 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72  after-update',pr
1b8a0 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
1b8b0 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
1b8c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1b8d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1b8e0 6f 6c 66 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e  olf.a,old.b,old.
1b8f0 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  c,new.a,new.b,ne
1b900 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
1b910 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
1b920 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b  ,b) VALUES(1,2);
1b930 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
1b940 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
1b950 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
1b960 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
1b970 43 4f 4e 46 4c 49 43 54 28 61 0f 20 44 4f 20 55  CONFLICT(a. DO U
1b980 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63  PDATE SET c=t1.c
1b990 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  +1;.  SELECT * F
1b9a0 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45  ROM record;.  DE
1b9b0 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
1b9c0 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
1b9d0 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
1b9e0 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,2).    ON CONFL
1b9f0 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
1ba00 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45   SET c=c+1 WHERE
1ba10 20 63 3c 30 3b 0a 20 20 53 45 60 45 43 54 20 2a   c<0;.  SE`ECT *
1ba20 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 82 6c   FROM record;..l
1ba30 7b 04 00 85 5d 20 20 43 52 45 41 54 45 20 54 41  {...]  CREATE TA
1ba40 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52  BLE t1(a INTEGER
1ba50 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20   PRIMARY KEY, b 
1ba60 69 6e 74 2c 20 63 20 44 45 46 41 20 61 2c 62 30  int, c DEFA a,b0
1ba70 29 57 49 54 48 4f 55 54 20 52 4f 57 49 44 3b 0a  )WITHOUT ROWID;.
1ba80 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
1ba90 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
1baa0 29 2c 28 33 2c 34 29 3b 0a 20 20 57 49 54 48 20  ),(3,4);.  WITH 
1bab0 6e 78 28 61 2c 62 29 20 41 53 20 28 56 41 4c 55  nx(a,b) AS (VALU
1bac0 45 53 28 31 2c 38 29 2c 28 32 2c 31 31 29 2c 28  ES(1,8),(2,11),(
1bad0 33 2c 31 29 2c 28 32 2c 31 35 29 2c 28 31 2c 34  3,1),(2,15),(1,4
1bae0 29 2c 28 31 2c 39 39 29 29 0a 20 20 49 4e 53 45  ),(1,99)).  INSE
1baf0 52 54 20 49 4e 54 4f 20 6d 61 69 6e 2e 74 31 20  RT INTO main.t1 
1bb00 41 53 20 74 32 28 61 2c 62 29 20 53 45 4c 45 43  AS t2(a,b) SELEC
1bb10 54 20 61 2c 20 62 20 46 52 4f 4d 20 6e 78 20 57  T a, b FROM nx W
1bb20 48 45 52 45 20 74 72 75 65 0a 20 20 20 20 4f 4e  HERE true.    ON
1bb30 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
1bb40 55 50 44 41 54 45 20 53 45 54 20 62 3d 65 78 63  UPDATE SET b=exc
1bb50 6c 75 64 65 64 2e 62 2c 20 63 3d 74 32 2e 63 2b  luded.b, c=t2.c+
1bb60 43 55 52 52 45 4e 54 5f 44 41 54 45 3c 65 78 63  CURRENT_DATE<exc
1bb70 6c 75 64 65 64 2e 62 3b 0a 20 20 53 45 4c 45 43  luded.b;.  SELEC
1bb80 54 20 2a 2c 20 27 78 27 20 46 52 4f 4d 20 74 31  T *, 'x' FROM t1
1bb90 20 4f 52 44 45 52 20 42 59 20 61 3b 0a 88 60 7a   ORDER BY a;..`z
1bba0 04 00 91 45 20 20 43 52 45 41 54 45 20 54 41 42  ...E  CREATE TAB
1bbb0 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20  LE t1(a INTEGER 
1bbc0 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
1bbd0 6e 74 2c 20 63 20 44 45 46 41 20 61 2c 62 30 29  nt, c DEFA a,b0)
1bbe0 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ;.  CREATE TABLE
1bbf0 20 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20   record(x TEXT, 
1bc00 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54  y TEXT);.  CREAT
1bc10 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46  E TRIGGER r1 BEF
1bc20 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  ORE INSERT ON t1
1bc30 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
1bc40 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
1bc50 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
1bc60 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74  S('before-insert
1bc70 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
1bc80 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
1bc90 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
1bca0 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
1bcb0 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54   r2 AFTER INSERT
1bcc0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
1bcd0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
1bce0 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c  ord(x,y)     VAL
1bcf0 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72  UES('after-inser
1bd00 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  t',printf('%d,%d
1bd10 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
1bd20 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
1bd30 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
1bd40 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41  R r3 BEFORE UPDA
1bd50 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
1bd60 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
1bd70 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
1bd80 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
1bd90 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  e-update',printf
1bda0 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
1bdb0 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
1bdc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1bdd0 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
1bde0 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
1bdf0 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
1be00 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
1be10 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41  ER r4 AFTER UPDA
1be20 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
1be30 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
1be40 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
1be50 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
1be60 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
1be70 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
1be80 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
1be90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1bea0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
1beb0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
1bec0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
1bed0 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52  ;.  END;.  INSER
1bee0 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
1bef0 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45  ALUES(1,2);.  DE
1bf00 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
1bf10 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
1bf20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
1bf30 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,2).    ON CONFL
1bf40 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
1bf50 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20   SET c=t1.c+1;. 
1bf60 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
1bf70 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20  ecord;.  DELETE 
1bf80 46 52 4f 4d 20 72 65 63 6f 72 64 3b 45 58 50 4c  FROM record;EXPL
1bf90 41 49 4e 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  AIN.  INSERT INT
1bfa0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
1bfb0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
1bfc0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
1bfd0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
1bfe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
1bff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
1c000 0d 00 00 00 07 01 d9 00 1b b2 17 64 13 16 0e c8  ...........d....
1c010 0a 7a 06 2c 01 d9 00 00 00 00 00 00 00 00 00 00  .z.,............
1c020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c0a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c0b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c0c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c0d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c0e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c0f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c1a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c1b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c1c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1c1d0 00 00 00 00 00 00 00 00 00 88 4f 81 08 04 00 91  ..........O.....
1c1e0 23 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  #  CREATE TABLE 
1c1f0 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49  t1(a INTEGER PRI
1c200 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c  MARY KEY, b int,
1c210 20 63 20 44 45 46 41 55 4c 54 20 30 20 20 20 20   c DEFAULT 0    
1c220 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1c230 20 20 20 20 29 3b 0a 20 20 43 52 45 41 54 45 20      );.  CREATE 
1c240 54 41 42 4c 45 20 72 65 63 84 72 64 28 78 20 54  TABLE rec.rd(x T
1c250 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20  EXT, y TEXT);.  
1c260 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
1c270 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20  1 BEFORE INSERT 
1c280 4e 4f 54 20 49 4e 44 45 58 45 44 4f 4e 20 74 31  NOT INDEXEDON t1
1c290 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
1c2a0 54 20 49 4e 54 4f 20 72 de de de de de de de de  T INTO r........
1c2b0 de de de de de de de de de de de de de 65 63 6f  .............eco
1c2c0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
1c2d0 56 41 4c 55 45 8b 28 27 62 65 66 6f 72 65 2d 69  VALUE.('before-i
1c2e0 6e 73 65 72 74 27 2c 70 72 69 00 00 10 00 27 25  nsert',pri....'%
1c2f0 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e  d,%d,%d',new.a,n
1c300 65 77 2e 62 2c 6e 65 77 2e 63 29 29 20 0a 20 20  ew.b,new.c)) .  
1c310 45 4e 44 39 0a 20 20 43 52 41 46 54 45 52 20 49  END9.  CRAFTER I
1c320 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 01 49  NSERT ON t1 BE.I
1c330 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
1c340 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20  O record(x,y)   
1c350 20 20 56 41 4c 55 45 3e 28 27 61 66 74 65 72 2d    VALUE>('after-
1c360 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
1c370 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c  %d,%d,%d',new.a,
1c380 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
1c390 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
1c3a0 52 49 47 47 45 52 20 72 85 20 42 45 46 4f 52 45  RIGGER r. BEFORE
1c3b0 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
1c3c0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
1c3d0 4e 54 00 10 72 65 63 6f 72 64 28 78 2c 69 29 0a  NT..record(x,i).
1c3e0 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 67          VALUES(g
1c3f0 20 6c 6f 77 65 72 28 31 11 62 65 66 6f 72 65 2d   lower(1.before-
1c400 75 70 54 54 54 54 54 54 54 54 54 5d 54 54 54 54  upTTTTTTTTT]TTTT
1c410 54 54 54 64 61 74 65 27 2c 70 72 69 6e 74 66 28  TTTdate',printf(
1c420 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 20 20 20  '%d,%d,%d/%d,   
1c430 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
1c440 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
1c450 4e 54 4f 20 72 de de de de de de de 2c 6f 6c 64  NTO r.......,old
1c460 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
1c470 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
1c480 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
1c490 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55  IGGER r4 AFTER U
1c4a0 50 44 41 54 45 20 4f 4e 20 74 30 20 42 45 47 49  PDATE ON t0 BEGI
1c4b0 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
1c4c0 4f 2a 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O*record(x,y).  
1c4d0 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
1c4e0 74 65 72 2d 8e 70 64 61 74 65 27 2c 70 72 69 6e  ter-.pdate',prin
1c4f0 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
1c500 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
1c510 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1c520 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
1c530 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
1c540 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 85 2e  new.a,new.b,ne..
1c550 63 29 29 3b 0a 20 20 45 4e 41 4c 55 45 53 28 31  c));.  ENALUES(1
1c560 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  ,2);.  DELETE FR
1c570 4f 4d 20 72 65 63 6f 72 49 4e 54 4f 20 74 31 28  OM recorINTO t1(
1c580 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
1c590 0a 20 20 72 69 6e 74 66 43 4f 4e 46 4c 49 43 54  .  rintfCONFLICT
1c5a0 28 61 29 20 44 4f 20 55 50 44 41 2a 20 46 52 4f  (a) DO UPDA* FRO
1c5b0 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45  M record;.  DELE
1c5c0 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
1c5d0 20 04 49 4e 53 45 52 54 20 49 4e 54 4f 20 2c 32   .INSERT INTO ,2
1c5e0 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
1c5f0 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
1c600 45 54 20 63 74 72 69 31 20 57 48 45 52 45 20 63  ET ctri1 WHERE c
1c610 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  <0;.  SELECT * F
1c620 52 4f 4d 20 72 65 63 6f 72 64 20 0a 88 4a 81 07  ROM record ..J..
1c630 04 00 91 19 20 20 43 52 45 41 54 45 20 54 41 42  ....  CREATE TAB
1c640 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20  LE t1(a INTEGER 
1c650 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
1c660 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 0a  nt, c DEFAULT 0.
1c670 2c 20 20 20 20 20 20 20 56 29 3b 0a 2c 20 79 20  ,       V);., y 
1c680 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20  TEXT);.  CREATE 
1c690 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52  TRIGGER r1 BEFOR
1c6a0 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  E INSERT ON t1 B
1c6b0 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
1c6c0 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
1c6d0 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
1c6e0 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c  'before-insert',
1c6f0 70 72 69 6e 74 66 28 53 28 27 27 25 64 2c 25 64  printf(S(''%d,%d
1c700 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
1c710 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
1c720 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
1c730 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52  R r2 AFTER INSER
1c740 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
1c750 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
1c760 63 6f 72 50 28 78 2c 79 29 20 20 20 20 20 56 41  corP(x,y)     VA
1c770 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65  LUES('after-inse
1c780 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  rt',printf('%d,%
1c790 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e  d,%d',new.a,new.
1c7a0 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
1c7b0 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
1c7c0 45 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44  ER r3 BEFORE UPD
1c7d0 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
1c7e0 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
1c7f0 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
1c800 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f      VALUES('befo
1c810 72 65 2d 75 70 40 00 74 65 27 2c 70 72 69 6e 74  re-up@.te',print
1c820 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25  f('%d,%d,%d/%d,%
1c830 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 41  d,%d',.        A
1c840 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1c850 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
1c860 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
1c870 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
1c880 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
1c890 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44  GER r4 AFTER UPD
1c8a0 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
1c8b0 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
1c8c0 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
1c8d0 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
1c8e0 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  r-update',printf
1c8f0 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
1c900 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
1c910 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1c920 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 66 2e              olf.
1c930 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65  a,old.b,old.c,ne
1c940 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
1c950 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45  );.  END;.  INSE
1c960 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
1c970 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44  VALUES(1,2);.  D
1c980 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
1c990 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
1c9a0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
1c9b0 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46  1,2).    ON CONF
1c9c0 4c 49 43 54 28 61 0f 20 44 4f 20 55 50 44 41 54  LICT(a. DO UPDAT
1c9d0 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a  E SET c=t1.c+1;.
1c9e0 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
1c9f0 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45  record;.  DELETE
1ca00 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
1ca10 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
1ca20 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
1ca30 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
1ca40 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
1ca50 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30   c=c+1 WHERE c<0
1ca60 3b 0a 20 20 53 45 60 45 43 54 20 2a 20 46 52 4f  ;.  SE`ECT * FRO
1ca70 4d 20 72 65 63 6f 72 64 3b 0a 88 4a 81 06 04 00  M record;..J....
1ca80 91 19 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ..  CREATE TABLE
1ca90 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
1caa0 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74  IMARY KEY, b int
1cab0 2c 20 63 20 44 45 46 41 55 4c 54 20 30 0a 20 20  , c DEFAULT 0.  
1cac0 2c 20 20 20 20 20 56 29 3b 0a 2c 20 79 20 54 45  ,     V);., y TE
1cad0 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52  XT);.  CREATE TR
1cae0 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20  IGGER r1 BEFORE 
1caf0 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
1cb00 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
1cb10 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
1cb20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
1cb30 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72  efore-insert',pr
1cb40 69 6e 74 66 28 53 28 27 27 25 64 2c 25 64 2c 25  intf(S(''%d,%d,%
1cb50 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
1cb60 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
1cb70 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
1cb80 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r2 AFTER INSERT 
1cb90 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
1cba0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
1cbb0 72 50 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55  rP(x,y)     VALU
1cbc0 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74  ES('after-insert
1cbd0 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
1cbe0 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
1cbf0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
1cc00 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
1cc10 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54   r3 BEFORE UPDAT
1cc20 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
1cc30 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
1cc40 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
1cc50 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
1cc60 2d 75 70 40 00 74 65 27 2c 70 72 69 6e 74 66 28  -up@.te',printf(
1cc70 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
1cc80 25 64 27 2c 0a 20 20 20 20 20 20 20 20 41 20 20  %d',.        A  
1cc90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1cca0 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f     old.a,old.b,o
1ccb0 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ld.c,new.a,new.b
1ccc0 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
1ccd0 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
1cce0 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54  R r4 AFTER UPDAT
1ccf0 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
1cd00 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
1cd10 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
1cd20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
1cd30 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
1cd40 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
1cd50 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
1cd60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1cd70 20 20 20 20 20 20 20 20 20 20 6f 6c 66 2e 61 2c            olf.a,
1cd80 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
1cd90 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
1cda0 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54  .  END;.  INSERT
1cdb0 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
1cdc0 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c  LUES(1,2);.  DEL
1cdd0 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  ETE FROM record;
1cde0 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
1cdf0 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
1ce00 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49  2).    ON CONFLI
1ce10 43 54 28 61 0f 20 44 4f 20 55 50 44 41 54 45 20  CT(a. DO UPDATE 
1ce20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20  SET c=t1.c+1;.  
1ce30 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
1ce40 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46  cord;.  DELETE F
1ce50 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e  ROM record;.  IN
1ce60 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
1ce70 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20  ) VALUES(1,2).  
1ce80 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
1ce90 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
1cea0 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a  =c+1 WHERE c<0;.
1ceb0 20 20 53 45 60 45 43 54 20 2a 20 46 52 4f 4d 20    SE`ECT * FROM 
1cec0 72 65 63 6f 72 64 3b 0a 88 4a 81 05 04 00 91 19  record;..J......
1ced0 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
1cee0 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d  1(a INTEGER PRIM
1cef0 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20  ARY KEY, b int, 
1cf00 63 20 44 45 46 41 55 4c 54 20 30 0a 20 20 20 2c  c DEFAULT 0.   ,
1cf10 20 20 20 20 56 29 3b 0a 2c 20 79 20 54 45 58 54      V);., y TEXT
1cf20 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  );.  CREATE TRIG
1cf30 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e  GER r1 BEFORE IN
1cf40 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
1cf50 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
1cf60 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
1cf70 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
1cf80 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ore-insert',prin
1cf90 74 66 28 53 28 27 27 25 64 2c 25 64 2c 25 64 27  tf(S(''%d,%d,%d'
1cfa0 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
1cfb0 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
1cfc0 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32  REATE TRIGGER r2
1cfd0 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e   AFTER INSERT ON
1cfe0 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
1cff0 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 50  SERT INTO recorP
1d000 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53  (x,y)     VALUES
1d010 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c  ('after-insert',
1d020 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
1d030 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ',new.a,new.b,ne
1d040 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
1d050 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
1d060 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20  3 BEFORE UPDATE 
1d070 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
1d080 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
1d090 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
1d0a0 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75  VALUES('before-u
1d0b0 70 40 00 74 65 27 2c 70 72 69 6e 74 66 28 27 25  p@.te',printf('%
1d0c0 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
1d0d0 27 2c 0a 20 20 20 20 20 20 20 20 41 20 20 20 20  ',.        A    
1d0e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1d0f0 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
1d100 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
1d110 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
1d120 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
1d130 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20  r4 AFTER UPDATE 
1d140 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
1d150 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
1d160 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
1d170 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70  VALUES('after-up
1d180 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
1d190 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
1d1a0 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
1d1b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1d1c0 20 20 20 20 20 20 20 20 6f 6c 66 2e 61 2c 6f 6c          olf.a,ol
1d1d0 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
1d1e0 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
1d1f0 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49   END;.  INSERT I
1d200 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
1d210 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54  ES(1,2);.  DELET
1d220 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
1d230 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
1d240 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
1d250 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
1d260 28 61 0f 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a. DO UPDATE SE
1d270 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45  T c=t1.c+1;.  SE
1d280 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
1d290 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  rd;.  DELETE FRO
1d2a0 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
1d2b0 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
1d2c0 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
1d2d0 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
1d2e0 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63  O UPDATE SET c=c
1d2f0 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20  +1 WHERE c<0;.  
1d300 53 45 60 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SE`ECT * FROM re
1d310 63 6f 72 64 3b 0a 88 4a 81 04 04 00 91 19 20 20  cord;..J......  
1d320 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
1d330 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52  a INTEGER PRIMAR
1d340 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20  Y KEY, b int, c 
1d350 44 45 46 41 55 4c 54 20 30 0a 20 20 20 20 2c 20  DEFAULT 0.    , 
1d360 20 20 56 29 3b 0a 2c 20 79 20 54 45 58 54 29 3b    V);., y TEXT);
1d370 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
1d380 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45  R r1 BEFORE INSE
1d390 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  RT ON t1 BEGIN. 
1d3a0 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
1d3b0 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
1d3c0 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
1d3d0 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  e-insert',printf
1d3e0 28 53 28 27 27 25 64 2c 25 64 2c 25 64 27 2c 6e  (S(''%d,%d,%d',n
1d3f0 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
1d400 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
1d410 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
1d420 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74  FTER INSERT ON t
1d430 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
1d440 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 50 28 78  RT INTO recorP(x
1d450 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27  ,y)     VALUES('
1d460 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
1d470 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c  intf('%d,%d,%d',
1d480 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
1d490 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
1d4a0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
1d4b0 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e  BEFORE UPDATE ON
1d4c0 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
1d4d0 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
1d4e0 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
1d4f0 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 40  LUES('before-up@
1d500 00 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  .te',printf('%d,
1d510 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
1d520 0a 20 20 20 20 20 20 20 20 41 20 20 20 20 20 20  .        A      
1d530 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
1d540 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
1d550 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
1d560 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
1d570 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34  REATE TRIGGER r4
1d580 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e   AFTER UPDATE ON
1d590 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
1d5a0 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
1d5b0 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
1d5c0 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61  LUES('after-upda
1d5d0 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
1d5e0 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
1d5f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1d600 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1d610 20 20 20 20 20 20 6f 6c 66 2e 61 2c 6f 6c 64 2e        olf.a,old.
1d620 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
1d630 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
1d640 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ND;.  INSERT INT
1d650 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
1d660 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20  (1,2);.  DELETE 
1d670 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
1d680 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
1d690 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
1d6a0 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
1d6b0 0f 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  . DO UPDATE SET 
1d6c0 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45  c=t1.c+1;.  SELE
1d6d0 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64  CT * FROM record
1d6e0 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
1d6f0 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
1d700 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
1d710 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e  LUES(1,2).    ON
1d720 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
1d730 55 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31  UPDATE SET c=c+1
1d740 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45   WHERE c<0;.  SE
1d750 60 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  `ECT * FROM reco
1d760 72 64 3b 0a 88 4a 81 03 04 00 91 19 20 20 43 52  rd;..J......  CR
1d770 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20  EATE TABLE t1(a 
1d780 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20  INTEGER PRIMARY 
1d790 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45  KEY, b int, c DE
1d7a0 46 41 55 4c 54 20 30 0a 20 20 20 20 20 2c 20 20  FAULT 0.     ,  
1d7b0 56 29 3b 0a 2c 20 79 20 54 45 58 54 29 3b 0a 20  V);., y TEXT);. 
1d7c0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
1d7d0 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54  r1 BEFORE INSERT
1d7e0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
1d7f0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
1d800 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
1d810 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
1d820 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 53  insert',printf(S
1d830 28 27 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77  (''%d,%d,%d',new
1d840 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
1d850 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
1d860 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46 54  E TRIGGER r2 AFT
1d870 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  ER INSERT ON t1 
1d880 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
1d890 20 49 4e 54 4f 20 72 65 63 6f 72 50 28 78 2c 79   INTO recorP(x,y
1d8a0 29 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66  )     VALUES('af
1d8b0 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ter-insert',prin
1d8c0 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65  tf('%d,%d,%d',ne
1d8d0 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
1d8e0 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
1d8f0 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42 45  TE TRIGGER r3 BE
1d900 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74  FORE UPDATE ON t
1d910 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
1d920 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
1d930 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
1d940 45 53 28 27 62 65 66 6f 72 65 2d 75 70 40 00 74  ES('before-up@.t
1d950 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
1d960 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
1d970 20 20 20 20 20 20 20 41 20 20 20 20 20 20 20 20         A        
1d980 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64               old
1d990 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e  .a,old.b,old.c,n
1d9a0 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
1d9b0 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
1d9c0 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20 41  ATE TRIGGER r4 A
1d9d0 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74  FTER UPDATE ON t
1d9e0 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
1d9f0 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
1da00 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
1da10 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74 65  ES('after-update
1da20 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
1da30 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20  %d/%d,%d,%d',.  
1da40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1da50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1da60 20 20 20 20 6f 6c 66 2e 61 2c 6f 6c 64 2e 62 2c      olf.a,old.b,
1da70 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
1da80 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
1da90 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
1daa0 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
1dab0 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  ,2);.  DELETE FR
1dac0 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
1dad0 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
1dae0 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20   VALUES(1,2).   
1daf0 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 0f 20   ON CONFLICT(a. 
1db00 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d  DO UPDATE SET c=
1db10 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54  t1.c+1;.  SELECT
1db20 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
1db30 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
1db40 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
1db50 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
1db60 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43  ES(1,2).    ON C
1db70 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50  ONFLICT(a) DO UP
1db80 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57  DATE SET c=c+1 W
1db90 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 60 45  HERE c<0;.  SE`E
1dba0 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64  CT * FROM record
1dbb0 3b 0a 88 4a 81 02 04 00 91 19 20 20 43 52 45 41  ;..J......  CREA
1dbc0 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
1dbd0 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
1dbe0 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41  Y, b int, c DEFA
1dbf0 55 4c 54 20 30 0a 20 20 20 20 20 20 20 20 56 29  ULT 0.        V)
1dc00 3b 0a 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43  ;., y TEXT);.  C
1dc10 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31  REATE TRIGGER r1
1dc20 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f   BEFORE INSERT O
1dc30 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
1dc40 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
1dc50 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
1dc60 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e  ALUES('before-in
1dc70 73 65 72 74 27 2c 70 72 69 6e 74 66 28 53 28 27  sert',printf(S('
1dc80 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
1dc90 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
1dca0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
1dcb0 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
1dcc0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
1dcd0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
1dce0 4e 54 4f 20 72 65 63 6f 72 50 28 78 2c 79 29 20  NTO recorP(x,y) 
1dcf0 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
1dd00 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
1dd10 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%d,%d,%d',new.
1dd20 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
1dd30 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
1dd40 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
1dd50 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
1dd60 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
1dd70 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
1dd80 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
1dd90 28 27 62 65 66 6f 72 65 2d 75 70 40 00 74 65 27  ('before-up@.te'
1dda0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
1ddb0 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
1ddc0 20 20 20 20 20 41 20 20 20 20 20 20 20 20 20 20       A          
1ddd0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
1dde0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
1ddf0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
1de00 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
1de10 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
1de20 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
1de30 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
1de40 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
1de50 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
1de60 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
1de70 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
1de80 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
1de90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1dea0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1deb0 20 20 6f 6c 66 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    olf.a,old.b,ol
1dec0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
1ded0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
1dee0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
1def0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
1df00 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
1df10 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
1df20 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
1df30 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
1df40 4e 20 43 4f 4e 46 4c 49 43 54 28 61 0f 20 44 4f  N CONFLICT(a. DO
1df50 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
1df60 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
1df70 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
1df80 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
1df90 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
1dfa0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
1dfb0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
1dfc0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
1dfd0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
1dfe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 60 45 43 54  RE c<0;.  SE`ECT
1dff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
1e000 0d 00 00 00 07 01 91 00 1b 8c 17 36 12 d9 0e 7c  ...........6...|
1e010 0a 2f 05 e0 01 91 00 00 00 00 00 00 00 00 00 00  ./..............
1e020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e0a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e0b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e0c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e0d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e0e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e0f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
1e190 00 88 4b 81 0f 04 00 91 1b 20 20 43 52 45 41 54  ..K......  CREAT
1e1a0 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54  E TABLE t1(a INT
1e1b0 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59  EGER PRIMARY KEY
1e1c0 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55  , b int, c DEFAU
1e1d0 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20  LT 0);.  CREATE 
1e1e0 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54  TABLE record(x T
1e1f0 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20  EXT, y TEXT);.  
1e200 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
1e210 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20  1 BEFORE INSERT 
1e220 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
1e230 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
1e240 65 2d 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  e-b,new.c));.  E
1e250 4e 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  Ninsert',printf(
1e260 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
1e270 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
1e280 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
1e290 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
1e2a0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
1e2b0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
1e2c0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
1e2d0 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
1e2e0 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
1e2f0 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%d,%d,%d',new.
1e300 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
1e310 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
1e320 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
1e330 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
1e340 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
1e350 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
1e360 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
1e370 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
1e380 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
1e390 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
1e3a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1e3b0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
1e3c0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
1e3d0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
1e3e0 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
1e3f0 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
1e400 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
1e410 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
1e420 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
1e430 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
1e440 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
1e450 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
1e460 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
1e470 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1e480 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1e490 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
1e4a0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
1e4b0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
1e4c0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
1e4d0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
1e4e0 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
1e4f0 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
1e500 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
1e510 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
1e520 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
1e530 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
1e540 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
1e550 20 46 52 4f 4d 20 72 65 43 6f 72 64 3b 0a 20 20   FROM reCord;.  
1e560 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
1e570 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
1e580 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
1e590 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
1e5a0 46 4c 32 43 54 28 61 29 20 44 4f 20 55 50 44 41  FL2CT(a) DO UPDA
1e5b0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
1e5c0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
1e5d0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
1e5e0 88 4b 81 0e 04 00 91 1b 20 20 43 52 45 41 54 45  .K......  CREATE
1e5f0 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45   TABLE t1(a INTE
1e600 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c  GER PRIMARY KEY,
1e610 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c   b int, c DEFAUL
1e620 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54  T 0);.  CREATE T
1e630 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45  ABLE record(x TE
1e640 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43  XT, y TEXT);.  C
1e650 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31  REATE TRIGGER r1
1e660 20 42 45 46 4f 52 45 20 44 45 4c 45 54 45 20 4f   BEFORE DELETE O
1e670 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
1e680 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
1e690 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
1e6a0 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e  ALUES('before-in
1e6b0 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64  sert',printf('%d
1e6c0 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65  ,%d,%d',new.a,ne
1e6d0 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
1e6e0 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
1e6f0 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49 4e  GGER r2 AFTER IN
1e700 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
1e710 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
1e720 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20   record(x,y)    
1e730 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69   VALUES('after-i
1e740 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25  nsert',printf('%
1e750 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e  d,%d,%d',new.a,n
1e760 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
1e770 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
1e780 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20  IGGER r3 BEFORE 
1e790 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
1e7a0 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
1e7b0 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
1e7c0 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
1e7d0 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72  efore-update',pr
1e7e0 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
1e7f0 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
1e800 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
1e810 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
1e820 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
1e830 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
1e840 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20  RIGGER r4 AFTER 
1e850 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
1e860 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
1e870 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
1e880 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61         VALUES('a
1e890 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69  fter-update',pri
1e8a0 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
1e8b0 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
1e8c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1e8d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
1e8e0 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
1e8f0 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
1e900 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49  .c));.  END;.  I
1e910 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 63 2c  NSERT INTO t1(c,
1e920 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a  b) VALUES(1,2);.
1e930 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
1e940 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
1e950 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
1e960 45 53 28 31 2c 32 29 0a 4f 4e 20 43 4f 4e 46 4c  ES(1,2).ON CONFL
1e970 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
1e980 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20   SET c=t1.c+1;. 
1e990 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
1e9a0 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20  ecord;.  DELETE 
1e9b0 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
1e9c0 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
1e9d0 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
1e9e0 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
1e9f0 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
1ea00 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b  c=c+1 WHERE c<0;
1ea10 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
1ea20 20 72 65 63 6f 72 64 3b 56 41 43 55 55 4d 0a 88   record;VACUUM..
1ea30 49 81 0d 04 00 91 17 20 20 43 52 45 41 54 45 20  I......  CREATE 
1ea40 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47  TABLE t1(a INTEG
1ea50 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  ER PRIMARY KEY, 
1ea60 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
1ea70 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41   0);.  CREATE TA
1ea80 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58  BLE record(x TEX
1ea90 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52  T, y TEXT);.  CR
1eaa0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20  EATE TRIGGER r1 
1eab0 42 45 46 4f 52 45 20 44 45 4c 45 54 45 20 4f 4e  BEFORE DELETE ON
1eac0 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
1ead0 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
1eae0 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
1eaf0 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73  LUES('before-ins
1eb00 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ert',printf('%d,
1eb10 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77  %d,%d',new.a,new
1eb20 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
1eb30 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
1eb40 47 45 52 20 72 32 20 41 46 54 45 52 20 49 4e 53  GER r2 AFTER INS
1eb50 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ERT ON t1 BEGIN.
1eb60 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
1eb70 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20  record(x,y)     
1eb80 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e  VALUES('after-in
1eb90 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64  sert',printf('%d
1eba0 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65  ,%d,%d',new.a,ne
1ebb0 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
1ebc0 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
1ebd0 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20 55  GGER r3 BEFORE U
1ebe0 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
1ebf0 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
1ec00 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
1ec10 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
1ec20 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69  fore-update',pri
1ec30 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
1ec40 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
1ec50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1ec60 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 2c 64         old.a,o,d
1ec70 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
1ec80 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
1ec90 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
1eca0 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55  IGGER r4 AFTER U
1ecb0 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
1ecc0 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
1ecd0 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
1ece0 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
1ecf0 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ter-update',prin
1ed00 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
1ed10 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
1ed20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1ed30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
1ed40 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
1ed50 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
1ed60 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e  c));.  END;.  IN
1ed70 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
1ed80 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20  ) VALUES(1,2);. 
1ed90 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
1eda0 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
1edb0 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
1edc0 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
1edd0 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
1ede0 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31  ATE SET c=t1.c+1
1edf0 3b 0a 20 20 53 45 4c 64 3b 0a 20 20 44 45 4c 45  ;.  SELd;.  DELE
1ee00 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
1ee10 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
1ee20 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
1ee30 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
1ee40 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
1ee50 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63  ET c=c+1 WHERE c
1ee60 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  <0;.  SELECT * F
1ee70 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 59 81 0c  ROM record;..Y..
1ee80 04 00 91 37 20 20 43 52 45 41 54 45 20 54 41 42  ...7  CREATE TAB
1ee90 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20  LE t1(a INTEGER 
1eea0 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
1eeb0 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29  nt, c DEFAULT 0)
1eec0 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ;.  CREATE TABLE
1eed0 20 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20   record(x TEXT, 
1eee0 79 20 54 2c 58 54 29 3b 0a 20 20 43 52 45 41 54  y T,XT);.  CREAT
1eef0 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46  E TRIGGER r1 BEF
1ef00 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  ORE INSERT ON t1
1ef10 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
1ef20 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
1ef30 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
1ef40 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74  S('before-insert
1ef50 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
1ef60 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
1ef70 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
1ef80 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
1ef90 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54   r2 AFTER INSERT
1efa0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
1efb0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
1efc0 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c  ord(x,y)     VAL
1efd0 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72  UES('after-inser
1efe0 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  t',printf('%d,%d
1eff0 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
1f000 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
1f010 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
1f020 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41  R r3 BEFORE UPDA
1f030 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
1f040 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
1f050 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
1f060 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
1f070 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  e-update',printf
1f080 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
1f090 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
1f0a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1f0b0 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
1f0c0 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
1f0d0 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
1f0e0 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
1f0f0 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41  ER r4 AFTER UPDA
1f100 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
1f110 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
1f120 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
1f130 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
1f140 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
1f150 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
1f160 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
1f170 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1f180 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
1f190 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
1f1a0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
1f1b0 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52  ;.  END;.  INSER
1f1c0 54 20 49 4e 54 4f 20 74 31 28 63 2c 62 29 20 56  T INTO t1(c,b) V
1f1d0 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45  ALUES(1,2);.  DE
1f1e0 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
1f1f0 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
1f200 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
1f210 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,2).    ON CONFL
1f220 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
1f230 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20   SET c=t1.c+1;. 
1f240 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
1f250 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20  ecord;.  DELETE 
1f260 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
1f270 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
1f280 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
1f290 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
1f2a0 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
1f2b0 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b  c=c+1 WHERE c<0;
1f2c0 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
1f2d0 20 72 65 63 6f 72 64 3b 0a 88 59 81 0b 04 00 91   record;..Y.....
1f2e0 37 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  7  CREATE TABLE 
1f2f0 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49  t1(a INTEGER PRI
1f300 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c  MARY KEY, b int,
1f310 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20   c DEFAULT 0);. 
1f320 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65   CREATE TABLE re
1f330 63 6f 72 64 28 78 20 2c 45 58 54 2c 20 79 2c 54  cord(x ,EXT, y,T
1f340 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54  EXT);.  CREATE T
1f350 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45  RIGGER r1 BEFORE
1f360 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
1f370 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
1f380 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
1f390 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
1f3a0 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70  before-insert',p
1f3b0 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27  rintf('%d,%d,%d'
1f3c0 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
1f3d0 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
1f3e0 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32  REATE TRIGGER r2
1f3f0 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e   AFTER INSERT ON
1f400 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
1f410 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
1f420 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53  (x,y)     VALUES
1f430 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c  ('after-insert',
1f440 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
1f450 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ',new.a,new.b,ne
1f460 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
1f470 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
1f480 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20  3 BEFORE UPDATE 
1f490 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
1f4a0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
1f4b0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
1f4c0 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75  VALUES('before-u
1f4d0 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
1f4e0 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
1f4f0 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
1f500 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1f510 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
1f520 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
1f530 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
1f540 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
1f550 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20  r4 AFTER UPDATE 
1f560 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
1f570 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
1f580 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
1f590 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70  VALUES('after-up
1f5a0 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
1f5b0 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
1f5c0 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
1f5d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1f5e0 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
1f5f0 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
1f600 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
1f610 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49   END;.  INSERT I
1f620 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
1f630 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54  ES(1,2);.  DELET
1f640 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
1f650 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
1f660 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
1f670 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
1f680 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
1f690 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45  T c=t1.c+1;.  SE
1f6a0 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
1f6b0 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  rd;.  DELETE FRO
1f6c0 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
1f6d0 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
1f6e0 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
1f6f0 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
1f700 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63  O UPDATE SET c=c
1f710 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20  +1 WHERE c<0;.  
1f720 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
1f730 63 6f 72 64 3b 0a 88 52 81 0a 04 00 91 29 20 20  cord;..R.....)  
1f740 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
1f750 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52  a INTEGER PRIMAR
1f760 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20  Y KEY, b int, c 
1f770 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52  DEFAULT 0);.  CR
1f780 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72  EATE TABLE recor
1f790 64 28 78 20 27 61 27 27 62 27 20 54 45 58 54 2c  d(x 'a''b' TEXT,
1f7a0 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41   y TEXT);.  CREA
1f7b0 54 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45  TE TRIGGER r1 BE
1f7c0 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74  FORE INSERT ON t
1f7d0 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
1f7e0 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
1f7f0 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
1f800 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72  ES('before-inser
1f810 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  t',printf('%d,%d
1f820 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
1f830 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
1f840 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
1f850 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52  R r2 AFTER INSER
1f860 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
1f870 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
1f880 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41  cord(x,y)     VA
1f890 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65  LUES('after-inse
1f8a0 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  rt',printf('%d,%
1f8b0 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e  d,%d',new.a,new.
1f8c0 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
1f8d0 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
1f8e0 45 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44  ER r3 BEFORE UPD
1f8f0 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
1f900 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
1f910 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
1f920 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f      VALUES('befo
1f930 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74  re-update',print
1f940 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25  f('%d,%d,%d/%d,%
1f950 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20  d,%d',.         
1f960 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
1f970 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
1f980 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
1f990 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
1f9a0 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44  GER r4 AFTER UPD
1f9b0 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
1f9c0 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
1f9d0 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
1f9e0 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
1f9f0 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  r-update',printf
1fa00 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
1fa10 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
1fa20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1fa30 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e              old.
1fa40 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65  a,old.b,old.c,ne
1fa50 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
1fa60 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45  );.  END;.  INSE
1fa70 52 54 20 49 4e 54 4f 20 74 31 28 63 2c 62 29 20  RT INTO t1(c,b) 
1fa80 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44  VALUES(1,2);.  D
1fa90 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
1faa0 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
1fab0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
1fac0 31 2c 32 29 0a 4f 4e 20 43 4f 4e 46 4c 49 43 54  1,2).ON CONFLICT
1fad0 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
1fae0 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45  T c=t1.c+1;.  SE
1faf0 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
1fb00 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  rd;.  DELETE FRO
1fb10 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
1fb20 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
1fb30 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
1fb40 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
1fb50 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63  O UPDATE SET c=c
1fb60 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20  +1 WHERE c<0;.  
1fb70 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
1fb80 63 6f 72 64 3b 56 41 43 55 55 4d 0a 88 70 81 09  cord;VACUUM..p..
1fb90 04 00 91 65 20 20 43 52 45 41 54 45 20 54 41 42  ...e  CREATE TAB
1fba0 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20  LE t1(a INTEGER 
1fbb0 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
1fbc0 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 20  nt, c DEFAULT 0 
1fbd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 29 3b                );
1fbe0 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
1fbf0 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79  record(x TEXT, y
1fc00 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45   TEXT);.  CREATE
1fc10 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f   TRIGGER r1 BEFO
1fc20 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  RE INSERT ON t1 
1fc30 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
1fc40 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
1fc50 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
1fc60 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27  ('before-insert'
1fc70 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
1fc80 64 27 2c 6e 65 77 2e 61 2c 6e 54 41 42 4c 45 20  d',new.a,nTABLE 
1fc90 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49  t1(a INTEGER PRI
1fca0 4d 41 52 59 65 77 2e 62 2c 6e 65 77 2e 63 29 29  MARYew.b,new.c))
1fcb0 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
1fcc0 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46 54  E TRIGGER r2 AFT
1fcd0 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  ER INSERT ON t1 
1fce0 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
1fcf0 20 4f 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   ONTO record(x,y
1fd00 29 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66  )     VALUES('af
1fd10 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ter-insert',prin
1fd20 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65  tf('%d,%d,%d',ne
1fd30 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
1fd40 29 3b 0a 20 20 47 45 52 20 72 33 20 42 45 46 4f  );.  GER r3 BEFO
1fd50 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
1fd60 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
1fd70 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
1fd80 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
1fd90 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
1fda0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
1fdb0 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
1fdc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1fdd0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
1fde0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
1fdf0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 63  .a,new.b,new.c)c
1fe00 6c 75 64 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  lud END;.  CREAT
1fe10 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
1fe20 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
1fe30 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
1fe40 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
1fe50 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
1fe60 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
1fe70 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
1fe80 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
1fe90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1fea0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1feb0 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
1fec0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
1fed0 6e 65 56 49 45 57 29 3b 0a 20 20 45 4e 44 3b 0a  neVIEW);.  END;.
1fee0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
1fef0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
1ff00 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
1ff10 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
1ff20 54 20 49 4e 54 4f 20 74 31 28 41 2c 62 29 20 56  T INTO t1(A,b) V
1ff30 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
1ff40 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
1ff50 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
1ff60 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
1ff70 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
1ff80 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
1ff90 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
1ffa0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
1ffb0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 00 00 00 80  (1,2).    ON....
1ffc0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
1ffd0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
1ffe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
1fff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
20000 0d 00 00 00 07 01 74 00 1b 76 17 19 12 cc 0e 6f  ......t..v.....o
20010 0a 20 05 c3 01 74 00 00 00 00 00 00 00 00 00 00  . ...t..........
20020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
200a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
200b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
200c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
200d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
200e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
200f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
20170 00 00 00 00 88 4b 81 16 04 00 91 1b 20 20 43 52  .....K......  CR
20180 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20  EATE TABLE t1(a 
20190 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20  INTEGER PRIMARY 
201a0 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45  KEY, b int, c DE
201b0 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41  FAULT 0);.  CREA
201c0 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28  TE TABLE record(
201d0 78 20 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b  x TEXT, y TEXT);
201e0 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
201f0 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45  R r1 BEFORE INSE
20200 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  RT ON t1 BEGIN. 
20210 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
20220 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
20230 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
20240 65 2d 69 6e 73 65 72 74 27 2c 45 58 49 53 54 53  e-insert',EXISTS
20250 28 53 45 4c 45 43 54 27 25 64 2c 25 64 2c 25 64  (SELECT'%d,%d,%d
20260 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ',new.a,new.b,ne
20270 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
20280 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
20290 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f  2 AFTER INSERT O
202a0 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
202b0 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
202c0 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45  d(x,y)     VALUE
202d0 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27  S('after-insert'
202e0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
202f0 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
20300 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
20310 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
20320 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45  r3 BEFORE UPDATE
20330 20 4f 4e 20 74 31 20 42 45 47 49 4e 20 49 4e 53   ON t1 BEGIN INS
20340 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
20350 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
20360 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61  UES('before-upda
20370 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
20380 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
20390 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
203a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
203b0 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
203c0 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
203d0 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
203e0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20  EATE TRIGGER r4 
203f0 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20  AFTER UPDATE ON 
20400 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
20410 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
20420 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
20430 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74  UES('after-updat
20440 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
20450 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
20460 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
20470 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
20480 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
20490 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
204a0 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
204b0 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  D;.  INSERT INTO
204c0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
204d0 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 49 4e  1,2);.  DELETEIN
204e0 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
204f0 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20  ) VALUES(1,2).  
20500 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
20510 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
20520 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43  =t1.c+1;.  SELEC
20530 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
20540 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
20550 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
20560 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
20570 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
20580 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
20590 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20  PDATE SET c=c+1 
205a0 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c  WHERE c<0;.  SEL
205b0 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
205c0 64 3b 0a 88 59 81 15 04 00 91 37 20 20 43 52 45  d;..Y.....7  CRE
205d0 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49  ATE TABLE t1(a I
205e0 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b  NTEGER PRIMARY K
205f0 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46  EY, b int, c DEF
20600 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54  AULT 0);.  CREAT
20610 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78  E TABLE record(x
20620 20 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a   TEXT, y TEXT);.
20630 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
20640 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52   r1 BEFORE INSER
20650 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
20660 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
20670 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
20680 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
20690 2d 69 6e 73 65 72 74 27 2c 40 72 69 6e 74 66 28  -insert',@rintf(
206a0 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
206b0 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
206c0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
206d0 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
206e0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
206f0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
20700 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
20710 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
20720 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
20730 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%d,%d,%d',new.
20740 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
20750 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
20760 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
20770 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
20780 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
20790 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
207a0 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
207b0 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
207c0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
207d0 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
207e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
207f0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
20800 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
20810 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
20820 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
20830 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
20840 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
20850 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
20860 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
20870 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
20880 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
20890 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
208a0 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
208b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
208c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
208d0 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
208e0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
208f0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
20900 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
20910 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
20920 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
20930 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
20940 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
20950 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
20960 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
20970 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
20980 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
20990 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
209a0 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
209b0 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
209c0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
209d0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
209e0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
209f0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
20a00 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
20a10 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
20a20 88 4b 81 14 04 00 91 1b 20 20 43 52 45 41 54 45  .K......  CREATE
20a30 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45   TABLE t1(a INTE
20a40 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c  GER PRIMARY KEY,
20a50 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c   b int, c DEFAUL
20a60 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54  T 0);.  CREATE T
20a70 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45  ABLE record(x TE
20a80 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43  XT, y TEXT);.  C
20a90 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31  REATE TRIGGER r1
20aa0 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f   BEFORE INSERT O
20ab0 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
20ac0 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
20ad0 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
20ae0 41 4c 55 45 53 28 20 72 65 70 6c 61 63 65 28 31  ALUES( replace(1
20af0 2c 31 2c 31 29 2c 70 72 69 6e 74 66 28 20 74 72  ,1,1),printf( tr
20b00 69 6d 28 31 2c 31 29 2c 6e 65 77 2e 61 2c 6e 65  im(1,1),new.a,ne
20b10 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
20b20 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
20b30 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49 4e  GGER r2 AFTER IN
20b40 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
20b50 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
20b60 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20   record(x,y)    
20b70 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69   VALUES('after-i
20b80 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 20 67  nsert',printf( g
20b90 6c 6f 62 28 31 2c 31 29 2c 6e 65 77 2e 61 2c 6e  lob(1,1),new.a,n
20ba0 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
20bb0 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
20bc0 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20  IGGER r3 BEFORE 
20bd0 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
20be0 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
20bf0 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
20c00 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
20c10 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72  efore-update',pr
20c20 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
20c30 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
20c40 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
20c50 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
20c60 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
20c70 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
20c80 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20  RIGGER r4 AFTER 
20c90 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
20ca0 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
20cb0 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
20cc0 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61         VALUES('a
20cd0 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69  fter-update',pri
20ce0 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
20cf0 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
20d00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
20d10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
20d20 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
20d30 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
20d40 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49  .c));.  END;.  I
20d50 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
20d60 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a  b) VALUES(1,2);.
20d70 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
20d80 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
20d90 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
20da0 45 53 28 31 2c 32 29 0a 4f 4e 20 43 4f 4e 46 4c  ES(1,2).ON CONFL
20db0 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
20dc0 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20   SET c=t1.c+1;. 
20dd0 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
20de0 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20  ecord;.  DELETE 
20df0 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
20e00 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
20e10 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
20e20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
20e30 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
20e40 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b  c=c+1 WHERE c<0;
20e50 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
20e60 20 72 65 63 6f 72 64 3b 56 41 43 55 55 4d 0a 88   record;VACUUM..
20e70 59 81 13 04 00 91 37 20 20 43 52 45 41 54 45 20  Y.....7  CREATE 
20e80 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47  TABLE t1(a INTEG
20e90 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  ER PRIMARY KEY, 
20ea0 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
20eb0 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41   0);.  CREATE TA
20ec0 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58  BLE record(x TEX
20ed0 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52  T, y TEXT);.  CR
20ee0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20  EATE TRIGGER r1 
20ef0 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e  BEFORE INSERT ON
20f00 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
20f10 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
20f20 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
20f30 4c 55 45 53 28 20 72 65 70 6c 61 63 65 28 31 2c  LUES( replace(1,
20f40 31 2c 31 29 2c 70 72 69 6e 74 66 28 20 64 61 74  1,1),printf( dat
20f50 65 74 69 6d 65 28 31 2c 31 2c 31 29 2c 6e 65 77  etime(1,1,1),new
20f60 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
20f70 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
20f80 47 45 52 20 72 32 20 41 46 54 45 52 20 49 4e 53  GER r2 AFTER INS
20f90 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ERT ON t1 BEGIN.
20fa0 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
20fb0 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20  record(x,y)     
20fc0 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e  VALUES('after-in
20fd0 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64  sert',printf('%d
20fe0 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65  ,%d,%d',new.a,ne
20ff0 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
21000 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
21010 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20 55  GGER r3 BEFORE U
21020 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
21030 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
21040 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
21050 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
21060 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69  fore-update',pri
21070 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
21080 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
21090 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
210a0 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
210b0 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
210c0 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
210d0 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
210e0 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55  IGGER r4 AFTER U
210f0 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
21100 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
21110 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
21120 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
21130 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ter-update',prin
21140 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
21150 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
21160 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
21170 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
21180 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
21190 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
211a0 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e  c));.  END;.  IN
211b0 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
211c0 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20  ) VALUES(1,2);. 
211d0 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
211e0 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
211f0 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
21200 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
21210 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
21220 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31  ATE SET c=t1.c+1
21230 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
21240 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45  M record;.  DELE
21250 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
21260 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
21270 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
21280 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
21290 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
212a0 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63  ET c=c+1 WHERE c
212b0 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  <0;.  SELECT * F
212c0 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 49 81 12  ROM record;..I..
212d0 04 00 91 17 20 20 43 52 45 41 54 45 20 54 41 42  ....  CREATE TAB
212e0 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20  LE t1(a INTEGER 
212f0 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
21300 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29  nt, c DEFAULT 0)
21310 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ;.  CREATE TABLE
21320 20 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20   record(x TEXT, 
21330 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54  y TEXT);.  CREAT
21340 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46  E TRIGGER r1 BEF
21350 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  ORE INSERT ON t1
21360 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
21370 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
21380 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
21390 53 28 20 6a 73 6f 6e 5f 74 79 70 65 28 31 2c 31  S( json_type(1,1
213a0 29 2c 70 72 69 6e 74 66 28 20 74 72 69 6d 28 31  ),printf( trim(1
213b0 2c 31 29 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  ,1),new.a,new.b,
213c0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
213d0 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
213e0 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54   r2 AFTER INSERT
213f0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
21400 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
21410 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c  ord(x,y)     VAL
21420 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72  UES('after-inser
21430 74 27 2c 70 72 69 6e 74 66 28 20 67 6c 6f 62 28  t',printf( glob(
21440 31 2c 31 29 2c 20 6a 73 6f 6e 5f 72 65 6d 6f 76  1,1), json_remov
21450 65 28 31 2c 31 29 29 29 3b 0a 20 20 45 4e 44 3b  e(1,1)));.  END;
21460 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
21470 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41  R r3 BEFORE UPDA
21480 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
21490 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
214a0 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
214b0 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
214c0 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  e-update',printf
214d0 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
214e0 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
214f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
21500 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
21510 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
21520 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
21530 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
21540 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41  ER r4 AFTER UPDA
21550 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
21560 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
21570 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
21580 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
21590 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
215a0 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
215b0 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
215c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
215d0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
215e0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
215f0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
21600 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52  ;.  END;.  INSER
21610 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
21620 41 4c 55 45 53 28 31 2c 32 29 3b 0a 4d 20 72 65  ALUES(1,2);.M re
21630 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
21640 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
21650 45 53 28 31 2c 32 29 0a 4f 4e 20 43 4f 4e 46 4c  ES(1,2).ON CONFL
21660 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
21670 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20   SET c=t1.c+1;. 
21680 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
21690 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20  ecord;.  DELETE 
216a0 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
216b0 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
216c0 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
216d0 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
216e0 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
216f0 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b  c=c+1 WHERE c<0;
21700 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
21710 20 72 65 63 6f 72 64 3b 0a 88 59 81 11 04 00 91   record;..Y.....
21720 37 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  7  CREATE TABLE 
21730 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49  t1(a INTEGER PRI
21740 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c  MARY KEY, b int,
21750 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20   c DEFAULT 0);. 
21760 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65   CREATE TABLE re
21770 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54  cord(x TEXT, y T
21780 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54  EXT);.  CREATE T
21790 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45  RIGGER r1 BEFORE
217a0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
217b0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
217c0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 78 29 0a  NTO record(x,x).
217d0 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
217e0 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70  before-insert',p
217f0 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27  rintf('%d,%d,%d'
21800 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
21810 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
21820 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32  REATE TRIGGER r2
21830 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e   AFTER INSERT ON
21840 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
21850 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
21860 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53  (x,y)     VALUES
21870 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c  ('after-insert',
21880 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
21890 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ',new.a,new.b,ne
218a0 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
218b0 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
218c0 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20  3 BEFORE UPDATE 
218d0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
218e0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
218f0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
21900 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75  VALUES('before-u
21910 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
21920 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
21930 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
21940 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
21950 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
21960 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
21970 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
21980 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
21990 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20  r4 AFTER UPDATE 
219a0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
219b0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
219c0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
219d0 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70  VALUES('after-up
219e0 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
219f0 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
21a00 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
21a10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
21a20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
21a30 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
21a40 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
21a50 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49   END;.  INSERT I
21a60 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
21a70 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54  ES(1,2);.  DELET
21a80 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
21a90 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
21aa0 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
21ab0 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
21ac0 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
21ad0 54 20 61 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45  T a=t1.c+1;.  SE
21ae0 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
21af0 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  rd;.  DELETE FRO
21b00 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
21b10 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
21b20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
21b30 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
21b40 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63  O UPDATE SET c=c
21b50 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20  +1 WHERE c<0;.  
21b60 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
21b70 63 6f 72 64 3b 0a 89 06 81 10 04 00 92 11 20 20  cord;.........  
21b80 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
21b90 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52  a INTEGER PRIMAR
21ba0 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20  Y KEY, b int, c 
21bb0 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52  DEFAULT 0);.  CR
21bc0 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72  EATE TABLE recor
21bd0 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58 54  d(x TEXT, y TEXT
21be0 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  );.  CREATE TRIG
21bf0 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e  GER r1 BEFORE IN
21c00 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
21c10 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
21c20 20 72 65 63 6f 72 46 28 78 43 79 29 0a 20 20 20   recorF(xCy).   
21c30 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
21c40 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ore-insert',prin
21c50 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65  tf('%d,%d,%d',ne
21c60 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
21c70 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
21c80 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46  TE TRIGGER r2 AF
21c90 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  TER INSERT ON t1
21ca0 20 42 45 47 4e 4e 0a 20 20 20 20 49 4e 53 45 52   BEGNN.    INSER
21cb0 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
21cc0 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27 61  y)     VALUES('a
21cd0 66 74 65 72 2d 69 6e 73 65 68 74 27 2c 70 72 69  fter-inseht',pri
21ce0 00 40 ff 28 27 25 64 2c 25 64 2c 22 64 27 2c 6e  .@.('%d,%d,"d',n
21cf0 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
21d00 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
21d10 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42  ATE TRIGGER r3 B
21d20 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20  EFORE UPDATE ON 
21d30 7f ff ff ff 45 47 49 4e 0a 20 20 20 20 49 4e 53  ....EGIN.    INS
21d40 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
21d50 78 2c 91 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,.).        VAL
21d60 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61  UES('before-upda
21d70 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
21d80 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
21d90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
21da0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
21db0 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
21dc0 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
21dd0 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
21de0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20  EATE TRIGGER r4 
21df0 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20  AFTER UPDATE ON 
21e00 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
21e10 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
21e20 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
21e30 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74  UES('after-updat
21e40 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
21e50 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
21e60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
21e70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
21e80 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
21e90 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
21ea0 2e 62 2c 6e 44 45 46 41 55 4c 54 20 30 29 3b 0a  .b,nDEFAULT 0);.
21eb0 20 20 43 52 65 77 3b 0a 20 20 45 4e 44 3b 0a 20    CRew;.  END;. 
21ec0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
21ed0 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
21ee0 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
21ef0 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
21f00 20 49 4e 54 4f 20 74 4c 55 45 53 28 27 62 65 31   INTO tLUES('be1
21f10 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
21f20 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
21f30 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
21f40 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53  ET c=t1.c+1;.  S
21f50 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63  ELECT * FROM rec
21f60 6f 72 64 3b 0a 20 20 44 45 4c 45 54 3f 20 46 5d  ord;.  DELET? F]
21f70 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
21f80 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
21f90 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20   VALUES(1,2).   
21fa0 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 e2 e2   ON CONFLICT(a..
21fb0 e2 e2 e2 e2 e2 e2 e2 e2 e2 e2 e2 e2 e2 e2 e2 e2  ................
21fc0 e2 e2 e2 e2 e2 e2 e2 29 20 44 4f 20 55 50 44 41  .......) DO UPDA
21fd0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
21fe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
21ff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
22000 0d 00 00 00 07 01 ca 00 1b b3 17 66 13 14 0e c5  ...........f....
22010 0a 76 06 27 01 ca 00 00 00 00 00 00 00 00 00 00  .v.'............
22020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
220a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
220b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
220c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
220d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
220e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
220f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
22190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
221a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
221b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
221c0 00 00 00 00 00 00 00 00 00 00 88 59 81 1d 04 00  ...........Y....
221d0 91 37 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  .7  CREATE TABLE
221e0 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
221f0 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74  IMARY KEY, b int
22200 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a  , c DEFAULT 0);.
22210 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72    CREATE TABLE r
22220 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20  ecord(x TEXT, y 
22230 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20  TEXT);.  CREATE 
22240 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52  TRIGGER r1 BEFOR
22250 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  E INSERT ON t1 B
22260 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
22270 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
22280 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
22290 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c  'before-insert',
222a0 70 72 69 6e 74 66 28 20 20 6d 61 78 28 31 2c 31  printf(  max(1,1
222b0 29 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ),new.a,new.b,ne
222c0 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
222d0 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
222e0 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f  2 AFTER INSERT O
222f0 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
22300 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
22310 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45  d(x,y)     VALUE
22320 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27  S('after-insert'
22330 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
22340 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
22350 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
22360 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
22370 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45  r3 BEFORE UPDATE
22380 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
22390 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
223a0 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
223b0 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
223c0 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
223d0 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
223e0 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
223f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
22400 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
22410 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
22420 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
22430 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
22440 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45   r4 AFTER UPDATE
22450 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
22460 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
22470 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
22480 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75   VALUES('after-u
22490 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
224a0 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
224b0 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
224c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
224d0 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
224e0 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
224f0 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
22500 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20    END;.  INSERT 
22510 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
22520 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45  UES(1,2);.  DELE
22530 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
22540 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
22550 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
22560 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
22570 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
22580 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53  ET c=t1.c+1;.  S
22590 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63  ELECT * FROM rec
225a0 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  ord;.  DELETE FR
225b0 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
225c0 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
225d0 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20   VALUES(1,2).   
225e0 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20   ON CONFLICT(a) 
225f0 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d  DO UPDATE SET c=
22600 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20  c+1 WHERE c<0;. 
22610 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
22620 65 63 6f 72 64 3b 0a 88 4b 81 1c 04 00 91 1b 20  ecord;..K...... 
22630 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
22640 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41  (a INTEGER PRIMA
22650 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63  RY KEY, b int, c
22660 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43   DEFAULT 0);.  C
22670 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f  REATE TABLE reco
22680 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58  rd(x TEXT, y TEX
22690 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  T);.  CREATE TRI
226a0 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49  GGER r1 BEFORE I
226b0 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
226c0 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
226d0 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
226e0 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
226f0 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69  fore-insert',pri
22700 20 49 4e 28 53 45 4c 45 43 54 27 25 64 2c 25 64   IN(SELECT'%d,%d
22710 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
22720 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
22730 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
22740 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52  R r2 AFTER INSER
22750 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
22760 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
22770 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41  cord(x,y)     VA
22780 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65  LUES('after-inse
22790 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  rt',printf('%d,%
227a0 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e  d,%d',new.a,new.
227b0 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
227c0 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
227d0 45 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44  ER r3 BEFORE UPD
227e0 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 20  ATE ON t1 BEGIN 
227f0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
22800 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
22810 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75  VALUES('before-u
22820 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
22830 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
22840 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
22850 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
22860 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
22870 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
22880 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
22890 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
228a0 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20  r4 AFTER UPDATE 
228b0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
228c0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
228d0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
228e0 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70  VALUES('after-up
228f0 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
22900 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
22910 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
22920 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
22930 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
22940 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
22950 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
22960 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49   END;.  INSERT I
22970 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
22980 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54  ES(1,2);.  DELET
22990 45 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28  EINSERT INTO t1(
229a0 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
229b0 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
229c0 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
229d0 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45  T c=t1.c+1;.  SE
229e0 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
229f0 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  rd;.  DELETE FRO
22a00 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
22a10 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
22a20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
22a30 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
22a40 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63  O UPDATE SET c=c
22a50 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20  +1 WHERE c<0;.  
22a60 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
22a70 63 6f 72 64 3b 0a 88 4b 81 1b 04 00 91 1b 20 20  cord;..K......  
22a80 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
22a90 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52  a INTEGER PRIMAR
22aa0 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20  Y KEY, b int, c 
22ab0 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52  DEFAULT 0);.  CR
22ac0 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72  EATE TABLE recor
22ad0 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58 54  d(x TEXT, y TEXT
22ae0 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  );.  CREATE TRIG
22af0 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e  GER r1 BEFORE IN
22b00 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
22b10 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
22b20 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
22b30 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
22b40 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 20  ore-insert',pri 
22b50 3e 3d 28 53 45 4c 45 43 54 27 25 64 2c 25 64 2c  >=(SELECT'%d,%d,
22b60 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
22b70 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
22b80 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
22b90 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54   r2 AFTER INSERT
22ba0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
22bb0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
22bc0 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c  ord(x,y)     VAL
22bd0 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72  UES('after-inser
22be0 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  t',printf('%d,%d
22bf0 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
22c00 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
22c10 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
22c20 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41  R r3 BEFORE UPDA
22c30 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 20 49  TE ON t1 BEGIN I
22c40 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
22c50 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
22c60 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70  ALUES('before-up
22c70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
22c80 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
22c90 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
22ca0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
22cb0 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e  old.a,old.b,old.
22cc0 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  c,new.a,new.b,ne
22cd0 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
22ce0 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
22cf0 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f  4 AFTER UPDATE O
22d00 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
22d10 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
22d20 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
22d30 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64  ALUES('after-upd
22d40 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
22d50 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 49  %d,%d/%d,%d,%d'I
22d60 4e 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  N               
22d70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
22d80 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
22d90 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
22da0 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
22db0 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  END;.  INSERT IN
22dc0 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
22dd0 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45  S(1,2);.  DELETE
22de0 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
22df0 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
22e00 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
22e10 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
22e20 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c   c=t1.c+1;.  SEL
22e30 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
22e40 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  d;.  DELETE FROM
22e50 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
22e60 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
22e70 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
22e80 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
22e90 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b   UPDATE SET c=c+
22ea0 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53  1 WHERE c<0;.  S
22eb0 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63  ELECT * FROM rec
22ec0 6f 72 64 3b 0a 88 4b 81 1a 04 00 91 1b 20 20 43  ord;..K......  C
22ed0 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 61  REATE TABLE t1(a
22ee0 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59   INTEGER PRIMARY
22ef0 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44   KEY, b int, c D
22f00 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45  EFAULT 0);.  CRE
22f10 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64  ATE TABLE record
22f20 28 78 20 54 45 58 54 2c 20 79 20 54 45 58 54 29  (x TEXT, y TEXT)
22f30 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
22f40 45 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53  ER r1 BEFORE INS
22f50 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ERT ON t1 BEGIN.
22f60 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
22f70 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
22f80 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f      VALUES('befo
22f90 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 20 3e  re-insert',pri >
22fa0 3d 28 53 45 4c 45 43 54 27 25 64 2c 25 64 2c 25  =(SELECT'%d,%d,%
22fb0 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
22fc0 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
22fd0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
22fe0 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r2 AFTER INSERT 
22ff0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
23000 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
23010 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55  rd(x,y)     VALU
23020 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74  ES('after-insert
23030 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
23040 25 64 27 2c 6e 65 77 2c 61 2c 6e 65 77 2e 62 2c  %d',new,a,new.b,
23050 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
23060 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
23070 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54   r3 BEFORE UPDAT
23080 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 20 49 4e  E ON t1 BEGIN IN
23090 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
230a0 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
230b0 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64  LUES('before-upd
230c0 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
230d0 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
230e0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
230f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
23100 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
23110 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
23120 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
23130 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34  REATE TRIGGER r4
23140 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e   AFTER UPDATE ON
23150 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
23160 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
23170 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
23180 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61  LUES('after-upda
23190 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
231a0 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
231b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
231c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
231d0 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
231e0 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
231f0 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
23200 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ND;.  INSERT INT
23210 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
23220 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 49  (1,2);.  DELETEI
23230 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
23240 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
23250 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
23260 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
23270 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45  c=t1.c+1;.  SELE
23280 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64  CT * FROM record
23290 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
232a0 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
232b0 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
232c0 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e  LUES(1,2).    ON
232d0 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
232e0 55 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31  UPDATE SET c=c+1
232f0 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45   WHERE c<0;.  SE
23300 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
23310 72 64 3b 0a 88 4e 81 19 04 00 91 21 20 20 43 52  rd;..N.....!  CR
23320 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20  EATE TABLE t1(a 
23330 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20  INTEGER PRIMARY 
23340 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45  KEY, b int, c DE
23350 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41  FAULT 0);.  CREA
23360 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28  TE TABLE record(
23370 78 20 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b  x TEXT, y TEXT);
23380 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
23390 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45  R r1 BEFORE INSE
233a0 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  RT ON t1 BEGIN. 
233b0 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
233c0 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
233d0 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
233e0 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 20 3e 3d  e-insert',pri >=
233f0 28 53 45 4c 45 43 54 20 40 31 27 25 64 2c 25 64  (SELECT @1'%d,%d
23400 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
23410 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
23420 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
23430 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52  R r2 AFTER INSER
23440 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
23450 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
23460 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41  cord(x,y)     VA
23470 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65  LUES('after-inse
23480 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  rt',printf('%d,%
23490 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e  d,%d',new.a,new.
234a0 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
234b0 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
234c0 45 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44  ER r3 BEFORE UPD
234d0 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 20  ATE ON t1 BEGIN 
234e0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
234f0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
23500 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75  VALUES('before-u
23510 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
23520 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
23530 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
23540 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
23550 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
23560 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
23570 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
23580 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
23590 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20  r4 AFTER UPDATE 
235a0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
235b0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
235c0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
235d0 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70  VALUES('after-up
235e0 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
235f0 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
23600 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
23610 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
23620 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
23630 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
23640 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
23650 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49   END;.  INSERT I
23660 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
23670 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54  ES(1,2);.  DELET
23680 45 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28  EINSERT INTO t1(
23690 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
236a0 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
236b0 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
236c0 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45  T c=t1.c+1;.  SE
236d0 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
236e0 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  rd;.  DELETE FRO
236f0 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
23700 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
23710 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
23720 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
23730 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63  O UPDATE SET c=c
23740 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20  +1 WHERE c<0;.  
23750 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
23760 63 6f 72 64 3b 0a 88 49 81 18 04 00 91 17 20 20  cord;..I......  
23770 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
23780 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52  a INTEGER PRIMAR
23790 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20  Y KEY, b int, c 
237a0 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52  DEFAULT 0);.  CR
237b0 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72  EATE TABLE recor
237c0 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58 54  d(x TEXT, y TEXT
237d0 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  );.  CREATE TRIG
237e0 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e  GER r1 BEFORE IN
237f0 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
23800 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
23810 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
23820 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
23830 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 20  ore-insert',pri 
23840 3e 3d 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65  >=('%d,%d,%d',ne
23850 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
23860 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
23870 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46  TE TRIGGER r2 AF
23880 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  TER INSERT ON t1
23890 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
238a0 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
238b0 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27 61  y)     VALUES('a
238c0 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69  fter-insert',pri
238d0 6e 74 66 28 20 64 61 74 65 74 69 6d 65 28 31 2c  ntf( datetime(1,
238e0 31 2c 31 29 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  1,1),new.b,new.c
238f0 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
23900 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42  ATE TRIGGER r3 B
23910 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20  EFORE UPDATE ON 
23920 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
23930 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
23940 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
23950 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61  UES('before-upda
23960 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
23970 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
23980 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
23990 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
239a0 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
239b0 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
239c0 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
239d0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20  EATE TRIGGER r4 
239e0 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20  AFTER UPDATE ON 
239f0 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
23a00 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
23a10 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
23a20 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74  UES('after-updat
23a30 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
23a40 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
23a50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
23a60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
23a70 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
23a80 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
23a90 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
23aa0 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  D;.  INSERT INTO
23ab0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
23ac0 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 49 4e  1,2);.  DELETEIN
23ad0 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
23ae0 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20  ) VALUES(1,2).  
23af0 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
23b00 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
23b10 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43  =t1.c+1;.  SELEC
23b20 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
23b30 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
23b40 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
23b50 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
23b60 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
23b70 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
23b80 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20  PDATE SET c=c+1 
23b90 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c  WHERE c<0;.  SEL
23ba0 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
23bb0 64 3b 0a 88 49 81 17 04 00 91 17 20 20 43 52 45  d;..I......  CRE
23bc0 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49  ATE TABLE t1(a I
23bd0 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b  NTEGER PRIMARY K
23be0 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46  EY, b int, c DEF
23bf0 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54  AULT 0);.  CREAT
23c00 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78  E TABLE record(x
23c10 20 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a   TEXT, y TEXT);.
23c20 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
23c30 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52   r1 BEFORE INSER
23c40 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
23c50 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
23c60 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
23c70 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
23c80 2d 69 6e 73 65 72 74 27 2c 70 72 69 20 3e 3d 28  -insert',pri >=(
23c90 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
23ca0 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
23cb0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
23cc0 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
23cd0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
23ce0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
23cf0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
23d00 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
23d10 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 20 3e 3d  r-insert',pri >=
23d20 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%d,%d,%d',new.
23d30 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
23d40 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
23d50 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
23d60 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
23d70 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
23d80 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
23d90 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
23da0 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
23db0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
23dc0 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
23dd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
23de0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
23df0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
23e00 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
23e10 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
23e20 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
23e30 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
23e40 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
23e50 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
23e60 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
23e70 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
23e80 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
23e90 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
23ea0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
23eb0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
23ec0 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
23ed0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
23ee0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
23ef0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
23f00 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
23f10 29 3b 0a 20 20 44 45 4c 45 54 45 49 4e 53 45 52  );.  DELETEINSER
23f20 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
23f30 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
23f40 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
23f50 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
23f60 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
23f70 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
23f80 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
23f90 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
23fa0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
23fb0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
23fc0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
23fd0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
23fe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
23ff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
24000 0d 00 00 00 07 01 91 00 1b 9f 17 42 12 f5 0e 98  ...........B....
24010 0a 3b 05 ee 01 91 00 00 00 00 00 00 00 00 00 00  .;..............
24020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
240a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
240b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
240c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
240d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
240e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
240f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
24190 00 88 59 81 24 04 00 91 37 20 20 43 52 45 41 54  ..Y.$...7  CREAT
241a0 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54  E TABLE t1(a INT
241b0 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59  EGER PRIMARY KEY
241c0 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55  , b int, c DEFAU
241d0 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20  LT 0);.  CREATE 
241e0 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54  TABLE record(x T
241f0 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20  EXT, y TEXT);.  
24200 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
24210 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20  1 BEFORE INSERT 
24220 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
24230 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
24240 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
24250 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69  VALUES('before-i
24260 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 20 64  nsert',printf( d
24270 61 74 65 74 69 6d 65 28 31 20 2d 31 31 29 2c 6e  atetime(1 -11),n
24280 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
24290 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
242a0 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49  IGGER r2 AFTER I
242b0 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
242c0 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
242d0 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20  O record(x,y)   
242e0 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
242f0 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
24300 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c  %d,%d,%d',new.a,
24310 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
24320 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
24330 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45  RIGGER r3 BEFORE
24340 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
24350 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
24360 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
24370 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
24380 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70  before-update',p
24390 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
243a0 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
243b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
243c0 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
243d0 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
243e0 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
243f0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
24400 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52  TRIGGER r4 AFTER
24410 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
24420 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
24430 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
24440 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
24450 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72  after-update',pr
24460 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
24470 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
24480 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
24490 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
244a0 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e  old.a,old.b,old.
244b0 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  c,new.a,new.b,ne
244c0 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
244d0 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
244e0 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b  ,b) VALUES(1,2);
244f0 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
24500 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
24510 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
24520 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
24530 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
24540 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63  PDATE SET c=t1.c
24550 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  +1;.  SELECT * F
24560 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45  ROM record;.  DE
24570 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
24580 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
24590 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
245a0 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,2).    ON CONFL
245b0 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
245c0 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45   SET c=c+1 WHERE
245d0 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a   c<0;.  SELECT *
245e0 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 49   FROM record;..I
245f0 81 23 04 00 91 17 20 20 43 52 45 41 54 45 20 54  .#....  CREATE T
24600 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45  ABLE t1(a INTEGE
24610 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62  R PRIMARY KEY, b
24620 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20   int, c DEFAULT 
24630 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42  0);.  CREATE TAB
24640 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58 54  LE record(x TEXT
24650 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45  , y TEXT);.  CRE
24660 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20 42  ATE TRIGGER r1 B
24670 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20  EFORE INSERT ON 
24680 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
24690 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
246a0 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
246b0 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65  UES('before-inse
246c0 72 74 27 2c 70 72 69 6e 74 66 28 20 64 61 74 65  rt',printf( date
246d0 74 69 6d 65 28 20 4e 55 4c 4c 29 2c 6e 65 77 2e  time( NULL),new.
246e0 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
246f0 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
24700 45 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45  ER r2 AFTER INSE
24710 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  RT ON t1 BEGIN. 
24720 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
24730 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56  ecord(x,y)     V
24740 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73  ALUES('after-ins
24750 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ert',printf('%d,
24760 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77  %d,%d',new.a,new
24770 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
24780 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
24790 47 45 52 20 72 33 20 42 45 46 4f 52 45 20 55 50  GER r3 BEFORE UP
247a0 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e  DATE ON t1 BEGIN
247b0 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
247c0 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
247d0 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
247e0 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ore-update',prin
247f0 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
24800 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
24810 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
24820 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
24830 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
24840 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
24850 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
24860 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50  GGER r4 AFTER UP
24870 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e  DATE ON t1 BEGIN
24880 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
24890 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
248a0 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74       VALUES('aft
248b0 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74  er-update',print
248c0 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25  f('%d,%d,%d/%d,%
248d0 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20  d,%d',.         
248e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
248f0 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64               old
24900 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e  .a,old.b,old.c,n
24910 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
24920 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53  ));.  END;.  INS
24930 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
24940 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20   VALUES(1,2);.  
24950 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
24960 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
24970 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
24980 28 31 2c 32 29 0a 00 20 20 20 4f 4e 20 43 4f 4e  (1,2)..   ON CON
24990 46 4c 49 43 54 28 20 63 3d 74 31 2e 63 2b 31 3b  FLICT( c=t1.c+1;
249a0 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
249b0 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54   record;.  DELET
249c0 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
249d0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
249e0 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
249f0 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
24a00 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
24a10 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c  T c=c+1 WHERE c<
24a20 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52  0;.  SELECT * FR
24a30 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 59 81 22 04  OM record;..Y.".
24a40 00 91 37 20 20 43 52 45 41 54 45 20 54 41 42 4c  ..7  CREATE TABL
24a50 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50  E t1(a INTEGER P
24a60 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
24a70 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  t, c DEFAULT 0);
24a80 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
24a90 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79  record(x TEXT, y
24aa0 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45   TEXT);.  CREATE
24ab0 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f   TRIGGER r1 BEFO
24ac0 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  RE INSERT ON t1 
24ad0 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
24ae0 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
24af0 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
24b00 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27  ('before-insert'
24b10 2c 70 72 69 6e 74 66 28 20 64 61 74 65 74 69 6d  ,printf( datetim
24b20 65 28 20 31 3d 31 31 29 2c 6e 65 77 2e 62 2c 6e  e( 1=11),new.b,n
24b30 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
24b40 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
24b50 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r2 AFTER INSERT 
24b60 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
24b70 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
24b80 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55  rd(x,y)     VALU
24b90 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74  ES('after-insert
24ba0 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
24bb0 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
24bc0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
24bd0 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
24be0 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54   r3 BEFORE UPDAT
24bf0 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
24c00 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
24c10 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
24c20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
24c30 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
24c40 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
24c50 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
24c60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
24c70 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f     old.a,old.b,o
24c80 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ld.c,new.a,new.b
24c90 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
24ca0 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
24cb0 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54  R r4 AFTER UPDAT
24cc0 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
24cd0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
24ce0 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
24cf0 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
24d00 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
24d10 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
24d20 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
24d30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
24d40 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
24d50 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
24d60 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
24d70 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54  .  END;.  INSERT
24d80 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
24d90 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c  LUES(1,2);.  DEL
24da0 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  ETE FROM record;
24db0 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
24dc0 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
24dd0 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49  2).    ON CONFLI
24de0 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20  CT(a) DO UPDATE 
24df0 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20  SET c=t1.c+1;.  
24e00 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
24e10 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46  cord;.  DELETE F
24e20 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e  ROM record;.  IN
24e30 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
24e40 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20  ) VALUES(1,2).  
24e50 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
24e60 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
24e70 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a  =c+1 WHERE c<0;.
24e80 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
24e90 72 65 63 6f 72 64 3b 0a 88 59 81 21 04 00 91 37  record;..Y.!...7
24ea0 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
24eb0 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d  1(a INTEGER PRIM
24ec0 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20  ARY KEY, b int, 
24ed0 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20  c DEFAULT 0);.  
24ee0 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63  CREATE TABLE rec
24ef0 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45  ord(x TEXT, y TE
24f00 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52  XT);.  CREATE TR
24f10 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20  IGGER r1 BEFORE 
24f20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
24f30 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
24f40 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
24f50 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
24f60 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72  efore-insert',pr
24f70 69 6e 74 66 28 20 64 61 74 65 74 69 6d 65 28 20  intf( datetime( 
24f80 2d 31 2c 31 29 2c 6e 65 77 2e 62 2c 6e 65 77 2e  -1,1),new.b,new.
24f90 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
24fa0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20  EATE TRIGGER r2 
24fb0 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20  AFTER INSERT ON 
24fc0 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
24fd0 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
24fe0 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28  x,y)     VALUES(
24ff0 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70  'after-insert',p
25000 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27  rintf('%d,%d,%d'
25010 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
25020 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
25030 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33  REATE TRIGGER r3
25040 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f   BEFORE UPDATE O
25050 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
25060 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
25070 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
25080 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70  ALUES('before-up
25090 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
250a0 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
250b0 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
250c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
250d0 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e  old.a,old.b,old.
250e0 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  c,new.a,new.b,ne
250f0 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
25100 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
25110 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f  4 AFTER UPDATE O
25120 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
25130 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
25140 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
25150 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64  ALUES('after-upd
25160 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
25170 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
25180 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
25190 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
251a0 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
251b0 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
251c0 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
251d0 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  END;.  INSERT IN
251e0 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
251f0 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45  S(1,2);.  DELETE
25200 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
25210 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
25220 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
25230 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
25240 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
25250 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c   c=t1.c+1;.  SEL
25260 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
25270 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  d;.  DELETE FROM
25280 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
25290 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
252a0 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
252b0 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
252c0 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b   UPDATE SET c=c+
252d0 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53  1 WHERE c<0;.  S
252e0 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63  ELECT * FROM rec
252f0 6f 72 64 3b 0a 88 49 81 20 04 00 91 17 20 20 43  ord;..I. ....  C
25300 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28 61  REATE TABLE t1(a
25310 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59   INTEGER PRIMARY
25320 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44   KEY, b int, c D
25330 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45  EFAULT 0);.  CRE
25340 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64  ATE TABLE record
25350 28 78 20 54 45 58 54 2c 20 79 20 54 45 58 54 29  (x TEXT, y TEXT)
25360 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
25370 45 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53  ER r1 BEFORE INS
25380 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ERT ON t1 BEGIN.
25390 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
253a0 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
253b0 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f      VALUES('befo
253c0 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74  re-insert',print
253d0 66 28 20 64 61 74 65 74 69 6d 65 28 20 20 22 61  f( datetime(  "a
253e0 22 29 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  "),new.b,new.c))
253f0 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
25400 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46 54  E TRIGGER r2 AFT
25410 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  ER INSERT ON t1 
25420 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
25430 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
25440 29 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66  )     VALUES('af
25450 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ter-insert',prin
25460 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65  tf('%d,%d,%d',ne
25470 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
25480 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
25490 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42 45  TE TRIGGER r3 BE
254a0 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74  FORE UPDATE ON t
254b0 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
254c0 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
254d0 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
254e0 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74  ES('before-updat
254f0 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
25500 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
25510 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
25520 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64               old
25530 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e  .a,old.b,old.c,n
25540 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
25550 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
25560 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20 41  ATE TRIGGER r4 A
25570 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74  FTER UPDATE ON t
25580 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
25590 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
255a0 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
255b0 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74 65  ES('after-update
255c0 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
255d0 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20  %d/%d,%d,%d',.  
255e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
255f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
25600 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
25610 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
25620 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
25630 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
25640 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
25650 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  ,2);.  DELETE FR
25660 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
25670 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
25680 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 00 20 20   VALUES(1,2)..  
25690 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 20 63 3d   ON CONFLICT( c=
256a0 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54  t1.c+1;.  SELECT
256b0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
256c0 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
256d0 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
256e0 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
256f0 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43  ES(1,2).    ON C
25700 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50  ONFLICT(a) DO UP
25710 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57  DATE SET c=c+1 W
25720 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45  HERE c<0;.  SELE
25730 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64  CT * FROM record
25740 3b 0a 88 59 81 1f 04 00 91 37 20 20 43 52 45 41  ;..Y.....7  CREA
25750 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
25760 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
25770 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41  Y, b int, c DEFA
25780 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45  ULT 0);.  CREATE
25790 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20   TABLE record(x 
257a0 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20  TEXT, y TEXT);. 
257b0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
257c0 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54  r1 BEFORE INSERT
257d0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
257e0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
257f0 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
25800 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
25810 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 20  insert',printf( 
25820 63 68 61 6e 67 65 73 28 29 2c 6e 65 77 2e 61 2c  changes(),new.a,
25830 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
25840 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
25850 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20  RIGGER r2 AFTER 
25860 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
25870 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
25880 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20  TO record(x,y)  
25890 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
258a0 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
258b0 27 25 64 2c 25 64 2c 25 64 27 2c 20 73 71 6c 69  '%d,%d,%d', sqli
258c0 74 65 5f 76 65 72 73 69 6f 6e 28 29 29 29 3b 0a  te_version()));.
258d0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
258e0 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52  TRIGGER r3 BEFOR
258f0 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  E UPDATE ON t1 B
25900 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
25910 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
25920 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
25930 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c  'before-update',
25940 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
25950 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
25960 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
25970 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
25980 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
25990 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
259a0 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
259b0 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45   TRIGGER r4 AFTE
259c0 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  R UPDATE ON t1 B
259d0 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
259e0 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
259f0 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
25a00 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70  'after-update',p
25a10 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
25a20 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
25a30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
25a40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
25a50 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
25a60 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
25a70 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
25a80 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
25a90 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
25aa0 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
25ab0 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
25ac0 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
25ad0 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e  LUES(1,2).    ON
25ae0 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
25af0 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e  UPDATE SET c=t1.
25b00 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20  c+1;.  SELECT * 
25b10 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44  FROM record;.  D
25b20 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
25b30 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
25b40 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
25b50 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46  1,2).    ON CONF
25b60 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54  LICT(a) DO UPDAT
25b70 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45 52  E SET c=c+1 WHER
25b80 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20  E c<0;.  SELECT 
25b90 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88  * FROM record;..
25ba0 5d 81 1e 04 00 91 3f 20 20 43 52 45 41 54 45 20  ].....?  CREATE 
25bb0 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47  TABLE t1(a INTEG
25bc0 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  ER PRIMARY KEY, 
25bd0 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
25be0 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41   0);.  CREATE TA
25bf0 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58  BLE record(x TEX
25c00 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52  T, y TEXT);.  CR
25c10 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20  EATE TRIGGER r1 
25c20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e  BEFORE INSERT ON
25c30 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
25c40 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
25c50 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
25c60 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73  LUES('before-ins
25c70 65 72 74 27 2c 70 72 69 6e 74 66 28 20 27 61 27  ert',printf( 'a'
25c80 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
25c90 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
25ca0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
25cb0 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
25cc0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
25cd0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
25ce0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
25cf0 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
25d00 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
25d10 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%d,%d,%d',new.
25d20 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
25d30 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
25d40 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
25d50 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
25d60 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
25d70 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
25d80 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
25d90 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
25da0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
25db0 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
25dc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
25dd0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
25de0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
25df0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
25e00 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
25e10 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
25e20 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
25e30 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
25e40 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
25e50 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
25e60 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
25e70 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
25e80 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
25e90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
25ea0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
25eb0 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
25ec0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
25ed0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
25ee0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
25ef0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
25f00 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
25f10 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
25f20 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
25f30 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
25f40 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
25f50 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
25f60 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
25f70 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
25f80 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
25f90 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
25fa0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
25fb0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
25fc0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
25fd0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
25fe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
25ff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
26000 0d 00 00 00 07 01 7f 00 1b a3 17 46 12 f9 0e 96  ...........F....
26010 0a 39 05 dc 01 7f 00 00 00 00 00 00 00 00 00 00  .9..............
26020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
260a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
260b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
260c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
260d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
260e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
260f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
26170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 88  ................
26180 59 81 2b 04 00 91 37 20 20 43 52 45 41 54 45 20  Y.+...7  CREATE 
26190 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47  TABLE t1(a INTEG
261a0 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  ER PRIMARY KEY, 
261b0 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
261c0 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41   0);.  CREATE TA
261d0 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58  BLE record(x TEX
261e0 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52  T, y TEXT);.  CR
261f0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20  EATE TRIGGER r1 
26200 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e  BEFORE INSERT ON
26210 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
26220 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
26230 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
26240 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73  LUES('before-ins
26250 65 72 74 27 2c 70 72 69 6e 74 66 28 20 64 61 74  ert',printf( dat
26260 65 74 69 6d 65 28 31 2c 31 45 31 29 2c 6e 65 77  etime(1,1E1),new
26270 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
26280 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
26290 47 45 52 20 72 32 20 41 46 54 45 52 20 49 4e 53  GER r2 AFTER INS
262a0 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ERT ON t1 BEGIN.
262b0 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
262c0 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20  record(x,y)     
262d0 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e  VALUES('after-in
262e0 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64  sert',printf('%d
262f0 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65  ,%d,%d',new.a,ne
26300 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
26310 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
26320 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20 55  GGER r3 BEFORE U
26330 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
26340 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
26350 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
26360 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
26370 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69  fore-update',pri
26380 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
26390 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
263a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
263b0 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
263c0 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
263d0 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
263e0 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
263f0 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55  IGGER r4 AFTER U
26400 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
26410 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
26420 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
26430 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
26440 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ter-update',prin
26450 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
26460 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
26470 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
26480 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
26490 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
264a0 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
264b0 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e  c));.  END;.  IN
264c0 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
264d0 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20  ) VALUES(1,2);. 
264e0 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
264f0 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
26500 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
26510 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
26520 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
26530 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31  ATE SET c=t1.c+1
26540 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
26550 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45  M record;.  DELE
26560 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
26570 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
26580 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
26590 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
265a0 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
265b0 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63  ET c=c+1 WHERE c
265c0 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  <0;.  SELECT * F
265d0 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 59 81 2a  ROM record;..Y.*
265e0 04 00 91 37 20 20 43 52 45 41 54 45 20 54 41 42  ...7  CREATE TAB
265f0 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20  LE t1(a INTEGER 
26600 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
26610 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29  nt, c DEFAULT 0)
26620 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ;.  CREATE TABLE
26630 20 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20   record(x TEXT, 
26640 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54  y TEXT);.  CREAT
26650 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46  E TRIGGER r1 BEF
26660 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  ORE INSERT ON t1
26670 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
26680 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
26690 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
266a0 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74  S('before-insert
266b0 27 2c 70 72 69 6e 74 66 28 20 64 61 74 65 74 69  ',printf( dateti
266c0 6d 65 28 31 2c 31 2c 31 29 2c 6e 65 77 2e 62 2c  me(1,1,1),new.b,
266d0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
266e0 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
266f0 20 72 32 20 41 46 54 45 52 20 55 50 44 41 54 45   r2 AFTER UPDATE
26700 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
26710 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
26720 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c  ord(x,y)     VAL
26730 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72  UES('after-inser
26740 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  t',printf('%d,%d
26750 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
26760 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
26770 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
26780 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41  R r3 BEFORE UPDA
26790 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
267a0 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
267b0 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
267c0 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
267d0 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  e-update',printf
267e0 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
267f0 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
26800 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
26810 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
26820 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
26830 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
26840 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
26850 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41  ER r4 AFTER UPDA
26860 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
26870 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
26880 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
26890 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
268a0 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
268b0 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
268c0 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
268d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
268e0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
268f0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
26900 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
26910 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52  ;.  END;.  INSER
26920 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
26930 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45  ALUES(1,2);.  DE
26940 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
26950 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
26960 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
26970 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,2).    ON CONFL
26980 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
26990 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20   SET c=t1.c+1;. 
269a0 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
269b0 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20  ecord;.  DELETE 
269c0 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
269d0 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
269e0 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
269f0 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
26a00 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
26a10 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b  c=c+1 WHERE c<0;
26a20 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
26a30 20 72 65 63 6f 72 64 3b 0a 88 59 81 29 04 00 91   record;..Y.)...
26a40 37 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  7  CREATE TABLE 
26a50 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49  t1(a INTEGER PRI
26a60 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c  MARY KEY, b int,
26a70 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20   c DEFAULT 0);. 
26a80 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65   CREATE TABLE re
26a90 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54  cord(x TEXT, y T
26aa0 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54  EXT);.  CREATE T
26ab0 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45  RIGGER r1 BEFORE
26ac0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
26ad0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
26ae0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
26af0 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
26b00 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70  before-insert',p
26b10 72 69 6e 74 66 28 20 64 61 74 65 74 69 6d 65 28  rintf( datetime(
26b20 31 2c 31 2c 31 29 2c 6e 65 77 2e 62 2c 6e 65 77  1,1,1),new.b,new
26b30 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
26b40 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32  REATE TRIGGER r2
26b50 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e   AFTER INSERT ON
26b60 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
26b70 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
26b80 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53  (x,y)     VALUES
26b90 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c  ('after-insert',
26ba0 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
26bb0 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ',new.a,new.b,ne
26bc0 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
26bd0 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
26be0 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20  3 BEFORE UPDATE 
26bf0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
26c00 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
26c10 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
26c20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75  VALUES('before-u
26c30 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
26c40 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
26c50 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
26c60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
26c70 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
26c80 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
26c90 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
26ca0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
26cb0 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20  r4 AFTER UPDATE 
26cc0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
26cd0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
26ce0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
26cf0 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70  VALUES('after-up
26d00 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
26d10 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
26d20 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
26d30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
26d40 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
26d50 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
26d60 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
26d70 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49   END;.  INSERT I
26d80 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
26d90 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54  ES(1,2);.  DELET
26da0 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
26db0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
26dc0 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
26dd0 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
26de0 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
26df0 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45  T c=t1.c+1;.  SE
26e00 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
26e10 72 64 3b 0a 20 41 4e 41 4c 59 5a 45 20 46 52 4f  rd;. ANALYZE FRO
26e20 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
26e30 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
26e40 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
26e50 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
26e60 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63  O UPDATE SET c=c
26e70 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20  +1 WHERE c<0;.  
26e80 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
26e90 63 6f 72 64 3b 0a 88 5f 81 28 04 00 91 43 20 20  cord;.._.(...C  
26ea0 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
26eb0 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52  a INTEGER PRIMAR
26ec0 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20  Y KEY, b int, c 
26ed0 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52  DEFAULT 0);.  CR
26ee0 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72  EATE TABLE recor
26ef0 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58 54  d(x TEXT, y TEXT
26f00 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  );.  CREATE TRIG
26f10 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e  GER r1 BEFORE IN
26f20 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
26f30 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
26f40 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
26f50 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
26f60 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ore-insert',prin
26f70 74 66 28 20 64 61 74 65 74 69 6d 65 28 31 2c 31  tf( datetime(1,1
26f80 2c 31 29 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  ,1),new.b,new.c)
26f90 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
26fa0 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46  TE TRIGGER r2 AF
26fb0 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  TER INSERT ON t1
26fc0 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
26fd0 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
26fe0 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27 61  y)     VALUES('a
26ff0 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69  fter-insert',pri
27000 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
27010 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
27020 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
27030 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42  ATE TRIGGER r3 B
27040 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20  EFORE UPDATE ON 
27050 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
27060 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
27070 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
27080 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61  UES('before-upda
27090 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
270a0 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
270b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
270c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
270d0 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
270e0 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
270f0 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
27100 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20  EATE TRIGGER r4 
27110 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20  AFTER UPDATE ON 
27120 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
27130 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
27140 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
27150 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74  UES('after-updat
27160 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
27170 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
27180 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
27190 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
271a0 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
271b0 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
271c0 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
271d0 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  D;.  INSERT INTO
271e0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
271f0 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46  1,2);.  DELETE F
27200 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e  ROM record;.  IN
27210 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
27220 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20  ) VALUES(1,2).  
27230 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
27240 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
27250 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43  =t1.c+1;.  SELEC
27260 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
27270 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
27280 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
27290 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
272a0 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
272b0 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
272c0 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20  PDATE SET c=c+1 
272d0 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c  WHERE c<0;.  SEL
272e0 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
272f0 64 3b 56 41 43 55 55 4d 0a 88 49 81 27 04 00 91  d;VACUUM..I.'...
27300 17 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
27310 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49  t1(a INTEGER PRI
27320 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c  MARY KEY, b int,
27330 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20   c DEFAULT 0);. 
27340 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65   CREATE TABLE re
27350 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54  cord(x TEXT, y T
27360 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54  EXT);.  CREATE T
27370 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45  RIGGER r1 BEFORE
27380 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
27390 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
273a0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
273b0 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
273c0 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70  before-insert',p
273d0 72 69 6e 74 66 28 20 64 61 74 65 74 69 6d 65 28  rintf( datetime(
273e0 31 2c 31 2c 31 29 2c 6e 65 77 2e 62 2c 6e 65 77  1,1,1),new.b,new
273f0 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
27400 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32  REATE TRIGGER r2
27410 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e   AFTER INSERT ON
27420 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
27430 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
27440 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53  (x,y)     VALUES
27450 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c  ('after-insert',
27460 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
27470 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ',new.a,new.b,ne
27480 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
27490 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
274a0 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20  3 BEFORE UPDATE 
274b0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
274c0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
274d0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
274e0 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75  VALUES('before-u
274f0 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
27500 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
27510 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
27520 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
27530 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
27540 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
27550 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
27560 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
27570 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20  r4 AFTER UPDATE 
27580 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
27590 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
275a0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
275b0 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70  VALUES('after-up
275c0 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
275d0 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
275e0 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
275f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
27600 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
27610 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
27620 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
27630 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49   END;.  INSERT I
27640 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
27650 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54  ES(1,2);.  DELET
27660 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
27670 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
27680 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
27690 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
276a0 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
276b0 54 20 63 3d 20 73 74 72 66 74 69 6d 65 28 31 2c  T c= strftime(1,
276c0 31 2c 31 2c 31 29 20 46 52 4f 4d 20 72 65 63 6f  1,1,1) FROM reco
276d0 72 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  r record;.  INSE
276e0 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
276f0 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
27700 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
27710 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63  O UPDATE SET c=c
27720 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20  +1 WHERE c<0;.  
27730 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
27740 63 6f 72 64 3b 0a 88 59 81 26 04 00 91 37 20 20  cord;..Y.&...7  
27750 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
27760 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52  a INTEGER PRIMAR
27770 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20  Y KEY, b int, c 
27780 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52  DEFAULT 0);.  CR
27790 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72  EATE TABLE recor
277a0 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58 54  d(x TEXT, y TEXT
277b0 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  );.  CREATE TRIG
277c0 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e  GER r1 BEFORE IN
277d0 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
277e0 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
277f0 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
27800 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
27810 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ore-insert',prin
27820 74 66 28 20 64 61 74 65 74 69 6d 65 28 31 2c 31  tf( datetime(1,1
27830 2c 31 29 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  ,1),new.b,new.c)
27840 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
27850 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46  TE TRIGGER r2 AF
27860 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  TER INSERT ON t1
27870 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
27880 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
27890 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 20 63  y)     VALUES( c
278a0 6f 61 6c 65 73 63 65 28 31 2c 31 29 2c 70 72 69  oalesce(1,1),pri
278b0 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
278c0 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
278d0 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
278e0 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42  ATE TRIGGER r3 B
278f0 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20  EFORE UPDATE ON 
27900 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
27910 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
27920 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
27930 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61  UES('before-upda
27940 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
27950 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
27960 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
27970 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
27980 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
27990 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
279a0 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
279b0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20  EATE TRIGGER r4 
279c0 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20  AFTER UPDATE ON 
279d0 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
279e0 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
279f0 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
27a00 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74  UES('after-updat
27a10 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
27a20 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
27a30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
27a40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
27a50 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
27a60 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
27a70 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
27a80 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  D;.  INSERT INTO
27a90 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
27aa0 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46  1,2);.  DELETE F
27ab0 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e  ROM record;.  IN
27ac0 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
27ad0 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20  ) VALUES(1,2).  
27ae0 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
27af0 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
27b00 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43  =t1.c+1;.  SELEC
27b10 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
27b20 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
27b30 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
27b40 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
27b50 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
27b60 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
27b70 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20  PDATE SET c=c+1 
27b80 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c  WHERE c<0;.  SEL
27b90 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
27ba0 64 3b 0a 88 59 81 25 04 00 91 37 20 20 43 52 45  d;..Y.%...7  CRE
27bb0 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49  ATE TABLE t1(a I
27bc0 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b  NTEGER PRIMARY K
27bd0 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46  EY, b int, c DEF
27be0 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54  AULT 0);.  CREAT
27bf0 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78  E TABLE record(x
27c00 20 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a   TEXT, y TEXT);.
27c10 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
27c20 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52   r1 BEFORE INSER
27c30 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
27c40 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
27c50 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
27c60 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
27c70 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
27c80 20 64 61 74 65 74 69 6d 65 28 31 2c 20 2d 31 29   datetime(1, -1)
27c90 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
27ca0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
27cb0 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
27cc0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
27cd0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
27ce0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
27cf0 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
27d00 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
27d10 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%d,%d,%d',new.
27d20 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
27d30 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
27d40 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
27d50 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
27d60 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
27d70 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
27d80 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
27d90 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
27da0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
27db0 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
27dc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
27dd0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
27de0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
27df0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
27e00 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
27e10 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
27e20 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
27e30 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
27e40 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
27e50 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
27e60 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
27e70 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
27e80 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
27e90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
27ea0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
27eb0 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
27ec0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
27ed0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
27ee0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
27ef0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
27f00 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
27f10 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
27f20 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
27f30 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
27f40 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
27f50 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
27f60 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
27f70 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
27f80 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
27f90 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
27fa0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
27fb0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
27fc0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
27fd0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
27fe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
27ff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
28000 0d 00 00 00 07 01 97 00 1b a3 17 46 12 f9 0e aa  ...........F....
28010 0a 4d 05 fe 01 97 00 00 00 00 00 00 00 00 00 00  .M..............
28020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
280a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
280b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
280c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
280d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
280e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
280f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
28190 00 00 00 00 00 00 00 88 63 81 32 04 00 91 4b 20  ........c.2...K 
281a0 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
281b0 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41  (a INTEGER PRIMA
281c0 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63  RY KEY, b int, c
281d0 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43   DEFAULT 0);.  C
281e0 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f  REATE TABLE reco
281f0 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58  rd(x TEXT, y TEX
28200 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  T);.  CREATE TRI
28210 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49  GGER r1 BEFORE I
28220 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
28230 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
28240 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
28250 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
28260 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69  fore-insert',pri
28270 6e 74 66 28 20 74 72 69 6d 28 20 6c 74 72 69 6d  ntf( trim( ltrim
28280 28 31 2c 31 29 2c 31 29 2c 6e 65 77 2e 61 2c 6e  (1,1),1),new.a,n
28290 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
282a0 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
282b0 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49  IGGER r2 AFTER I
282c0 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
282d0 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
282e0 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20  O record(x,y)   
282f0 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
28300 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
28310 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c  %d,%d,%d',new.a,
28320 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
28330 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
28340 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45  RIGGER r3 BEFORE
28350 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
28360 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
28370 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
28380 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
28390 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70  before-update',p
283a0 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
283b0 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
283c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
283d0 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
283e0 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
283f0 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
28400 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
28410 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52  TRIGGER r4 AFTER
28420 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
28430 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
28440 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
28450 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
28460 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72  after-update',pr
28470 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
28480 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
28490 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
284a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
284b0 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e  old.a,old.b,old.
284c0 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  c,new.a,new.b,ne
284d0 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
284e0 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
284f0 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b  ,b) VALUES(1,2);
28500 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
28510 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
28520 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
28530 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
28540 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
28550 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63  PDATE SET c=t1.c
28560 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  +1;.  SELECT * F
28570 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45  ROM record;.  DE
28580 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
28590 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
285a0 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
285b0 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,2).    ON CONFL
285c0 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
285d0 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45   SET c=c+1 WHERE
285e0 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a   c<0;.  SELECT *
285f0 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 4b   FROM record;..K
28600 81 31 04 00 91 1b 20 20 43 52 45 41 54 45 20 54  .1....  CREATE T
28610 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45  ABLE t1(a INTEGE
28620 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62  R PRIMARY KEY, b
28630 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20   int, c DEFAULT 
28640 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42  0);.  CREATE TAB
28650 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58 54  LE record(x TEXT
28660 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45  , y TEXT);.  CRE
28670 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20 42  ATE TRIGGER r1 B
28680 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20  EFORE INSERT ON 
28690 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
286a0 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
286b0 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
286c0 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65  UES('before-inse
286d0 72 74 27 2c 70 72 69 6e 74 66 28 20 73 71 6c 69  rt',printf( sqli
286e0 74 65 5f 63 6f 6d 70 69 6c 65 6f 70 74 69 6f 6e  te_compileoption
286f0 5f 67 65 74 28 31 29 29 29 3b 0a 20 20 45 4e 44  _get(1)));.  END
28700 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
28710 45 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45  ER r2 AFTER INSE
28720 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  RT ON t1 BEGIN. 
28730 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
28740 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56  ecord(x,y)     V
28750 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73  ALUES('after-ins
28760 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ert',printf('%d,
28770 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77  %d,%d',new.a,new
28780 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
28790 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
287a0 47 45 52 20 72 33 20 42 45 46 4f 52 45 20 55 50  GER r3 BEFORE UP
287b0 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e  DATE ON t1 BEGIN
287c0 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
287d0 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
287e0 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
287f0 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ore-update',prin
28800 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
28810 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
28820 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
28830 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
28840 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
28850 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
28860 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50  GGER r4 AFTER UP
28870 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e  DATE ON t1 BEGIN
28880 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
28890 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
288a0 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74       VALUES('aft
288b0 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74  er-update',print
288c0 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25  f('%d,%d,%d/%d,%
288d0 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20  d,%d',.         
288e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
288f0 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64               old
28900 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e  .a,old.b,old.c,n
28910 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
28920 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53  ));.  END;.  INS
28930 45 52 54 20 49 4e 54 4f 20 74 31 28 63 2c 62 29  ERT INTO t1(c,b)
28940 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20   VALUES(1,2);.  
28950 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
28960 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
28970 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
28980 28 31 2c 32 29 0a 4f 4e 20 43 4f 4e 46 4c 49 43  (1,2).ON CONFLIC
28990 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
289a0 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53  ET c=t1.c+1;.  S
289b0 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63  ELECT * FROM rec
289c0 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  ord;.  DELETE FR
289d0 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
289e0 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
289f0 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20   VALUES(1,2).   
28a00 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20   ON CONFLICT(a) 
28a10 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d  DO UPDATE SET c=
28a20 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20  c+1 WHERE c<0;. 
28a30 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
28a40 65 63 6f 72 64 3b 56 41 43 55 55 4d 0a 88 59 81  ecord;VACUUM..Y.
28a50 30 04 00 91 37 20 20 43 52 45 41 54 45 20 54 41  0...7  CREATE TA
28a60 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52  BLE t1(a INTEGER
28a70 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20   PRIMARY KEY, b 
28a80 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30  int, c DEFAULT 0
28a90 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c  );.  CREATE TABL
28aa0 45 20 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c  E record(x TEXT,
28ab0 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41   y TEXT);.  CREA
28ac0 54 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45  TE TRIGGER r1 BE
28ad0 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74  FORE INSERT ON t
28ae0 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
28af0 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
28b00 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
28b10 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72  ES('before-inser
28b20 74 27 2c 70 72 69 6e 74 66 28 20 6c 69 6b 65 6c  t',printf( likel
28b30 79 28 31 29 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  y(1),new.a,new.b
28b40 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
28b50 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
28b60 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52  R r2 AFTER INSER
28b70 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
28b80 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
28b90 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41  cord(x,y)     VA
28ba0 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65  LUES('after-inse
28bb0 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  rt',printf('%d,%
28bc0 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e  d,%d',new.a,new.
28bd0 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
28be0 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
28bf0 45 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44  ER r3 BEFORE UPD
28c00 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
28c10 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
28c20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
28c30 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f      VALUES('befo
28c40 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74  re-update',print
28c50 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25  f('%d,%d,%d/%d,%
28c60 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20  d,%d',.         
28c70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
28c80 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
28c90 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
28ca0 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
28cb0 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
28cc0 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44  GER r4 AFTER UPD
28cd0 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
28ce0 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
28cf0 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
28d00 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
28d10 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  r-update',printf
28d20 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
28d30 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
28d40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
28d50 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e              old.
28d60 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65  a,old.b,old.c,ne
28d70 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
28d80 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45  );.  END;.  INSE
28d90 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
28da0 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44  VALUES(1,2);.  D
28db0 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
28dc0 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
28dd0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
28de0 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46  1,2).    ON CONF
28df0 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54  LICT(a) DO UPDAT
28e00 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a  E SET c=t1.c+1;.
28e10 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
28e20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45  record;.  DELETE
28e30 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
28e40 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
28e50 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
28e60 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
28e70 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
28e80 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30   c=c+1 WHERE c<0
28e90 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
28ea0 4d 20 72 65 63 6f 72 64 3b 0a 88 4b 81 2f 04 00  M record;..K./..
28eb0 91 1b 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ..  CREATE TABLE
28ec0 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
28ed0 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74  IMARY KEY, b int
28ee0 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a  , c DEFAULT 0);.
28ef0 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72    CREATE TABLE r
28f00 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20  ecord(x TEXT, y 
28f10 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20  TEXT);.  CREATE 
28f20 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52  TRIGGER r1 BEFOR
28f30 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  E INSERT ON t1 B
28f40 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
28f50 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
28f60 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
28f70 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c  'before-insert',
28f80 70 72 69 6e 74 66 28 20 6c 65 6e 67 74 68 28 31  printf( length(1
28f90 29 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ),new.a,new.b,ne
28fa0 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
28fb0 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
28fc0 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f  2 AFTER INSERT O
28fd0 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
28fe0 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
28ff0 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45  d(x,y)     VALUE
29000 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27  S('after-insert'
29010 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
29020 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
29030 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
29040 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
29050 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45  r3 BEFORE UPDATE
29060 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
29070 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
29080 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
29090 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
290a0 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
290b0 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
290c0 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
290d0 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
290e0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
290f0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
29100 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
29110 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45   r4 AFTER UPDATE
29120 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
29130 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
29140 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
29150 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75   VALUES('after-u
29160 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
29170 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
29180 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
29190 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
291a0 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
291b0 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
291c0 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
291d0 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20    END;.  INSERT 
291e0 49 4e 54 4f 20 74 31 28 63 2c 62 29 20 56 41 4c  INTO t1(c,b) VAL
291f0 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45  UES(1,2);.  DELE
29200 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
29210 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
29220 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
29230 29 0a 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29  ).ON CONFLICT(a)
29240 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
29250 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43  =t1.c+1;.  SELEC
29260 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
29270 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
29280 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
29290 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
292a0 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
292b0 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
292c0 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20  PDATE SET c=c+1 
292d0 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c  WHERE c<0;.  SEL
292e0 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
292f0 64 3b 56 41 43 55 55 4d 0a 88 49 81 2e 04 00 91  d;VACUUM..I.....
29300 17 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
29310 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49  t1(a INTEGER PRI
29320 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c  MARY KEY, b int,
29330 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20   c DEFAULT 0);. 
29340 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65   CREATE TABLE re
29350 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54  cord(x TEXT, y T
29360 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54  EXT);.  CREATE T
29370 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45  RIGGER r1 BEFORE
29380 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
29390 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
293a0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
293b0 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
293c0 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70  before-insert',p
293d0 72 69 6e 74 66 28 20 6a 73 6f 6e 5f 73 65 74 28  rintf( json_set(
293e0 31 2c 31 2c 31 29 2c 6e 65 77 2e 62 2c 6e 65 77  1,1,1),new.b,new
293f0 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
29400 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32  REATE TRIGGER r2
29410 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e   AFTER INSERT ON
29420 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
29430 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
29440 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53  (x,y)     VALUES
29450 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c  ('after-insert',
29460 70 72 69 6e 74 66 28 20 6a 73 6f 6e 5f 73 65 74  printf( json_set
29470 28 31 2c 31 2c 31 29 2c 6e 65 77 2e 62 2c 6e 65  (1,1,1),new.b,ne
29480 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
29490 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
294a0 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20  3 BEFORE UPDATE 
294b0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
294c0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
294d0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
294e0 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75  VALUES('before-u
294f0 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
29500 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
29510 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
29520 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
29530 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
29540 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
29550 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
29560 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
29570 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20  r4 AFTER UPDATE 
29580 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
29590 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
295a0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
295b0 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70  VALUES('after-up
295c0 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
295d0 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
295e0 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
295f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
29600 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
29610 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
29620 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
29630 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49   END;.  INSERT I
29640 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
29650 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54  ES(1,2);.  DELET
29660 45 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28  EINSERT INTO t1(
29670 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
29680 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
29690 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
296a0 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45  T c=t1.c+1;.  SE
296b0 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
296c0 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  rd;.  DELETE FRO
296d0 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
296e0 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
296f0 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
29700 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
29710 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63  O UPDATE SET c=c
29720 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20  +1 WHERE c<0;.  
29730 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
29740 63 6f 72 64 3b 0a 88 59 81 2d 04 00 91 37 20 20  cord;..Y.-...7  
29750 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
29760 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52  a INTEGER PRIMAR
29770 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20  Y KEY, b int, c 
29780 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52  DEFAULT 0);.  CR
29790 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72  EATE TABLE recor
297a0 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58 54  d(x TEXT, y TEXT
297b0 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  );.  CREATE TRIG
297c0 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e  GER r1 BEFORE IN
297d0 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
297e0 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
297f0 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
29800 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
29810 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ore-insert',prin
29820 74 66 28 20 6a 73 6f 6e 5f 70 61 74 63 68 28 31  tf( json_patch(1
29830 2c 31 29 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  ,1),new.b,new.c)
29840 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
29850 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46  TE TRIGGER r2 AF
29860 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  TER INSERT ON t1
29870 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
29880 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
29890 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27 61  y)     VALUES('a
298a0 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69  fter-insert',pri
298b0 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
298c0 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
298d0 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
298e0 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42  ATE TRIGGER r3 B
298f0 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20  EFORE UPDATE ON 
29900 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
29910 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
29920 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
29930 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61  UES('before-upda
29940 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
29950 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
29960 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
29970 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
29980 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
29990 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
299a0 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
299b0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20  EATE TRIGGER r4 
299c0 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20  AFTER UPDATE ON 
299d0 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
299e0 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
299f0 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
29a00 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74  UES('after-updat
29a10 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
29a20 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
29a30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
29a40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
29a50 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
29a60 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
29a70 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
29a80 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  D;.  INSERT INTO
29a90 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
29aa0 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46  1,2);.  DELETE F
29ab0 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e  ROM record;.  IN
29ac0 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
29ad0 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20  ) VALUES(1,2).  
29ae0 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
29af0 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
29b00 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43  =t1.c+1;.  SELEC
29b10 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
29b20 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
29b30 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
29b40 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
29b50 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
29b60 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
29b70 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20  PDATE SET c=c+1 
29b80 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c  WHERE c<0;.  SEL
29b90 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
29ba0 64 3b 0a 88 59 81 2c 04 00 91 37 20 20 43 52 45  d;..Y.,...7  CRE
29bb0 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49  ATE TABLE t1(a I
29bc0 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b  NTEGER PRIMARY K
29bd0 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46  EY, b int, c DEF
29be0 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54  AULT 0);.  CREAT
29bf0 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78  E TABLE record(x
29c00 20 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a   TEXT, y TEXT);.
29c10 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
29c20 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52   r1 BEFORE INSER
29c30 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
29c40 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
29c50 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
29c60 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
29c70 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
29c80 20 64 61 74 65 74 69 6d 65 28 31 2e 31 2c 31 29   datetime(1.1,1)
29c90 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
29ca0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
29cb0 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
29cc0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
29cd0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
29ce0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
29cf0 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
29d00 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
29d10 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%d,%d,%d',new.
29d20 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
29d30 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
29d40 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
29d50 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
29d60 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
29d70 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
29d80 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
29d90 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
29da0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
29db0 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
29dc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
29dd0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
29de0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
29df0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
29e00 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
29e10 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
29e20 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
29e30 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
29e40 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
29e50 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
29e60 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
29e70 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
29e80 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
29e90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
29ea0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
29eb0 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
29ec0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
29ed0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
29ee0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
29ef0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
29f00 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
29f10 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
29f20 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
29f30 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
29f40 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
29f50 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
29f60 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
29f70 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
29f80 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
29f90 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
29fa0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
29fb0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
29fc0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
29fd0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
29fe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
29ff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
2a000 0d 00 00 00 07 01 9a 00 1b a0 17 47 12 f8 0e a9  ...........G....
2a010 0a 50 05 f7 01 9a 00 00 00 00 00 00 00 00 00 00  .P..............
2a020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a0a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a0b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a0c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a0d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a0e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a0f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2a190 00 00 00 00 00 00 00 00 00 00 88 59 81 39 04 00  ...........Y.9..
2a1a0 91 37 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  .7  CREATE TABLE
2a1b0 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
2a1c0 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74  IMARY KEY, b int
2a1d0 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a  , c DEFAULT 0);.
2a1e0 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72    CREATE TABLE r
2a1f0 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20  ecord(x TEXT, y 
2a200 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20  TEXT);.  CREATE 
2a210 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52  TRIGGER r1 BEFOR
2a220 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  E INSERT ON t1 B
2a230 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
2a240 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
2a250 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
2a260 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c  'before-insert',
2a270 70 72 69 6e 74 66 28 20 74 72 69 6d 28 31 2c 31  printf( trim(1,1
2a280 29 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ),new.a,new.b,ne
2a290 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
2a2a0 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
2a2b0 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f  2 AFTER INSERT O
2a2c0 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
2a2d0 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
2a2e0 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45  d(x,y)     VALUE
2a2f0 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27  S('after-insert'
2a300 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
2a310 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
2a320 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
2a330 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
2a340 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45  r3 BEFORE UPDATE
2a350 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
2a360 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
2a370 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
2a380 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
2a390 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
2a3a0 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
2a3b0 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
2a3c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2a3d0 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
2a3e0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
2a3f0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
2a400 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
2a410 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45   r4 AFTER UPDATE
2a420 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
2a430 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
2a440 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
2a450 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75   VALUES('after-u
2a460 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
2a470 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
2a480 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
2a490 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2a4a0 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
2a4b0 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
2a4c0 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
2a4d0 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20    END;.  INSERT 
2a4e0 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
2a4f0 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45  UES(1,2);.  DELE
2a500 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
2a510 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
2a520 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
2a530 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
2a540 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
2a550 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53  ET c=t1.c+1;.  S
2a560 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63  ELECT * FROM rec
2a570 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  ord;.  DELETE FR
2a580 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 41 4e 41 4c  OM record;. ANAL
2a590 59 5a 45 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  YZE INTO t1(a,b)
2a5a0 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20   VALUES(1,2).   
2a5b0 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20   ON CONFLICT(a) 
2a5c0 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d  DO UPDATE SET c=
2a5d0 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20  c+1 WHERE c<0;. 
2a5e0 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
2a5f0 65 63 6f 72 64 3b 0a 88 55 81 38 04 00 91 2f 20  ecord;..U.8.../ 
2a600 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
2a610 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41  (a INTEGER PRIMA
2a620 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63  RY KEY, b int, c
2a630 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43   DEFAULT 0);.  C
2a640 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f  REATE TABLE reco
2a650 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58  rd(x TEXT, y TEX
2a660 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  T);.  CREATE TRI
2a670 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49  GGER r1 BEFORE I
2a680 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
2a690 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
2a6a0 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
2a6b0 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
2a6c0 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69  fore-insert',pri
2a6d0 6e 74 66 28 20 74 72 69 6d 28 31 2c 31 29 2c 6e  ntf( trim(1,1),n
2a6e0 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
2a6f0 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
2a700 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
2a710 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74  FTER INSERT ON t
2a720 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
2a730 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
2a740 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27  ,y)     VALUES('
2a750 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
2a760 69 6e 74 66 28 20 74 72 69 6d 28 31 2c 31 29 2c  intf( trim(1,1),
2a770 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
2a780 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
2a790 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
2a7a0 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e  BEFORE UPDATE ON
2a7b0 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
2a7c0 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
2a7d0 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
2a7e0 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64  LUES('before-upd
2a7f0 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
2a800 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
2a810 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
2a820 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
2a830 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
2a840 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
2a850 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
2a860 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34  REATE TRIGGER r4
2a870 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e   AFTER UPDATE ON
2a880 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
2a890 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
2a8a0 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
2a8b0 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61  LUES('after-upda
2a8c0 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
2a8d0 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
2a8e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2a8f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2a900 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
2a910 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
2a920 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
2a930 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ND;.  INSERT INT
2a940 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
2a950 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20  (1,2);.  DELETE 
2a960 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
2a970 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
2a980 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 4f  b) VALUES(1,2).O
2a990 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
2a9a0 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
2a9b0 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
2a9c0 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
2a9d0 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
2a9e0 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
2a9f0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
2aa00 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
2aa10 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
2aa20 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
2aa30 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
2aa40 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
2aa50 88 55 81 37 04 00 91 2f 20 20 43 52 45 41 54 45  .U.7.../  CREATE
2aa60 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45   TABLE t1(a INTE
2aa70 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c  GER PRIMARY KEY,
2aa80 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c   b int, c DEFAUL
2aa90 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54  T 0);.  CREATE T
2aaa0 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45  ABLE record(x TE
2aab0 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43  XT, y TEXT);.  C
2aac0 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31  REATE TRIGGER r1
2aad0 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f   BEFORE INSERT O
2aae0 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
2aaf0 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
2ab00 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
2ab10 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e  ALUES('before-in
2ab20 73 65 72 74 27 2c 70 72 69 6e 74 66 28 20 74 72  sert',printf( tr
2ab30 69 6d 28 31 2c 31 29 2c 6e 65 77 2e 61 2c 6e 65  im(1,1),new.a,ne
2ab40 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
2ab50 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
2ab60 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49 4e  GGER r2 AFTER IN
2ab70 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
2ab80 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
2ab90 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20   record(x,y)    
2aba0 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69   VALUES('after-i
2abb0 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 20 67  nsert',printf( g
2abc0 6c 6f 62 28 31 2c 31 29 2c 6e 65 77 2e 61 2c 6e  lob(1,1),new.a,n
2abd0 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
2abe0 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
2abf0 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20  IGGER r3 BEFORE 
2ac00 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
2ac10 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
2ac20 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
2ac30 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
2ac40 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72  efore-update',pr
2ac50 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
2ac60 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
2ac70 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
2ac80 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
2ac90 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
2aca0 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
2acb0 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20  RIGGER r4 AFTER 
2acc0 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
2acd0 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
2ace0 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
2acf0 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61         VALUES('a
2ad00 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69  fter-update',pri
2ad10 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
2ad20 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
2ad30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2ad40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
2ad50 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
2ad60 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
2ad70 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49  .c));.  END;.  I
2ad80 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
2ad90 62 29 20 56 41 4c 55 45 53 28 32 30 30 31 2d 30  b) VALUES(2001-0
2ada0 31 2d 30 31 31 2c 32 29 3b 0a 20 20 44 45 4c 45  1-011,2);.  DELE
2adb0 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
2adc0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
2add0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
2ade0 29 0a 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29  ).ON CONFLICT(a)
2adf0 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
2ae00 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43  =t1.c+1;.  SELEC
2ae10 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
2ae20 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
2ae30 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
2ae40 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
2ae50 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
2ae60 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
2ae70 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20  PDATE SET c=c+1 
2ae80 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c  WHERE c<0;.  SEL
2ae90 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
2aea0 64 3b 56 41 43 55 55 4d 0a 88 4b 81 36 04 00 91  d;VACUUM..K.6...
2aeb0 1b 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
2aec0 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49  t1(a INTEGER PRI
2aed0 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c  MARY KEY, b int,
2aee0 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20   c DEFAULT 0);. 
2aef0 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65   CREATE TABLE re
2af00 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54  cord(x TEXT, y T
2af10 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54  EXT);.  CREATE T
2af20 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45  RIGGER r1 BEFORE
2af30 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
2af40 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
2af50 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
2af60 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
2af70 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70  before-insert',p
2af80 72 69 6e 74 66 28 20 74 72 69 6d 28 31 2c 31 29  rintf( trim(1,1)
2af90 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
2afa0 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
2afb0 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32  REATE TRIGGER r2
2afc0 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e   AFTER INSERT ON
2afd0 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
2afe0 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
2aff0 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53  (x,y)     VALUES
2b000 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c  ('after-insert',
2b010 70 72 69 6e 74 66 28 20 67 6c 6f 62 28 31 2c 31  printf( glob(1,1
2b020 29 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ),new.a,new.b,ne
2b030 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
2b040 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
2b050 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20  3 BEFORE UPDATE 
2b060 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
2b070 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
2b080 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
2b090 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75  VALUES('before-u
2b0a0 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
2b0b0 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
2b0c0 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
2b0d0 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
2b0e0 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
2b0f0 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
2b100 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
2b110 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20  r4 AFTER UPDATE 
2b120 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
2b130 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
2b140 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
2b150 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70  VALUES('after-up
2b160 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
2b170 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
2b180 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
2b190 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2b1a0 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
2b1b0 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
2b1c0 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
2b1d0 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49   END;.  INSERT I
2b1e0 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
2b1f0 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54  ES(1,2);.  DELET
2b200 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
2b210 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
2b220 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
2b230 0a 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20  .ON CONFLICT(a) 
2b240 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d  DO UPDATE SET c=
2b250 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54  t1.c+1;.  SELECT
2b260 20 61 62 73 28 31 29 20 72 65 63 6f 72 64 3b 0a   abs(1) record;.
2b270 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
2b280 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
2b290 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
2b2a0 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43  ES(1,2).    ON C
2b2b0 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50  ONFLICT(a) DO UP
2b2c0 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57  DATE SET c=c+1 W
2b2d0 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45  HERE c<0;.  SELE
2b2e0 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64  CT * FROM record
2b2f0 3b 56 41 43 55 55 4d 0a 88 4b 81 35 04 00 91 1b  ;VACUUM..K.5....
2b300 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
2b310 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d  1(a INTEGER PRIM
2b320 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20  ARY KEY, b int, 
2b330 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20  c DEFAULT 0);.  
2b340 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63  CREATE TABLE rec
2b350 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45  ord(x TEXT, y TE
2b360 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52  XT);.  CREATE TR
2b370 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20  IGGER r1 BEFORE 
2b380 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
2b390 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
2b3a0 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
2b3b0 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
2b3c0 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72  efore-insert',pr
2b3d0 69 6e 74 66 28 20 74 72 69 6d 28 31 2c 31 29 2c  intf( trim(1,1),
2b3e0 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
2b3f0 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
2b400 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20  EATE TRIGGER r2 
2b410 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20  AFTER INSERT ON 
2b420 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
2b430 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
2b440 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28  x,y)     VALUES(
2b450 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70  'after-insert',p
2b460 72 69 6e 74 66 28 20 67 6c 6f 62 28 31 2c 31 29  rintf( glob(1,1)
2b470 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
2b480 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
2b490 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33  REATE TRIGGER r3
2b4a0 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f   BEFORE UPDATE O
2b4b0 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
2b4c0 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
2b4d0 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
2b4e0 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70  ALUES('before-up
2b4f0 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
2b500 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
2b510 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
2b520 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e  old.a,old.b,old.
2b530 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  c,new.a,new.b,ne
2b540 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
2b550 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
2b560 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f  4 AFTER UPDATE O
2b570 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
2b580 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
2b590 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
2b5a0 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64  ALUES('after-upd
2b5b0 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
2b5c0 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
2b5d0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
2b5e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2b5f0 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
2b600 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
2b610 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
2b620 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  END;.  INSERT IN
2b630 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
2b640 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45  S(1,2);.  DELETE
2b650 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
2b660 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
2b670 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
2b680 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
2b690 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74  O UPDATE SET c=t
2b6a0 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20  1.c+1;.  SELECT 
2b6b0 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  * FROM record;. 
2b6c0 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
2b6d0 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
2b6e0 54 4f 20 74 31 28 63 2c 62 29 20 56 41 4c 55 45  TO t1(c,b) VALUE
2b6f0 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
2b700 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
2b710 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48  ATE SET c=c+1 WH
2b720 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43  ERE c<0;.  SELEC
2b730 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
2b740 56 41 43 55 55 4d 0a 88 55 81 34 04 00 91 2f 20  VACUUM..U.4.../ 
2b750 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
2b760 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41  (a INTEGER PRIMA
2b770 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63  RY KEY, b int, c
2b780 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43   DEFAULT 0);.  C
2b790 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f  REATE TABLE reco
2b7a0 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58  rd(x TEXT, y TEX
2b7b0 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  T);.  CREATE TRI
2b7c0 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49  GGER r1 BEFORE I
2b7d0 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
2b7e0 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
2b7f0 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
2b800 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
2b810 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69  fore-insert',pri
2b820 6e 74 66 28 20 74 72 69 6d 28 31 2c 31 29 2c 20  ntf( trim(1,1), 
2b830 69 6e 73 74 72 28 31 2c 31 29 2c 6e 65 77 2e 63  instr(1,1),new.c
2b840 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
2b850 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
2b860 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74  FTER INSERT ON t
2b870 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
2b880 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
2b890 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27  ,y)     VALUES('
2b8a0 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
2b8b0 69 6e 74 66 28 20 67 6c 6f 62 28 31 2c 31 29 2c  intf( glob(1,1),
2b8c0 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
2b8d0 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
2b8e0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
2b8f0 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e  BEFORE UPDATE ON
2b900 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
2b910 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
2b920 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
2b930 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64  LUES('before-upd
2b940 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
2b950 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
2b960 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
2b970 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
2b980 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
2b990 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
2b9a0 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
2b9b0 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34  REATE TRIGGER r4
2b9c0 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e   AFTER UPDATE ON
2b9d0 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
2b9e0 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
2b9f0 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
2ba00 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61  LUES('after-upda
2ba10 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
2ba20 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
2ba30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2ba40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2ba50 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
2ba60 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
2ba70 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
2ba80 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ND;.  INSERT INT
2ba90 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
2baa0 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20  (1,2);.  DELETE 
2bab0 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
2bac0 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
2bad0 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 4f  b) VALUES(1,2).O
2bae0 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
2baf0 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
2bb00 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
2bb10 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
2bb20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
2bb30 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
2bb40 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
2bb50 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
2bb60 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
2bb70 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
2bb80 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
2bb90 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
2bba0 88 5c 81 33 04 00 91 3d 20 20 43 52 45 41 54 45  .\.3...=  CREATE
2bbb0 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45   TABLE t1(a INTE
2bbc0 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c  GER PRIMARY KEY,
2bbd0 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c   b int, c DEFAUL
2bbe0 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54  T 0);.  CREATE T
2bbf0 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45  ABLE record(x TE
2bc00 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43  XT, y TEXT);.  C
2bc10 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31  REATE TRIGGER r1
2bc20 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f   BEFORE INSERT O
2bc30 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
2bc40 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
2bc50 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
2bc60 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e  ALUES('before-in
2bc70 73 65 72 74 27 2c 70 72 69 6e 74 66 28 20 74 72  sert',printf( tr
2bc80 69 6d 28 31 2c 20 2d 31 31 29 2c 6e 65 77 2e 61  im(1, -11),new.a
2bc90 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
2bca0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
2bcb0 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
2bcc0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
2bcd0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
2bce0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
2bcf0 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
2bd00 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
2bd10 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%d,%d,%d',new.
2bd20 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
2bd30 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
2bd40 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
2bd50 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
2bd60 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
2bd70 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
2bd80 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
2bd90 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
2bda0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
2bdb0 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
2bdc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2bdd0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
2bde0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
2bdf0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
2be00 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
2be10 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
2be20 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
2be30 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
2be40 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
2be50 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
2be60 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
2be70 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
2be80 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
2be90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2bea0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2beb0 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
2bec0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
2bed0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
2bee0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
2bef0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
2bf00 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
2bf10 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
2bf20 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
2bf30 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
2bf40 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
2bf50 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
2bf60 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
2bf70 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
2bf80 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
2bf90 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
2bfa0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
2bfb0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
2bfc0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
2bfd0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
2bfe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
2bff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
2c000 0d 00 00 00 07 01 2a 00 1b ab 17 41 12 d0 0e 5f  ......*....A..._
2c010 09 f8 05 91 01 2a 00 00 00 00 00 00 00 00 00 00  .....*..........
2c020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c0a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c0b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c0c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c0d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c0e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c0f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2c120 00 00 00 00 00 00 00 00 00 00 88 63 81 40 04 00  ...........c.@..
2c130 91 4b 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  .K  CREATE TABLE
2c140 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
2c150 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74  IMARY KEY, b int
2c160 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a  , c DEFAULT 0);.
2c170 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72    CREATE TABLE r
2c180 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20  ecord(x TEXT, y 
2c190 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20  TEXT);.  CREATE 
2c1a0 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52  TRIGGER r1 BEFOR
2c1b0 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  E INSERT ON t1 B
2c1c0 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
2c1d0 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
2c1e0 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
2c1f0 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c  'before-insert',
2c200 70 72 69 6e 74 66 28 20 74 72 69 6d 28 31 32 30  printf( trim(120
2c210 30 31 45 30 31 2d 30 31 2c 31 29 2c 6e 65 77 2e  01E01-01,1),new.
2c220 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
2c230 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
2c240 20 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45   TRIGGER r2 AFTE
2c250 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  R INSERT ON t1 B
2c260 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
2c270 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
2c280 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74       VALUES('aft
2c290 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74  er-insert',print
2c2a0 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77  f('%d,%d,%d',new
2c2b0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
2c2c0 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
2c2d0 45 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46  E TRIGGER r3 BEF
2c2e0 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31  ORE UPDATE ON t1
2c2f0 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
2c300 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
2c310 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
2c320 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65  S('before-update
2c330 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
2c340 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20  %d/%d,%d,%d',.  
2c350 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2c360 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e              old.
2c370 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65  a,old.b,old.c,ne
2c380 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
2c390 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
2c3a0 54 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46  TE TRIGGER r4 AF
2c3b0 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31  TER UPDATE ON t1
2c3c0 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
2c3d0 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
2c3e0 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
2c3f0 53 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27  S('after-update'
2c400 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
2c410 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
2c420 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2c430 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2c440 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f     old.a,old.b,o
2c450 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ld.c,new.a,new.b
2c460 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
2c470 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
2c480 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
2c490 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  2);.  DELETE FRO
2c4a0 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
2c4b0 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
2c4c0 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
2c4d0 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
2c4e0 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74  O UPDATE SET c=t
2c4f0 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20  1.c+1;.  SELECT 
2c500 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  * FROM record;. 
2c510 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
2c520 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
2c530 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
2c540 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
2c550 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
2c560 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48  ATE SET c=c+1 WH
2c570 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43  ERE c<0;.  SELEC
2c580 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
2c590 0a 88 63 81 3f 04 00 91 4b 20 20 43 52 45 41 54  ..c.?...K  CREAT
2c5a0 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54  E TABLE t1(a INT
2c5b0 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59  EGER PRIMARY KEY
2c5c0 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55  , b int, c DEFAU
2c5d0 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20  LT 0);.  CREATE 
2c5e0 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54  TABLE record(x T
2c5f0 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20  EXT, y TEXT);.  
2c600 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
2c610 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20  1 BEFORE INSERT 
2c620 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
2c630 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
2c640 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
2c650 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69  VALUES('before-i
2c660 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 20 74  nsert',printf( t
2c670 72 69 6d 28 31 32 30 30 31 2d 30 31 2d 4e 55 4c  rim(12001-01-NUL
2c680 4c 29 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  L),new.a,new.b,n
2c690 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
2c6a0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
2c6b0 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r2 AFTER INSERT 
2c6c0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
2c6d0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
2c6e0 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55  rd(x,y)     VALU
2c6f0 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74  ES('after-insert
2c700 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
2c710 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
2c720 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
2c730 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
2c740 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54   r3 BEFORE UPDAT
2c750 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
2c760 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
2c770 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
2c780 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
2c790 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
2c7a0 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
2c7b0 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
2c7c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2c7d0 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f     old.a,old.b,o
2c7e0 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ld.c,new.a,new.b
2c7f0 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
2c800 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
2c810 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54  R r4 AFTER UPDAT
2c820 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
2c830 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
2c840 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
2c850 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
2c860 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
2c870 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
2c880 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
2c890 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2c8a0 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
2c8b0 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
2c8c0 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
2c8d0 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54  .  END;.  INSERT
2c8e0 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
2c8f0 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c  LUES(1,2);.  DEL
2c900 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  ETE FROM record;
2c910 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
2c920 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
2c930 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49  2).    ON CONFLI
2c940 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20  CT(a) DO UPDATE 
2c950 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20  SET c=t1.c+1;.  
2c960 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
2c970 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46  cord;.  DELETE F
2c980 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e  ROM record;.  IN
2c990 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
2c9a0 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20  ) VALUES(1,2).  
2c9b0 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
2c9c0 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
2c9d0 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a  =c+1 WHERE c<0;.
2c9e0 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
2c9f0 72 65 63 6f 72 64 3b 0a 88 63 81 3e 04 00 91 4b  record;..c.>...K
2ca00 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
2ca10 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d  1(a INTEGER PRIM
2ca20 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20  ARY KEY, b int, 
2ca30 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20  c DEFAULT 0);.  
2ca40 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63  CREATE TABLE rec
2ca50 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45  ord(x TEXT, y TE
2ca60 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52  XT);.  CREATE TR
2ca70 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20  IGGER r1 BEFORE 
2ca80 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
2ca90 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
2caa0 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
2cab0 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
2cac0 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72  efore-insert',pr
2cad0 69 6e 74 66 28 20 74 72 69 6d 28 31 32 30 30 31  intf( trim(12001
2cae0 2d 30 31 2d 30 31 2c 39 29 2c 6e 65 77 2e 61 2c  -01-01,9),new.a,
2caf0 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
2cb00 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
2cb10 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20  RIGGER r2 AFTER 
2cb20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
2cb30 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
2cb40 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20  TO record(x,y)  
2cb50 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
2cb60 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
2cb70 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
2cb80 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
2cb90 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
2cba0 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52  TRIGGER r3 BEFOR
2cbb0 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  E UPDATE ON t1 B
2cbc0 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
2cbd0 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
2cbe0 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
2cbf0 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c  'before-update',
2cc00 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
2cc10 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
2cc20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2cc30 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
2cc40 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
2cc50 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
2cc60 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
2cc70 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45   TRIGGER r4 AFTE
2cc80 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  R UPDATE ON t1 B
2cc90 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
2cca0 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
2ccb0 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
2ccc0 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70  'after-update',p
2ccd0 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
2cce0 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
2ccf0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2cd00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2cd10 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
2cd20 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
2cd30 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
2cd40 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
2cd50 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
2cd60 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
2cd70 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
2cd80 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
2cd90 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e  LUES(1,2).    ON
2cda0 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
2cdb0 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e  UPDATE SET c=t1.
2cdc0 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20  c+1;.  SELECT * 
2cdd0 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44  FROM record;.  D
2cde0 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
2cdf0 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
2ce00 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
2ce10 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46  1,2).    ON CONF
2ce20 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54  LICT(a) DO UPDAT
2ce30 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45 52  E SET c=c+1 WHER
2ce40 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20  E c<0;.  SELECT 
2ce50 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88  * FROM record;..
2ce60 6d 81 3d 04 00 91 5f 20 20 43 52 45 41 54 45 20  m.=..._  CREATE 
2ce70 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47  TABLE t1(a INTEG
2ce80 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  ER PRIMARY KEY, 
2ce90 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
2cea0 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41   0);.  CREATE TA
2ceb0 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58  BLE record(x TEX
2cec0 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52  T, y TEXT);.  CR
2ced0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20  EATE TRIGGER r1 
2cee0 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e  BEFORE INSERT ON
2cef0 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
2cf00 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
2cf10 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
2cf20 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73  LUES('before-ins
2cf30 65 72 74 27 2c 70 72 69 6e 74 66 28 20 74 72 69  ert',printf( tri
2cf40 6d 28 31 32 30 30 31 2d 30 31 2d 30 31 2c 32 30  m(12001-01-01,20
2cf50 30 31 2d 30 31 2d 30 31 31 29 2c 6e 65 77 2e 61  01-01-011),new.a
2cf60 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
2cf70 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
2cf80 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
2cf90 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
2cfa0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
2cfb0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
2cfc0 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
2cfd0 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
2cfe0 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%d,%d,%d',new.
2cff0 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
2d000 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
2d010 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
2d020 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
2d030 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
2d040 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
2d050 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
2d060 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
2d070 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
2d080 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
2d090 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2d0a0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
2d0b0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
2d0c0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
2d0d0 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
2d0e0 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
2d0f0 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
2d100 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
2d110 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
2d120 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
2d130 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
2d140 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
2d150 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
2d160 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2d170 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2d180 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
2d190 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
2d1a0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
2d1b0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
2d1c0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
2d1d0 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
2d1e0 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
2d1f0 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
2d200 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
2d210 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
2d220 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
2d230 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
2d240 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
2d250 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
2d260 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
2d270 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
2d280 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
2d290 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
2d2a0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
2d2b0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
2d2c0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
2d2d0 88 6d 81 3c 04 00 91 5f 20 20 43 52 45 41 54 45  .m.<..._  CREATE
2d2e0 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45   TABLE t1(a INTE
2d2f0 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c  GER PRIMARY KEY,
2d300 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c   b int, c DEFAUL
2d310 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54  T 0);.  CREATE T
2d320 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45  ABLE record(x TE
2d330 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43  XT, y TEXT);.  C
2d340 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31  REATE TRIGGER r1
2d350 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f   BEFORE INSERT O
2d360 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
2d370 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
2d380 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
2d390 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e  ALUES('before-in
2d3a0 73 65 72 74 27 2c 70 72 69 6e 74 66 28 20 74 72  sert',printf( tr
2d3b0 69 6d 28 31 32 30 30 31 2d 30 31 2d 30 31 2c 31  im(12001-01-01,1
2d3c0 32 30 30 31 2d 30 31 2d 30 31 29 2c 6e 65 77 2e  2001-01-01),new.
2d3d0 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
2d3e0 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
2d3f0 20 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45   TRIGGER r2 AFTE
2d400 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  R INSERT ON t1 B
2d410 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
2d420 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
2d430 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74       VALUES('aft
2d440 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74  er-insert',print
2d450 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77  f('%d,%d,%d',new
2d460 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
2d470 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
2d480 45 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46  E TRIGGER r3 BEF
2d490 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31  ORE UPDATE ON t1
2d4a0 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
2d4b0 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
2d4c0 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
2d4d0 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65  S('before-update
2d4e0 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
2d4f0 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20  %d/%d,%d,%d',.  
2d500 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2d510 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e              old.
2d520 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65  a,old.b,old.c,ne
2d530 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
2d540 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
2d550 54 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46  TE TRIGGER r4 AF
2d560 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31  TER UPDATE ON t1
2d570 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
2d580 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
2d590 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
2d5a0 53 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27  S('after-update'
2d5b0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
2d5c0 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
2d5d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2d5e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2d5f0 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f     old.a,old.b,o
2d600 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ld.c,new.a,new.b
2d610 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
2d620 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
2d630 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
2d640 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  2);.  DELETE FRO
2d650 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
2d660 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
2d670 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
2d680 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
2d690 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74  O UPDATE SET c=t
2d6a0 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20  1.c+1;.  SELECT 
2d6b0 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  * FROM record;. 
2d6c0 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
2d6d0 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
2d6e0 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
2d6f0 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
2d700 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
2d710 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48  ATE SET c=c+1 WH
2d720 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43  ERE c<0;.  SELEC
2d730 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
2d740 0a 88 66 81 3b 04 00 91 51 20 20 43 52 45 41 54  ..f.;...Q  CREAT
2d750 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54  E TABLE t1(a INT
2d760 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59  EGER PRIMARY KEY
2d770 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55  , b int, c DEFAU
2d780 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20  LT 0);.  CREATE 
2d790 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54  TABLE record(x T
2d7a0 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20  EXT, y TEXT);.  
2d7b0 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
2d7c0 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20  1 BEFORE INSERT 
2d7d0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
2d7e0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
2d7f0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
2d800 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69  VALUES('before-i
2d810 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 20 74  nsert',printf( t
2d820 72 69 6d 28 31 32 30 30 31 2d 30 31 2d 30 31 2c  rim(12001-01-01,
2d830 20 2d 31 31 29 2c 6e 65 77 2e 61 2c 6e 65 77 2e   -11),new.a,new.
2d840 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
2d850 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
2d860 45 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45  ER r2 AFTER INSE
2d870 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  RT ON t1 BEGIN. 
2d880 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
2d890 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56  ecord(x,y)     V
2d8a0 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73  ALUES('after-ins
2d8b0 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ert',printf('%d,
2d8c0 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77  %d,%d',new.a,new
2d8d0 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
2d8e0 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
2d8f0 47 45 52 20 72 33 20 42 45 46 4f 52 45 20 55 50  GER r3 BEFORE UP
2d900 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e  DATE ON t1 BEGIN
2d910 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
2d920 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
2d930 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
2d940 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ore-update',prin
2d950 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
2d960 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
2d970 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2d980 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
2d990 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
2d9a0 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
2d9b0 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
2d9c0 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50  GGER r4 AFTER UP
2d9d0 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e  DATE ON t1 BEGIN
2d9e0 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
2d9f0 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
2da00 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74       VALUES('aft
2da10 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74  er-update',print
2da20 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25  f('%d,%d,%d/%d,%
2da30 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20  d,%d',.         
2da40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2da50 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64               old
2da60 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e  .a,old.b,old.c,n
2da70 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
2da80 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53  ));.  END;.  INS
2da90 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
2daa0 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20   VALUES(1,2);.  
2dab0 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
2dac0 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
2dad0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
2dae0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
2daf0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
2db00 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b  TE SET c=t1.c+1;
2db10 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
2db20 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54   record;.  DELET
2db30 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
2db40 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
2db50 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
2db60 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
2db70 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
2db80 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c  T c=c+1 WHERE c<
2db90 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52  0;.  SELECT * FR
2dba0 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 51 81 3a 04  OM record;..Q.:.
2dbb0 00 91 27 20 20 43 52 45 41 54 45 20 54 41 42 4c  ..'  CREATE TABL
2dbc0 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50  E t1(a INTEGER P
2dbd0 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
2dbe0 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  t, c DEFAULT 0);
2dbf0 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
2dc00 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79  record(x TEXT, y
2dc10 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45   TEXT);.  CREATE
2dc20 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f   TRIGGER r1 BEFO
2dc30 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  RE INSERT ON t1 
2dc40 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
2dc50 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
2dc60 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
2dc70 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27  ('before-insert'
2dc80 2c 70 72 69 6e 74 66 28 20 74 72 69 6d 28 31 2c  ,printf( trim(1,
2dc90 31 29 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  1),new.a,new.b,n
2dca0 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
2dcb0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
2dcc0 72 32 a0 41 46 54 45 52 20 49 4e 53 45 52 54 20  r2.AFTER INSERT 
2dcd0 4f 4e 20 74 31 20 42 45 47 49 4e 20 49 4e 53 45  ON t1 BEGIN INSE
2dce0 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
2dcf0 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27  ,y)     VALUES('
2dd00 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
2dd10 69 6e 74 66 28 20 67 6c 6f 62 28 31 2c 31 29 2c  intf( glob(1,1),
2dd20 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
2dd30 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
2dd40 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
2dd50 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e  BEFORE UPDATE ON
2dd60 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
2dd70 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
2dd80 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
2dd90 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64  LUES('before-upd
2dda0 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
2ddb0 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
2ddc0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
2ddd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
2dde0 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
2ddf0 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
2de00 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
2de10 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34  REATE TRIGGER r4
2de20 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e   AFTER UPDATE ON
2de30 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
2de40 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
2de50 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
2de60 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61  LUES('after-upda
2de70 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
2de80 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
2de90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2dea0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2deb0 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
2dec0 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
2ded0 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
2dee0 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ND;.  INSERT INT
2def0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
2df00 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20  (1,2);.  DELETE 
2df10 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
2df20 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
2df30 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 4f  b) VALUES(1,2).O
2df40 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
2df50 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
2df60 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
2df70 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
2df80 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
2df90 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
2dfa0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
2dfb0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
2dfc0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
2dfd0 54 45 20 53 45 54 20 63 3d 63 3b 31 20 57 48 45  TE SET c=c;1 WHE
2dfe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
2dff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
2e000 0d 00 00 00 07 01 72 00 1b 99 17 4a 12 ed 0e 9e  ......r....J....
2e010 0a 3a 05 d6 01 72 00 00 00 00 00 00 00 00 00 00  .:...r..........
2e020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e0a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e0b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e0c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e0d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e0e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e0f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
2e170 00 00 88 60 81 47 04 00 91 45 20 20 43 52 45 41  ...`.G...E  CREA
2e180 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
2e190 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
2e1a0 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41  Y, b int, c DEFA
2e1b0 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45  ULT 0);.  CREATE
2e1c0 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20   TABLE record(x 
2e1d0 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20  TEXT, y TEXT);. 
2e1e0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
2e1f0 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54  r1 BEFORE INSERT
2e200 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
2e210 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
2e220 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
2e230 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
2e240 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
2e250 25 20 2d 36 64 2c 25 64 27 2c 6e 65 77 2e 61 2c  % -6d,%d',new.a,
2e260 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
2e270 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
2e280 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20  RIGGER r2 AFTER 
2e290 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
2e2a0 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
2e2b0 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20  TO record(x,y)  
2e2c0 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
2e2d0 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
2e2e0 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
2e2f0 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
2e300 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
2e310 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52  TRIGGER r3 BEFOR
2e320 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  E UPDATE ON t1 B
2e330 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
2e340 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
2e350 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
2e360 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c  'before-update',
2e370 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
2e380 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
2e390 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2e3a0 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
2e3b0 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
2e3c0 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
2e3d0 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
2e3e0 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45   TRIGGER r4 AFTE
2e3f0 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  R UPDATE ON t1 B
2e400 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
2e410 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
2e420 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
2e430 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70  'after-update',p
2e440 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
2e450 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
2e460 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2e470 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2e480 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
2e490 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
2e4a0 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
2e4b0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
2e4c0 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
2e4d0 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
2e4e0 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
2e4f0 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
2e500 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e  LUES(1,2).    ON
2e510 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
2e520 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e  UPDATE SET c=t1.
2e530 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20  c+1;.  SELECT * 
2e540 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44  FROM record;.  D
2e550 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
2e560 64 3b 45 58 50 4c 41 49 4e 0a 20 20 49 4e 53 45  d;EXPLAIN.  INSE
2e570 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
2e580 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
2e590 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
2e5a0 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63  O UPDATE SET c=c
2e5b0 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20  +1 WHERE c<0;.  
2e5c0 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
2e5d0 63 6f 72 64 3b 0a 88 60 81 46 04 00 91 45 20 20  cord;..`.F...E  
2e5e0 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
2e5f0 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52  a INTEGER PRIMAR
2e600 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20  Y KEY, b int, c 
2e610 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52  DEFAULT 0);.  CR
2e620 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72  EATE TABLE recor
2e630 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58 54  d(x TEXT, y TEXT
2e640 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  );.  CREATE TRIG
2e650 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e  GER r1 BEFORE IN
2e660 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
2e670 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
2e680 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
2e690 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
2e6a0 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ore-insert',prin
2e6b0 74 66 28 27 25 20 2d 34 64 2c 25 64 27 2c 6e 65  tf('% -4d,%d',ne
2e6c0 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
2e6d0 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
2e6e0 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46  TE TRIGGER r2 AF
2e6f0 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  TER INSERT ON t1
2e700 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
2e710 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
2e720 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27 61  y)     VALUES('a
2e730 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69  fter-insert',pri
2e740 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
2e750 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
2e760 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
2e770 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42  ATE TRIGGER r3 B
2e780 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20  EFORE UPDATE ON 
2e790 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
2e7a0 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
2e7b0 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
2e7c0 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61  UES('before-upda
2e7d0 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
2e7e0 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
2e7f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2e800 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
2e810 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
2e820 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
2e830 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
2e840 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20  EATE TRIGGER r4 
2e850 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20  AFTER UPDATE ON 
2e860 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
2e870 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
2e880 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
2e890 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74  UES('after-updat
2e8a0 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
2e8b0 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
2e8c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2e8d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2e8e0 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
2e8f0 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
2e900 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
2e910 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  D;.  INSERT INTO
2e920 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
2e930 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46  1,2);.  DELETE F
2e940 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e  ROM record;.  IN
2e950 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
2e960 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20  ) VALUES(1,2).  
2e970 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
2e980 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
2e990 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43  =t1.c+1;.  SELEC
2e9a0 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
2e9b0 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
2e9c0 65 63 6f 72 64 3b 45 58 50 4c 41 49 4e 0a 20 20  ecord;EXPLAIN.  
2e9d0 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
2e9e0 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
2e9f0 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
2ea00 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
2ea10 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30   c=c+1 WHERE c<0
2ea20 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
2ea30 4d 20 72 65 63 6f 72 64 3b 0a 88 60 81 45 04 00  M record;..`.E..
2ea40 91 45 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  .E  CREATE TABLE
2ea50 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
2ea60 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74  IMARY KEY, b int
2ea70 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a  , c DEFAULT 0);.
2ea80 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72    CREATE TABLE r
2ea90 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20  ecord(x TEXT, y 
2eaa0 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20  TEXT);.  CREATE 
2eab0 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52  TRIGGER r1 BEFOR
2eac0 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  E INSERT ON t1 B
2ead0 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
2eae0 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
2eaf0 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
2eb00 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c  'before-insert',
2eb10 70 72 69 6e 74 66 28 27 25 20 2c 31 64 2c 25 64  printf('% ,1d,%d
2eb20 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ',new.a,new.b,ne
2eb30 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
2eb40 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
2eb50 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f  2 AFTER INSERT O
2eb60 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
2eb70 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
2eb80 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45  d(x,y)     VALUE
2eb90 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27  S('after-insert'
2eba0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
2ebb0 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
2ebc0 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
2ebd0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
2ebe0 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45  r3 BEFORE UPDATE
2ebf0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
2ec00 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
2ec10 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
2ec20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
2ec30 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
2ec40 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
2ec50 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
2ec60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2ec70 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
2ec80 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
2ec90 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
2eca0 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
2ecb0 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45   r4 AFTER UPDATE
2ecc0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
2ecd0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
2ece0 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
2ecf0 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75   VALUES('after-u
2ed00 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
2ed10 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
2ed20 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
2ed30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2ed40 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
2ed50 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
2ed60 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
2ed70 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20    END;.  INSERT 
2ed80 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
2ed90 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45  UES(1,2);.  DELE
2eda0 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
2edb0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
2edc0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
2edd0 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
2ede0 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
2edf0 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53  ET c=t1.c+1;.  S
2ee00 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63  ELECT * FROM rec
2ee10 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  ord;.  DELETE FR
2ee20 4f 4d 20 72 65 63 6f 72 64 3b 45 58 50 4c 41 49  OM record;EXPLAI
2ee30 4e 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  N.  INSERT INTO 
2ee40 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
2ee50 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,2).    ON CONFL
2ee60 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
2ee70 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45   SET c=c+1 WHERE
2ee80 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a   c<0;.  SELECT *
2ee90 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 4b   FROM record;..K
2eea0 81 44 04 00 91 1b 20 20 43 52 45 41 54 45 20 54  .D....  CREATE T
2eeb0 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45  ABLE t1(a INTEGE
2eec0 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62  R PRIMARY KEY, b
2eed0 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20   int, c DEFAULT 
2eee0 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42  0);.  CREATE TAB
2eef0 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58 54  LE record(x TEXT
2ef00 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45  , y TEXT);.  CRE
2ef10 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20 42  ATE TRIGGER r1 B
2ef20 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20  EFORE INSERT ON 
2ef30 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
2ef40 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
2ef50 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
2ef60 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65  UES('before-inse
2ef70 72 74 27 2c 70 72 69 6e 74 66 28 27 25 20 2a 73  rt',printf('% *s
2ef80 2c 25 64 2c 25 64 27 2c 20 73 71 6c 69 74 65 5f  ,%d,%d', sqlite_
2ef90 76 65 72 73 69 6f 6e 28 29 29 29 3b 0a 20 20 45  version()));.  E
2efa0 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
2efb0 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49 4e  GGER r2 AFTER IN
2efc0 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
2efd0 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
2efe0 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20   record(x,y)    
2eff0 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69   VALUES('after-i
2f000 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25  nsert',printf('%
2f010 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e  d,%d,%d',new.a,n
2f020 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
2f030 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
2f040 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20  IGGER r3 BEFORE 
2f050 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
2f060 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
2f070 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
2f080 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
2f090 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72  efore-update',pr
2f0a0 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
2f0b0 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
2f0c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2f0d0 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
2f0e0 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
2f0f0 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
2f100 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
2f110 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20  RIGGER r4 AFTER 
2f120 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
2f130 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
2f140 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
2f150 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61         VALUES('a
2f160 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69  fter-update',pri
2f170 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
2f180 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
2f190 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2f1a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
2f1b0 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
2f1c0 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
2f1d0 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49  .c));.  END;.  I
2f1e0 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
2f1f0 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a  b) VALUES(1,2);.
2f200 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
2f210 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
2f220 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
2f230 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43  ES(1,2).    ON C
2f240 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50  ONFLICT(a) DO UP
2f250 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b  DATE SET c=t1.c+
2f260 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52  1;.  SELECT * FR
2f270 4f 4d 20 01 65 63 6f 72 20 72 65 63 6f 72 64 3b  OM .ecor record;
2f280 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
2f290 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
2f2a0 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49  2).    ON CONFLI
2f2b0 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20  CT(a) DO UPDATE 
2f2c0 53 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20  SET c=c+1 WHERE 
2f2d0 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20  c<0;.  SELECT * 
2f2e0 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 59 81  FROM record;..Y.
2f2f0 43 04 00 91 37 20 20 43 52 45 41 54 45 20 54 41  C...7  CREATE TA
2f300 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52  BLE t1(a INTEGER
2f310 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20   PRIMARY KEY, b 
2f320 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30  int, c DEFAULT 0
2f330 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c  );.  CREATE TABL
2f340 45 20 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c  E record(x TEXT,
2f350 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41   y TEXT);.  CREA
2f360 54 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45  TE TRIGGER r1 BE
2f370 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74  FORE INSERT ON t
2f380 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
2f390 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
2f3a0 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
2f3b0 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72  ES('before-inser
2f3c0 74 27 2c 70 72 69 6e 74 66 28 20 74 79 70 65 6f  t',printf( typeo
2f3d0 66 28 31 29 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  f(1),new.a,new.b
2f3e0 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
2f3f0 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
2f400 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52  R r2 AFTER INSER
2f410 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
2f420 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
2f430 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41  cord(x,y)     VA
2f440 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65  LUES('after-inse
2f450 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  rt',printf('%d,%
2f460 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e  d,%d',new.a,new.
2f470 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
2f480 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
2f490 45 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44  ER r3 BEFORE UPD
2f4a0 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
2f4b0 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
2f4c0 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
2f4d0 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f      VALUES('befo
2f4e0 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74  re-update',print
2f4f0 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25  f('%d,%d,%d/%d,%
2f500 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20  d,%d',.         
2f510 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2f520 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
2f530 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
2f540 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
2f550 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
2f560 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44  GER r4 AFTER UPD
2f570 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
2f580 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
2f590 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
2f5a0 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
2f5b0 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  r-update',printf
2f5c0 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
2f5d0 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
2f5e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2f5f0 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e              old.
2f600 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65  a,old.b,old.c,ne
2f610 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
2f620 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45  );.  END;.  INSE
2f630 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
2f640 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44  VALUES(1,2);.  D
2f650 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
2f660 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
2f670 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
2f680 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46  1,2).    ON CONF
2f690 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54  LICT(a) DO UPDAT
2f6a0 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a  E SET c=t1.c+1;.
2f6b0 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
2f6c0 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45  record;.  DELETE
2f6d0 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
2f6e0 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
2f6f0 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
2f700 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
2f710 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
2f720 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30   c=c+1 WHERE c<0
2f730 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
2f740 4d 20 72 65 63 6f 72 64 3b 0a 88 4b 81 42 04 00  M record;..K.B..
2f750 91 1b 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ..  CREATE TABLE
2f760 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
2f770 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74  IMARY KEY, b int
2f780 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a  , c DEFAULT 0);.
2f790 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72    CREATE TABLE r
2f7a0 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20  ecord(x TEXT, y 
2f7b0 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20  TEXT);.  CREATE 
2f7c0 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52  TRIGGER r1 BEFOR
2f7d0 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  E INSERT ON t1 B
2f7e0 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
2f7f0 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
2f800 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
2f810 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c  'before-insert',
2f820 70 72 69 6e 74 66 28 20 74 72 69 6d 28 31 3c 31  printf( trim(1<1
2f830 29 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ),new.a,new.b,ne
2f840 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
2f850 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
2f860 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f  2 AFTER INSERT O
2f870 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
2f880 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
2f890 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45  d(x,y)     VALUE
2f8a0 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27  S('after-insert'
2f8b0 2c 70 72 69 6e 74 66 28 20 67 6c 6f 62 28 31 2c  ,printf( glob(1,
2f8c0 31 29 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  1),new.a,new.b,n
2f8d0 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
2f8e0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
2f8f0 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45  r3 BEFORE UPDATE
2f900 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
2f910 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
2f920 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
2f930 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
2f940 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
2f950 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
2f960 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
2f970 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
2f980 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
2f990 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
2f9a0 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
2f9b0 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45   r4 AFTER UPDATE
2f9c0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
2f9d0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
2f9e0 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
2f9f0 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75   VALUES('after-u
2fa00 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
2fa10 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
2fa20 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
2fa30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2fa40 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
2fa50 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
2fa60 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
2fa70 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20    END;.  INSERT 
2fa80 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
2fa90 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45  UES(1,2);.  DELE
2faa0 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
2fab0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
2fac0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
2fad0 29 0a 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29  ).ON CONFLICT(a)
2fae0 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
2faf0 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43  =t1.c+1;.  SELEC
2fb00 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
2fb10 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
2fb20 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
2fb30 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
2fb40 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
2fb50 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
2fb60 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20  PDATE SET c=c+1 
2fb70 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c  WHERE c<0;.  SEL
2fb80 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
2fb90 64 3b 56 41 43 55 55 4d 0a 88 63 81 41 04 00 91  d;VACUUM..c.A...
2fba0 4b 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  K  CREATE TABLE 
2fbb0 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49  t1(a INTEGER PRI
2fbc0 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c  MARY KEY, b int,
2fbd0 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20   c DEFAULT 0);. 
2fbe0 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65   CREATE TABLE re
2fbf0 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54  cord(x TEXT, y T
2fc00 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54  EXT);.  CREATE T
2fc10 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45  RIGGER r1 BEFORE
2fc20 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
2fc30 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
2fc40 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
2fc50 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
2fc60 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70  before-insert',p
2fc70 72 69 6e 74 66 28 20 74 72 69 6d 28 31 32 30 30  rintf( trim(1200
2fc80 45 2d 30 31 2d 30 31 2c 31 29 2c 6e 65 77 2e 61  E-01-01,1),new.a
2fc90 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
2fca0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
2fcb0 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
2fcc0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
2fcd0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
2fce0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
2fcf0 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
2fd00 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
2fd10 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%d,%d,%d',new.
2fd20 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
2fd30 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
2fd40 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
2fd50 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
2fd60 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
2fd70 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
2fd80 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
2fd90 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
2fda0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
2fdb0 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
2fdc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2fdd0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
2fde0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
2fdf0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
2fe00 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
2fe10 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
2fe20 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
2fe30 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
2fe40 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
2fe50 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
2fe60 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
2fe70 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
2fe80 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
2fe90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2fea0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2feb0 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
2fec0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
2fed0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
2fee0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
2fef0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
2ff00 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
2ff10 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
2ff20 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
2ff30 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
2ff40 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
2ff50 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
2ff60 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
2ff70 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
2ff80 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
2ff90 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
2ffa0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
2ffb0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
2ffc0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
2ffd0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
2ffe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
2fff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
30000 0d 00 00 00 07 01 82 00 1b a3 17 56 12 f9 0e 9c  ...........V....
30010 0a 3f 05 e2 01 82 00 00 00 00 00 00 00 00 00 00  .?..............
30020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
300a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
300b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
300c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
300d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
300e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
300f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
30180 00 00 88 5c 81 4e 04 00 91 3d 20 20 43 52 45 41  ...\.N...=  CREA
30190 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
301a0 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
301b0 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41  Y, b int, c DEFA
301c0 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45  ULT 0);.  CREATE
301d0 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20   TABLE record(x 
301e0 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20  TEXT, y TEXT);. 
301f0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
30200 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54  r1 BEFORE INSERT
30210 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
30220 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
30230 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
30240 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
30250 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
30260 25 64 2c 25 20 20 2d 31 38 25 64 27 2c 6e 65 77  %d,%  -18%d',new
30270 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
30280 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
30290 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46 54  E TRIGGER r2 AFT
302a0 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  ER INSERT ON t1 
302b0 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
302c0 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
302d0 29 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66  )     VALUES('af
302e0 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ter-insert',prin
302f0 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65  tf('%d,%d,%d',ne
30300 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
30310 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
30320 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42 45  TE TRIGGER r3 BE
30330 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74  FORE UPDATE ON t
30340 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
30350 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
30360 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
30370 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74  ES('before-updat
30380 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
30390 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
303a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
303b0 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64               old
303c0 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e  .a,old.b,old.c,n
303d0 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
303e0 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
303f0 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20 41  ATE TRIGGER r4 A
30400 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74  FTER UPDATE ON t
30410 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
30420 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
30430 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
30440 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74 65  ES('after-update
30450 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
30460 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20  %d/%d,%d,%d',.  
30470 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
30480 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
30490 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
304a0 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
304b0 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
304c0 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
304d0 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
304e0 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  ,2);.  DELETE FR
304f0 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
30500 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
30510 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20   VALUES(1,2).   
30520 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20   ON CONFLICT(a) 
30530 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d  DO UPDATE SET c=
30540 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54  t1.c+1;.  SELECT
30550 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
30560 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
30570 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
30580 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
30590 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43  ES(1,2).    ON C
305a0 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50  ONFLICT(a) DO UP
305b0 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57  DATE SET c=c+1 W
305c0 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45  HERE c<0;.  SELE
305d0 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64  CT * FROM record
305e0 3b 0a 88 59 81 4d 04 00 91 37 20 20 43 52 45 41  ;..Y.M...7  CREA
305f0 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
30600 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
30610 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41  Y, b int, c DEFA
30620 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45  ULT 0);.  CREATE
30630 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20   TABLE record(x 
30640 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20  TEXT, y TEXT);. 
30650 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
30660 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54  r1 BEFORE INSERT
30670 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
30680 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
30690 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
306a0 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
306b0 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
306c0 25 63 ac 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c  %c.%d,%d',new.a,
306d0 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
306e0 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
306f0 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20  RIGGER r2 AFTER 
30700 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
30710 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
30720 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20  TO record(x,y)  
30730 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
30740 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
30750 27 25 63 ac 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%c.%d,%d',new.a
30760 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
30770 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
30780 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52  TRIGGER r3 BEFOR
30790 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  E UPDATE ON t1 B
307a0 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
307b0 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
307c0 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
307d0 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c  'before-update',
307e0 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
307f0 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
30800 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
30810 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
30820 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
30830 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
30840 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
30850 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45   TRIGGER r4 AFTE
30860 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  R UPDATE ON t1 B
30870 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
30880 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
30890 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
308a0 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70  'after-update',p
308b0 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
308c0 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
308d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
308e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
308f0 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
30900 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
30910 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
30920 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
30930 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
30940 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
30950 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
30960 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
30970 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e  LUES(1,2).    ON
30980 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
30990 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e  UPDATE SET c=t1.
309a0 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20  c+1;.  SELECT * 
309b0 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44  FROM record;.  D
309c0 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
309d0 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
309e0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
309f0 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46  1,2).    ON CONF
30a00 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54  LICT(a) DO UPDAT
30a10 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45 52  E SET c=c+1 WHER
30a20 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20  E c<0;.  SELECT 
30a30 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88  * FROM record;..
30a40 59 81 4c 04 00 91 37 20 20 43 52 45 41 54 45 20  Y.L...7  CREATE 
30a50 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47  TABLE t1(a INTEG
30a60 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  ER PRIMARY KEY, 
30a70 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
30a80 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41   0);.  CREATE TA
30a90 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58  BLE record(x TEX
30aa0 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52  T, y TEXT);.  CR
30ab0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20  EATE TRIGGER r1 
30ac0 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e  BEFORE INSERT ON
30ad0 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
30ae0 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
30af0 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
30b00 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73  LUES('before-ins
30b10 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 63 ac  ert',printf('%c.
30b20 25 64 2c 25 64 27 2c 20 6a 75 6c 69 61 6e 64 61  %d,%d', julianda
30b30 79 28 31 2c 31 2c 31 29 29 29 3b 0a 20 20 45 4e  y(1,1,1)));.  EN
30b40 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
30b50 47 45 52 20 72 32 20 41 46 54 45 52 20 49 4e 53  GER r2 AFTER INS
30b60 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ERT ON t1 BEGIN.
30b70 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
30b80 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20  record(x,y)     
30b90 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e  VALUES('after-in
30ba0 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64  sert',printf('%d
30bb0 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65  ,%d,%d',new.a,ne
30bc0 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
30bd0 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
30be0 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20 55  GGER r3 BEFORE U
30bf0 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
30c00 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
30c10 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
30c20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
30c30 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69  fore-update',pri
30c40 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
30c50 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
30c60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
30c70 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
30c80 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
30c90 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
30ca0 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
30cb0 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55  IGGER r4 AFTER U
30cc0 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
30cd0 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
30ce0 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
30cf0 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
30d00 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ter-update',prin
30d10 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
30d20 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
30d30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
30d40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
30d50 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
30d60 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
30d70 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e  c));.  END;.  IN
30d80 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
30d90 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20  ) VALUES(1,2);. 
30da0 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
30db0 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
30dc0 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
30dd0 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
30de0 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
30df0 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31  ATE SET c=t1.c+1
30e00 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
30e10 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45  M record;.  DELE
30e20 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
30e30 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
30e40 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
30e50 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
30e60 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
30e70 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63  ET c=c+1 WHERE c
30e80 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  <0;.  SELECT * F
30e90 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 59 81 4b  ROM record;..Y.K
30ea0 04 00 91 37 20 20 43 52 45 41 54 45 20 54 41 42  ...7  CREATE TAB
30eb0 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20  LE t1(a INTEGER 
30ec0 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
30ed0 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29  nt, c DEFAULT 0)
30ee0 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ;.  CREATE TABLE
30ef0 20 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20   record(x TEXT, 
30f00 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54  y TEXT);.  CREAT
30f10 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46  E TRIGGER r1 BEF
30f20 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  ORE INSERT ON t1
30f30 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
30f40 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
30f50 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
30f60 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74  S('before-insert
30f70 27 2c 70 72 69 6e 74 66 28 27 25 53 2c 25 64 2c  ',printf('%S,%d,
30f80 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
30f90 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
30fa0 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
30fb0 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54   r2 AFTER INSERT
30fc0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
30fd0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
30fe0 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c  ord(x,y)     VAL
30ff0 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72  UES('after-inser
31000 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  t',printf('%d,%d
31010 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
31020 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
31030 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
31040 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41  R r3 BEFORE UPDA
31050 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
31060 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
31070 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
31080 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
31090 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  e-update',printf
310a0 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
310b0 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
310c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
310d0 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
310e0 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
310f0 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
31100 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
31110 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41  ER r4 AFTER UPDA
31120 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
31130 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
31140 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
31150 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
31160 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
31170 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
31180 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
31190 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
311a0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
311b0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
311c0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
311d0 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52  ;.  END;.  INSER
311e0 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
311f0 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45  ALUES(1,2);.  DE
31200 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
31210 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
31220 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
31230 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,2).    ON CONFL
31240 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
31250 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20   SET c=t1.c+1;. 
31260 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
31270 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20  ecord;.  DELETE 
31280 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
31290 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
312a0 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20  b) VALUES(1,2). 
312b0 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
312c0 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
312d0 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b  c=c+1 WHERE c<0;
312e0 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
312f0 20 72 65 63 6f 72 64 3b 0a 88 59 81 4a 04 00 91   record;..Y.J...
31300 37 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  7  CREATE TABLE 
31310 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49  t1(a INTEGER PRI
31320 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c  MARY KEY, b int,
31330 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20   c DEFAULT 0);. 
31340 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65   CREATE TABLE re
31350 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54  cord(x TEXT, y T
31360 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54  EXT);.  CREATE T
31370 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45  RIGGER r1 BEFORE
31380 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
31390 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
313a0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
313b0 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
313c0 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70  before-insert',p
313d0 72 69 6e 74 66 28 27 25 53 2c 25 64 2c 25 64 27  rintf('%S,%d,%d'
313e0 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
313f0 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
31400 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32  REATE TRIGGER r2
31410 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e   AFTER INSERT ON
31420 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
31430 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
31440 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53  (x,y)     VALUES
31450 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c  ('after-insert',
31460 70 72 69 6e 74 66 28 27 25 53 2c 25 64 2c 25 64  printf('%S,%d,%d
31470 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ',new.a,new.b,ne
31480 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
31490 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
314a0 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20  3 BEFORE UPDATE 
314b0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
314c0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
314d0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
314e0 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75  VALUES('before-u
314f0 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
31500 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
31510 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
31520 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
31530 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
31540 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
31550 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
31560 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
31570 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20  r4 AFTER UPDATE 
31580 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
31590 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
315a0 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
315b0 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70  VALUES('after-up
315c0 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
315d0 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
315e0 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
315f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
31600 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
31610 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
31620 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
31630 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49   END;.  INSERT I
31640 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
31650 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54  ES(1,2);.  DELET
31660 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
31670 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
31680 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
31690 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
316a0 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
316b0 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45  T c=t1.c+1;.  SE
316c0 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
316d0 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  rd;.  DELETE FRO
316e0 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
316f0 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
31700 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20  VALUES(1,2).    
31710 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44  ON CONFLICT(a) D
31720 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 63  O UPDATE SET c=c
31730 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20 20  +1 WHERE c<0;.  
31740 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65  SELECT * FROM re
31750 63 6f 72 64 3b 0a 88 49 81 49 04 00 91 17 20 20  cord;..I.I....  
31760 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31 28  CREATE TABLE t1(
31770 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52  a INTEGER PRIMAR
31780 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63 20  Y KEY, b int, c 
31790 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43 52  DEFAULT 0);.  CR
317a0 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f 72  EATE TABLE recor
317b0 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58 54  d(x TEXT, y TEXT
317c0 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  );.  CREATE TRIG
317d0 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49 4e  GER r1 BEFORE IN
317e0 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
317f0 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
31800 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20   record(x,y).   
31810 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66       VALUES('bef
31820 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e  ore-insert',prin
31830 74 66 28 27 25 2c 64 25 64 2c 25 64 27 2c 6e 65  tf('%,d%d,%d',ne
31840 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
31850 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41  );.  END;.  CREA
31860 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41 46  TE TRIGGER r2 AF
31870 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  TER INSERT ON t1
31880 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
31890 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
318a0 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27 61  y)     VALUES('a
318b0 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72 69  fter-insert',pri
318c0 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e  ntf('%d,%d,%d',n
318d0 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
318e0 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
318f0 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20 42  ATE TRIGGER r3 B
31900 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e 20  EFORE UPDATE ON 
31910 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
31920 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
31930 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
31940 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64 61  UES('before-upda
31950 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
31960 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
31970 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
31980 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
31990 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
319a0 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
319b0 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
319c0 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34 20  EATE TRIGGER r4 
319d0 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e 20  AFTER UPDATE ON 
319e0 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
319f0 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
31a00 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c  x,y).        VAL
31a10 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61 74  UES('after-updat
31a20 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  e',printf('%d,%d
31a30 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20  ,%d/%d,%d,%d',. 
31a40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
31a50 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
31a60 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
31a70 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
31a80 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
31a90 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  D;.  INSERT INTO
31aa0 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
31ab0 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46  1,2);.  DELETE F
31ac0 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e  ROM record;.  IN
31ad0 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
31ae0 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 00 20  ) VALUES(1,2).. 
31af0 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 20 63    ON CONFLICT( c
31b00 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43  =t1.c+1;.  SELEC
31b10 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
31b20 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
31b30 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
31b40 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
31b50 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
31b60 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
31b70 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20  PDATE SET c=c+1 
31b80 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c  WHERE c<0;.  SEL
31b90 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
31ba0 64 3b 0a 88 59 81 48 04 00 91 37 20 20 43 52 45  d;..Y.H...7  CRE
31bb0 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49  ATE TABLE t1(a I
31bc0 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b  NTEGER PRIMARY K
31bd0 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46  EY, b int, c DEF
31be0 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54  AULT 0);.  CREAT
31bf0 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78  E TABLE record(x
31c00 20 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a   TEXT, y TEXT);.
31c10 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
31c20 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52   r1 BEFORE INSER
31c30 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
31c40 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
31c50 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
31c60 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
31c70 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
31c80 27 25 25 59 25 20 2a 25 64 27 2c 6e 65 77 2e 61  '%%Y% *%d',new.a
31c90 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
31ca0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
31cb0 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
31cc0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
31cd0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
31ce0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
31cf0 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
31d00 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
31d10 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%d,%d,%d',new.
31d20 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
31d30 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
31d40 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
31d50 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
31d60 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
31d70 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
31d80 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
31d90 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
31da0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
31db0 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
31dc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
31dd0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
31de0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
31df0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
31e00 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
31e10 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
31e20 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
31e30 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
31e40 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
31e50 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
31e60 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
31e70 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
31e80 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
31e90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
31ea0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
31eb0 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
31ec0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
31ed0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
31ee0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
31ef0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
31f00 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
31f10 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
31f20 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
31f30 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
31f40 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
31f50 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
31f60 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
31f70 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
31f80 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
31f90 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
31fa0 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
31fb0 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
31fc0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
31fd0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
31fe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
31ff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
32000 0d 00 00 00 07 01 52 00 1b 97 17 3a 12 dd 0e 80  ......R....:....
32010 0a 23 05 b2 01 52 00 00 00 00 00 00 00 00 00 00  .#...R..........
32020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
320a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
320b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
320c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
320d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
320e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
320f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
32150 00 00 88 5c 81 55 04 00 91 3d 20 20 43 52 45 41  ...\.U...=  CREA
32160 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
32170 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
32180 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41  Y, b int, c DEFA
32190 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45  ULT 0);.  CREATE
321a0 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20   TABLE record(x 
321b0 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20  TEXT, y TEXT);. 
321c0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
321d0 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54  r1 BEFORE INSERT
321e0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
321f0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
32200 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
32210 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
32220 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
32230 25 64 2c 25 20 2a 25 64 27 2c 6e 65 77 2e 61 2c  %d,% *%d',new.a,
32240 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
32250 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
32260 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20  RIGGER r2 AFTER 
32270 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
32280 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
32290 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20  TO record(x,y)  
322a0 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
322b0 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
322c0 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
322d0 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
322e0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
322f0 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52  TRIGGER r3 BEFOR
32300 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  E UPDATE ON t1 B
32310 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
32320 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
32330 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
32340 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c  'before-update',
32350 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
32360 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
32370 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
32380 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
32390 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
323a0 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
323b0 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
323c0 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45   TRIGGER r4 AFTE
323d0 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  R UPDATE ON t1 B
323e0 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
323f0 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
32400 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
32410 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70  'after-update',p
32420 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
32430 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
32440 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
32450 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
32460 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
32470 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
32480 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
32490 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
324a0 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 20 2d  a,b) VALUES(1, -
324b0 31 32 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  12);.  DELETE FR
324c0 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
324d0 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
324e0 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20   VALUES(1,2).   
324f0 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20   ON CONFLICT(a) 
32500 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d  DO UPDATE SET c=
32510 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54  t1.c+1;.  SELECT
32520 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
32530 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
32540 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
32550 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
32560 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43  ES(1,2).    ON C
32570 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50  ONFLICT(a) DO UP
32580 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57  DATE SET c=c+1 W
32590 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45  HERE c<0;.  SELE
325a0 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64  CT * FROM record
325b0 3b 0a 88 6d 81 54 04 00 91 5f 20 20 43 52 45 41  ;..m.T..._  CREA
325c0 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
325d0 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
325e0 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41  Y, b int, c DEFA
325f0 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45  ULT 0);.  CREATE
32600 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20   TABLE record(x 
32610 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20  TEXT, y TEXT);. 
32620 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
32630 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54  r1 BEFORE INSERT
32640 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
32650 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
32660 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
32670 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
32680 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
32690 25 64 2c 25 20 2a 25 64 27 2c 6e 65 77 2e 61 2c  %d,% *%d',new.a,
326a0 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
326b0 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
326c0 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20  RIGGER r2 AFTER 
326d0 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
326e0 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
326f0 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20  TO record(x,y)  
32700 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
32710 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
32720 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
32730 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
32740 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
32750 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52  TRIGGER r3 BEFOR
32760 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  E UPDATE ON t1 B
32770 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
32780 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
32790 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
327a0 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c  'before-update',
327b0 70 72 69 6e 74 66 28 27 25 64 2c 25 20 2a 25 64  printf('%d,% *%d
327c0 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
327d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
327e0 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
327f0 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
32800 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
32810 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
32820 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45   TRIGGER r4 AFTE
32830 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  R UPDATE ON t1 B
32840 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
32850 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
32860 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
32870 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70  'after-update',p
32880 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
32890 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
328a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
328b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
328c0 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
328d0 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
328e0 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
328f0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
32900 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 32  a,b) VALUES(1,22
32910 30 30 31 2d 30 31 2d 30 31 29 3b 0a 20 20 44 45  001-01-01);.  DE
32920 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
32930 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
32940 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
32950 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,2).    ON CONFL
32960 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
32970 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20   SET c=t1.c+1;. 
32980 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
32990 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20  ecord;.  DELETE 
329a0 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
329b0 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
329c0 62 29 20 56 41 4c 55 45 53 28 31 2c 32 32 30 30  b) VALUES(1,2200
329d0 31 2d 30 31 2d 30 31 29 0a 20 20 20 20 4f 4e 20  1-01-01).    ON 
329e0 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
329f0 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20  PDATE SET c=c+1 
32a00 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c  WHERE c<0;.  SEL
32a10 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
32a20 64 3b 0a 88 59 81 53 04 00 91 37 20 20 43 52 45  d;..Y.S...7  CRE
32a30 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49  ATE TABLE t1(a I
32a40 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b  NTEGER PRIMARY K
32a50 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46  EY, b int, c DEF
32a60 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54  AULT 0);.  CREAT
32a70 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78  E TABLE record(x
32a80 20 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a   TEXT, y TEXT);.
32a90 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
32aa0 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52   r1 BEFORE INSER
32ab0 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
32ac0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
32ad0 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
32ae0 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
32af0 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
32b00 27 25 64 2c 25 20 2a 25 64 27 2c 6e 65 77 2e 61  '%d,% *%d',new.a
32b10 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
32b20 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
32b30 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
32b40 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
32b50 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
32b60 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
32b70 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
32b80 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
32b90 28 27 25 64 2c 25 20 2a 25 64 27 2c 6e 65 77 2e  ('%d,% *%d',new.
32ba0 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
32bb0 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
32bc0 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
32bd0 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
32be0 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
32bf0 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
32c00 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
32c10 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
32c20 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
32c30 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
32c40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
32c50 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
32c60 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
32c70 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
32c80 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
32c90 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
32ca0 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
32cb0 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
32cc0 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
32cd0 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
32ce0 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
32cf0 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
32d00 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
32d10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
32d20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
32d30 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
32d40 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
32d50 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
32d60 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
32d70 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
32d80 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
32d90 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
32da0 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
32db0 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
32dc0 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
32dd0 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
32de0 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
32df0 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
32e00 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
32e10 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
32e20 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
32e30 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  (1,2).    ON CON
32e40 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
32e50 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
32e60 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
32e70 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
32e80 88 59 81 52 04 00 91 37 20 20 43 52 45 41 54 45  .Y.R...7  CREATE
32e90 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45   TABLE t1(a INTE
32ea0 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c  GER PRIMARY KEY,
32eb0 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c   b int, c DEFAUL
32ec0 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54  T 0);.  CREATE T
32ed0 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45  ABLE record(x TE
32ee0 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43  XT, y TEXT);.  C
32ef0 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31  REATE TRIGGER r1
32f00 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f   BEFORE INSERT O
32f10 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
32f20 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
32f30 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
32f40 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e  ALUES('before-in
32f50 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64  sert',printf('%d
32f60 2c 25 20 2a 25 64 27 2c 6e 65 77 2e 61 2c 6e 65  ,% *%d',new.a,ne
32f70 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
32f80 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
32f90 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49 4e  GGER r2 AFTER IN
32fa0 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
32fb0 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
32fc0 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20   record(x,y)    
32fd0 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69   VALUES('after-i
32fe0 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 20 6a  nsert',printf( j
32ff0 73 6f 6e 5f 73 65 74 28 31 2c 31 2c 31 29 2c 6e  son_set(1,1,1),n
33000 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
33010 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
33020 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20  IGGER r3 BEFORE 
33030 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
33040 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
33050 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
33060 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
33070 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72  efore-update',pr
33080 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
33090 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
330a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
330b0 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
330c0 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
330d0 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
330e0 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
330f0 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20  RIGGER r4 AFTER 
33100 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
33110 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
33120 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
33130 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61         VALUES('a
33140 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69  fter-update',pri
33150 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
33160 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
33170 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
33180 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
33190 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
331a0 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
331b0 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49  .c));.  END;.  I
331c0 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
331d0 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a  b) VALUES(1,2);.
331e0 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
331f0 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
33200 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
33210 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43  ES(1,2).    ON C
33220 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50  ONFLICT(a) DO UP
33230 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b  DATE SET c=t1.c+
33240 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52  1;.  SELECT * FR
33250 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c  OM record;.  DEL
33260 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  ETE FROM record;
33270 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74  .  INSERT INTO t
33280 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c  1(a,b) VALUES(1,
33290 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49  2).    ON CONFLI
332a0 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20  CT(a) DO UPDATE 
332b0 53 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20  SET c=c+1 WHERE 
332c0 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20  c<0;.  SELECT * 
332d0 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 59 81  FROM record;..Y.
332e0 51 04 00 91 37 20 20 43 52 45 41 54 45 20 54 41  Q...7  CREATE TA
332f0 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52  BLE t1(a INTEGER
33300 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20   PRIMARY KEY, b 
33310 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30  int, c DEFAULT 0
33320 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c  );.  CREATE TABL
33330 45 20 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c  E record(x TEXT,
33340 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41   y TEXT);.  CREA
33350 54 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45  TE TRIGGER r1 BE
33360 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74  FORE INSERT ON t
33370 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
33380 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
33390 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55  ,y).        VALU
333a0 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72  ES('before-inser
333b0 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 20  t',printf('%d,% 
333c0 2a 25 64 27 2c 6e 65 77 2e 61 2c 2d 75 6e 69 63  *%d',new.a,-unic
333d0 6f 64 65 28 31 29 29 29 3b 0a 20 20 45 4e 44 3b  ode(1)));.  END;
333e0 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
333f0 52 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52  R r2 AFTER INSER
33400 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
33410 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
33420 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41  cord(x,y)     VA
33430 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65  LUES('after-inse
33440 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  rt',printf('%d,%
33450 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e  d,%d',new.a,new.
33460 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
33470 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
33480 45 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44  ER r3 BEFORE UPD
33490 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
334a0 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
334b0 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
334c0 20 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f      VALUES('befo
334d0 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74  re-update',print
334e0 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25  f('%d,%d,%d/%d,%
334f0 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20  d,%d',.         
33500 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
33510 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62       old.a,old.b
33520 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77  ,old.c,new.a,new
33530 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
33540 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
33550 47 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44  GER r4 AFTER UPD
33560 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ATE ON t1 BEGIN.
33570 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
33580 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20  record(x,y).    
33590 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
335a0 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  r-update',printf
335b0 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
335c0 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
335d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
335e0 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e              old.
335f0 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65  a,old.b,old.c,ne
33600 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29  w.a,new.b,new.c)
33610 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45  );.  END;.  INSE
33620 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 63 29 20  RT INTO t1(a,c) 
33630 56 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44  VALUES(1,2);.  D
33640 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
33650 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
33660 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
33670 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46  1,2).    ON CONF
33680 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54  LICT(a) DO UPDAT
33690 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a  E SET c=t1.c+1;.
336a0 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
336b0 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45  record;.  DELETE
336c0 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
336d0 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
336e0 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 0a  ,b) VALUES(1,2).
336f0 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
33700 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
33710 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30   c=c+1 WHERE c<0
33720 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
33730 4d 20 72 65 63 6f 72 64 3b 0a 88 59 81 50 04 00  M record;..Y.P..
33740 91 37 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  .7  CREATE TABLE
33750 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
33760 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74  IMARY KEY, b int
33770 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a  , c DEFAULT 0);.
33780 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72    CREATE TABLE r
33790 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20  ecord(x TEXT, y 
337a0 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20  TEXT);.  CREATE 
337b0 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52  TRIGGER r1 BEFOR
337c0 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  E INSERT ON t1 B
337d0 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
337e0 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
337f0 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
33800 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c  'before-insert',
33810 70 72 69 6e 74 66 28 27 25 64 2c 25 20 2a 25 64  printf('%d,% *%d
33820 27 2c 20 6a 75 6c 69 61 6e 64 61 79 28 31 2c 31  ', julianday(1,1
33830 2c 31 29 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  ,1)));.  END;.  
33840 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
33850 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f  2 AFTER INSERT O
33860 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
33870 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
33880 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45  d(x,y)     VALUE
33890 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27  S('after-insert'
338a0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
338b0 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
338c0 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
338d0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
338e0 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45  r3 BEFORE UPDATE
338f0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
33900 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
33910 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
33920 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
33930 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
33940 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
33950 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
33960 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
33970 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
33980 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
33990 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
339a0 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
339b0 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45   r4 AFTER UPDATE
339c0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
339d0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
339e0 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
339f0 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75   VALUES('after-u
33a00 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
33a10 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
33a20 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
33a30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
33a40 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
33a50 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
33a60 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
33a70 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20    END;.  INSERT 
33a80 49 4e 54 4f 20 74 31 28 61 2c 63 29 20 56 41 4c  INTO t1(a,c) VAL
33a90 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45  UES(1,2);.  DELE
33aa0 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
33ab0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
33ac0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
33ad0 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
33ae0 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
33af0 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53  ET c=t1.c+1;.  S
33b00 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63  ELECT * FROM rec
33b10 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  ord;.  DELETE FR
33b20 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
33b30 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
33b40 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20   VALUES(1,2).   
33b50 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20   ON CONFLICT(a) 
33b60 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d  DO UPDATE SET c=
33b70 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a 20  c+1 WHERE c<0;. 
33b80 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
33b90 65 63 6f 72 64 3b 0a 88 65 81 4f 04 00 91 4f 20  ecord;..e.O...O 
33ba0 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
33bb0 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41  (a INTEGER PRIMA
33bc0 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63  RY KEY, b int, c
33bd0 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43   DEFAULT 0);.  C
33be0 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f  REATE TABLE reco
33bf0 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58  rd(x TEXT, y TEX
33c00 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  T);.  CREATE TRI
33c10 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49  GGER r1 BEFORE I
33c20 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
33c30 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
33c40 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
33c50 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
33c60 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69  fore-insert',pri
33c70 6e 74 66 28 27 25 64 2c 25 20 2a 25 59 25 64 27  ntf('%d,% *%Y%d'
33c80 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
33c90 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
33ca0 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32  REATE TRIGGER r2
33cb0 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e   AFTER INSERT ON
33cc0 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
33cd0 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
33ce0 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53  (x,y)     VALUES
33cf0 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c  ('after-insert',
33d00 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
33d10 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ',new.a,new.b,ne
33d20 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
33d30 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
33d40 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20  3 BEFORE UPDATE 
33d50 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
33d60 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
33d70 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
33d80 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75  VALUES('before-u
33d90 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
33da0 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
33db0 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
33dc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
33dd0 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
33de0 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
33df0 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
33e00 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
33e10 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20  r4 AFTER UPDATE 
33e20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
33e30 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
33e40 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
33e50 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70  VALUES('after-up
33e60 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
33e70 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
33e80 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
33e90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
33ea0 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
33eb0 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
33ec0 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
33ed0 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49   END;.  INSERT I
33ee0 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
33ef0 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54  ES(1,2);.  DELET
33f00 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
33f10 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
33f20 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
33f30 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
33f40 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
33f50 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45  T c=t1.c+1;.  SE
33f60 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
33f70 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  rd;.  DELETE FRO
33f80 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
33f90 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
33fa0 56 41 4c 55 45 53 28 31 2c 32 32 30 30 31 35 30  VALUES(1,2200150
33fb0 31 2d 30 31 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  1-01).    ON CON
33fc0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
33fd0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
33fe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
33ff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
34000 0d 00 00 00 07 01 1c 00 1b 8c 17 2c 12 bb 0e 51  ...........,...Q
34010 09 ea 05 83 01 1c 00 00 00 00 00 00 00 00 00 00  ................
34020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
340a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
340b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
340c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
340d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
340e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
340f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
34110 00 00 00 00 00 00 00 00 00 00 00 00 88 63 81 5c  .............c.\
34120 04 00 91 4b 20 20 43 52 45 41 54 45 20 54 41 42  ...K  CREATE TAB
34130 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20  LE t1(a INTEGER 
34140 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
34150 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29  nt, c DEFAULT 0)
34160 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ;.  CREATE TABLE
34170 20 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20   record(x TEXT, 
34180 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54  y TEXT);.  CREAT
34190 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46  E TRIGGER r1 BEF
341a0 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  ORE INSERT ON t1
341b0 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
341c0 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
341d0 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
341e0 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74  S('before-insert
341f0 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 20 2a  ',printf('%d,% *
34200 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
34210 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
34220 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
34230 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54   r2 AFTER INSERT
34240 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
34250 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
34260 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c  ord(x,y)     VAL
34270 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72  UES('after-inser
34280 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  t',printf('%d,%d
34290 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
342a0 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
342b0 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
342c0 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41  R r3 BEFORE UPDA
342d0 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
342e0 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
342f0 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
34300 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
34310 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  e-update',printf
34320 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
34330 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
34340 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
34350 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
34360 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
34370 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
34380 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
34390 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41  ER r4 AFTER UPDA
343a0 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
343b0 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
343c0 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
343d0 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
343e0 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
343f0 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
34400 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
34410 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
34420 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
34430 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
34440 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
34450 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52  ;.  END;.  INSER
34460 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
34470 41 4c 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45  ALUES(1,2);.  DE
34480 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
34490 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
344a0 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
344b0 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c  ,2).    ON CONFL
344c0 49 43 54 28 61 29 20 44 4f 20 55 50 44 41 54 45  ICT(a) DO UPDATE
344d0 20 53 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20   SET c=t1.c+1;. 
344e0 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72   SELECT * FROM r
344f0 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20  ecord;.  DELETE 
34500 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49  FROM record;.  I
34510 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
34520 62 29 20 56 41 4c 55 45 53 28 31 2c 32 32 30 30  b) VALUES(1,2200
34530 31 2d 30 31 2d 30 31 29 0a 00 20 20 20 4f 4e 20  1-01-01)..   ON 
34540 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
34550 50 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20  PDATE SET c=c+1 
34560 57 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c  WHERE c<0;.  SEL
34570 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72  ECT * FROM recor
34580 64 3b 0a 88 63 81 5b 04 00 91 4b 20 20 43 52 45  d;..c.[...K  CRE
34590 41 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49  ATE TABLE t1(a I
345a0 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b  NTEGER PRIMARY K
345b0 45 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46  EY, b int, c DEF
345c0 41 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54  AULT 0);.  CREAT
345d0 45 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78  E TABLE record(x
345e0 20 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a   TEXT, y TEXT);.
345f0 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
34600 20 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52   r1 BEFORE INSER
34610 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  T ON t1 BEGIN.  
34620 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
34630 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
34640 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
34650 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
34660 27 25 64 2c 25 20 2a 25 64 27 2c 6e 65 77 2e 61  '%d,% *%d',new.a
34670 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
34680 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
34690 54 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52  TRIGGER r2 AFTER
346a0 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
346b0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
346c0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20  NTO record(x,y) 
346d0 20 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65      VALUES('afte
346e0 72 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66  r-insert',printf
346f0 28 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e  ('%d,%d,%d',new.
34700 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
34710 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
34720 20 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f   TRIGGER r3 BEFO
34730 52 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  RE UPDATE ON t1 
34740 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
34750 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
34760 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
34770 28 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27  ('before-update'
34780 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
34790 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20  d/%d,%d,%d',.   
347a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
347b0 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
347c0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
347d0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
347e0 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54  ;.  END;.  CREAT
347f0 45 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54  E TRIGGER r4 AFT
34800 45 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20  ER UPDATE ON t1 
34810 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
34820 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
34830 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
34840 28 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c  ('after-update',
34850 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
34860 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
34870 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
34880 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
34890 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
348a0 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
348b0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
348c0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
348d0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
348e0 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d  );.  DELETE FROM
348f0 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52   record;.  INSER
34900 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
34910 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f  ALUES(1,2).    O
34920 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f  N CONFLICT(a) DO
34930 20 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31   UPDATE SET c=t1
34940 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a  .c+1;.  SELECT *
34950 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20   FROM record;.  
34960 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f  DELETE FROM reco
34970 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  rd;.  INSERT INT
34980 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
34990 28 31 2c 32 32 30 30 2f 2d 30 31 2d 30 31 29 0a  (1,2200/-01-01).
349a0 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28      ON CONFLICT(
349b0 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54  a) DO UPDATE SET
349c0 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30   c=c+1 WHERE c<0
349d0 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
349e0 4d 20 72 65 63 6f 72 64 3b 0a 88 63 81 5a 04 00  M record;..c.Z..
349f0 91 4b 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  .K  CREATE TABLE
34a00 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52   t1(a INTEGER PR
34a10 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74  IMARY KEY, b int
34a20 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a  , c DEFAULT 0);.
34a30 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72    CREATE TABLE r
34a40 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20  ecord(x TEXT, y 
34a50 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20  TEXT);.  CREATE 
34a60 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52  TRIGGER r1 BEFOR
34a70 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42  E INSERT ON t1 B
34a80 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
34a90 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
34aa0 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
34ab0 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c  'before-insert',
34ac0 70 72 69 6e 74 66 28 27 25 64 2c 25 20 2a 25 64  printf('%d,% *%d
34ad0 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ',new.a,new.b,ne
34ae0 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
34af0 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
34b00 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f  2 AFTER INSERT O
34b10 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
34b20 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
34b30 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45  d(x,y)     VALUE
34b40 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27  S('after-insert'
34b50 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25  ,printf('%d,%d,%
34b60 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
34b70 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
34b80 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
34b90 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45  r3 BEFORE UPDATE
34ba0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
34bb0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
34bc0 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
34bd0 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
34be0 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
34bf0 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
34c00 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
34c10 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
34c20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c    old.a,old.b,ol
34c30 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  d.c,new.a,new.b,
34c40 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
34c50 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
34c60 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45   r4 AFTER UPDATE
34c70 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
34c80 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
34c90 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
34ca0 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75   VALUES('after-u
34cb0 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
34cc0 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
34cd0 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
34ce0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
34cf0 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
34d00 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
34d10 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
34d20 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20    END;.  INSERT 
34d30 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
34d40 55 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45  UES(1,2);.  DELE
34d50 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
34d60 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
34d70 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
34d80 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
34d90 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
34da0 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53  ET c=t1.c+1;.  S
34db0 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63  ELECT * FROM rec
34dc0 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  ord;.  DELETE FR
34dd0 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
34de0 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
34df0 20 56 41 4c 55 45 53 28 31 2c 32 32 30 2a 31 35   VALUES(1,220*15
34e00 30 31 2d 30 31 29 0a 20 20 20 20 4f 4e 20 43 4f  01-01).    ON CO
34e10 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
34e20 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48  ATE SET c=c+1 WH
34e30 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43  ERE c<0;.  SELEC
34e40 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
34e50 0a 88 66 81 59 04 00 91 51 20 20 43 52 45 41 54  ..f.Y...Q  CREAT
34e60 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54  E TABLE t1(a INT
34e70 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59  EGER PRIMARY KEY
34e80 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55  , b int, c DEFAU
34e90 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20  LT 0);.  CREATE 
34ea0 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54  TABLE record(x T
34eb0 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20  EXT, y TEXT);.  
34ec0 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
34ed0 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20  1 BEFORE INSERT 
34ee0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
34ef0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
34f00 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
34f10 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69  VALUES('before-i
34f20 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25  nsert',printf('%
34f30 64 2c 25 20 2a 25 64 27 2c 6e 65 77 2e 61 2c 6e  d,% *%d',new.a,n
34f40 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
34f50 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
34f60 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49  IGGER r2 AFTER I
34f70 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
34f80 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
34f90 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20  O record(x,y)   
34fa0 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
34fb0 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
34fc0 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c  %d,%d,%d',new.a,
34fd0 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
34fe0 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
34ff0 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45  RIGGER r3 BEFORE
35000 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
35010 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
35020 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
35030 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
35040 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70  before-update',p
35050 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
35060 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
35070 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
35080 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
35090 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
350a0 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
350b0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
350c0 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52  TRIGGER r4 AFTER
350d0 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
350e0 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
350f0 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
35100 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
35110 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72  after-update',pr
35120 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
35130 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
35140 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
35150 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
35160 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e  old.a,old.b,old.
35170 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  c,new.a,new.b,ne
35180 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
35190 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
351a0 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b  ,b) VALUES(1,2);
351b0 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
351c0 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
351d0 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
351e0 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
351f0 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
35200 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63  PDATE SET c=t1.c
35210 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  +1;.  SELECT * F
35220 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45  ROM record;.  DE
35230 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
35240 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
35250 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
35260 2c 32 32 20 2d 31 30 30 31 2d 30 31 2d 30 31 29  ,22 -1001-01-01)
35270 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
35280 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
35290 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c  T c=c+1 WHERE c<
352a0 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52  0;.  SELECT * FR
352b0 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 6d 81 58 04  OM record;..m.X.
352c0 00 91 5f 20 20 43 52 45 41 54 45 20 54 41 42 4c  .._  CREATE TABL
352d0 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50  E t1(a INTEGER P
352e0 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
352f0 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  t, c DEFAULT 0);
35300 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
35310 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79  record(x TEXT, y
35320 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45   TEXT);.  CREATE
35330 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f   TRIGGER r1 BEFO
35340 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  RE INSERT ON t1 
35350 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
35360 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
35370 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
35380 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27  ('before-insert'
35390 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 20 2a 25  ,printf('%d,% *%
353a0 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
353b0 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
353c0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
353d0 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r2 AFTER INSERT 
353e0 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
353f0 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
35400 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55  rd(x,y)     VALU
35410 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74  ES('after-insert
35420 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
35430 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
35440 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
35450 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
35460 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54   r3 BEFORE UPDAT
35470 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
35480 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
35490 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
354a0 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
354b0 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
354c0 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
354d0 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
354e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
354f0 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f     old.a,old.b,o
35500 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ld.c,new.a,new.b
35510 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
35520 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
35530 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41 54  R r4 AFTER UPDAT
35540 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
35550 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
35560 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
35570 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
35580 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27  update',printf('
35590 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25  %d,%d,%d/%d,%d,%
355a0 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20  d',.            
355b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
355c0 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
355d0 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
355e0 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
355f0 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54  .  END;.  INSERT
35600 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
35610 4c 55 45 53 28 31 2c 31 32 30 30 31 2d 30 31 2d  LUES(1,12001-01-
35620 30 31 29 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  01);.  DELETE FR
35630 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
35640 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
35650 20 56 41 4c 55 45 53 28 31 2c 32 29 0a 20 20 20   VALUES(1,2).   
35660 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29 20   ON CONFLICT(a) 
35670 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63 3d  DO UPDATE SET c=
35680 74 31 2e 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54  t1.c+1;.  SELECT
35690 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
356a0 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
356b0 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49  cord;.  INSERT I
356c0 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
356d0 45 53 28 31 2c 32 32 30 30 31 2d 30 31 2d 30 31  ES(1,22001-01-01
356e0 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
356f0 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
35700 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63  ET c=c+1 WHERE c
35710 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  <0;.  SELECT * F
35720 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 5c 81 57  ROM record;..\.W
35730 04 00 91 3d 20 20 43 52 45 41 54 45 20 54 41 42  ...=  CREATE TAB
35740 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20  LE t1(a INTEGER 
35750 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
35760 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29  nt, c DEFAULT 0)
35770 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ;.  CREATE TABLE
35780 20 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20   record(x TEXT, 
35790 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54  y TEXT);.  CREAT
357a0 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46  E TRIGGER r1 BEF
357b0 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  ORE INSERT ON t1
357c0 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
357d0 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
357e0 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
357f0 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74  S('before-insert
35800 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 20 2a  ',printf('%d,% *
35810 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
35820 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
35830 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
35840 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54   r2 AFTER INSERT
35850 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
35860 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
35870 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c  ord(x,y)     VAL
35880 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72  UES('after-inser
35890 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  t',printf('%d,%d
358a0 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
358b0 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
358c0 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
358d0 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41  R r3 BEFORE UPDA
358e0 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
358f0 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
35900 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
35910 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
35920 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  e-update',printf
35930 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
35940 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
35950 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
35960 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
35970 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
35980 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
35990 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
359a0 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41  ER r4 AFTER UPDA
359b0 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
359c0 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
359d0 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
359e0 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
359f0 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
35a00 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
35a10 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
35a20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
35a30 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
35a40 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
35a50 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
35a60 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52  ;.  END;.  INSER
35a70 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
35a80 41 4c 55 45 53 28 31 2c 20 2d 31 36 29 3b 0a 20  ALUES(1, -16);. 
35a90 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63   DELETE FROM rec
35aa0 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  ord;.  INSERT IN
35ab0 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
35ac0 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20 43 4f  S(1,2).    ON CO
35ad0 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
35ae0 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63 2b 31  ATE SET c=t1.c+1
35af0 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f  ;.  SELECT * FRO
35b00 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45 4c 45  M record;.  DELE
35b10 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
35b20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
35b30 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
35b40 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
35b50 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
35b60 45 54 20 63 3d 63 2b 31 20 57 48 45 52 45 20 63  ET c=c+1 WHERE c
35b70 3c 30 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  <0;.  SELECT * F
35b80 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 88 70 81 56  ROM record;..p.V
35b90 04 00 91 65 20 20 43 52 45 41 54 45 20 54 41 42  ...e  CREATE TAB
35ba0 4c 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20  LE t1(a INTEGER 
35bb0 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69  PRIMARY KEY, b i
35bc0 6e 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29  nt, c DEFAULT 0)
35bd0 3b 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45  ;.  CREATE TABLE
35be0 20 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20   record(x TEXT, 
35bf0 79 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54  y TEXT);.  CREAT
35c00 45 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46  E TRIGGER r1 BEF
35c10 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31  ORE INSERT ON t1
35c20 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52   BEGIN.    INSER
35c30 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c  T INTO record(x,
35c40 79 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45  y).        VALUE
35c50 53 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74  S('before-insert
35c60 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 20 2a  ',printf('%d,% *
35c70 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
35c80 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
35c90 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
35ca0 20 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54   r2 AFTER INSERT
35cb0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
35cc0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
35cd0 6f 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c  ord(x,y)     VAL
35ce0 55 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72  UES('after-inser
35cf0 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64  t',printf('%d,%d
35d00 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62  ,%d',new.a,new.b
35d10 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b  ,new.c));.  END;
35d20 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45  .  CREATE TRIGGE
35d30 52 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41  R r3 BEFORE UPDA
35d40 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
35d50 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
35d60 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
35d70 20 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72     VALUES('befor
35d80 65 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66  e-update',printf
35d90 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64  ('%d,%d,%d/%d,%d
35da0 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20  ,%d',.          
35db0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
35dc0 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c      old.a,old.b,
35dd0 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e  old.c,new.a,new.
35de0 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44  b,new.c));.  END
35df0 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47 47  ;.  CREATE TRIGG
35e00 45 52 20 72 34 20 41 46 54 45 52 20 55 50 44 41  ER r4 AFTER UPDA
35e10 54 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20  TE ON t1 BEGIN. 
35e20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72     INSERT INTO r
35e30 65 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20  ecord(x,y).     
35e40 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
35e50 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
35e60 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
35e70 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
35e80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
35e90 20 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61             old.a
35ea0 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77  ,old.b,old.c,new
35eb0 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29  .a,new.b,new.c))
35ec0 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52  ;.  END;.  INSER
35ed0 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56  T INTO t1(a,b) V
35ee0 41 4c 55 45 53 28 31 2c 20 2d 31 32 32 30 30 31  ALUES(1, -122001
35ef0 2d 30 31 2d 30 31 29 3b 0a 20 20 44 45 4c 45 54  -01-01);.  DELET
35f00 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
35f10 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
35f20 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
35f30 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
35f40 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
35f50 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45  T c=t1.c+1;.  SE
35f60 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
35f70 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  rd;.  DELETE FRO
35f80 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
35f90 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
35fa0 56 41 4c 55 45 53 28 31 2c 32 32 30 30 31 2d 30  VALUES(1,22001-0
35fb0 31 2d 30 31 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  1-01).    ON CON
35fc0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
35fd0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
35fe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
35ff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
36000 0d 00 00 00 07 00 f7 00 1b 99 17 32 12 c1 0e 50  ...........2...P
36010 09 df 05 68 00 f7 00 00 00 00 00 00 00 00 00 00  ...h............
36020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
36030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
36040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
36050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
36060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
36070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
36080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
36090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
360a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
360b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
360c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
360d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
360e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
360f0 00 00 00 00 00 00 00 88 6d 81 63 04 00 91 5f 20  ........m.c..._ 
36100 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 31   CREATE TABLE t1
36110 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41  (a INTEGER PRIMA
36120 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20 63  RY KEY, b int, c
36130 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20 43   DEFAULT 0);.  C
36140 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63 6f  REATE TABLE reco
36150 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45 58  rd(x TEXT, y TEX
36160 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  T);.  CREATE TRI
36170 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20 49  GGER r1 BEFORE I
36180 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
36190 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
361a0 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
361b0 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
361c0 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72 69  fore-insert',pri
361d0 6e 74 66 28 27 25 64 2c 25 20 2a 25 64 27 2c 6e  ntf('%d,% *%d',n
361e0 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63  ew.a,new.b,new.c
361f0 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45  ));.  END;.  CRE
36200 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20 41  ATE TRIGGER r2 A
36210 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20 74  FTER INSERT ON t
36220 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45  1 BEGIN.    INSE
36230 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78  RT INTO record(x
36240 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28 27  ,y)     VALUES('
36250 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70 72  after-insert',pr
36260 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27 2c  intf('%d,%d,%d',
36270 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
36280 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
36290 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33 20  EATE TRIGGER r3 
362a0 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f 4e  BEFORE UPDATE ON
362b0 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
362c0 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
362d0 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
362e0 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70 64  LUES('before-upd
362f0 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
36300 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
36310 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
36320 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
36330 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
36340 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
36350 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
36360 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 34  REATE TRIGGER r4
36370 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f 4e   AFTER UPDATE ON
36380 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
36390 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
363a0 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
363b0 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64 61  LUES('after-upda
363c0 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25  te',printf('%d,%
363d0 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c 0a  d,%d/%d,%d,%d',.
363e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
363f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
36400 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64 2e        old.a,old.
36410 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e 65  b,old.c,new.a,ne
36420 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
36430 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54  ND;.  INSERT INT
36440 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53  O t1(a,b) VALUES
36450 28 31 2c 32 32 30 30 31 2d 30 31 36 30 31 29 3b  (1,22001-01601);
36460 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
36470 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
36480 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
36490 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
364a0 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
364b0 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63  PDATE SET c=t1.c
364c0 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  +1;.  SELECT * F
364d0 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45  ROM record;.  DE
364e0 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
364f0 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
36500 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
36510 2c 32 32 30 30 31 2d 30 31 2d 30 31 29 0a 20 20  ,22001-01-01).  
36520 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61 29    ON CONFLICT(a)
36530 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20 63   DO UPDATE SET c
36540 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b 0a  =c+1 WHERE c<0;.
36550 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20    SELECT * FROM 
36560 72 65 63 6f 72 64 3b 0a 88 73 81 62 04 00 91 6b  record;..s.b...k
36570 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 74    CREATE TABLE t
36580 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49 4d  1(a INTEGER PRIM
36590 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c 20  ARY KEY, b int, 
365a0 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20 20  c DEFAULT 0);.  
365b0 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65 63  CREATE TABLE rec
365c0 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54 45  ord(x TEXT, y TE
365d0 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54 52  XT);.  CREATE TR
365e0 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45 20  IGGER r1 BEFORE 
365f0 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
36600 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
36610 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
36620 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
36630 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70 72  efore-insert',pr
36640 69 6e 74 66 28 27 25 64 2c 25 20 2a 25 64 27 2c  intf('%d,% *%d',
36650 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
36660 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43 52  c));.  END;.  CR
36670 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32 20  EATE TRIGGER r2 
36680 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e 20  AFTER INSERT ON 
36690 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e 53  t1 BEGIN.    INS
366a0 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64 28  ERT INTO record(
366b0 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53 28  x,y)     VALUES(
366c0 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c 70  'after-insert',p
366d0 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 27  rintf('%d,%d,%d'
366e0 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
366f0 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
36700 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 33  REATE TRIGGER r3
36710 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20 4f   BEFORE UPDATE O
36720 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
36730 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
36740 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
36750 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75 70  ALUES('before-up
36760 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
36770 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
36780 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
36790 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
367a0 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e  old.a,old.b,old.
367b0 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  c,new.a,new.b,ne
367c0 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
367d0 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
367e0 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20 4f  4 AFTER UPDATE O
367f0 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
36800 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
36810 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
36820 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70 64  ALUES('after-upd
36830 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ate',printf('%d,
36840 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27 2c  %d,%d/%d,%d,%d',
36850 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
36860 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
36870 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
36880 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
36890 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
368a0 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e  END;.  INSERT IN
368b0 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45  TO t1(a,b) VALUE
368c0 53 28 31 2c 32 32 30 30 31 2d 30 31 2d 30 31 29  S(1,22001-01-01)
368d0 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
368e0 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
368f0 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
36900 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e  LUES(1,2).    ON
36910 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
36920 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e  UPDATE SET c=t1.
36930 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20  c+1;.  SELECT * 
36940 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44  FROM record;.  D
36950 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
36960 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
36970 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
36980 31 2c 32 32 30 30 31 2d 30 31 2d 30 31 29 0a 20  1,22001-01-01). 
36990 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
369a0 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
369b0 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b  c=c+1 WHERE c<0;
369c0 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
369d0 20 72 65 63 6f 72 64 3b 56 41 43 55 55 4d 0a 88   record;VACUUM..
369e0 6d 81 61 04 00 91 5f 20 20 43 52 45 41 54 45 20  m.a..._  CREATE 
369f0 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45 47  TABLE t1(a INTEG
36a00 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20  ER PRIMARY KEY, 
36a10 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c 54  b int, c DEFAULT
36a20 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54 41   0);.  CREATE TA
36a30 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45 58  BLE record(x TEX
36a40 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43 52  T, y TEXT);.  CR
36a50 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31 20  EATE TRIGGER r1 
36a60 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f 4e  BEFORE INSERT ON
36a70 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
36a80 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
36a90 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56 41  (x,y).        VA
36aa0 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e 73  LUES('before-ins
36ab0 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64 2c  ert',printf('%d,
36ac0 25 20 2a 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77  % *%d',new.a,new
36ad0 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e  .b,new.c));.  EN
36ae0 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49 47  D;.  CREATE TRIG
36af0 47 45 52 20 72 32 20 41 46 54 45 52 20 49 4e 53  GER r2 AFTER INS
36b00 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a  ERT ON t1 BEGIN.
36b10 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
36b20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20 20  record(x,y)     
36b30 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69 6e  VALUES('after-in
36b40 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64  sert',printf('%d
36b50 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e 65  ,%d,%d',new.a,ne
36b60 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
36b70 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
36b80 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20 55  GGER r3 BEFORE U
36b90 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
36ba0 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
36bb0 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
36bc0 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62 65        VALUES('be
36bd0 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72 69  fore-update',pri
36be0 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
36bf0 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
36c00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
36c10 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c 64         old.a,old
36c20 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c 6e  .b,old.c,new.a,n
36c30 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
36c40 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
36c50 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20 55  IGGER r4 AFTER U
36c60 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47 49  PDATE ON t1 BEGI
36c70 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
36c80 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20 20  O record(x,y).  
36c90 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61 66        VALUES('af
36ca0 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69 6e  ter-update',prin
36cb0 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c  tf('%d,%d,%d/%d,
36cc0 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20 20  %d,%d',.        
36cd0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
36ce0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6c                ol
36cf0 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c  d.a,old.b,old.c,
36d00 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e  new.a,new.b,new.
36d10 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49 4e  c));.  END;.  IN
36d20 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62  SERT INTO t1(a,b
36d30 29 20 56 41 4c 55 45 53 28 31 2c 32 32 30 30 31  ) VALUES(1,22001
36d40 2d 30 31 2d 30 31 29 3b 0a 20 20 44 45 4c 45 54  -01-01);.  DELET
36d50 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
36d60 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
36d70 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
36d80 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
36d90 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
36da0 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45  T c=t1.c+1;.  SE
36db0 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
36dc0 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  rd;.  DELETE FRO
36dd0 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
36de0 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
36df0 56 41 4c 55 45 53 28 31 2c 31 32 30 30 31 2d 30  VALUES(1,12001-0
36e00 31 2d 30 31 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  1-01).    ON CON
36e10 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
36e20 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
36e30 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
36e40 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
36e50 88 6d 81 60 04 00 91 5f 20 20 43 52 45 41 54 45  .m.`..._  CREATE
36e60 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54 45   TABLE t1(a INTE
36e70 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c  GER PRIMARY KEY,
36e80 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55 4c   b int, c DEFAUL
36e90 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20 54  T 0);.  CREATE T
36ea0 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54 45  ABLE record(x TE
36eb0 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20 43  XT, y TEXT);.  C
36ec0 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 31  REATE TRIGGER r1
36ed0 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20 4f   BEFORE INSERT O
36ee0 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49  N t1 BEGIN.    I
36ef0 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72  NSERT INTO recor
36f00 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20 56  d(x,y).        V
36f10 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69 6e  ALUES('before-in
36f20 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25 64  sert',printf('%d
36f30 2c 25 20 2a 25 64 27 2c 6e 65 77 2e 61 2c 6e 65  ,% *%d',new.a,ne
36f40 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20 45  w.b,new.c));.  E
36f50 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52 49  ND;.  CREATE TRI
36f60 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49 4e  GGER r2 AFTER IN
36f70 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49 4e  SERT ON t1 BEGIN
36f80 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
36f90 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20 20   record(x,y)    
36fa0 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 69   VALUES('after-i
36fb0 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25  nsert',printf('%
36fc0 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c 6e  d,%d,%d',new.a,n
36fd0 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
36fe0 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
36ff0 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45 20  IGGER r3 BEFORE 
37000 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
37010 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
37020 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
37030 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 62         VALUES('b
37040 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70 72  efore-update',pr
37050 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
37060 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
37070 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
37080 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
37090 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
370a0 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
370b0 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
370c0 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52 20  RIGGER r4 AFTER 
370d0 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45 47  UPDATE ON t1 BEG
370e0 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
370f0 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a 20  TO record(x,y). 
37100 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27 61         VALUES('a
37110 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72 69  fter-update',pri
37120 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25 64  ntf('%d,%d,%d/%d
37130 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20 20  ,%d,%d',.       
37140 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
37150 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f                 o
37160 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e 63  ld.a,old.b,old.c
37170 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
37180 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 49  .c));.  END;.  I
37190 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c  NSERT INTO t1(a,
371a0 62 29 20 56 41 4c 55 45 53 28 31 2c 32 30 30 30  b) VALUES(1,2000
371b0 31 2d 30 31 2d 30 31 29 3b 0a 20 20 44 45 4c 45  1-01-01);.  DELE
371c0 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a  TE FROM record;.
371d0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31    INSERT INTO t1
371e0 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32  (a,b) VALUES(1,2
371f0 29 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43  ).    ON CONFLIC
37200 54 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53  T(a) DO UPDATE S
37210 45 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53  ET c=t1.c+1;.  S
37220 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63  ELECT * FROM rec
37230 6f 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52  ord;.  DELETE FR
37240 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53  OM record;.  INS
37250 45 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29  ERT INTO t1(a,b)
37260 20 56 41 4c 55 45 53 28 31 2c 32 32 30 30 31 2d   VALUES(1,22001-
37270 30 31 2d 30 31 29 0a 20 20 20 20 4f 4e 20 43 4f  01-01).    ON CO
37280 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44  NFLICT(a) DO UPD
37290 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48  ATE SET c=c+1 WH
372a0 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43  ERE c<0;.  SELEC
372b0 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b  T * FROM record;
372c0 0a 88 6d 81 5f 04 00 91 5f 20 20 43 52 45 41 54  ..m._..._  CREAT
372d0 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e 54  E TABLE t1(a INT
372e0 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59  EGER PRIMARY KEY
372f0 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41 55  , b int, c DEFAU
37300 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45 20  LT 0);.  CREATE 
37310 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20 54  TABLE record(x T
37320 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20 20  EXT, y TEXT);.  
37330 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
37340 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20  1 BEFORE INSERT 
37350 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
37360 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
37370 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
37380 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 69  VALUES('before-i
37390 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27 25  nsert',printf('%
373a0 64 2c 25 20 2a 25 64 27 2c 6e 65 77 2e 61 2c 6e  d,% *%d',new.a,n
373b0 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20 20  ew.b,new.c));.  
373c0 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54 52  END;.  CREATE TR
373d0 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20 49  IGGER r2 AFTER I
373e0 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47 49  NSERT ON t1 BEGI
373f0 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  N.    INSERT INT
37400 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20 20  O record(x,y)   
37410 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d    VALUES('after-
37420 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
37430 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61 2c  %d,%d,%d',new.a,
37440 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
37450 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
37460 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52 45  RIGGER r3 BEFORE
37470 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
37480 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
37490 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
374a0 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
374b0 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c 70  before-update',p
374c0 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
374d0 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
374e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
374f0 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f           old.a,o
37500 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61  ld.b,old.c,new.a
37510 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
37520 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
37530 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45 52  TRIGGER r4 AFTER
37540 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42 45   UPDATE ON t1 BE
37550 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
37560 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
37570 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
37580 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70 72  after-update',pr
37590 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f 25  intf('%d,%d,%d/%
375a0 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20 20  d,%d,%d',.      
375b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
375c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
375d0 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64 2e  old.a,old.b,old.
375e0 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  c,new.a,new.b,ne
375f0 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
37600 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28 61  INSERT INTO t1(a
37610 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29 3b  ,b) VALUES(1,2);
37620 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72  .  DELETE FROM r
37630 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54 20  ecord;.  INSERT 
37640 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c  INTO t1(a,b) VAL
37650 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e 20  UES(1,2).    ON 
37660 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55  CONFLICT(a) DO U
37670 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e 63  PDATE SET c=t1.c
37680 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20 46  +1;.  SELECT * F
37690 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44 45  ROM record;.  DE
376a0 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72 64  LETE FROM record
376b0 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20  ;.  INSERT INTO 
376c0 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28 31  t1(a,b) VALUES(1
376d0 2c 32 32 32 30 30 31 2d 30 31 2d 30 31 30 30 31  ,222001-01-01001
376e0 35 30 31 2d 30 31 29 0a 20 20 20 20 4f 4e 20 43  501-01).    ON C
376f0 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50  ONFLICT(a) DO UP
37700 44 41 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57  DATE SET c=c+1 W
37710 48 45 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45  HERE c<0;.  SELE
37720 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64  CT * FROM record
37730 3b 0a 88 63 81 5e 04 00 91 4b 20 20 43 52 45 41  ;..c.^...K  CREA
37740 54 45 20 54 41 42 4c 45 20 74 31 28 61 20 49 4e  TE TABLE t1(a IN
37750 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45  TEGER PRIMARY KE
37760 59 2c 20 62 20 69 6e 74 2c 20 63 20 44 45 46 41  Y, b int, c DEFA
37770 55 4c 54 20 30 29 3b 0a 20 20 43 52 45 41 54 45  ULT 0);.  CREATE
37780 20 54 41 42 4c 45 20 72 65 63 6f 72 64 28 78 20   TABLE record(x 
37790 54 45 58 54 2c 20 79 20 54 45 58 54 29 3b 0a 20  TEXT, y TEXT);. 
377a0 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
377b0 72 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54  r1 BEFORE INSERT
377c0 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20   ON t1 BEGIN.   
377d0 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63   INSERT INTO rec
377e0 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20  ord(x,y).       
377f0 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d   VALUES('before-
37800 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28 27  insert',printf('
37810 25 64 2c 25 20 2a 25 64 27 2c 6e 65 77 2e 61 2c  %d,% *%d',new.a,
37820 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
37830 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20 54   END;.  CREATE T
37840 52 49 47 47 45 52 20 72 32 20 41 46 54 45 52 20  RIGGER r2 AFTER 
37850 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45 47  INSERT ON t1 BEG
37860 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49 4e  IN.    INSERT IN
37870 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 20 20  TO record(x,y)  
37880 20 20 20 56 41 4c 55 45 53 28 27 61 66 74 65 72     VALUES('after
37890 2d 69 6e 73 65 72 74 27 2c 70 72 69 6e 74 66 28  -insert',printf(
378a0 27 25 64 2c 25 64 2c 25 64 27 2c 6e 65 77 2e 61  '%d,%d,%d',new.a
378b0 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a  ,new.b,new.c));.
378c0 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45 20    END;.  CREATE 
378d0 54 52 49 47 47 45 52 20 72 33 20 42 45 46 4f 52  TRIGGER r3 BEFOR
378e0 45 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  E UPDATE ON t1 B
378f0 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
37900 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
37910 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
37920 27 62 65 66 6f 72 65 2d 75 70 64 61 74 65 27 2c  'before-update',
37930 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
37940 2f 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20  /%d,%d,%d',.    
37950 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
37960 20 20 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c            old.a,
37970 6f 6c 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e  old.b,old.c,new.
37980 61 2c 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b  a,new.b,new.c));
37990 0a 20 20 45 4e 44 3b 0a 20 20 43 52 45 41 54 45  .  END;.  CREATE
379a0 20 54 52 49 47 47 45 52 20 72 34 20 41 46 54 45   TRIGGER r4 AFTE
379b0 52 20 55 50 44 41 54 45 20 4f 4e 20 74 31 20 42  R UPDATE ON t1 B
379c0 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20  EGIN.    INSERT 
379d0 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29  INTO record(x,y)
379e0 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28  .        VALUES(
379f0 27 61 66 74 65 72 2d 75 70 64 61 74 65 27 2c 70  'after-update',p
37a00 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64 2f  rintf('%d,%d,%d/
37a10 25 64 2c 25 64 2c 25 64 27 2c 0a 20 20 20 20 20  %d,%d,%d',.     
37a20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
37a30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
37a40 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
37a50 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
37a60 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
37a70 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
37a80 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
37a90 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20  ;.  DELETE FROM 
37aa0 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45 52 54  record;.  INSERT
37ab0 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41   INTO t1(a,b) VA
37ac0 4c 55 45 53 28 31 2c 32 29 0a 20 20 20 20 4f 4e  LUES(1,2).    ON
37ad0 20 43 4f 4e 46 4c 49 43 54 28 61 29 20 44 4f 20   CONFLICT(a) DO 
37ae0 55 50 44 41 54 45 20 53 45 54 20 63 3d 74 31 2e  UPDATE SET c=t1.
37af0 63 2b 31 3b 0a 20 20 53 45 4c 45 43 54 20 2a 20  c+1;.  SELECT * 
37b00 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20 20 44  FROM record;.  D
37b10 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 63 6f 72  ELETE FROM recor
37b20 64 3b 0a 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  d;.  INSERT INTO
37b30 20 74 31 28 61 2c 62 29 20 56 41 4c 55 45 53 28   t1(a,b) VALUES(
37b40 31 2c 32 32 30 30 31 35 30 31 2d 30 31 29 0a 20  1,22001501-01). 
37b50 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 28 61     ON CONFLICT(a
37b60 29 20 44 4f 20 55 50 44 41 54 45 20 53 45 54 20  ) DO UPDATE SET 
37b70 63 3d 63 2b 31 20 57 48 45 52 45 20 63 3c 30 3b  c=c+1 WHERE c<0;
37b80 0a 20 20 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d  .  SELECT * FROM
37b90 20 72 65 63 6f 72 64 3b 0a 88 63 81 5d 04 00 91   record;..c.]...
37ba0 4b 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  K  CREATE TABLE 
37bb0 74 31 28 61 20 49 4e 54 45 47 45 52 20 50 52 49  t1(a INTEGER PRI
37bc0 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e 74 2c  MARY KEY, b int,
37bd0 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b 0a 20   c DEFAULT 0);. 
37be0 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 72 65   CREATE TABLE re
37bf0 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79 20 54  cord(x TEXT, y T
37c00 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45 20 54  EXT);.  CREATE T
37c10 52 49 47 47 45 52 20 72 31 20 42 45 46 4f 52 45  RIGGER r1 BEFORE
37c20 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20 42 45   INSERT ON t1 BE
37c30 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54 20 49  GIN.    INSERT I
37c40 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79 29 0a  NTO record(x,y).
37c50 20 20 20 20 20 20 20 20 56 41 4c 55 45 53 28 27          VALUES('
37c60 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27 2c 70  before-insert',p
37c70 72 69 6e 74 66 28 27 25 64 2c 25 20 2a 25 64 27  rintf('%d,% *%d'
37c80 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65 77  ,new.a,new.b,new
37c90 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20 43  .c));.  END;.  C
37ca0 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72 32  REATE TRIGGER r2
37cb0 20 41 46 54 45 52 20 49 4e 53 45 52 54 20 4f 4e   AFTER INSERT ON
37cc0 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20 49 4e   t1 BEGIN.    IN
37cd0 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f 72 64  SERT INTO record
37ce0 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55 45 53  (x,y)     VALUES
37cf0 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74 27 2c  ('after-insert',
37d00 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c 25 64  printf('%d,%d,%d
37d10 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e 65  ',new.a,new.b,ne
37d20 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20 20  w.c));.  END;.  
37d30 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20 72  CREATE TRIGGER r
37d40 33 20 42 45 46 4f 52 45 20 55 50 44 41 54 45 20  3 BEFORE UPDATE 
37d50 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
37d60 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
37d70 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
37d80 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65 2d 75  VALUES('before-u
37d90 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25  pdate',printf('%
37da0 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64  d,%d,%d/%d,%d,%d
37db0 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  ',.             
37dc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
37dd0 20 6f 6c 64 2e 61 2c 6f 6c 64 2e 62 2c 6f 6c 64   old.a,old.b,old
37de0 2e 63 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  .c,new.a,new.b,n
37df0 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
37e00 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
37e10 72 34 20 41 46 54 45 52 20 55 50 44 41 54 45 20  r4 AFTER UPDATE 
37e20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
37e30 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
37e40 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20 20 20  rd(x,y).        
37e50 56 41 4c 55 45 53 28 27 61 66 74 65 72 2d 75 70  VALUES('after-up
37e60 64 61 74 65 27 2c 70 72 69 6e 74 66 28 27 25 64  date',printf('%d
37e70 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c 25 64 27  ,%d,%d/%d,%d,%d'
37e80 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,.              
37e90 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
37ea0 20 20 20 20 20 20 20 20 6f 6c 64 2e 61 2c 6f 6c          old.a,ol
37eb0 64 2e 62 2c 6f 6c 64 2e 63 2c 6e 65 77 2e 61 2c  d.b,old.c,new.a,
37ec0 6e 65 77 2e 62 2c 6e 65 77 2e 63 29 29 3b 0a 20  new.b,new.c));. 
37ed0 20 45 4e 44 3b 0a 20 20 49 4e 53 45 52 54 20 49   END;.  INSERT I
37ee0 4e 54 4f 20 74 31 28 61 2c 62 29 20 56 41 4c 55  NTO t1(a,b) VALU
37ef0 45 53 28 31 2c 32 29 3b 0a 20 20 44 45 4c 45 54  ES(1,2);.  DELET
37f00 45 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a 20  E FROM record;. 
37f10 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 31 28   INSERT INTO t1(
37f20 61 2c 62 29 20 56 41 4c 55 45 53 28 31 2c 32 29  a,b) VALUES(1,2)
37f30 0a 20 20 20 20 4f 4e 20 43 4f 4e 46 4c 49 43 54  .    ON CONFLICT
37f40 28 61 29 20 44 4f 20 55 50 44 41 54 45 20 53 45  (a) DO UPDATE SE
37f50 54 20 63 3d 74 31 2e 63 2b 31 3b 0a 20 20 53 45  T c=t1.c+1;.  SE
37f60 4c 45 43 54 20 2a 20 46 52 4f 4d 20 72 65 63 6f  LECT * FROM reco
37f70 72 64 3b 0a 20 20 44 45 4c 45 54 45 20 46 52 4f  rd;.  DELETE FRO
37f80 4d 20 72 65 63 6f 72 64 3b 0a 20 20 49 4e 53 45  M record;.  INSE
37f90 52 54 20 49 4e 54 4f 20 74 31 28 61 2c 62 29 20  RT INTO t1(a,b) 
37fa0 56 41 4c 55 45 53 28 31 2c 32 32 30 30 31 35 30  VALUES(1,2200150
37fb0 2f 2d 30 31 29 0a 20 20 20 20 4f 4e 20 43 4f 4e  /-01).    ON CON
37fc0 46 4c 49 43 54 28 61 29 20 44 4f 20 55 50 44 41  FLICT(a) DO UPDA
37fd0 54 45 20 53 45 54 20 63 3d 63 2b 31 20 57 48 45  TE SET c=c+1 WHE
37fe0 52 45 20 63 3c 30 3b 0a 20 20 53 45 4c 45 43 54  RE c<0;.  SELECT
37ff0 20 2a 20 46 52 4f 4d 20 72 65 63 6f 72 64 3b 0a   * FROM record;.
38000 0d 00 00 00 07 01 1b 00 1b 8f 17 1e 12 c1 0e 64  ...............d
38010 09 fd 05 8c 01 1b 00 00 00 00 00 00 00 00 00 00  ................
38020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
380a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
380b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
380c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
380d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
380e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
380f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
38110 00 00 00 00 00 00 00 00 00 00 00 88 6d 81 6a 04  ............m.j.
38120 00 91 5f 20 20 43 52 45 41 54 45 20 54 41 42 4c  .._  CREATE TABL
38130 45 20 74 31 28 61 20 49 4e 54 45 47 45 52 20 50  E t1(a INTEGER P
38140 52 49 4d 41 52 59 20 4b 45 59 2c 20 62 20 69 6e  RIMARY KEY, b in
38150 74 2c 20 63 20 44 45 46 41 55 4c 54 20 30 29 3b  t, c DEFAULT 0);
38160 0a 20 20 43 52 45 41 54 45 20 54 41 42 4c 45 20  .  CREATE TABLE 
38170 72 65 63 6f 72 64 28 78 20 54 45 58 54 2c 20 79  record(x TEXT, y
38180 20 54 45 58 54 29 3b 0a 20 20 43 52 45 41 54 45   TEXT);.  CREATE
38190 20 54 52 49 47 47 45 52 20 72 31 20 42 45 46 4f   TRIGGER r1 BEFO
381a0 52 45 20 49 4e 53 45 52 54 20 4f 4e 20 74 31 20  RE INSERT ON t1 
381b0 42 45 47 49 4e 0a 20 20 20 20 49 4e 53 45 52 54  BEGIN.    INSERT
381c0 20 49 4e 54 4f 20 72 65 63 6f 72 64 28 78 2c 79   INTO record(x,y
381d0 29 0a 20 20 20 20 20 20 20 20 56 41 4c 55 45 53  ).        VALUES
381e0 28 27 62 65 66 6f 72 65 2d 69 6e 73 65 72 74 27  ('before-insert'
381f0 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 20 2a 25  ,printf('%d,% *%
38200 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c 6e  d',new.a,new.b,n
38210 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a 20  ew.c));.  END;. 
38220 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52 20   CREATE TRIGGER 
38230 72 32 20 41 46 54 45 52 20 49 4e 53 45 52 54 20  r2 AFTER INSERT 
38240 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20 20 20  ON t1 BEGIN.    
38250 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65 63 6f  INSERT INTO reco
38260 72 64 28 78 2c 79 29 20 20 20 20 20 56 41 4c 55  rd(x,y)     VALU
38270 45 53 28 27 61 66 74 65 72 2d 69 6e 73 65 72 74  ES('after-insert
38280 27 2c 70 72 69 6e 74 66 28 27 25 64 2c 25 64 2c  ',printf('%d,%d,
38290 25 64 27 2c 6e 65 77 2e 61 2c 6e 65 77 2e 62 2c  %d',new.a,new.b,
382a0 6e 65 77 2e 63 29 29 3b 0a 20 20 45 4e 44 3b 0a  new.c));.  END;.
382b0 20 20 43 52 45 41 54 45 20 54 52 49 47 47 45 52    CREATE TRIGGER
382c0 20 72 33 20 42 45 46 4f 52 45 20 55 50 44 41 54   r3 BEFORE UPDAT
382d0 45 20 4f 4e 20 74 31 20 42 45 47 49 4e 0a 20 20  E ON t1 BEGIN.  
382e0 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 72 65    INSERT INTO re
382f0 63 6f 72 64 28 78 2c 79 29 0a 20 20 20 20 20 20  cord(x,y).      
38300 20 20 56 41 4c 55 45 53 28 27 62 65 66 6f 72 65    VALUES('before
38310 2d 75 70 64 61 74 65 27 2c 70 72 69 6e 74 66 28  -update',printf(
38320 27 25 64 2c 25 64 2c 25 64 2f 25 64 2c 25 64 2c  '%d,%d,%d/%d,%d,
38330 25 64 27 2c 0a 20 20 20 20 20 20 20 20 20 20 20  %d',.           
38340 20 20 20 20 20 2