1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>SQLite Virtual Machine Opcodes</title>
<style type="text/css">
body {
margin: auto;
font-family: Verdana, sans-serif;
padding: 8px 1%;
}
a { color: #044a64 }
a:visited { color: #734559 }
.logo { position:absolute; margin:3px; }
.tagline {
float:right;
text-align:right;
font-style:italic;
width:300px;
margin:12px;
margin-top:58px;
}
.menubar {
clear: both;
border-radius: 8px;
background: #044a64;
padding: 0px;
margin: 0px;
cell-spacing: 0px;
}
.toolbar {
text-align: center;
line-height: 1.6em;
margin: 0;
padding: 0px 8px;
}
.toolbar a { color: white; text-decoration: none; padding: 6px 12px; }
.toolbar a:visited { color: white; }
.toolbar a:hover { color: #044a64; background: white; }
.content { margin: 5%; }
.content dt { font-weight:bold; }
.content dd { margin-bottom: 25px; margin-left:20%; }
.content ul { padding:0px; padding-left: 15px; margin:0px; }
/* Things for "fancyformat" documents start here. */
.fancy img+p {font-style:italic}
.fancy .codeblock i { color: darkblue; }
.fancy h1,.fancy h2,.fancy h3,.fancy h4 {font-weight:normal;color:#044a64}
.fancy h2 { margin-left: 10px }
.fancy h3 { margin-left: 20px }
.fancy h4 { margin-left: 30px }
.fancy th {white-space:nowrap;text-align:left;border-bottom:solid 1px #444}
.fancy th, .fancy td {padding: 0.2em 1ex; vertical-align:top}
.fancy #toc a { color: darkblue ; text-decoration: none }
.fancy .todo { color: #AA3333 ; font-style : italic }
.fancy .todo:before { content: 'TODO:' }
.fancy p.todo { border: solid #AA3333 1px; padding: 1ex }
.fancy img { display:block; }
.fancy :link:hover, .fancy :visited:hover { background: wheat }
.fancy p,.fancy ul,.fancy ol { margin: 1em 5ex }
.fancy li p { margin: 1em 0 }
/* End of "fancyformat" specific rules. */
</style>
</head>
<body>
<div><!-- container div to satisfy validator -->
<a href="index.html">
<img class="logo" src="images/sqlite370_banner.gif" alt="SQLite Logo"
border="0"></a>
<div><!-- IE hack to prevent disappearing logo--></div>
<div class="tagline">Small. Fast. Reliable.<br>Choose any three.</div>
<table width=100% class="menubar"><tr>
<td width=100%>
<div class="toolbar">
<a href="about.html">About</a>
<a href="sitemap.html">Sitemap</a>
<a href="docs.html">Documentation</a>
<a href="download.html">Download</a>
<a href="copyright.html">License</a>
<a href="news.html">News</a>
<a href="support.html">Support</a>
</div>
<script>
gMsg = "Search SQLite Docs..."
function entersearch() {
var q = document.getElementById("q");
if( q.value == gMsg ) { q.value = "" }
q.style.color = "black"
q.style.fontStyle = "normal"
}
function leavesearch() {
var q = document.getElementById("q");
if( q.value == "" ) {
q.value = gMsg
q.style.color = "#044a64"
q.style.fontStyle = "italic"
}
}
function hideorshow(btn,obj){
var x = document.getElementById(obj);
var b = document.getElementById(btn);
if( x.style.display!='none' ){
x.style.display = 'none';
b.innerHTML='show';
}else{
x.style.display = '';
b.innerHTML='hide';
}
return false;
}
</script>
<td>
<div style="padding:0 1em 0px 0;white-space:nowrap">
<form name=f method="GET" action="http://www.sqlite.org/search">
<input id=q name=q type=text
onfocus="entersearch()" onblur="leavesearch()" style="width:24ex;padding:1px 1ex; border:solid white 1px; font-size:0.9em ; font-style:italic;color:#044a64;" value="Search SQLite Docs...">
<input type=submit value="Go" style="border:solid white 1px;background-color:#044a64;color:white;font-size:0.9em;padding:0 1ex">
</form>
</div>
</table>
<div class=startsearch></div>
<h2>The SQLite Virtual Machine</h2>
<h3>Introduction</h3>
<p>In order to execute an SQL statement, the SQLite library first parses
the SQL, analyzes the statement, then generates a short program to execute
the statement. The program is generated for a "virtual machine" implemented
by the SQLite library. That virtual machine is sometimes called the
"VDBE" or "Virtual DataBase Engine".
This document describes the operation of the VDBE.</p>
<p>This document is intended as a reference, not a tutorial.
A separate <a href="vdbe.html">Virtual Machine Tutorial</a> is
available. If you are looking for a narrative description
of how the virtual machine works, you should read the tutorial
and not this document. Once you have a basic idea of what the
virtual machine does, you can refer back to this document for
the details on a particular opcode.
Unfortunately, the virtual machine tutorial was written for
SQLite version 1.0. There are substantial changes in the virtual
machine for version 2.0 and again for version 3.0.0 and again
for version 3.5.5 and the tutorial document has not been updated.
But the
basic concepts behind the virtual machine still apply.
</p>
<p>The source code to the virtual machine is in the
<a href="http://www.sqlite.org/src/finfo?name=src/vdbe.c">vdbe.c</a> source
file. All of the opcode definitions further down in this document are
contained in comments in the source file. In fact, the opcode table
in this document
was generated by scanning the
<a href="http://www.sqlite.org/src/finfo?name=src/vdbe.c">vdbe.c</a> source file
and extracting the necessary information from comments. So the
source code comments are really the canonical source of information
about the virtual machine. When in doubt, refer to the source code.</p>
<p>Each instruction in the virtual machine consists of an opcode and
up to five operands named P1, P2 P3, P4, and P5. The P1, P2, and P3
operands are 32-bit signed integers. These operands often refer to
registers but can also be use dfor other purposes. The P1 operand is
usually the cursor number for opcodes that operate on cursors.
P2 is usually the jump destination jump instructions.
P4 may be a 32-bit signed integer, a 64-bit signed integer, a
64-bit floating point value, a string literal, a Blob literal,
a pointer to a collating sequence comparison function, or a
pointer to the implementation of an application-defined SQL
function, or various other things. P5 is an unsigned character
normally used as a flag.
Some operators use all five operands. Some use
one or two. Some operators use none of the operands.<p>
<p>The virtual machine begins execution on instruction number 0.
Execution continues until a Halt instruction is seen, or until
the program counter becomes one greater than the address of
last instruction, or there is an execution error.
When the virtual machine halts, all memory
that it allocated is released and all database cursors it may
have had open are closed. If the execution stopped due to an
error, any pending transactions are terminated and changes made
to the database are rolled back.</p>
<p>The virtual machine can have zero or more cursors. Each cursor
is a pointer into a single table or index within the database.
There can be multiple cursors pointing at the same index or table.
All cursors operate independently, even cursors pointing to the same
indices or tables.
The only way for the virtual machine to interact with a database
file is through a cursor.
Instructions in the virtual
machine can create a new cursor (OpenRead or OpenWrite),
read data from a cursor
(Column), advance the cursor to the next entry in the table
(Next) or index (NextIdx), and many other operations.
All cursors are automatically
closed when the virtual machine terminates.</p>
<p>The virtual machine contains an arbitrary number of registers
with addresses beginning at one and growing upward.
Each register can a single SQL value (a string, a BLOB, a signed 64-bit
integer, a 64-bit floating point number, or a NULL). A register might
also hold objects used internally by SQLite, such as a RowSet or Frame.
</p>
<h3>Viewing Programs Generated By SQLite</h3>
<p>Every SQL statement that SQLite interprets results in a program
for the virtual machine. But if you precede the SQL statement with
the keyword <a href="lang_explain.html">EXPLAIN</a> the virtual machine will not execute the
program. Instead, the instructions of the program will be returned
like a query result. This feature is useful for debugging and
for learning how the virtual machine operates. For example:
</p>
<blockquote><pre>$ <b>sqlite3 ex1.db</b>
sqlite> <b>.explain</b>
sqlite> <b>explain delete from tbl1 where two<20;</b>
addr opcode p1 p2 p3 p4 p5 comment
---- ------------- ---- ---- ---- ------------- -- -------------
0 Trace 0 0 0 00
1 Goto 0 23 0 00
2 Null 0 1 0 00 r[1]=NULL
3 OpenRead 0 2 0 2 00 root=2 iDb=0; tbl1
4 Explain 0 0 0 SCAN TABLE tbl1 00
5 Noop 0 0 0 00 Begin WHERE-loop0: tbl1
6 Rewind 0 14 0 00
7 Column 0 1 2 00 r[2]=tbl1.two
8 Ge 3 13 2 (BINARY) 6a if r[3]>=r[2] goto 13
9 Noop 0 0 0 00 Begin WHERE-core
10 Rowid 0 4 0 00 r[4]=rowid
11 RowSetAdd 1 4 0 00 rowset(1)=r[4]
12 Noop 0 0 0 00 End WHERE-core
13 Next 0 7 0 01
14 Noop 0 0 0 00 End WHERE-loop0: tbl1
15 Close 0 0 0 00
16 OpenWrite 0 2 0 3 00 root=2 iDb=0; tbl1
17 RowSetRead 1 21 4 00 r[4]=rowset(1)
18 NotExists 0 20 4 1 00 intkey=r[4]
19 Delete 0 1 0 tbl1 00
20 Goto 0 17 0 00
21 Close 0 0 0 00
22 Halt 0 0 0 00
23 Transaction 0 1 0 00
24 VerifyCookie 0 1 0 00
25 TableLock 0 2 1 tbl1 00 iDb=0 root=2 write=1
26 Integer 20 3 0 00 r[3]=20
27 Goto 0 2 0 00</pre></blockquote>
<p>All you have to do is add the <a href="lang_explain.html">EXPLAIN</a> keyword to the front of the
SQL statement. But if you use the "<a href="cli.html#explain">.explain</a>"
command in the <a href="cli.html">CLI</a>,
it will set up the output mode to make the VDBE code easier for
humans to read.</p>
<p>When SQLite is compiled with the <a href="compile.html#debug">SQLITE_DEBUG</a> compile-time option,
extra <a href="pragma.html#syntax">PRAGMA</a> commands are available that are useful for debugging and
for exploring the operation of the VDBE. For example the <a href="pragma.html#pragma_vdbe_trace">vdbe_trace</a>
pragma can be enabled to cause a disassembly of each VDBE opcode to be
printed on standard output as the opcode is executed. These debugging
pragmas include:
<ul>
<li> <a href="pragma.html#pragma_parser_trace">PRAGMA parser_trace</a>
<li> <a href="pragma.html#pragma_vdbe_addoptrace">PRAGMA vdbe_addoptrace</a>
<li> <a href="pragma.html#pragma_vdbe_debug">PRAGMA vdbe_debug</a>
<li> <a href="pragma.html#pragma_vdbe_listing">PRAGMA vdbe_listing</a>
<li> <a href="pragma.html#pragma_vdbe_trace">PRAGMA vdbe_trace</a>
</ul>
</p>
<h3>The Opcodes</h3>
<p>There are currently 151
opcodes defined by the virtual machine.
All currently defined opcodes are described in the table below.
This table was generated automatically by scanning the source code
from the file
<a href="http://www.sqlite.org/src/artifact/5a1afb571853ddb911d698ac996bc4fd8ddf1eed">vdbe.c</a>.</p>
<p>Remember: The VDBE opcodes are <u>not</u> part of the interface
definition for SQLite. The number of opcodes and their names and meanings
are subject to change from one release of SQLite to the next.
<p><table cellspacing="1" border="1" cellpadding="10">
<tr><th>Opcode Name</th><th>Description</th></tr>
<tr><td valign="top" align="center">
<a name="Add"></a><p>Add</p>
<td><p>Add the value in register P1 to the value in register P2
and store the result in register P3.
If either input is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="AddImm"></a><p>AddImm</p>
<td><p>Add the constant P2 to the value in register P1.
The result is always an integer.</p>
<p>To force any register to be an integer, just add 0.</td></tr>
<tr><td valign="top" align="center">
<a name="Affinity"></a><p>Affinity</p>
<td><p>Apply affinities to a range of P2 registers starting with P1.</p>
<p>P4 is a string that is P2 characters long. The nth character of the
string indicates the column affinity that should be used for the nth
memory cell in the range.</td></tr>
<tr><td valign="top" align="center">
<a name="AggFinal"></a><p>AggFinal</p>
<td><p>Execute the finalizer function for an aggregate. P1 is
the memory location that is the accumulator for the aggregate.</p>
<p>P2 is the number of arguments that the step function takes and
P4 is a pointer to the FuncDef for this function. The P2
argument is not used by this opcode. It is only there to disambiguate
functions that can take varying numbers of arguments. The
P4 argument is only needed for the degenerate case where
the step function was not previously called.</td></tr>
<tr><td valign="top" align="center">
<a name="AggStep"></a><p>AggStep</p>
<td><p>Execute the step function for an aggregate. The
function has P5 arguments. P4 is a pointer to the FuncDef
structure that specifies the function. Use register
P3 as the accumulator.</p>
<p>The P5 arguments are taken from register P2 and its
successors.</td></tr>
<tr><td valign="top" align="center">
<a name="And"></a><p>And</p>
<td><p>Take the logical AND of the values in registers P1 and P2 and
write the result into register P3.</p>
<p>If either P1 or P2 is 0 (false) then the result is 0 even if
the other input is NULL. A NULL and true or two NULLs give
a NULL output.</td></tr>
<tr><td valign="top" align="center">
<a name="AutoCommit"></a><p>AutoCommit</p>
<td><p>Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll
back any currently active btree transactions. If there are any active
VMs (apart from this one), then a ROLLBACK fails. A COMMIT fails if
there are active writing VMs or active VMs that use shared cache.</p>
<p>This instruction causes the VM to halt.</td></tr>
<tr><td valign="top" align="center">
<a name="BitAnd"></a><p>BitAnd</p>
<td><p>Take the bit-wise AND of the values in register P1 and P2 and
store the result in register P3.
If either input is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="BitNot"></a><p>BitNot</p>
<td><p>Interpret the content of register P1 as an integer. Store the
ones-complement of the P1 value into register P2. If P1 holds
a NULL then store a NULL in P2.</td></tr>
<tr><td valign="top" align="center">
<a name="BitOr"></a><p>BitOr</p>
<td><p>Take the bit-wise OR of the values in register P1 and P2 and
store the result in register P3.
If either input is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="Blob"></a><p>Blob</p>
<td><p>P4 points to a blob of data P1 bytes long. Store this
blob in register P2.</td></tr>
<tr><td valign="top" align="center">
<a name="Cast"></a><p>Cast</p>
<td><p>Force the value in register P1 to be the type defined by P2.</p>
<p><ul>
<li value="97"> TEXT
<li value="98"> BLOB
<li value="99"> NUMERIC
<li value="100"> INTEGER
<li value="101"> REAL
</ul></p>
<p>A NULL value is not changed by this routine. It remains NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="Checkpoint"></a><p>Checkpoint</p>
<td><p>Checkpoint database P1. This is a no-op if P1 is not currently in
WAL mode. Parameter P2 is one of SQLITE_CHECKPOINT_PASSIVE, FULL
or RESTART. Write 1 or 0 into mem[P3] if the checkpoint returns
SQLITE_BUSY or not, respectively. Write the number of pages in the
WAL after the checkpoint into mem[P3+1] and the number of pages
in the WAL that have been checkpointed after the checkpoint
completes into mem[P3+2]. However on an error, mem[P3+1] and
mem[P3+2] are initialized to -1.</td></tr>
<tr><td valign="top" align="center">
<a name="Clear"></a><p>Clear</p>
<td><p>Delete all contents of the database table or index whose root page
in the database file is given by P1. But, unlike <a href="#Destroy">Destroy</a>, do not
remove the table or index from the database file.</p>
<p>The table being clear is in the main database file if P2==0. If
P2==1 then the table to be clear is in the auxiliary database file
that is used to store tables create using CREATE TEMPORARY TABLE.</p>
<p>If the P3 value is non-zero, then the table referred to must be an
intkey table (an SQL table, not an index). In this case the row change
count is incremented by the number of rows in the table being cleared.
If P3 is greater than zero, then the value stored in register P3 is
also incremented by the number of rows in the table being cleared.</p>
<p>See also: <a href="#Destroy">Destroy</a></td></tr>
<tr><td valign="top" align="center">
<a name="Close"></a><p>Close</p>
<td><p>Close a cursor previously opened as P1. If P1 is not
currently open, this instruction is a no-op.</td></tr>
<tr><td valign="top" align="center">
<a name="CollSeq"></a><p>CollSeq</p>
<td><p>P4 is a pointer to a <a href="#CollSeq">CollSeq</a> struct. If the next call to a user function
or aggregate calls sqlite3GetFuncCollSeq(), this collation sequence will
be returned. This is used by the built-in min(), max() and nullif()
functions.</p>
<p>If P1 is not zero, then it is a register that a subsequent min() or
max() aggregate will set to 1 if the current row is not the minimum or
maximum. The P1 register is initialized to 0 by this instruction.</p>
<p>The interface used by the implementation of the aforementioned functions
to retrieve the collation sequence set by this opcode is not available
publicly, only to user functions defined in func.c.</td></tr>
<tr><td valign="top" align="center">
<a name="Column"></a><p>Column</p>
<td><p>Interpret the data that cursor P1 points to as a structure built using
the <a href="#MakeRecord">MakeRecord</a> instruction. (See the <a href="#MakeRecord">MakeRecord</a> opcode for additional
information about the format of the data.) Extract the P2-th column
from this record. If there are less that (P2+1)
values in the record, extract a NULL.</p>
<p>The value extracted is stored in register P3.</p>
<p>If the column contains fewer than P2 fields, then extract a NULL. Or,
if the P4 argument is a P4_MEM use the value of the P4 argument as
the result.</p>
<p>If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,
then the cache of the cursor is reset prior to extracting the column.
The first <a href="#Column">Column</a> against a pseudo-table after the value of the content
register has changed should have this bit set.</p>
<p>If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 when
the result is guaranteed to only be used as the argument of a length()
or typeof() function, respectively. The loading of large blobs can be
skipped for length() and all content loading can be skipped for typeof().</td></tr>
<tr><td valign="top" align="center">
<a name="Compare"></a><p>Compare</p>
<td><p>Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this
vector "A") and in reg(P2)..reg(P2+P3-1) ("B"). Save the result of
the comparison for use by the next <a href="#Jump">Jump</a> instruct.</p>
<p>If P5 has the OPFLAG_PERMUTE bit set, then the order of comparison is
determined by the most recent <a href="#Permutation">Permutation</a> operator. If the
OPFLAG_PERMUTE bit is clear, then register are compared in sequential
order.</p>
<p>P4 is a KeyInfo structure that defines collating sequences and sort
orders for the comparison. The permutation applies to registers
only. The KeyInfo elements are used sequentially.</p>
<p>The comparison is a sort comparison, so NULLs compare equal,
NULLs are less than numbers, numbers are less than strings,
and strings are less than blobs.</td></tr>
<tr><td valign="top" align="center">
<a name="Concat"></a><p>Concat</p>
<td><p>Add the text in register P1 onto the end of the text in
register P2 and store the result in register P3.
If either the P1 or P2 text are NULL then store NULL in P3.</p>
<p>P3 = P2 || P1</p>
<p>It is illegal for P1 and P3 to be the same register. Sometimes,
if P3 is the same register as P2, the implementation is able
to avoid a memcpy().</td></tr>
<tr><td valign="top" align="center">
<a name="Copy"></a><p>Copy</p>
<td><p>Make a copy of registers P1..P1+P3 into registers P2..P2+P3.</p>
<p>This instruction makes a deep copy of the value. A duplicate
is made of any string or blob constant. See also <a href="#SCopy">SCopy</a>.</td></tr>
<tr><td valign="top" align="center">
<a name="Count"></a><p>Count</p>
<td><p>Store the number of entries (an integer value) in the table or index
opened by cursor P1 in register P2</td></tr>
<tr><td valign="top" align="center">
<a name="CreateIndex"></a><p>CreateIndex</p>
<td><p>Allocate a new index in the main database file if P1==0 or in the
auxiliary database file if P1==1 or in an attached database if
P1>1. Write the root page number of the new table into
register P2.</p>
<p>See documentation on <a href="#CreateTable">CreateTable</a> for additional information.</td></tr>
<tr><td valign="top" align="center">
<a name="CreateTable"></a><p>CreateTable</p>
<td><p>Allocate a new table in the main database file if P1==0 or in the
auxiliary database file if P1==1 or in an attached database if
P1>1. Write the root page number of the new table into
register P2</p>
<p>The difference between a table and an index is this: A table must
have a 4-byte integer key and can have arbitrary data. An index
has an arbitrary key but no data.</p>
<p>See also: <a href="#CreateIndex">CreateIndex</a></td></tr>
<tr><td valign="top" align="center">
<a name="Delete"></a><p>Delete</p>
<td><p>Delete the record at which the P1 cursor is currently pointing.</p>
<p>The cursor will be left pointing at either the next or the previous
record in the table. If it is left pointing at the next record, then
the next <a href="#Next">Next</a> instruction will be a no-op. Hence it is OK to delete
a record from within a <a href="#Next">Next</a> loop.</p>
<p>If the OPFLAG_NCHANGE flag of P2 is set, then the row change count is
incremented (otherwise not).</p>
<p>P1 must not be pseudo-table. It has to be a real table with
multiple rows.</p>
<p>If P4 is not NULL, then it is the name of the table that P1 is
pointing to. The update hook will be invoked, if it exists.
If P4 is not NULL then the P1 cursor must have been positioned
using <a href="#NotFound">NotFound</a> prior to invoking this opcode.</td></tr>
<tr><td valign="top" align="center">
<a name="Destroy"></a><p>Destroy</p>
<td><p>Delete an entire database table or index whose root page in the database
file is given by P1.</p>
<p>The table being destroyed is in the main database file if P3==0. If
P3==1 then the table to be clear is in the auxiliary database file
that is used to store tables create using CREATE TEMPORARY TABLE.</p>
<p>If AUTOVACUUM is enabled then it is possible that another root page
might be moved into the newly deleted root page in order to keep all
root pages contiguous at the beginning of the database. The former
value of the root page that moved - its value before the move occurred -
is stored in register P2. If no page
movement was required (because the table being dropped was already
the last one in the database) then a zero is stored in register P2.
If AUTOVACUUM is disabled then a zero is stored in register P2.</p>
<p>See also: <a href="#Clear">Clear</a></td></tr>
<tr><td valign="top" align="center">
<a name="Divide"></a><p>Divide</p>
<td><p>Divide the value in register P1 by the value in register P2
and store the result in register P3 (P3=P2/P1). If the value in
register P1 is zero, then the result is NULL. If either input is
NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="DropIndex"></a><p>DropIndex</p>
<td><p>Remove the internal (in-memory) data structures that describe
the index named P4 in database P1. This is called after an index
is dropped from disk (using the <a href="#Destroy">Destroy</a> opcode)
in order to keep the internal representation of the
schema consistent with what is on disk.</td></tr>
<tr><td valign="top" align="center">
<a name="DropTable"></a><p>DropTable</p>
<td><p>Remove the internal (in-memory) data structures that describe
the table named P4 in database P1. This is called after a table
is dropped from disk (using the <a href="#Destroy">Destroy</a> opcode) in order to keep
the internal representation of the
schema consistent with what is on disk.</td></tr>
<tr><td valign="top" align="center">
<a name="DropTrigger"></a><p>DropTrigger</p>
<td><p>Remove the internal (in-memory) data structures that describe
the trigger named P4 in database P1. This is called after a trigger
is dropped from disk (using the <a href="#Destroy">Destroy</a> opcode) in order to keep
the internal representation of the
schema consistent with what is on disk.</td></tr>
<tr><td valign="top" align="center">
<a name="EndCoroutine"></a><p>EndCoroutine</p>
<td><p>The instruction at the address in register P1 is a <a href="#Yield">Yield</a>.
<a href="#Jump">Jump</a> to the P2 parameter of that <a href="#Yield">Yield</a>.
After the jump, register P1 becomes undefined.</p>
<p>See also: <a href="#InitCoroutine">InitCoroutine</a></td></tr>
<tr><td valign="top" align="center">
<a name="Eq"></a><p>Eq</p>
<td><p>This works just like the Lt opcode except that the jump is taken if
the operands in registers P1 and P3 are equal.
See the Lt opcode for additional information.</p>
<p>If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
true or false and is never NULL. If both operands are NULL then the result
of comparison is true. If either operand is NULL then the result is false.
If neither operand is NULL the result is the same as it would be if
the SQLITE_NULLEQ flag were omitted from P5.</td></tr>
<tr><td valign="top" align="center">
<a name="Expire"></a><p>Expire</p>
<td><p>Cause precompiled statements to expire. When an expired statement
is executed using sqlite3_step() it will either automatically
reprepare itself (if it was originally created using sqlite3_prepare_v2())
or it will fail with SQLITE_SCHEMA.</p>
<p>If P1 is 0, then all SQL statements become expired. If P1 is non-zero,
then only the currently executing statement is expired.</td></tr>
<tr><td valign="top" align="center">
<a name="FkCounter"></a><p>FkCounter</p>
<td><p>Increment a "constraint counter" by P2 (P2 may be negative or positive).
If P1 is non-zero, the database constraint counter is incremented
(deferred foreign key constraints). Otherwise, if P1 is zero, the
statement counter is incremented (immediate foreign key constraints).</td></tr>
<tr><td valign="top" align="center">
<a name="FkIfZero"></a><p>FkIfZero</p>
<td><p>This opcode tests if a foreign key constraint-counter is currently zero.
If so, jump to instruction P2. Otherwise, fall through to the next
instruction.</p>
<p>If P1 is non-zero, then the jump is taken if the database constraint-counter
is zero (the one that counts deferred constraint violations). If P1 is
zero, the jump is taken if the statement constraint-counter is zero
(immediate foreign key constraint violations).</td></tr>
<tr><td valign="top" align="center">
<a name="Found"></a><p>Found</p>
<td><p>If P4==0 then register P3 holds a blob constructed by <a href="#MakeRecord">MakeRecord</a>. If
P4>0 then register P3 is the first of P4 registers that form an unpacked
record.</p>
<p>Cursor P1 is on an index btree. If the record identified by P3 and P4
is a prefix of any entry in P1 then a jump is made to P2 and
P1 is left pointing at the matching entry.</p>
<p>This operation leaves the cursor in a state where it can be
advanced in the forward direction. The <a href="#Next">Next</a> instruction will work,
but not the <a href="#Prev">Prev</a> instruction.</p>
<p>See also: <a href="#NotFound">NotFound</a>, <a href="#NoConflict">NoConflict</a>, <a href="#NotExists">NotExists</a>. SeekGe</td></tr>
<tr><td valign="top" align="center">
<a name="Function"></a><p>Function</p>
<td><p>Invoke a user function (P4 is a pointer to a <a href="#Function">Function</a> structure that
defines the function) with P5 arguments taken from register P2 and
successors. The result of the function is stored in register P3.
Register P3 must not be one of the function inputs.</p>
<p>P1 is a 32-bit bitmask indicating whether or not each argument to the
function was determined to be constant at compile time. If the first
argument was constant then bit 0 of P1 is set. This is used to determine
whether meta data associated with a user function argument using the
sqlite3_set_auxdata() API may be safely retained until the next
invocation of this opcode.</p>
<p>See also: <a href="#AggStep">AggStep</a> and <a href="#AggFinal">AggFinal</a></td></tr>
<tr><td valign="top" align="center">
<a name="Ge"></a><p>Ge</p>
<td><p>This works just like the Lt opcode except that the jump is taken if
the content of register P3 is greater than or equal to the content of
register P1. See the Lt opcode for additional information.</td></tr>
<tr><td valign="top" align="center">
<a name="Gosub"></a><p>Gosub</p>
<td><p>Write the current address onto register P1
and then jump to address P2.</td></tr>
<tr><td valign="top" align="center">
<a name="Goto"></a><p>Goto</p>
<td><p>An unconditional jump to address P2.
The next instruction executed will be
the one at index P2 from the beginning of
the program.</p>
<p>The P1 parameter is not actually used by this opcode. However, it
is sometimes set to 1 instead of 0 as a hint to the command-line shell
that this <a href="#Goto">Goto</a> is the bottom of a loop and that the lines from P2 down
to the current line should be indented for EXPLAIN output.</td></tr>
<tr><td valign="top" align="center">
<a name="Gt"></a><p>Gt</p>
<td><p>This works just like the Lt opcode except that the jump is taken if
the content of register P3 is greater than the content of
register P1. See the Lt opcode for additional information.</td></tr>
<tr><td valign="top" align="center">
<a name="Halt"></a><p>Halt</p>
<td><p>Exit immediately. All open cursors, etc are closed
automatically.</p>
<p>P1 is the result code returned by sqlite3_exec(), sqlite3_reset(),
or sqlite3_finalize(). For a normal halt, this should be SQLITE_OK (0).
For errors, it can be some other value. If P1!=0 then P2 will determine
whether or not to rollback the current transaction. Do not rollback
if P2==OE_Fail. Do the rollback if P2==OE_Rollback. If P2==OE_Abort,
then back out all changes that have occurred during this execution of the
VDBE, but do not rollback the transaction.</p>
<p>If P4 is not null then it is an error message string.</p>
<p>P5 is a value between 0 and 4, inclusive, that modifies the P4 string.</p>
<p>0: (no change)
1: NOT NULL contraint failed: P4
2: UNIQUE constraint failed: P4
3: CHECK constraint failed: P4
4: FOREIGN KEY constraint failed: P4</p>
<p>If P5 is not zero and P4 is NULL, then everything after the ":" is
omitted.</p>
<p>There is an implied "Halt 0 0 0" instruction inserted at the very end of
every program. So a jump past the last instruction of the program
is the same as executing <a href="#Halt">Halt</a>.</td></tr>
<tr><td valign="top" align="center">
<a name="HaltIfNull"></a><p>HaltIfNull</p>
<td><p>Check the value in register P3. If it is NULL then <a href="#Halt">Halt</a> using
parameter P1, P2, and P4 as if this were a <a href="#Halt">Halt</a> instruction. If the
value in register P3 is not NULL, then this routine is a no-op.
The P5 parameter should be 1.</td></tr>
<tr><td valign="top" align="center">
<a name="IdxDelete"></a><p>IdxDelete</p>
<td><p>The content of P3 registers starting at register P2 form
an unpacked index key. This opcode removes that entry from the
index opened by cursor P1.</td></tr>
<tr><td valign="top" align="center">
<a name="IdxGE"></a><p>IdxGE</p>
<td><p>The P4 register values beginning with P3 form an unpacked index
key that omits the PRIMARY KEY. <a href="#Compare">Compare</a> this key value against the index
that P1 is currently pointing to, ignoring the PRIMARY KEY or ROWID
fields at the end.</p>
<p>If the P1 index entry is greater than or equal to the key value
then jump to P2. Otherwise fall through to the next instruction.</td></tr>
<tr><td valign="top" align="center">
<a name="IdxGT"></a><p>IdxGT</p>
<td><p>The P4 register values beginning with P3 form an unpacked index
key that omits the PRIMARY KEY. <a href="#Compare">Compare</a> this key value against the index
that P1 is currently pointing to, ignoring the PRIMARY KEY or ROWID
fields at the end.</p>
<p>If the P1 index entry is greater than the key value
then jump to P2. Otherwise fall through to the next instruction.</td></tr>
<tr><td valign="top" align="center">
<a name="IdxInsert"></a><p>IdxInsert</p>
<td><p>Register P2 holds an SQL index key made using the
<a href="#MakeRecord">MakeRecord</a> instructions. This opcode writes that key
into the index P1. Data for the entry is nil.</p>
<p>P3 is a flag that provides a hint to the b-tree layer that this
insert is likely to be an append.</p>
<p>If P5 has the OPFLAG_NCHANGE bit set, then the change counter is
incremented by this instruction. If the OPFLAG_NCHANGE bit is clear,
then the change counter is unchanged.</p>
<p>If P5 has the OPFLAG_USESEEKRESULT bit set, then the cursor must have
just done a seek to the spot where the new entry is to be inserted.
This flag avoids doing an extra seek.</p>
<p>This instruction only works for indices. The equivalent instruction
for tables is <a href="#Insert">Insert</a>.</td></tr>
<tr><td valign="top" align="center">
<a name="IdxLE"></a><p>IdxLE</p>
<td><p>The P4 register values beginning with P3 form an unpacked index
key that omits the PRIMARY KEY or ROWID. <a href="#Compare">Compare</a> this key value against
the index that P1 is currently pointing to, ignoring the PRIMARY KEY or
ROWID on the P1 index.</p>
<p>If the P1 index entry is less than or equal to the key value then jump
to P2. Otherwise fall through to the next instruction.</td></tr>
<tr><td valign="top" align="center">
<a name="IdxLT"></a><p>IdxLT</p>
<td><p>The P4 register values beginning with P3 form an unpacked index
key that omits the PRIMARY KEY or ROWID. <a href="#Compare">Compare</a> this key value against
the index that P1 is currently pointing to, ignoring the PRIMARY KEY or
ROWID on the P1 index.</p>
<p>If the P1 index entry is less than the key value then jump to P2.
Otherwise fall through to the next instruction.</td></tr>
<tr><td valign="top" align="center">
<a name="IdxRowid"></a><p>IdxRowid</p>
<td><p>Write into register P2 an integer which is the last entry in the record at
the end of the index key pointed to by cursor P1. This integer should be
the rowid of the table entry to which this index entry points.</p>
<p>See also: <a href="#Rowid">Rowid</a>, <a href="#MakeRecord">MakeRecord</a>.</td></tr>
<tr><td valign="top" align="center">
<a name="If"></a><p>If</p>
<td><p>Jump to P2 if the value in register P1 is true. The value
is considered true if it is numeric and non-zero. If the value
in P1 is NULL then take the jump if and only if P3 is non-zero.</td></tr>
<tr><td valign="top" align="center">
<a name="IfNeg"></a><p>IfNeg</p>
<td><p>Register P1 must contain an integer. <a href="#Add">Add</a> literal P3 to the value in
register P1 then if the value of register P1 is less than zero, jump to P2.</td></tr>
<tr><td valign="top" align="center">
<a name="IfNot"></a><p>IfNot</p>
<td><p>Jump to P2 if the value in register P1 is False. The value
is considered false if it has a numeric value of zero. If the value
in P1 is NULL then take the jump if and only if P3 is non-zero.</td></tr>
<tr><td valign="top" align="center">
<a name="IfPos"></a><p>IfPos</p>
<td><p>If the value of register P1 is 1 or greater, jump to P2.</p>
<p>It is illegal to use this instruction on a register that does
not contain an integer. An assertion fault will result if you try.</td></tr>
<tr><td valign="top" align="center">
<a name="IfZero"></a><p>IfZero</p>
<td><p>The register P1 must contain an integer. <a href="#Add">Add</a> literal P3 to the
value in register P1. If the result is exactly 0, jump to P2.</td></tr>
<tr><td valign="top" align="center">
<a name="IncrVacuum"></a><p>IncrVacuum</p>
<td><p>Perform a single step of the incremental vacuum procedure on
the P1 database. If the vacuum has finished, jump to instruction
P2. Otherwise, fall through to the next instruction.</td></tr>
<tr><td valign="top" align="center">
<a name="Init"></a><p>Init</p>
<td><p>Programs contain a single instance of this opcode as the very first
opcode.</p>
<p>If tracing is enabled (by the sqlite3_trace()) interface, then
the UTF-8 string contained in P4 is emitted on the trace callback.
Or if P4 is blank, use the string returned by sqlite3_sql().</p>
<p>If P2 is not zero, jump to instruction P2.</td></tr>
<tr><td valign="top" align="center">
<a name="InitCoroutine"></a><p>InitCoroutine</p>
<td><p>Set up register P1 so that it will <a href="#Yield">Yield</a> to the coroutine
located at address P3.</p>
<p>If P2!=0 then the coroutine implementation immediately follows
this opcode. So jump over the coroutine implementation to
address P2.</p>
<p>See also: <a href="#EndCoroutine">EndCoroutine</a></td></tr>
<tr><td valign="top" align="center">
<a name="Insert"></a><p>Insert</p>
<td><p>Write an entry into the table of cursor P1. A new entry is
created if it doesn't already exist or the data for an existing
entry is overwritten. The data is the value MEM_Blob stored in register
number P2. The key is stored in register P3. The key must
be a MEM_Int.</p>
<p>If the OPFLAG_NCHANGE flag of P5 is set, then the row change count is
incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set,
then rowid is stored for subsequent return by the
sqlite3_last_insert_rowid() function (otherwise it is unmodified).</p>
<p>If the OPFLAG_USESEEKRESULT flag of P5 is set and if the result of
the last seek operation (OP_NotExists) was a success, then this
operation will not attempt to find the appropriate row before doing
the insert but will instead overwrite the row that the cursor is
currently pointing to. Presumably, the prior <a href="#NotExists">NotExists</a> opcode
has already positioned the cursor correctly. This is an optimization
that boosts performance by avoiding redundant seeks.</p>
<p>If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an
UPDATE operation. Otherwise (if the flag is clear) then this opcode
is part of an INSERT operation. The difference is only important to
the update hook.</p>
<p>Parameter P4 may point to a string containing the table-name, or
may be NULL. If it is not NULL, then the update-hook
(sqlite3.xUpdateCallback) is invoked following a successful insert.</p>
<p>(WARNING/TODO: If P1 is a pseudo-cursor and P2 is dynamically
allocated, then ownership of P2 is transferred to the pseudo-cursor
and register P2 becomes ephemeral. If the cursor is changed, the
value of register P2 will then change. Make sure this does not
cause any problems.)</p>
<p>This instruction only works on tables. The equivalent instruction
for indices is <a href="#IdxInsert">IdxInsert</a>.</td></tr>
<tr><td valign="top" align="center">
<a name="InsertInt"></a><p>InsertInt</p>
<td><p>This works exactly like <a href="#Insert">Insert</a> except that the key is the
integer value P3, not the value of the integer stored in register P3.</td></tr>
<tr><td valign="top" align="center">
<a name="Int64"></a><p>Int64</p>
<td><p>P4 is a pointer to a 64-bit integer value.
Write that value into register P2.</td></tr>
<tr><td valign="top" align="center">
<a name="Integer"></a><p>Integer</p>
<td><p>The 32-bit integer value P1 is written into register P2.</td></tr>
<tr><td valign="top" align="center">
<a name="IntegrityCk"></a><p>IntegrityCk</p>
<td><p>Do an analysis of the currently open database. Store in
register P1 the text of an error message describing any problems.
If no problems are found, store a NULL in register P1.</p>
<p>The register P3 contains the maximum number of allowed errors.
At most reg(P3) errors will be reported.
In other words, the analysis stops as soon as reg(P1) errors are
seen. Reg(P1) is updated with the number of errors remaining.</p>
<p>The root page numbers of all tables in the database are integer
stored in reg(P1), reg(P1+1), reg(P1+2), .... There are P2 tables
total.</p>
<p>If P5 is not zero, the check is done on the auxiliary database
file, not the main database file.</p>
<p>This opcode is used to implement the integrity_check pragma.</td></tr>
<tr><td valign="top" align="center">
<a name="IsNull"></a><p>IsNull</p>
<td><p>Jump to P2 if the value in register P1 is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="JournalMode"></a><p>JournalMode</p>
<td><p>Change the journal mode of database P1 to P3. P3 must be one of the
PAGER_JOURNALMODE_XXX values. If changing between the various rollback
modes (delete, truncate, persist, off and memory), this is a simple
operation. No IO is required.</p>
<p>If changing into or out of WAL mode the procedure is more complicated.</p>
<p>Write a string containing the final journal-mode to register P2.</td></tr>
<tr><td valign="top" align="center">
<a name="Jump"></a><p>Jump</p>
<td><p>Jump to the instruction at address P1, P2, or P3 depending on whether
in the most recent <a href="#Compare">Compare</a> instruction the P1 vector was less than
equal to, or greater than the P2 vector, respectively.</td></tr>
<tr><td valign="top" align="center">
<a name="Last"></a><p>Last</p>
<td><p>The next use of the <a href="#Rowid">Rowid</a> or <a href="#Column">Column</a> or <a href="#Prev">Prev</a> instruction for P1
will refer to the last entry in the database table or index.
If the table or index is empty and P2>0, then jump immediately to P2.
If P2 is 0 or if the table or index is not empty, fall through
to the following instruction.</p>
<p>This opcode leaves the cursor configured to move in reverse order,
from the end toward the beginning. In other words, the cursor is
configured to use <a href="#Prev">Prev</a>, not <a href="#Next">Next</a>.</td></tr>
<tr><td valign="top" align="center">
<a name="Le"></a><p>Le</p>
<td><p>This works just like the Lt opcode except that the jump is taken if
the content of register P3 is less than or equal to the content of
register P1. See the Lt opcode for additional information.</td></tr>
<tr><td valign="top" align="center">
<a name="LoadAnalysis"></a><p>LoadAnalysis</p>
<td><p>Read the sqlite_stat1 table for database P1 and load the content
of that table into the internal index hash table. This will cause
the analysis to be used when preparing all subsequent queries.</td></tr>
<tr><td valign="top" align="center">
<a name="Lt"></a><p>Lt</p>
<td><p>Compare the values in register P1 and P3. If reg(P3)<reg(P1) then
jump to address P2.</p>
<p>If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or
reg(P3) is NULL then take the jump. If the SQLITE_JUMPIFNULL
bit is clear then fall through if either operand is NULL.</p>
<p>The SQLITE_AFF_MASK portion of P5 must be an affinity character -
SQLITE_AFF_TEXT, SQLITE_AFF_INTEGER, and so forth. An attempt is made
to coerce both inputs according to this affinity before the
comparison is made. If the SQLITE_AFF_MASK is 0x00, then numeric
affinity is used. Note that the affinity conversions are stored
back into the input registers P1 and P3. So this opcode can cause
persistent changes to registers P1 and P3.</p>
<p>Once any conversions have taken place, and neither value is NULL,
the values are compared. If both values are blobs then memcmp() is
used to determine the results of the comparison. If both values
are text, then the appropriate collating function specified in
P4 is used to do the comparison. If P4 is not specified then
memcmp() is used to compare text string. If both values are
numeric, then a numeric comparison is used. If the two values
are of different types, then numbers are considered less than
strings and strings are considered less than blobs.</p>
<p>If the SQLITE_STOREP2 bit of P5 is set, then do not jump. Instead,
store a boolean result (either 0, or 1, or NULL) in register P2.</p>
<p>If the SQLITE_NULLEQ bit is set in P5, then NULL values are considered
equal to one another, provided that they do not have their MEM_Cleared
bit set.</td></tr>
<tr><td valign="top" align="center">
<a name="MakeRecord"></a><p>MakeRecord</p>
<td><p>Convert P2 registers beginning with P1 into the <a href="fileformat2.html#record_format">record format</a>
use as a data record in a database table or as a key
in an index. The <a href="#Column">Column</a> opcode can decode the record later.</p>
<p>P4 may be a string that is P2 characters long. The nth character of the
string indicates the column affinity that should be used for the nth
field of the index key.</p>
<p>The mapping from character to affinity is given by the SQLITE_AFF_
macros defined in sqliteInt.h.</p>
<p>If P4 is NULL then all index fields have the affinity NONE.</td></tr>
<tr><td valign="top" align="center">
<a name="MaxPgcnt"></a><p>MaxPgcnt</p>
<td><p>Try to set the maximum page count for database P1 to the value in P3.
Do not let the maximum page count fall below the current page count and
do not change the maximum page count value if P3==0.</p>
<p>Store the maximum page count after the change in register P2.</td></tr>
<tr><td valign="top" align="center">
<a name="MemMax"></a><p>MemMax</p>
<td><p>P1 is a register in the root frame of this VM (the root frame is
different from the current frame if this instruction is being executed
within a sub-program). Set the value of register P1 to the maximum of
its current value and the value in register P2.</p>
<p>This instruction throws an error if the memory cell is not initially
an integer.</td></tr>
<tr><td valign="top" align="center">
<a name="Move"></a><p>Move</p>
<td><p>Move the P3 values in register P1..P1+P3-1 over into
registers P2..P2+P3-1. Registers P1..P1+P3-1 are
left holding a NULL. It is an error for register ranges
P1..P1+P3-1 and P2..P2+P3-1 to overlap. It is an error
for P3 to be less than 1.</td></tr>
<tr><td valign="top" align="center">
<a name="Multiply"></a><p>Multiply</p>
<td><p>Multiply the value in register P1 by the value in register P2
and store the result in register P3.
If either input is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="MustBeInt"></a><p>MustBeInt</p>
<td><p>Force the value in register P1 to be an integer. If the value
in P1 is not an integer and cannot be converted into an integer
without data loss, then jump immediately to P2, or if P2==0
raise an SQLITE_MISMATCH exception.</td></tr>
<tr><td valign="top" align="center">
<a name="Ne"></a><p>Ne</p>
<td><p>This works just like the Lt opcode except that the jump is taken if
the operands in registers P1 and P3 are not equal. See the Lt opcode for
additional information.</p>
<p>If SQLITE_NULLEQ is set in P5 then the result of comparison is always either
true or false and is never NULL. If both operands are NULL then the result
of comparison is false. If either operand is NULL then the result is true.
If neither operand is NULL the result is the same as it would be if
the SQLITE_NULLEQ flag were omitted from P5.</td></tr>
<tr><td valign="top" align="center">
<a name="NewRowid"></a><p>NewRowid</p>
<td><p>Get a new integer record number (a.k.a "rowid") used as the key to a table.
The record number is not previously used as a key in the database
table that cursor P1 points to. The new record number is written
written to register P2.</p>
<p>If P3>0 then P3 is a register in the root frame of this VDBE that holds
the largest previously generated record number. No new record numbers are
allowed to be less than this value. When this value reaches its maximum,
an SQLITE_FULL error is generated. The P3 register is updated with the '
generated record number. This P3 mechanism is used to help implement the
AUTOINCREMENT feature.</td></tr>
<tr><td valign="top" align="center">
<a name="Next"></a><p>Next</p>
<td><p>Advance cursor P1 so that it points to the next key/data pair in its
table or index. If there are no more key/value pairs then fall through
to the following instruction. But if the cursor advance was successful,
jump immediately to P2.</p>
<p>The <a href="#Next">Next</a> opcode is only valid following an <a href="#SeekGT">SeekGT</a>, <a href="#SeekGE">SeekGE</a>, or
<a href="#Rewind">Rewind</a> opcode used to position the cursor. <a href="#Next">Next</a> is not allowed
to follow <a href="#SeekLT">SeekLT</a>, <a href="#SeekLE">SeekLE</a>, or <a href="#Last">Last</a>.</p>
<p>The P1 cursor must be for a real table, not a pseudo-table. P1 must have
been opened prior to this opcode or the program will segfault.</p>
<p>The P3 value is a hint to the btree implementation. If P3==1, that
means P1 is an SQL index and that this instruction could have been
omitted if that index had been unique. P3 is usually 0. P3 is
always either 0 or 1.</p>
<p>P4 is always of type P4_ADVANCE. The function pointer points to
sqlite3BtreeNext().</p>
<p>If P5 is positive and the jump is taken, then event counter
number P5-1 in the prepared statement is incremented.</p>
<p>See also: <a href="#Prev">Prev</a>, <a href="#NextIfOpen">NextIfOpen</a></td></tr>
<tr><td valign="top" align="center">
<a name="NextIfOpen"></a><p>NextIfOpen</p>
<td><p>This opcode works just like <a href="#Next">Next</a> except that if cursor P1 is not
open it behaves a no-op.</td></tr>
<tr><td valign="top" align="center">
<a name="NoConflict"></a><p>NoConflict</p>
<td><p>If P4==0 then register P3 holds a blob constructed by <a href="#MakeRecord">MakeRecord</a>. If
P4>0 then register P3 is the first of P4 registers that form an unpacked
record.</p>
<p>Cursor P1 is on an index btree. If the record identified by P3 and P4
contains any NULL value, jump immediately to P2. If all terms of the
record are not-NULL then a check is done to determine if any row in the
P1 index btree has a matching key prefix. If there are no matches, jump
immediately to P2. If there is a match, fall through and leave the P1
cursor pointing to the matching row.</p>
<p>This opcode is similar to <a href="#NotFound">NotFound</a> with the exceptions that the
branch is always taken if any part of the search key input is NULL.</p>
<p>This operation leaves the cursor in a state where it cannot be
advanced in either direction. In other words, the <a href="#Next">Next</a> and <a href="#Prev">Prev</a>
opcodes do not work after this operation.</p>
<p>See also: <a href="#NotFound">NotFound</a>, <a href="#Found">Found</a>, <a href="#NotExists">NotExists</a></td></tr>
<tr><td valign="top" align="center">
<a name="Noop"></a><p>Noop</p>
<td><p>Do nothing. This instruction is often useful as a jump
destination.</td></tr>
<tr><td valign="top" align="center">
<a name="Not"></a><p>Not</p>
<td><p>Interpret the value in register P1 as a boolean value. Store the
boolean complement in register P2. If the value in register P1 is
NULL, then a NULL is stored in P2.</td></tr>
<tr><td valign="top" align="center">
<a name="NotExists"></a><p>NotExists</p>
<td><p>P1 is the index of a cursor open on an SQL table btree (with integer
keys). P3 is an integer rowid. If P1 does not contain a record with
rowid P3 then jump immediately to P2. If P1 does contain a record
with rowid P3 then leave the cursor pointing at that record and fall
through to the next instruction.</p>
<p>The <a href="#NotFound">NotFound</a> opcode performs the same operation on index btrees
(with arbitrary multi-value keys).</p>
<p>This opcode leaves the cursor in a state where it cannot be advanced
in either direction. In other words, the <a href="#Next">Next</a> and <a href="#Prev">Prev</a> opcodes will
not work following this opcode.</p>
<p>See also: <a href="#Found">Found</a>, <a href="#NotFound">NotFound</a>, <a href="#NoConflict">NoConflict</a></td></tr>
<tr><td valign="top" align="center">
<a name="NotFound"></a><p>NotFound</p>
<td><p>If P4==0 then register P3 holds a blob constructed by <a href="#MakeRecord">MakeRecord</a>. If
P4>0 then register P3 is the first of P4 registers that form an unpacked
record.</p>
<p>Cursor P1 is on an index btree. If the record identified by P3 and P4
is not the prefix of any entry in P1 then a jump is made to P2. If P1
does contain an entry whose prefix matches the P3/P4 record then control
falls through to the next instruction and P1 is left pointing at the
matching entry.</p>
<p>This operation leaves the cursor in a state where it cannot be
advanced in either direction. In other words, the <a href="#Next">Next</a> and <a href="#Prev">Prev</a>
opcodes do not work after this operation.</p>
<p>See also: <a href="#Found">Found</a>, <a href="#NotExists">NotExists</a>, <a href="#NoConflict">NoConflict</a></td></tr>
<tr><td valign="top" align="center">
<a name="NotNull"></a><p>NotNull</p>
<td><p>Jump to P2 if the value in register P1 is not NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="Null"></a><p>Null</p>
<td><p>Write a NULL into registers P2. If P3 greater than P2, then also write
NULL into register P3 and every register in between P2 and P3. If P3
is less than P2 (typically P3 is zero) then only register P2 is
set to NULL.</p>
<p>If the P1 value is non-zero, then also set the MEM_Cleared flag so that
NULL values will not compare equal even if SQLITE_NULLEQ is set on
<a href="#Ne">Ne</a> or <a href="#Eq">Eq</a>.</td></tr>
<tr><td valign="top" align="center">
<a name="NullRow"></a><p>NullRow</p>
<td><p>Move the cursor P1 to a null row. Any <a href="#Column">Column</a> operations
that occur while the cursor is on the null row will always
write a NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="Once"></a><p>Once</p>
<td><p>Check the "once" flag number P1. If it is set, jump to instruction P2.
Otherwise, set the flag and fall through to the next instruction.
In other words, this opcode causes all following opcodes up through P2
(but not including P2) to run just once and to be skipped on subsequent
times through the loop.</p>
<p>All "once" flags are initially cleared whenever a prepared statement
first begins to run.</td></tr>
<tr><td valign="top" align="center">
<a name="OpenAutoindex"></a><p>OpenAutoindex</p>
<td><p>This opcode works the same as <a href="#OpenEphemeral">OpenEphemeral</a>. It has a
different name to distinguish its use. Tables created using
by this opcode will be used for automatically created transient
indices in joins.</td></tr>
<tr><td valign="top" align="center">
<a name="OpenEphemeral"></a><p>OpenEphemeral</p>
<td><p>Open a new cursor P1 to a transient table.
The cursor is always opened read/write even if
the main database is read-only. The ephemeral
table is deleted automatically when the cursor is closed.</p>
<p>P2 is the number of columns in the ephemeral table.
The cursor points to a BTree table if P4==0 and to a BTree index
if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure
that defines the format of keys in the index.</p>
<p>The P5 parameter can be a mask of the BTREE_* flags defined
in btree.h. These flags control aspects of the operation of
the btree. The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are
added automatically.</td></tr>
<tr><td valign="top" align="center">
<a name="OpenPseudo"></a><p>OpenPseudo</p>
<td><p>Open a new cursor that points to a fake table that contains a single
row of data. The content of that one row is the content of memory
register P2. In other words, cursor P1 becomes an alias for the
MEM_Blob content contained in register P2.</p>
<p>A pseudo-table created by this opcode is used to hold a single
row output from the sorter so that the row can be decomposed into
individual columns using the <a href="#Column">Column</a> opcode. The <a href="#Column">Column</a> opcode
is the only cursor opcode that works with a pseudo-table.</p>
<p>P3 is the number of fields in the records that will be stored by
the pseudo-table.</td></tr>
<tr><td valign="top" align="center">
<a name="OpenRead"></a><p>OpenRead</p>
<td><p>Open a read-only cursor for the database table whose root page is
P2 in a database file. The database file is determined by P3.
P3==0 means the main database, P3==1 means the database used for
temporary tables, and P3>1 means used the corresponding attached
database. Give the new cursor an identifier of P1. The P1
values need not be contiguous but all P1 values should be small integers.
It is an error for P1 to be negative.</p>
<p>If P5!=0 then use the content of register P2 as the root page, not
the value of P2 itself.</p>
<p>There will be a read lock on the database whenever there is an
open cursor. If the database was unlocked prior to this instruction
then a read lock is acquired as part of this instruction. A read
lock allows other processes to read the database but prohibits
any other process from modifying the database. The read lock is
released when all cursors are closed. If this instruction attempts
to get a read lock but fails, the script terminates with an
SQLITE_BUSY error code.</p>
<p>The P4 value may be either an integer (P4_INT32) or a pointer to
a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo
structure, then said structure defines the content and collating
sequence of the index being opened. Otherwise, if P4 is an integer
value, it is set to the number of columns in the table.</p>
<p>See also: <a href="#OpenWrite">OpenWrite</a>, <a href="#ReopenIdx">ReopenIdx</a></td></tr>
<tr><td valign="top" align="center">
<a name="OpenWrite"></a><p>OpenWrite</p>
<td><p>Open a read/write cursor named P1 on the table or index whose root
page is P2. Or if P5!=0 use the content of register P2 to find the
root page.</p>
<p>The P4 value may be either an integer (P4_INT32) or a pointer to
a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo
structure, then said structure defines the content and collating
sequence of the index being opened. Otherwise, if P4 is an integer
value, it is set to the number of columns in the table, or to the
largest index of any column of the table that is actually used.</p>
<p>This instruction works just like <a href="#OpenRead">OpenRead</a> except that it opens the cursor
in read/write mode. For a given table, there can be one or more read-only
cursors or a single read/write cursor but not both.</p>
<p>See also <a href="#OpenRead">OpenRead</a>.</td></tr>
<tr><td valign="top" align="center">
<a name="Or"></a><p>Or</p>
<td><p>Take the logical OR of the values in register P1 and P2 and
store the answer in register P3.</p>
<p>If either P1 or P2 is nonzero (true) then the result is 1 (true)
even if the other input is NULL. A NULL and false or two NULLs
give a NULL output.</td></tr>
<tr><td valign="top" align="center">
<a name="Pagecount"></a><p>Pagecount</p>
<td><p>Write the current number of pages in database P1 to memory cell P2.</td></tr>
<tr><td valign="top" align="center">
<a name="Param"></a><p>Param</p>
<td><p>This opcode is only ever present in sub-programs called via the
<a href="#Program">Program</a> instruction. <a href="#Copy">Copy</a> a value currently stored in a memory
cell of the calling (parent) frame to cell P2 in the current frames
address space. This is used by trigger programs to access the new.*
and old.* values.</p>
<p>The address of the cell in the parent frame is determined by adding
the value of the P1 argument to the value of the P1 argument to the
calling <a href="#Program">Program</a> instruction.</td></tr>
<tr><td valign="top" align="center">
<a name="ParseSchema"></a><p>ParseSchema</p>
<td><p>Read and parse all entries from the SQLITE_MASTER table of database P1
that match the WHERE clause P4.</p>
<p>This opcode invokes the parser to create a new virtual machine,
then runs the new virtual machine. It is thus a re-entrant opcode.</td></tr>
<tr><td valign="top" align="center">
<a name="Permutation"></a><p>Permutation</p>
<td><p>Set the permutation used by the <a href="#Compare">Compare</a> operator to be the array
of integers in P4.</p>
<p>The permutation is only valid until the next <a href="#Compare">Compare</a> that has
the OPFLAG_PERMUTE bit set in P5. Typically the <a href="#Permutation">Permutation</a> should
occur immediately prior to the <a href="#Compare">Compare</a>.</td></tr>
<tr><td valign="top" align="center">
<a name="Prev"></a><p>Prev</p>
<td><p>Back up cursor P1 so that it points to the previous key/data pair in its
table or index. If there is no previous key/value pairs then fall through
to the following instruction. But if the cursor backup was successful,
jump immediately to P2.</p>
<p>The <a href="#Prev">Prev</a> opcode is only valid following an <a href="#SeekLT">SeekLT</a>, <a href="#SeekLE">SeekLE</a>, or
<a href="#Last">Last</a> opcode used to position the cursor. <a href="#Prev">Prev</a> is not allowed
to follow <a href="#SeekGT">SeekGT</a>, <a href="#SeekGE">SeekGE</a>, or <a href="#Rewind">Rewind</a>.</p>
<p>The P1 cursor must be for a real table, not a pseudo-table. If P1 is
not open then the behavior is undefined.</p>
<p>The P3 value is a hint to the btree implementation. If P3==1, that
means P1 is an SQL index and that this instruction could have been
omitted if that index had been unique. P3 is usually 0. P3 is
always either 0 or 1.</p>
<p>P4 is always of type P4_ADVANCE. The function pointer points to
sqlite3BtreePrevious().</p>
<p>If P5 is positive and the jump is taken, then event counter
number P5-1 in the prepared statement is incremented.</td></tr>
<tr><td valign="top" align="center">
<a name="PrevIfOpen"></a><p>PrevIfOpen</p>
<td><p>This opcode works just like <a href="#Prev">Prev</a> except that if cursor P1 is not
open it behaves a no-op.</td></tr>
<tr><td valign="top" align="center">
<a name="Program"></a><p>Program</p>
<td><p>Execute the trigger program passed as P4 (type P4_SUBPROGRAM).</p>
<p>P1 contains the address of the memory cell that contains the first memory
cell in an array of values used as arguments to the sub-program. P2
contains the address to jump to if the sub-program throws an IGNORE
exception using the RAISE() function. Register P3 contains the address
of a memory cell in this (the parent) VM that is used to allocate the
memory required by the sub-vdbe at runtime.</p>
<p>P4 is a pointer to the VM containing the trigger program.</p>
<p>If P5 is non-zero, then recursive program invocation is enabled.</td></tr>
<tr><td valign="top" align="center">
<a name="ReadCookie"></a><p>ReadCookie</p>
<td><p>Read cookie number P3 from database P1 and write it into register P2.
P3==1 is the schema version. P3==2 is the database format.
P3==3 is the recommended pager cache size, and so forth. P1==0 is
the main database file and P1==1 is the database file used to store
temporary tables.</p>
<p>There must be a read-lock on the database (either a transaction
must be started or there must be an open cursor) before
executing this instruction.</td></tr>
<tr><td valign="top" align="center">
<a name="Real"></a><p>Real</p>
<td><p>P4 is a pointer to a 64-bit floating point value.
Write that value into register P2.</td></tr>
<tr><td valign="top" align="center">
<a name="RealAffinity"></a><p>RealAffinity</p>
<td><p>If register P1 holds an integer convert it to a real value.</p>
<p>This opcode is used when extracting information from a column that
has REAL affinity. Such column values may still be stored as
integers, for space efficiency, but after extraction we want them
to have only a real value.</td></tr>
<tr><td valign="top" align="center">
<a name="Remainder"></a><p>Remainder</p>
<td><p>Compute the remainder after integer register P2 is divided by
register P1 and store the result in register P3.
If the value in register P1 is zero the result is NULL.
If either operand is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="ReopenIdx"></a><p>ReopenIdx</p>
<td><p>The <a href="#ReopenIdx">ReopenIdx</a> opcode works exactly like ReadOpen except that it first
checks to see if the cursor on P1 is already open with a root page
number of P2 and if it is this opcode becomes a no-op. In other words,
if the cursor is already open, do not reopen it.</p>
<p>The <a href="#ReopenIdx">ReopenIdx</a> opcode may only be used with P5==0 and with P4 being
a P4_KEYINFO object. Furthermore, the P3 value must be the same as
every other <a href="#ReopenIdx">ReopenIdx</a> or <a href="#OpenRead">OpenRead</a> for the same cursor number.</p>
<p>See the <a href="#OpenRead">OpenRead</a> opcode documentation for additional information.</td></tr>
<tr><td valign="top" align="center">
<a name="ResetCount"></a><p>ResetCount</p>
<td><p>The value of the change counter is copied to the database handle
change counter (returned by subsequent calls to sqlite3_changes()).
Then the VMs internal change counter resets to 0.
This is used by trigger programs.</td></tr>
<tr><td valign="top" align="center">
<a name="ResetSorter"></a><p>ResetSorter</p>
<td><p>Delete all contents from the ephemeral table or sorter
that is open on cursor P1.</p>
<p>This opcode only works for cursors used for sorting and
opened with <a href="#OpenEphemeral">OpenEphemeral</a> or <a href="#SorterOpen">SorterOpen</a>.</td></tr>
<tr><td valign="top" align="center">
<a name="ResultRow"></a><p>ResultRow</p>
<td><p>The registers P1 through P1+P2-1 contain a single row of
results. This opcode causes the sqlite3_step() call to terminate
with an SQLITE_ROW return code and it sets up the sqlite3_stmt
structure to provide access to the r(P1)..r(P1+P2-1) values as
the result row.</td></tr>
<tr><td valign="top" align="center">
<a name="Return"></a><p>Return</p>
<td><p>Jump to the next instruction after the address in register P1. After
the jump, register P1 becomes undefined.</td></tr>
<tr><td valign="top" align="center">
<a name="Rewind"></a><p>Rewind</p>
<td><p>The next use of the <a href="#Rowid">Rowid</a> or <a href="#Column">Column</a> or <a href="#Next">Next</a> instruction for P1
will refer to the first entry in the database table or index.
If the table or index is empty and P2>0, then jump immediately to P2.
If P2 is 0 or if the table or index is not empty, fall through
to the following instruction.</p>
<p>This opcode leaves the cursor configured to move in forward order,
from the beginning toward the end. In other words, the cursor is
configured to use <a href="#Next">Next</a>, not <a href="#Prev">Prev</a>.</td></tr>
<tr><td valign="top" align="center">
<a name="RowData"></a><p>RowData</p>
<td><p>Write into register P2 the complete row data for cursor P1.
There is no interpretation of the data.
It is just copied onto the P2 register exactly as
it is found in the database file.</p>
<p>If the P1 cursor must be pointing to a valid row (not a NULL row)
of a real table, not a pseudo-table.</td></tr>
<tr><td valign="top" align="center">
<a name="Rowid"></a><p>Rowid</p>
<td><p>Store in register P2 an integer which is the key of the table entry that
P1 is currently point to.</p>
<p>P1 can be either an ordinary table or a virtual table. There used to
be a separate OP_VRowid opcode for use with virtual tables, but this
one opcode now works for both table types.</td></tr>
<tr><td valign="top" align="center">
<a name="RowKey"></a><p>RowKey</p>
<td><p>Write into register P2 the complete row key for cursor P1.
There is no interpretation of the data.
The key is copied onto the P2 register exactly as
it is found in the database file.</p>
<p>If the P1 cursor must be pointing to a valid row (not a NULL row)
of a real table, not a pseudo-table.</td></tr>
<tr><td valign="top" align="center">
<a name="RowSetAdd"></a><p>RowSetAdd</p>
<td><p>Insert the integer value held by register P2 into a boolean index
held in register P1.</p>
<p>An assertion fails if P2 is not an integer.</td></tr>
<tr><td valign="top" align="center">
<a name="RowSetRead"></a><p>RowSetRead</p>
<td><p>Extract the smallest value from boolean index P1 and put that value into
register P3. Or, if boolean index P1 is initially empty, leave P3
unchanged and jump to instruction P2.</td></tr>
<tr><td valign="top" align="center">
<a name="RowSetTest"></a><p>RowSetTest</p>
<td><p>Register P3 is assumed to hold a 64-bit integer value. If register P1
contains a RowSet object and that RowSet object contains
the value held in P3, jump to register P2. Otherwise, insert the
integer in P3 into the RowSet and continue on to the
next opcode.</p>
<p>The RowSet object is optimized for the case where successive sets
of integers, where each set contains no duplicates. Each set
of values is identified by a unique P4 value. The first set
must have P4==0, the final set P4=-1. P4 must be either -1 or
non-negative. For non-negative values of P4 only the lower 4
bits are significant.</p>
<p>This allows optimizations: (a) when P4==0 there is no need to test
the rowset object for P3, as it is guaranteed not to contain it,
(b) when P4==-1 there is no need to insert the value, as it will
never be tested for, and (c) when a value that is part of set X is
inserted, there is no need to search to see if the same value was
previously inserted as part of set X (only if it was previously
inserted as part of some other set).</td></tr>
<tr><td valign="top" align="center">
<a name="Savepoint"></a><p>Savepoint</p>
<td><p>Open, release or rollback the savepoint named by parameter P4, depending
on the value of P1. To open a new savepoint, P1==0. To release (commit) an
existing savepoint, P1==1, or to rollback an existing savepoint P1==2.</td></tr>
<tr><td valign="top" align="center">
<a name="SCopy"></a><p>SCopy</p>
<td><p>Make a shallow copy of register P1 into register P2.</p>
<p>This instruction makes a shallow copy of the value. If the value
is a string or blob, then the copy is only a pointer to the
original and hence if the original changes so will the copy.
Worse, if the original is deallocated, the copy becomes invalid.
Thus the program must guarantee that the original will not change
during the lifetime of the copy. Use <a href="#Copy">Copy</a> to make a complete
copy.</td></tr>
<tr><td valign="top" align="center">
<a name="Seek"></a><p>Seek</p>
<td><p>P1 is an open table cursor and P2 is a rowid integer. Arrange
for P1 to move so that it points to the rowid given by P2.</p>
<p>This is actually a deferred seek. Nothing actually happens until
the cursor is used to read a record. That way, if no reads
occur, no unnecessary I/O happens.</td></tr>
<tr><td valign="top" align="center">
<a name="SeekGE"></a><p>SeekGE</p>
<td><p>If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
use the value in register P3 as the key. If cursor P1 refers
to an SQL index, then P3 is the first in an array of P4 registers
that are used as an unpacked index key.</p>
<p>Reposition cursor P1 so that it points to the smallest entry that
is greater than or equal to the key value. If there are no records
greater than or equal to the key and P2 is not zero, then jump to P2.</p>
<p>This opcode leaves the cursor configured to move in forward order,
from the beginning toward the end. In other words, the cursor is
configured to use <a href="#Next">Next</a>, not <a href="#Prev">Prev</a>.</p>
<p>See also: <a href="#Found">Found</a>, <a href="#NotFound">NotFound</a>, SeekLt, SeekGt, SeekLe</td></tr>
<tr><td valign="top" align="center">
<a name="SeekGT"></a><p>SeekGT</p>
<td><p>If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
use the value in register P3 as a key. If cursor P1 refers
to an SQL index, then P3 is the first in an array of P4 registers
that are used as an unpacked index key.</p>
<p>Reposition cursor P1 so that it points to the smallest entry that
is greater than the key value. If there are no records greater than
the key and P2 is not zero, then jump to P2.</p>
<p>This opcode leaves the cursor configured to move in forward order,
from the beginning toward the end. In other words, the cursor is
configured to use <a href="#Next">Next</a>, not <a href="#Prev">Prev</a>.</p>
<p>See also: <a href="#Found">Found</a>, <a href="#NotFound">NotFound</a>, SeekLt, SeekGe, SeekLe</td></tr>
<tr><td valign="top" align="center">
<a name="SeekLE"></a><p>SeekLE</p>
<td><p>If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
use the value in register P3 as a key. If cursor P1 refers
to an SQL index, then P3 is the first in an array of P4 registers
that are used as an unpacked index key.</p>
<p>Reposition cursor P1 so that it points to the largest entry that
is less than or equal to the key value. If there are no records
less than or equal to the key and P2 is not zero, then jump to P2.</p>
<p>This opcode leaves the cursor configured to move in reverse order,
from the end toward the beginning. In other words, the cursor is
configured to use <a href="#Prev">Prev</a>, not <a href="#Next">Next</a>.</p>
<p>See also: <a href="#Found">Found</a>, <a href="#NotFound">NotFound</a>, SeekGt, SeekGe, SeekLt</td></tr>
<tr><td valign="top" align="center">
<a name="SeekLT"></a><p>SeekLT</p>
<td><p>If cursor P1 refers to an SQL table (B-Tree that uses integer keys),
use the value in register P3 as a key. If cursor P1 refers
to an SQL index, then P3 is the first in an array of P4 registers
that are used as an unpacked index key.</p>
<p>Reposition cursor P1 so that it points to the largest entry that
is less than the key value. If there are no records less than
the key and P2 is not zero, then jump to P2.</p>
<p>This opcode leaves the cursor configured to move in reverse order,
from the end toward the beginning. In other words, the cursor is
configured to use <a href="#Prev">Prev</a>, not <a href="#Next">Next</a>.</p>
<p>See also: <a href="#Found">Found</a>, <a href="#NotFound">NotFound</a>, SeekGt, SeekGe, SeekLe</td></tr>
<tr><td valign="top" align="center">
<a name="Sequence"></a><p>Sequence</p>
<td><p>Find the next available sequence number for cursor P1.
Write the sequence number into register P2.
The sequence number on the cursor is incremented after this
instruction.</td></tr>
<tr><td valign="top" align="center">
<a name="SequenceTest"></a><p>SequenceTest</p>
<td><p>P1 is a sorter cursor. If the sequence counter is currently zero, jump
to P2. Regardless of whether or not the jump is taken, increment the
the sequence value.</td></tr>
<tr><td valign="top" align="center">
<a name="SetCookie"></a><p>SetCookie</p>
<td><p>Write the content of register P3 (interpreted as an integer)
into cookie number P2 of database P1. P2==1 is the schema version.
P2==2 is the database format. P2==3 is the recommended pager cache
size, and so forth. P1==0 is the main database file and P1==1 is the
database file used to store temporary tables.</p>
<p>A transaction must be started before executing this opcode.</td></tr>
<tr><td valign="top" align="center">
<a name="ShiftLeft"></a><p>ShiftLeft</p>
<td><p>Shift the integer value in register P2 to the left by the
number of bits specified by the integer in register P1.
Store the result in register P3.
If either input is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="ShiftRight"></a><p>ShiftRight</p>
<td><p>Shift the integer value in register P2 to the right by the
number of bits specified by the integer in register P1.
Store the result in register P3.
If either input is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="SoftNull"></a><p>SoftNull</p>
<td><p>Set register P1 to have the value NULL as seen by the <a href="#MakeRecord">MakeRecord</a>
instruction, but do not free any string or blob memory associated with
the register, so that if the value was a string or blob that was
previously copied using <a href="#SCopy">SCopy</a>, the copies will continue to be valid.</td></tr>
<tr><td valign="top" align="center">
<a name="Sort"></a><p>Sort</p>
<td><p>This opcode does exactly the same thing as <a href="#Rewind">Rewind</a> except that
it increments an undocumented global variable used for testing.</p>
<p>Sorting is accomplished by writing records into a sorting index,
then rewinding that index and playing it back from beginning to
end. We use the <a href="#Sort">Sort</a> opcode instead of <a href="#Rewind">Rewind</a> to do the
rewinding so that the global variable will be incremented and
regression tests can determine whether or not the optimizer is
correctly optimizing out sorts.</td></tr>
<tr><td valign="top" align="center">
<a name="SorterCompare"></a><p>SorterCompare</p>
<td><p>P1 is a sorter cursor. This instruction compares a prefix of the
record blob in register P3 against a prefix of the entry that
the sorter cursor currently points to. Only the first P4 fields
of r[P3] and the sorter record are compared.</p>
<p>If either P3 or the sorter contains a NULL in one of their significant
fields (not counting the P4 fields at the end which are ignored) then
the comparison is assumed to be equal.</p>
<p>Fall through to next instruction if the two records compare equal to
each other. <a href="#Jump">Jump</a> to P2 if they are different.</td></tr>
<tr><td valign="top" align="center">
<a name="SorterData"></a><p>SorterData</p>
<td><p>Write into register P2 the current sorter data for sorter cursor P1.
Then clear the column header cache on cursor P3.</p>
<p>This opcode is normally use to move a record out of the sorter and into
a register that is the source for a pseudo-table cursor created using
<a href="#OpenPseudo">OpenPseudo</a>. That pseudo-table cursor is the one that is identified by
parameter P3. Clearing the P3 column cache as part of this opcode saves
us from having to issue a separate <a href="#NullRow">NullRow</a> instruction to clear that cache.</td></tr>
<tr><td valign="top" align="center">
<a name="SorterOpen"></a><p>SorterOpen</p>
<td><p>This opcode works like <a href="#OpenEphemeral">OpenEphemeral</a> except that it opens
a transient index that is specifically designed to sort large
tables using an external merge-sort algorithm.</p>
<p>If argument P3 is non-zero, then it indicates that the sorter may
assume that a stable sort considering the first P3 fields of each
key is sufficient to produce the required results.</td></tr>
<tr><td valign="top" align="center">
<a name="String"></a><p>String</p>
<td><p>The string value P4 of length P1 (bytes) is stored in register P2.</td></tr>
<tr><td valign="top" align="center">
<a name="String8"></a><p>String8</p>
<td><p>P4 points to a nul terminated UTF-8 string. This opcode is transformed
into a <a href="#String">String</a> before it is executed for the first time. During
this transformation, the length of string P4 is computed and stored
as the P1 parameter.</td></tr>
<tr><td valign="top" align="center">
<a name="Subtract"></a><p>Subtract</p>
<td><p>Subtract the value in register P1 from the value in register P2
and store the result in register P3.
If either input is NULL, the result is NULL.</td></tr>
<tr><td valign="top" align="center">
<a name="TableLock"></a><p>TableLock</p>
<td><p>Obtain a lock on a particular table. This instruction is only used when
the shared-cache feature is enabled.</p>
<p>P1 is the index of the database in sqlite3.aDb[] of the database
on which the lock is acquired. A readlock is obtained if P3==0 or
a write lock if P3==1.</p>
<p>P2 contains the root-page of the table to lock.</p>
<p>P4 contains a pointer to the name of the table being locked. This is only
used to generate an error message if the lock cannot be obtained.</td></tr>
<tr><td valign="top" align="center">
<a name="Transaction"></a><p>Transaction</p>
<td><p>Begin a transaction on database P1 if a transaction is not already
active.
If P2 is non-zero, then a write-transaction is started, or if a
read-transaction is already active, it is upgraded to a write-transaction.
If P2 is zero, then a read-transaction is started.</p>
<p>P1 is the index of the database file on which the transaction is
started. Index 0 is the main database file and index 1 is the
file used for temporary tables. Indices of 2 or more are used for
attached databases.</p>
<p>If a write-transaction is started and the Vdbe.usesStmtJournal flag is
true (this flag is set if the Vdbe may modify more than one row and may
throw an ABORT exception), a statement transaction may also be opened.
More specifically, a statement transaction is opened iff the database
connection is currently not in autocommit mode, or if there are other
active statements. A statement transaction allows the changes made by this
VDBE to be rolled back after an error without having to roll back the
entire transaction. If no error is encountered, the statement transaction
will automatically commit when the VDBE halts.</p>
<p>If P5!=0 then this opcode also checks the schema cookie against P3
and the schema generation counter against P4.
The cookie changes its value whenever the database schema changes.
This operation is used to detect when that the cookie has changed
and that the current process needs to reread the schema. If the schema
cookie in P3 differs from the schema cookie in the database header or
if the schema generation counter in P4 differs from the current
generation counter, then an SQLITE_SCHEMA error is raised and execution
halts. The sqlite3_step() wrapper function might then reprepare the
statement and rerun it from the beginning.</td></tr>
<tr><td valign="top" align="center">
<a name="Vacuum"></a><p>Vacuum</p>
<td><p>Vacuum the entire database. This opcode will cause other virtual
machines to be created and run. It may not be called from within
a transaction.</td></tr>
<tr><td valign="top" align="center">
<a name="Variable"></a><p>Variable</p>
<td><p>Transfer the values of bound parameter P1 into register P2</p>
<p>If the parameter is named, then its name appears in P4.
The P4 value is used by sqlite3_bind_parameter_name().</td></tr>
<tr><td valign="top" align="center">
<a name="VBegin"></a><p>VBegin</p>
<td><p>P4 may be a pointer to an sqlite3_vtab structure. If so, call the
xBegin method for that table.</p>
<p>Also, whether or not P4 is set, check that this is not being called from
within a callback to a virtual table xSync() method. If it is, the error
code will be set to SQLITE_LOCKED.</td></tr>
<tr><td valign="top" align="center">
<a name="VColumn"></a><p>VColumn</p>
<td><p>Store the value of the P2-th column of
the row of the virtual-table that the
P1 cursor is pointing to into register P3.</td></tr>
<tr><td valign="top" align="center">
<a name="VCreate"></a><p>VCreate</p>
<td><p>P4 is the name of a virtual table in database P1. Call the xCreate method
for that table.</td></tr>
<tr><td valign="top" align="center">
<a name="VDestroy"></a><p>VDestroy</p>
<td><p>P4 is the name of a virtual table in database P1. Call the xDestroy method
of that table.</td></tr>
<tr><td valign="top" align="center">
<a name="VFilter"></a><p>VFilter</p>
<td><p>P1 is a cursor opened using <a href="#VOpen">VOpen</a>. P2 is an address to jump to if
the filtered result set is empty.</p>
<p>P4 is either NULL or a string that was generated by the xBestIndex
method of the module. The interpretation of the P4 string is left
to the module implementation.</p>
<p>This opcode invokes the xFilter method on the virtual table specified
by P1. The integer query plan parameter to xFilter is stored in register
P3. Register P3+1 stores the argc parameter to be passed to the
xFilter method. Registers P3+2..P3+1+argc are the argc
additional parameters which are passed to
xFilter as argv. Register P3+2 becomes argv[0] when passed to xFilter.</p>
<p>A jump is made to P2 if the result set after filtering would be empty.</td></tr>
<tr><td valign="top" align="center">
<a name="VNext"></a><p>VNext</p>
<td><p>Advance virtual table P1 to the next row in its result set and
jump to instruction P2. Or, if the virtual table has reached
the end of its result set, then fall through to the next instruction.</td></tr>
<tr><td valign="top" align="center">
<a name="VOpen"></a><p>VOpen</p>
<td><p>P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
P1 is a cursor number. This opcode opens a cursor to the virtual
table and stores that cursor in P1.</td></tr>
<tr><td valign="top" align="center">
<a name="VRename"></a><p>VRename</p>
<td><p>P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
This opcode invokes the corresponding xRename method. The value
in register P1 is passed as the zName argument to the xRename method.</td></tr>
<tr><td valign="top" align="center">
<a name="VUpdate"></a><p>VUpdate</p>
<td><p>P4 is a pointer to a virtual table object, an sqlite3_vtab structure.
This opcode invokes the corresponding xUpdate method. P2 values
are contiguous memory cells starting at P3 to pass to the xUpdate
invocation. The value in register (P3+P2-1) corresponds to the
p2th element of the argv array passed to xUpdate.</p>
<p>The xUpdate method will do a DELETE or an INSERT or both.
The argv[0] element (which corresponds to memory cell P3)
is the rowid of a row to delete. If argv[0] is NULL then no
deletion occurs. The argv[1] element is the rowid of the new
row. This can be NULL to have the virtual table select the new
rowid for itself. The subsequent elements in the array are
the values of columns in the new row.</p>
<p>If P2==1 then no insert is performed. argv[0] is the rowid of
a row to delete.</p>
<p>P1 is a boolean flag. If it is set to true and the xUpdate call
is successful, then the value returned by sqlite3_last_insert_rowid()
is set to the value of the rowid for the row just inserted.</p>
<p>P5 is the error actions (OE_Replace, OE_Fail, OE_Ignore, etc) to
apply in the case of a constraint failure on an insert or update.</td></tr>
<tr><td valign="top" align="center">
<a name="Yield"></a><p>Yield</p>
<td><p>Swap the program counter with the value in register P1. This
has the effect of yielding to a coroutine.</p>
<p>If the coroutine that is launched by this instruction ends with
<a href="#Yield">Yield</a> or <a href="#Return">Return</a> then continue to the next instruction. But if
the coroutine launched by this instruction ends with
<a href="#EndCoroutine">EndCoroutine</a>, then jump to P2 rather than continuing with the
next instruction.</p>
<p>See also: <a href="#InitCoroutine">InitCoroutine</a></td></tr>
</table></p>
|