Documentation Source Text

Check-in [e76f948793]
Login

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

Overview
Comment:Break out the requirements text into separate ASCII text files in the req/ folder. Requirements are now in a format suitable for use with qabot. Requirements information is no longer automatically extracted from sqlite3.h or fileformat.in. Changes to requirements must be manually entered.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e76f948793ce63e7e148c6b6e162f3977b09e869
User & Date: drh 2008-12-09 22:49:02.000
Context
2008-12-10
00:47
File format and file I/O documents converted to read their requirements text out of the requirements TXT files. Requirements numbers are shifted up into the 30000 range. (check-in: e1a02f28ad user: drh tags: trunk)
2008-12-09
22:49
Break out the requirements text into separate ASCII text files in the req/ folder. Requirements are now in a format suitable for use with qabot. Requirements information is no longer automatically extracted from sqlite3.h or fileformat.in. Changes to requirements must be manually entered. (check-in: e76f948793 user: drh tags: trunk)
2008-12-03
14:52
Change the syntax diagrams to require a GROUP BY prior to a HAVING clause. CVSTrac ticket #3516. (check-in: 77ea14504b user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Deleted pages/appreq.in.
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
<title>Assumptions</title>

<h2>Assumptions Made By SQLite</h2>

<p>This document defines behavior that SQLite expects from the application
that is using SQLite.  We call these "assumptions", but they might also be
called "Application Requirements" since they can be thought of additional
requirements that are imposed on any application that uses SQLite.</p>

<p>Another way of looking at these invariants is that they are limitations
or constraints on the use of SQLite.  If an application fails to abide by
the assumptions described here, then the behavior of SQLite will be
undefined and probably undesirable.</p>

<p>Yet another way of thinking about these invariants is that all of the
statements listed below must be true in order for SQLite to operate correctly.
</p>

<table cellspacing="20">
<tcl>
foreach id [lsort [array names ALLREQ A*]] {
  hd_puts "<tr><td valign=\"top\">$id</td><td valign=\"top\">"
  if {$ALLREQ_VERBATIM($id)} {
    hd_puts $ALLREQ($id)
  } else {
    hd_resolve $ALLREQ($id)
  }
  hd_puts "</td></tr>"
}
</tcl>
</table>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






























































Changes to pages/capi3ref.in.
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  global inrow body rowbody rowtag keyword dflt_parent
  if {$inrow} {
    set rowbody [string trim $rowbody]
    append body $rowbody</td></tr>\n
    if {$dflt_parent!=""} {
      append rowbody " <$dflt_parent>"
    }
    hd_requirement $rowtag $rowbody
    set keyword($rowtag) 1
    set inrow 0
    set rowbody {}
    set rowtag {}
  }
}
proc endtab {} {
  global intab body







|
|







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  global inrow body rowbody rowtag keyword dflt_parent
  if {$inrow} {
    set rowbody [string trim $rowbody]
    append body $rowbody</td></tr>\n
    if {$dflt_parent!=""} {
      append rowbody " <$dflt_parent>"
    }
    #hd_requirement $rowtag $rowbody
    #set keyword($rowtag) 1
    set inrow 0
    set rowbody {}
    set rowtag {}
  }
}
proc endtab {} {
  global intab body
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
      set reqdf {}
      if {[regexp {\{([AHLS]\d\d\d\d\d)\}} $title all reqtag]} {
        regsub { *\{[AHLS]\d\d\d\d\d\}} $title {} title
        while {[regexp {<([AHLS]\d\d\d\d\d)>} $title all df]} {
          append reqdf <$df>
          regsub { *<[AHLS]\d\d\d\d\d>} $title {} title
        }
        set keyword($reqtag) 1
      }
      set kwlist [lsort [array names keyword]]
      unset -nocomplain keyword
      if {$exflag} {
        foreach kw $kwlist {set supported($kw) 1}
      } elseif {$obsflag} {
        foreach kw $kwlist {set supported($kw) 2}
      } else {
        foreach kw $kwlist {set supported($kw) 0}
      }
      set exflag 0
      set obsflag 0
      set key $type:$kwlist
      regsub -all { *\{[\w.]+\}} $body {} body
      set body [string map \
          {<todo> {<font color="red">(TODO: } </todo> )</font>} $body]
      set code [string map {& &amp; < &lt; > &gt;} $code]
      lappend content [list $key $title $type $kwlist $body $code]
      if {$reqtag!=""} {
        set reqbody "The sqlite3.h header file shall define the\n"
        append reqbody "the following interfaces:\n<blockquote><pre>\n"
        append reqbody $code
        append reqbody "\n</pre></blockquote>"
        hd_requirement $reqtag $reqbody$reqdf 1
      }

      set title {}
      set keywords {}
      set type {}
      set body {}
      set code {}
      set phase 0
      set dcnt 0







|


















|
|
|
|
|
|
<
>







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
      set reqdf {}
      if {[regexp {\{([AHLS]\d\d\d\d\d)\}} $title all reqtag]} {
        regsub { *\{[AHLS]\d\d\d\d\d\}} $title {} title
        while {[regexp {<([AHLS]\d\d\d\d\d)>} $title all df]} {
          append reqdf <$df>
          regsub { *<[AHLS]\d\d\d\d\d>} $title {} title
        }
        # set keyword($reqtag) 1
      }
      set kwlist [lsort [array names keyword]]
      unset -nocomplain keyword
      if {$exflag} {
        foreach kw $kwlist {set supported($kw) 1}
      } elseif {$obsflag} {
        foreach kw $kwlist {set supported($kw) 2}
      } else {
        foreach kw $kwlist {set supported($kw) 0}
      }
      set exflag 0
      set obsflag 0
      set key $type:$kwlist
      regsub -all { *\{[\w.]+\}} $body {} body
      set body [string map \
          {<todo> {<font color="red">(TODO: } </todo> )</font>} $body]
      set code [string map {& &amp; < &lt; > &gt;} $code]
      lappend content [list $key $title $type $kwlist $body $code]
      #if {$reqtag!=""} {
      #  set reqbody "The sqlite3.h header file shall define the\n"
      #  append reqbody "the following interfaces:\n<blockquote><pre>\n"
      #  append reqbody $code
      #  append reqbody "\n</pre></blockquote>"
      #  #hd_requirement $reqtag $reqbody$reqdf 1

      #}
      set title {}
      set keywords {}
      set type {}
      set body {}
      set code {}
      set phase 0
      set dcnt 0
Changes to pages/changes.in.
37
38
39
40
41
42
43










44
45
46
47
48
49
50
      <a href="http://www.sqlite.org/cvstrac/timeline">
      http://www.sqlite.org/cvstrac/timeline</a>.</p>
    }
    hd_close_aux
    hd_enable_main 1
  }
}











chng {2008 Nov 26 (3.6.6.2)} {
<li>Fix a bug in the b-tree delete algorithm that seems like it might be
    able to cause database corruption.  The bug was first introduced in
    [version 3.6.6] by check-in &#91;5899&#93; on 2008-11-13.</li>
<li>Fix a memory leak that can occur following a disk I/O error.</li>
}







>
>
>
>
>
>
>
>
>
>







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
      <a href="http://www.sqlite.org/cvstrac/timeline">
      http://www.sqlite.org/cvstrac/timeline</a>.</p>
    }
    hd_close_aux
    hd_enable_main 1
  }
}

chng {2008 Dec 18 (3.6.7)} {
<li>Reorganize the Unix interface in os_unix.c</li>
<li>Added support for "Proxy Locking" on MacOSX.</li>
<li>Changed the prototype of the [sqlite3_auto_extension()] interface in a
    way that is backwards compatible but which might cause warnings in new
    builds of applications that use that interface.</li>
<li>Changed the signature of the xDlSym method of the [sqlite3_vfs] object
    in a way that is backwards compatible but which might cause warnings.</li>
}

chng {2008 Nov 26 (3.6.6.2)} {
<li>Fix a bug in the b-tree delete algorithm that seems like it might be
    able to cause database corruption.  The bug was first introduced in
    [version 3.6.6] by check-in &#91;5899&#93; on 2008-11-13.</li>
<li>Fix a memory leak that can occur following a disk I/O error.</li>
}
Changes to pages/fileformat.in.
2423
2424
2425
2426
2427
2428
2429
2430

2431
2432
2433
2434
2435
2436
2437
    For example, execution of a single "UPDATE" statement may result in 
    many entries being removed and inserted into a table B-Tree and several
    index B-Trees. 
  <p>
    The list of operations above itemizes inserting and removing entries 
    from index and table B-Trees separately. Requirements specifying the
    set of database file operations required by various SQL statements
    may be found in [XXX]. The requirements in [XXX] are written so as to

    ensure that the constraints relating the content of a table B-Tree and 
    its associated index B-Trees are met (see section YYY). By contrast the
    requirements specifying the behaviour of the system when a 
    schema item (table, index, view or trigger) is added to or removed 
    from a database describe both the schema (sqlite_master) table
    modifications and any additional modifications made to other parts
    of the database file.







|
>







2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
    For example, execution of a single "UPDATE" statement may result in 
    many entries being removed and inserted into a table B-Tree and several
    index B-Trees. 
  <p>
    The list of operations above itemizes inserting and removing entries 
    from index and table B-Trees separately. Requirements specifying the
    set of database file operations required by various SQL statements
    may be found in <i>insert-link</i>. 
    The requirements in <i>insert-link</i> are written so as to
    ensure that the constraints relating the content of a table B-Tree and 
    its associated index B-Trees are met (see section YYY). By contrast the
    requirements specifying the behaviour of the system when a 
    schema item (table, index, view or trigger) is added to or removed 
    from a database describe both the schema (sqlite_master) table
    modifications and any additional modifications made to other parts
    of the database file.
2768
2769
2770
2771
2772
2773
2774
2775
2776
    <tr><td style="width:5ex" id="capi_sqlitert_requirements">[3]<td>
      C API Requirements Document.
    <tr><td style="width:5ex" id="sql_sqlitert_requirements">[4]<td>
      SQL Requirements Document.
    <tr><td style="width:5ex" id="io_sqlitert_requirements">[5]<td>
      File IO Requirements Document.
  </table>









<
<
2769
2770
2771
2772
2773
2774
2775


    <tr><td style="width:5ex" id="capi_sqlitert_requirements">[3]<td>
      C API Requirements Document.
    <tr><td style="width:5ex" id="sql_sqlitert_requirements">[4]<td>
      SQL Requirements Document.
    <tr><td style="width:5ex" id="io_sqlitert_requirements">[5]<td>
      File IO Requirements Document.
  </table>


Changes to pages/fileio.in.
1
2
3
4
5
6
7
8
9
10
11

<tcl>
proc hd_assumption {id text} {
  hd_requirement $id $text
}

proc process {text} {
  set zOut ""
  set zSpecial ""

  foreach zLine [split $text "\n"] {



|







1
2
3
4
5
6
7
8
9
10
11

<tcl>
proc hd_assumption {id text} {
  # hd_requirement $id $text
}

proc process {text} {
  set zOut ""
  set zSpecial ""

  foreach zLine [split $text "\n"] {
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        regexp { *ASSUMPTION *([^ ]+) *} $zLine -> zRecid
        append zOut "<p class=req id=$zRecid>"
        set zSpecial hd_assumption
        set zRecText ""
      }
      {^ *$} {
        if {$zSpecial ne ""} {
          $zSpecial $zRecid $zRecText
          set zSpecial ""
          append zOut </p>
        }
      }
      default {
        if {$zSpecial ne ""} {
          if {[regexp {^ *\. *$} $zLine]} {set zLine ""}







|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        regexp { *ASSUMPTION *([^ ]+) *} $zLine -> zRecid
        append zOut "<p class=req id=$zRecid>"
        set zSpecial hd_assumption
        set zRecText ""
      }
      {^ *$} {
        if {$zSpecial ne ""} {
          # $zSpecial $zRecid $zRecText
          set zSpecial ""
          append zOut </p>
        }
      }
      default {
        if {$zSpecial ne ""} {
          if {[regexp {^ *\. *$} $zLine]} {set zLine ""}
2244
2245
2246
2247
2248
2249
2250
2251
      C API Requirements Document.
    <tr><td style="width:5ex" id="sql_sqlitert_requirements">[2]<td>
      SQL Requirements Document.
    <tr><td style="width:5ex" id="ff_sqlitert_requirements">[3]<td>
      File Format Requirements Document.
  </table>
}]</tcl>








<
2244
2245
2246
2247
2248
2249
2250

      C API Requirements Document.
    <tr><td style="width:5ex" id="sql_sqlitert_requirements">[2]<td>
      SQL Requirements Document.
    <tr><td style="width:5ex" id="ff_sqlitert_requirements">[3]<td>
      File Format Requirements Document.
  </table>
}]</tcl>

Deleted pages/hlreq.in.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<title>High-Level Requirements</title>

<h2>High-Level Requirements for SQLite</h2>

<p>These "requirements" define what SQLite is and what it does.
Any software that implements these requirements is a compatible
implementation of SQLite.  To put it another way, these requirements
are the contract that SQLite makes with the application it serves.</p>


<table cellspacing="20">
<tcl>
foreach id [lsort [array names ALLREQ H*]] {
  hd_puts "<tr><td valign=\"top\">$id</td><td valign=\"top\">"
  if {$ALLREQ_VERBATIM($id)} {
    hd_puts $ALLREQ($id)
  } else {
    hd_resolve $ALLREQ($id)
  }
  hd_puts "</td></tr>"
}
</tcl>
</table>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































Changes to pages/reqmatrix.in.
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
<title>Requirements Derivation Matrix</title>










<h2>Requirements Derivation Matrix</h2>

<table cellspacing="20">
<tcl>
unset -nocomplain ALLREQ_CHILDREN
foreach id [array names ALLREQ] {set ALLREQ_CHILDREN($id) {}}
foreach cid [array names ALLREQ_DERIVEDFROM] {
  foreach pid $ALLREQ_DERIVEDFROM($cid) {
    lappend ALLREQ_CHILDREN($pid) $cid
  }
} 
foreach id [lsort [array names ALLREQ]] {
  if {[string index $id 0]=="A"} continue

  hd_puts "<tr><td valign=\"top\">$id</td><td valign=\"top\">"
  if {$ALLREQ_VERBATIM($id)} {
    hd_puts $ALLREQ($id)
  } else {
    hd_resolve $ALLREQ($id)
  }
  hd_puts <p>
  set plist $ALLREQ_DERIVEDFROM($id)
  if {[llength $plist]==0} {
    hd_puts "<i>No parents</i>"
  } else {
    hd_puts "Parents:"
    foreach pid $plist {
      hd_resolve " \[$pid\]"
    }
  }
  hd_puts </p><p>
  set clist $ALLREQ_CHILDREN($id)
  if {[llength $clist]==0} {
    hd_puts "<i>No children</i>"
  } else {
    hd_puts "Children:"
    foreach cid $clist {
      hd_resolve " \[$cid\]"
    }
  }
  hd_puts </p>
  hd_puts "</td></tr>"
}
</tcl>
</table>


>
>
>
>
>
>
>
>
>




|
|
|
|
|


|

>
|
<
|
<
|
<
|
|





|


|
|





|


|
|



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
<title>Requirements Derivation Matrix</title>

<tcl>
# Read all of the requirements content out of the "req" folder
#
unset -nocomplain REQMATRIX
foreach file [lsort [glob $::DOC/req/*.txt]] {
  hd_read_requirement_file $file REQMATRIX
}
</tcl>

<h2>Requirements Derivation Matrix</h2>

<table cellspacing="20">
<tcl>
unset -nocomplain REQMATRIX_CHILDREN
foreach id $REQMATRIX(*) {set REQMATRIX_CHILDREN($id) {}}
foreach id $REQMATRIX(*) {
  foreach pid [lindex $REQMATRIX($id) 0] {
    lappend REQMATRIX_CHILDREN($pid) $id
  }
} 
foreach id $REQMATRIX(*) {
  if {[string index $id 0]=="A"} continue
  hd_puts "\n<tr>\n"
  hd_puts "<td valign=\"top\"><a name=\"$id\">$id</a></td>\n"

  hd_puts "<td valign=\"top\">\n"

  hd_resolve [lindex $REQMATRIX($id) 1]

  hd_puts \n<p>
  set plist [lindex $REQMATRIX($id) 0]
  if {[llength $plist]==0} {
    hd_puts "<i>No parents</i>"
  } else {
    hd_puts "Parents:"
    foreach pid $plist {
      hd_puts " <a href=\"#$pid\">$pid</a>\n"
    }
  }
  hd_puts </p>\n<p>
  set clist $REQMATRIX_CHILDREN($id)
  if {[llength $clist]==0} {
    hd_puts "<i>No children</i>"
  } else {
    hd_puts "Children:"
    foreach cid $clist {
      hd_puts " <a href=\"#$cid\">$cid</a>\n"
    }
  }
  hd_puts </p>\n
  hd_puts "</td></tr>\n"
}
</tcl>
</table>
Added pages/requirements.in.






































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
<title>SQLite Requirements</title>

<h1>SQLite Requirements</h1>

<h2>1.0 Introduction</h2>

<p>These requirements strive to describe the interfaces and operation of 
SQLite in sufficient detail that a compatible implementation of SQLite
can be written solely from these requirements and without reference to
the canonical SQLite source code.</p>

<p>Software development processes typically recognize a hierarchy of
requirements:</p>

<ul>
<li>System requirements</li>
<li>High-level requirements</li>
<li>Derived high-level requirements</li>
<li>Low-level requirements</li>
<li>Derived low-level requirements</li>
</ul>

<p>The usual distinction between high-level and low-level requirements is
that high-level requirements describe "what" the system does and the
low-level requirements describe "how" the system does it.  Since the
the requirements denoted here describe the
behavior of SQLite and not its implementation, they are best thought of
as high-level requirements.  Consistent with that view, most of
the requirements numbers begin with the letter "<b>H</b>" (for "high-level"). 
A few of the requirements presented here specify broad objectives that
SQLite strives to achieve.  These broad requirements can be thought of
as system requirements and are number with an initial letter "<b>S</b>".</p>

<p>These requirements are hierarchical in the sense that the more
specific requirements are derived from broader and more general
requirements.  When requirement B is derived from requirement A, we say
that A is the parent of B and that B is a child of A.  The parent/child
relationships of all requirements are tracked.  All requirements presented
here ultimately derive from a single very broad, very high-level, and
very general system requirement called "S10000".</p>

<p>Some behaviors of SQLite are undefined.  For example, the order in
which result rows are returned from a SELECT statement is undefined if
there is no ORDER BY clause.  As another example, many of the C interfaces
require a pointer to an open [database connection] as their first argument
and the behavior of those interfaces is undefined (and probably undesirable)
if a pointer to some other object is supplied instead.  Some, but not all
undefined behaviors are explicitly stated and number in this document
with numbers beginning with the "<b>U</b>" for "Undefined".  Applications
that use SQLite should never depend on undefined behavior.  If a behavior
is not explicitly defined by a requirement, then the behavior is undefined,
and so explicitly stating undefined behaviors in this document is
technically redundant.  Nevertheless, we find that explicitly stating
some undefined behaviors helps application developers to better understand
the boundaries of operation of SQLite and to generate safer and more
accurate programs that use SQLite.</p>

<h2><a href="sysreq.html">2.0 System Requirements</a></h2>

<h2><a href="hlr10000.html">3.0 Application C-Language Interfaces</a></h2>

<h2><a href="hlr20000.html">4.0 C-Language Interfaces For
Extending SQLite</a></h2>

<h2><a href="hlr30000.html">5.0 Database File Format</a></h2>

<h2><a href="hlr40000.html">6.0 SQL Language Specification</a></h2>
Deleted pages/syntax.in.
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
<title>SQLite SQL Language Syntax Requirements</title>

<tcl>
proc syntaxreq {id derivedfrom explaination text {bnf {}}} {
  hd_fragment $id $id
  set dlist {}
  foreach d $derivedfrom {
    append dlist <$d>
  }
  if {$bnf!=""} {
    regsub -all {\n  } $bnf "\n" bnf
    append text <blockquote><pre>$bnf</pre></blockquote>
  }
  hd_requirement $id $text$dlist
  if {[string length $explaination]} {
    hd_resolve "<p>$explaination</p>"
  }
  hd_puts "<blockquote><b>$id:</b>"
  hd_resolve $text
  hd_puts {</b></blockquote>}
}
set syntax_dcnt 0
proc syntaxdef {namelist text} {
  global syntax_dcnt
  incr syntax_dcnt
  eval hd_fragment D$syntax_dcnt $namelist
  hd_resolve "\n<p>$text</p>\n\n"
}
</tcl>

<h1>SQLite Language Syntax Requirements</h1>

<p>These requirements make the distinction between "preparing" an
SQL statement and "evaluating" or "invoking" an SQL statement.
Preparation means that the SQL statement text is translated into
an internal binary representation that is more suitable for processing.
Evaluation or invocation means that the processing is actually carried out.
Preparation of an SQL statement is usually accomplished by interfaces
[sqlite3_prepare()], [sqlite3_prepare16()], or [sqlite3_prepare_v2()] and
evaluation or invocation of an SQLite statement is accomplished by
calling [sqlite3_step()].  However, if a statement is initially
prepared using [sqlite3_prepare_v2()] and a change to the database
schema is detected during evaluation, then the preparation is redone
automatically, by [sqlite3_step()].  So even though it is reasonable
to think about preparation as being a function of [sqlite3_prepare_v2()]
and its companions and evaluation as being a function of
[sqlite3_step()], the reader should keep in mind that
[sqlite3_step()] might also sometimes do preparations following
schema changes.</p>

<h2>1.0 General Requirements</h2>

<h3>1.1 Parser operation</h3>

<tcl>
syntaxreq {H42000} {} {
  SQLite expects all statements to be terminated by a semicolon.
  If a statement is submitted to SQLite that does not end in a
  semicolon, then a semicolon is added automatically by the tokenizer.
  (See [H41040].)
} {
  The SQLite parser shall accept SQL statements consisting of an SQL command
  followed by a semicolon.
} {
  sql_statement ::= cmd SEMI.
}
syntaxreq {H42002} {} {
  Acceptance by the parser does not imply that the SQL statement
  will be accepted by SQLite.  SQL statements may be rejected by other
  parts of the SQLite library.  Acceptance by the parser is a necessary
  but not a sufficient condition for the statement to work.
} {
  The preparation of an SQL statement that is not accepted by
  the SQLite parser shall fail with an error.
}
syntaxreq {H42004} {} {
  SQLite ignores case when comparing ASCII characters in identifiers and
  in type names.  (The rules for comparison of content are different.)
  Case is considered for other unicode characters, however.
  Hence, SQLite considers identifiers "A" and "a" to be equivalent but
  "&Aring;" and "&aring;" are distinct.
} {
  SQLite shall use the built-in NOCASE collating sequence when comparing
  identifiers and datatype names within SQL statements during 
  statement preparation.
}
syntaxreq {H42008} {} {
  Many tokens are allowed to "fallback" to the ID token.  The SQL
  language has many keywords.  The fallback token feature provides
  robustness in the case where a seldom-used keyword is accidentally
  used as the name of a table or column.
} {
  A token received by the parser shall be converted into an ID token
  if the original token value would have resulted in a syntax error,
  a token value of ID will allow the parse to continue,
  and if the original token value was one of:
     ABORT
     AFTER
     ANALYZE
     ASC
     ATTACH
     BEFORE
     BEGIN
     CASCADE
     CAST
     CONFLICT
     CTIME_KW
     DATABASE
     DEFERRED
     DESC
     DETACH
     EACH
     END
     EXCEPT
     EXCLUSIVE
     EXPLAIN
     FAIL
     FOR
     IF
     IGNORE
     IMMEDIATE
     INITIALLY
     INSTEAD
     INTERSECT
     KEY
     LIKE_KW
     MATCH
     OF
     OFFSET
     PLAN
     PRAGMA
     QUERY
     RAISE
     REINDEX
     RENAME
     REPLACE
     RESTRICT
     ROW
     TEMP
     TRIGGER
     UNION
     VACUUM
     VIEW
     VIRTUAL
}
syntaxreq {H42012} {} {
  A second level of fallback allows any token to be converted into
  the token ANY.  The ANY token is used to gather arbitrary delimited
  token sequences, such as used as the arguments to the CREATE VIRTUAL
  TABLE command.
} {
  A token received by the parser shall be converted into an ANY token
  if the original token value would have resulted in a syntax error
  and if a token value of ANY will allow the parse to continue.
}
 
</tcl>

<h3>1.2 Name Contexts</h3>

<p>Expressions in SQL statements often contain identifiers that refer
to columns in tables or views or to columns in the result set of a 
SELECT statement.
The process of determining which column an identifier refers to
is called "name resolution".</p>

<p>Names are resolved with the aid of a "name context".
A name context is a set of tables and views and result set expressions
to which an expression identifier can refer.  A single name context
is a hierarchy of "name context layers".  Subqueries have their own
name context layer (called the "inner layer") that is distinct from the
name context layer (called the "outer layer") associated with the overall 
statement.  In an SQL statement with multiple levels of tested subqueries,
there can be multiple name context layers in the name context.  In
other words, a complete name context is an ordered list of name
context layers.</p>

<p>Within a name context a "source" is a table or view containing columns
that expression names can match against.  Every source has a "canonical
name" which is the name of the table or view as it appears in the schema.
A source might also have an "aliased name" resulting from an AS clause.
The "source name" is the aliased name if it exists, otherwise the source
name is the canonical name.</p>

<p>Each name context layer has a "source set" and a "result set",
either or both of which can be empty.  The source set is an ordered set
of sources.  The result set is an ordered set of expressions with
an optional alias on each expression.  Roughly speaking, a source set
corresponds to the FROM clause of a SELECT statement and the result set
corresponds to the list of expressions that form the result set of the
SELECT statement.</p>

<p>A "empty name context" is a name context comprised of a single
name context layer in which both the source set and the result set are
empty.</p>

<h2>2.0 Transaction Control</h2>

<h3>2.1 BEGIN</h3>

<tcl>
syntaxreq {H42010} {} {} {
  The SQLite parser shall accept BEGIN statements
  that conform to the following syntax:
} {
  cmd ::= BEGIN transaction_type transaction_name.
  transaction_type ::= .
  transaction_type ::= DEFERRED.
  transaction_type ::= IMMEDIATE.
  transaction_type ::= EXCLUSIVE.
  transaction_name ::= .
  transaction_name ::= TRANSACTION.
  transaction_name ::= TRANSACTION name.
}
syntaxreq {H42013} {} {} {
  The successful evaluation of a BEGIN statement shall
  cause the [database connection] to exit autocommit mode.
}
syntaxreq {H42016} {} {} {
  The evaluation of a BEGIN TRANSACTION statement shall fail with an error
  if the [database connection] is not in autocommit mode at the
  start of evaluation.
}
syntaxreq {H42019} {} {} {
  If the <i>transaction_type</i> keyword is omitted from a
  BEGIN TRANSACTION statement then the behavior shall be the same
  as if the DEFERRED keyword were used.
}
syntaxreq {H42022} {} {} {
  When the DEFERRED keyword appears in a BEGIN statement
  the locking state of the underlying database files shall be
  the same before and after the statement is evaluated.
}
syntaxreq {H42025} {} {} {
  When the IMMEDIATE keyword appears in a BEGIN statement
  then successful evaluation of the statement shall cause a RESERVED
  lock to be obtained for all underlying database files.
}
syntaxreq {H42028} {} {} {
  When the EXCLUSIVE keyword appears in a BEGIN statement
  then successful evaluation of the statement shall cause a EXCLUSIVE 
  lock to be obtained for all underlying database files.
}
</tcl>
<p>The <i>transaction_name</i> clause of a BEGIN statement is
provided for syntactic compatibility to other SQL database engines.
The <i>transaction_name</i> clause is silently ignored.</p>

<h3>2.2 COMMIT</h3>

<tcl>
syntaxreq {H42110} {} {} {
  SQLite shall accept the following COMMIT statement syntax:
} {
  cmd ::= COMMIT transaction_name.
  cmd ::= END transaction_name.
}
syntaxreq {H42113} {} {} {
  The successful evaluation of COMMIT statement places the
  [database connection] in autocommit mode.
}
syntaxreq {H42116} {} {} {
  If a [database connection] is already in autocommit mode when
  a COMMIT statement is evaluated, then the statement shall fail
  with an error.
}
</tcl>
<p>The <i>transaction_name</i> clause of a COMMIT statement is
provided for syntactic compatibility to other SQL database engines.
The <i>transaction_name</i> clause is silently ignored.</p>

<p>The COMMIT and END statements are aliases for one another and
accomplish exactly the same thing.  One is merely a different way
of expression the other.</p>


<h3>2.3 ROLLBACK</h3>

<tcl>
syntaxreq {H42210} {} {} {
  The SQLite parser shall accept ROLLBACK statements
  that conform to the following syntax:
} {
  cmd ::= ROLLBACK transaction_name.
}
syntaxreq {H42213} {} {} {
  The successful evaluation of ROLLBACK statement places the
  [database connection] in autocommit mode.
}
syntaxreq {H42216} {} {} {
  If a [database connection] is already in autocommit mode when
  a ROLLBACK statement is invoked, then the statement invocation
  shall fail with an error.
}
syntaxreq {H42222} {} {
  A "pending statement" is a statement for which [sqlite3_step()]
  has been called at least once without a subsequent call to
  either [sqlite3_reset()] or [sqlite3_finalize()].
} {
  Other pending statements on the same [database connection]
  as a successfully evaluated ROLLBACK statement shall be aborted.
}
syntaxreq {H42225} {} {} {
  The successful evaluation of a ROLLBACK statement causes the
  current transaction on the [database connection] to roll back.
}
</tcl>
<p>The <i>transaction_name</i> clause of a BEGIN statement is
provided for syntactic compatibility to other SQL database engines.
The <i>transaction_name</i> clause is silently ignored.</p>


<h2>3.0 Data Definition Language (DDL)</h2>

<h3>3.1 CREATE TABLE</h3>

<tcl>
syntaxreq {H42310} {} {} {
  The SQLite parser shall accept CREATE TABLE statements
  that conform to the following syntax:
} {
  cmd ::= CREATE temp TABLE ifnotexists fullname table_definition.
  temp ::= .
  temp ::= TEMP.
  ifnotexists ::= .
  ifnotexists ::= IF NOT EXISTS.
}
</tcl>
<p>
  The <i>fullname</i> non-terminal symbol of the SQLite grammar specifies
  an SQL object contained within a particular database file.  A
  specific database might be stated explicitly:

      &lt;<i>fullname ::= databasename DOT objectname.</i>&gt;

  or the database might be implied:

      &lt;<i>fullname ::= objectname.</i>&gt;.

  An unspecified <i>databasename</i> has a default value that
  depends on context and which is specified by requirements.
</p>
<tcl>
syntaxreq {H42313} {} {} {
  When the TEMP keyword appears in a CREATE TABLE statement and the
  <i>databasename</i> exists and is something other than "temp", then
  the preparation of the CREATE TABLE statement shall fail with an error.
}
syntaxreq {H42316} {} {} {
  When the TEMP keyword appears in a CREATE TABLE statement the behavior
  shall be as if the <i>databasename</i> where "temp".
}
syntaxreq {H42319} {} {} {
  The successful evaluation of a CREATE TABLE statement shall cause
  a new SQL table whose name is given by the <i>objectname</i> to be
  created in the schema of the database whose name is given by the
  <i>databasename</i>.
}
syntaxreq {H42322} {} {} {
  If a CREATE TABLE statement specifies no <i>databasename</i> and omits
  the TEMP keyword then the behavior shall be as if a <i>databasename</i>
  of "main" where used.
}
syntaxreq {H42325} {} {} {
  The preparation of a CREATE TABLE statement shall fail with an 
  error if the IF NOT EXISTS clause is omitted and the <i>objectname</i>
  is the same as the name of a table or view
  in the same database.
}
syntaxreq {H42328} {} {} {
  The evaluation of a CREATE TABLE statement shall be a silent no-op if the
  IF NOT EXISTS clause is present and the <i>objectname</i>
  is the same as the name of a table or view
  in the same database.
}
syntaxreq {H42331} {} {} {
  The preparation of a CREATE TABLE statement shall fail with an error if the
  the <i>objectname</i> is the same as the name of an index
  in any database attached to the same [database connection].
}
syntaxreq {H42334} {} {} {
  The preparation of a CREATE TABLE statement shall fail with an error if the
  the <i>databasename</i> references a database that is not
  attached to the same [database connection].
}
</tcl>

<h4>3.1.1 CREATE TABLE column definitions</h4>

<tcl>
syntaxdef [list {ordinary CREATE TABLE statement} {CREATE TABLE AS statement}] {
  There are two varieties of CREATE TABLE statements.  The most common form
  specifies the names of all columns in the table together with datatype
  and constraint information.  This first form is called a
  "ordinary CREATE TABLE statement".  The second form of CREATE TABLE
  constructs a new table from the result set of a SELECT statement.
  The second form is called a "CREATE TABLE AS statement".
}
syntaxreq {H42410} {} {
  In an ordinary CREATE TABLE statement, the <i>table_definition</i>
  consists of a list of column definitions optionally followed by a 
  list of table constraints.
} {
  The SQLite parser shall accept the following syntax for the 
  <i>table_definition</i> section of a CREATE TABLE statement:
} {
  table_definition ::= LP columnlist constraint_opt RP.
  columnlist ::= column.
  columnlist ::= columnlist COMMON column.
  constraint_opt ::= .
  constraint_opt ::= COMMA constraint_list.
}
syntaxreq {H42413} {} {
  A column definition within an ordinary CREATE TABLE statement always
  has a column name.  It might also include a datatype for the
  column and zero or more contraints on the column.  But both the
  datatype and the constraints are options.  Other SQL database
  engines also have optional constraints but they usually make the
  datatype required.
} {
  The SQLite parser shall accept the following syntax
  for the <i>column</i> component of a <i>table_definition</i>.
} {
  column ::= name column_type column_constraint_list.
  column_type ::= .
  column_type ::= typename.
  column_type ::= typename LP signed_int RP.
  column_type ::= typename LP signed_int COMMA signed_int RP.
  typename ::= identifier.
  typename ::= typename identifier.
  signed_int ::= INTEGER.
  signed_int ::= MINUS INTEGER.
  signed_int ::= PLUS INTEGER.
}
syntaxreq {H42416} {} {} {
  The preparation of an [ordinary CREATE TABLE statement] shall fail 
  with an error if it specifies two or more columns with the same name.
}
syntaxreq {H42419} {} {} {
  The datatype affinity of each column in a table generate by an
  [ordinary CREATE TABLE statement]
  shall be determined from the <i>column_type</i>
  text using the following 5-step algorithm:
  <ol>
  <li><p> If the <i>column_type</i> contains the string "INT"
          then the affinity is INTEGER.</p></li>

  <li><p> Else if the <i>column_type</i> contains one of the strings
         "CHAR", "CLOB", or "TEXT" then the affinity is TEXT. </p></li>

  <li><p> Else if the <i>column_type</i> contains the string "BLOB" 
          or is omitted then the affinity is NONE. </p></li>

  <li><p> Else if the <i>column_type</i> constains one of the strings
          "REAL", "FLOA", or "DOUB" then the affinity
          is REAL. </p></li>

  <li><p> Otherwise the affinity is NUMERIC. </p></li>
  </ol>
}

syntaxreq {H42450} {} {} {
  The SQLite parser shall accept the following syntax for the list of column
  constraints and modifiers that follows a column definition in 
  an [ordinary CREATE TABLE statement].
} {
  column_constraint_list ::= .
  column_constraint_list ::= column_constraint_list named_column_constraint.
  named_column_constraint ::= CONSTRAINT name column_constraint.
  named_column_constraint ::= column_constraint.
  column_constraint ::= DEFAULT term.
  column_constraint ::= DEFAULT identifier.
  column_constraint ::= DEFAULT PLUS term.
  column_constraint ::= DEFAULT MINUS term.
  column_constraint ::= DEFAULT LP expr RP.
  column_constraint ::= NULL conflict.
  column_constraint ::= NOT NULL conflict.
  column_constraint ::= PRIMARY KEY sortorder conflict autoincr.
  column_constraint ::= UNIQUE conflict.
  column_constraint ::= CHECK LP expr RP.
  column_constraint ::= COLLATE identifier.
  column_constraint ::= foreign_key_constraint.
  column_constraint ::= deferrable_constraint.
  autoincr ::= .
  autoincr ::= AUTOINCR.
  indexlist_opt ::= .
  indexlist_opt ::= LP indexlist RP.
  conflict ::= .
  conflict ::= ON CONFLICT IGNORE.
  conflict ::= ON CONFLICT REPLACE.
  conflict ::= ON CONFLICT ABORT.
  conflict ::= ON CONFLICT FAIL.
  conflict ::= ON CONFLICT ROLLBACK.
}
syntaxreq {H42453} {} {} {
  When a column as a DEFAULT constraint, the default value for the
  column shall be the value specified by that constraint.
}
syntaxreq {H42456} {} {} {
  If a column has no DEFAULT constraint then the default value for
  that column shall be NULL.
}
syntaxreq {H42459} {} {
  Every column a table has a "null-conflict resolution behavior"
  which is one of NONE, IGNORE, REPLACE, FAIL, ABORT, or ROLLBACK.</p>

  <p>The default null-conflict resolution behavior is NONE, which means
  NULLs are allowed in the column.  This can be made explicit by
  specifying the NULL constraint.  But the use of the NULL constraint
  is merely a comment for human readers.  SQLite silently ignores the
  NULL constraint and its ON CONFLICT clause.  SQLite only cares
  about NOT NULL constraints since only NOT NULL constraints make
  a behaviorial difference.
} {
  If a column has no NOT NULL constraint then the NULL conflict
  resolution behavior for the column shall be NONE.
}
syntaxreq {H42462} {} {} {
  If a column has a NOT NULL constraint and that constrait lacks
  an ON CONFLICT clause
  then the null-conflict resolution behavior for the column shall
  be ABORT.
}
syntaxreq {H42465} {} {} {
  If a column has a NOT NULL constraint and that constraint
  has an ON CONFLICT clause
  then the null-conflict resolution behavior for the column shall
  be the behavior specified by the ON CONFLICT clause.
}
syntaxreq {H42467} {} {} {
  A column without a COLLATE constraint shall have a default
  collating sequence of BINARY.
}
syntaxreq {H42468} {} {} {
  A column with a COLLATE constraint shall have a default
  collating sequence as specified by the COLLATE constraint.
}

syntaxreq {H42470} {} {
  The rowid is the underlying key used for storing each row of a 
  table in the B-Tree that implements that table.  Every table has
  a rowid column which is either implicit or explicit.  There can
  be up to four names for the rowid within the same table.  All
  can be used interchangeably.
} {
  If the datatype of a single-column PRIMARY KEY is
  exactly "INTEGER" then the name of that column shall be
  an alias for the table rowid.
}
syntaxreq {H42472} {} {} {
  If a table contains no column named "ROWID" then "ROWID" shall be
  an alias for the table rowid.
}
syntaxreq {H42474} {} {} {
  If a table contains no column named "OID" then "OID" shall be
  an alias for the table rowid.
}
syntaxreq {H42476} {} {} {
  If a table contains no column named "_ROWID_" then "_ROWID_" shall be
  an alias for the table rowid.
}
syntaxreq {H42478} {} {
  The AUTOINCREMENT keyword is ignored except when it appears on an explicit
  rowid column.
} {
  A table shall have an autoincrementing rowid if and only if
  the PRIMARY KEY for the table is an alias for the rowid and
  the PRIMARY KEY declaration uses the AUTOINCR keyword.
}

syntaxreq {H42480} {} {} {
  Successful evaluation of a CREATE TABLE statement shall create
  an index for every UNIQUE constraint where the created index has
  a conflict resolution algorithm as specified by the ON CONFLICT
  clause of the UNIQUE constraint or a conflict resolution algorithm
  of ABORT if there is no ON CONFLICT clause on the constraint.
}


syntaxreq {H42510} {} {} {
  The SQLite parser shall accept the following syntax for the list of table
  contraints that occurs at the end of an [ordinary CREATE TABLE statement].
} {
  constraint_list ::= constraint.
  constraint_list ::= constraint_list constraint.
  constraint_list ::= constraint_list COMMA constraint.
  constraint ::= CHECK LP expr RP conflict.
  constraint ::= CONSTRAINT name.
  constraint ::= FOREIGN KEY LP columnlist RP foreign_key_constraint defer_opt.
  constraint ::= PRIMARY KEY LP indexlist autoinc RP conflict.
  constraint ::= UNIQUE LP indexlist RP conflict.
}
syntaxreq {H42513} {} {} {
  The preparation of a CREATE TABLE statement that contains more
  than one PRIMARY KEY constraint shall fail with an error.
}
syntaxreq {H42516} {} {} {
  The preparation of a CREATE TABLE statement that contains a
  CHECK constraint that uses a subquery shall fail with an error.
}
syntaxreq {H42517} {} {} {
  The preparation of a CREATE TABLE statement that contains a
  CHECK constraint that uses a parameter shall fail with an error.
}
syntaxreq {H42518} {} {} {
  Name resolution of the <i>expr</i> with each CHECK constraint of
  a CREATE TABLE statement shall be carried out using a name context
  with an empty result set and a source set holding
  single source element that is the
  table being created.
}
syntaxreq {H42521} {} {} {
  The preparation of a CREATE TABLE statement that contains a
  DEFAULT constraint with an non-constant expression
  shall fail with an error.
}
syntaxreq {H42536} {} {
  Except for the special case of INTEGER PRIMARY KEY, a
  PRIMARY KEY is just an alias for UNIQUE.
} {
  A PRIMARY KEY constraint that does not result in a rowid alias
  shall have the same effect as a UNIQUE constraint.
}
syntaxreq {H42539} {} {} {
  Preparation of a CREATE TABLE statement shall fail with an
  error if the <i>indexlist</i> of either a table PRIMARY KEY
  or a table UNIQUE constraint references a column that is not
  a column in the table.
}


syntaxreq {H42570} {} {
  Foreign key constraints are parsed for compatibility with other
  database engines but are not enforced by SQLite.
} {
  The SQLite parser shall accept the following syntax for a foreign
  key constraint as either a separate constraint or as part of a 
  column constraint in an [ordinary CREATE TABLE statement].
} {
  foreign_key_constraint ::= REFERENCES name indexlist_opt fkarglist.
  defer_opt ::= .
  defer_opt ::= deferrable_constraint.
  deferrable_constraint ::= NOT DEFERRABLE initially_deferred_clause.
  deferrable_constraint ::= DEFERRABLE initially_deferred_clause.
  fkarglist ::= .
  fkarglist ::= fkarglist fkarg.
  fkarg ::= MATCH name.
  fkarg ::= ON DELETE fkaction.
  fkarg ::= ON UPDATE fkaction.
  fkarg ::= ON INSERT fkaction.
  fkaction ::= SET NULL.
  fkaction ::= SET DEFAULT.
  fkaction ::= CASCADE.
  fkaction ::= RESTRICT.
  initially_deferred_clause ::= .
  initially_deferred_clause ::= INITIALLY DEFERRED.
  initially_deferred_clause ::= INITIALLY IMMEDIATE.
}
</tcl>

<h4>3.1.2 CREATE TABLE AS</h4>

<tcl>
syntaxreq {H42610} {} {
  The CREATE TABLE AS statement generates a new table to hold the
  result set of a SELECT statement.
} {
  The SQLite parser shall accept the following syntax for creating new
  database tables from the result set of SELECT statements.
} {
  table_definition ::= AS select.
}
syntaxreq {H42613} {} {
  The names of the columns in the generated table are taken from the
  column names of the SELECT statement.  All other attributes of the
  generated table are the default attributes for a column.  Hence, the
  table generated by a CREATE TABLE AS as the same behavior as an
  ordinary CREATE TABLE where the <i>table_definition</i> consists of
  a comma-separated list of column names with no datatypes or constraints
  of any kind.
} {
  The table generated by a CREATE TABLE AS statement shall have the
  same number of columns as the result set of the SELECT.
}
syntaxreq {H42616} {} {} {
  The names of the columns in a table generated by a CREATE TABLE AS
  statement shall have base names which are the names of the columns
  in the result set of the SELECT statement
}
syntaxreq {H42617} {} {} {
  Each column name in a table generated by a CREATE TABLE AS
  statement shall have an arbitrary suffix appended to its basename
  if and only if such a suffix is necessary to make the name
  distinct from all preceding column names in the table.
}
syntaxreq {H42619} {} {} {
  All columns in a table generated by a CREATE TABLE AS statement
  shall have a default value of NULL.
}
syntaxreq {H42622} {} {} {
  All columns in a table generated by a CREATE TABLE AS statement
  shall have a NULL conflict resolution behavior of NONE.
}
syntaxreq {H42625} {} {} {
  All columns in a table generated by a CREATE TABLE AS statement
  shall have an affinity of NONE.
}
syntaxreq {H42628} {} {} {
  All columns in a table generated by a CREATE TABLE AS statement
  shall have a default collating sequence of BINARY.
}

</tcl>


<h3>3.2 DROP TABLE</h3>

<tcl>
syntaxreq {H42700} {} {} {
  The SQLite parser shall accept DROP TABLE statements
  that conform to the following syntax.
} {
  cmd ::= DROP TABLE ifexists fullname.
  ifexists ::= .
  ifexists ::= IF EXISTS.
}
syntaxreq {H42710} {} {} {
  The preparation of a DROP TABLE statement shall fail with an
  error if the statement lacks an IF EXISTS clause and the
  <i>fullname</i> does not reference a existing table.
}
syntaxreq {H42713} {} {} {
  The evaluation of a DROP TABLE statement shall be a silent no-op
  if the the statement has an IF EXISTS clause and the
  <i>fullname</i> does not reference a existing table.
}
syntaxreq {H42716} {} {} {
  The successful evaluation of a DROP TABLE statement shall cause
  the table identified by <i>fullname</i> to be removed from its
  database and discarded.
}
syntaxreq {H42719} {} {} {
  The successful evaluation of a DROP TABLE statement shall cause
  all indices attached to the table identified by <i>fullname</i>
  to be removed from their database and discarded.
}
syntaxreq {H42721} {} {} {
  The successful evaluation of a DROP TABLE statement shall cause
  all triggers attached to the table identified by <i>fullname</i>
  to be removed from their database and discarded.
}
syntaxreq {H42724} {} {} {
  The preparation of a DROP TABLE statement shall fail with an
  error if <i>fullname</i> is a system table.
}
</tcl>

<h3>3.3 CREATE INDEX</h3>

<tcl>
syntaxreq {H42800} {} {} {
  The SQLite parser shall accept CREATE INDEX statements that 
  conform to the following syntax:
} {
  cmd ::= CREATE unique INDEX ifnotexists fullname ON tablename LP indexlist RP.
  tablename ::= name.
  indexlist ::= indexlist COMMA columnname collate sortorder.
  indexlist ::= columnname collate sortorder.
  columnname ::= name.
  collate ::= .
  collate ::= COLLATE identifier.
  sortorder ::= .
  sortorder ::= ASC.
  sortorder ::= DESC.
}
syntaxreq {H42803} {} {} {
  The target database of a CREATE INDEX statement shall be the 
  <i>databasename</i> specified in the <i>fullname</i> term of the
  statement if the <i>databasename</i> exists.
}
syntaxreq {H42806} {} {} {
  If the <i>fullname</i> term of a CREATE INDEX statement does not
  specify a <i>databasename</i> and the <i>tablename</i> references a table 
  that is in the "temp" database, then the target database for the statement
  shall be "temp".
}
syntaxreq {H42809} {} {} {
  If the <i>fullname</i> term of a CREATE INDEX statement does not
  specify a <i>databasename</i> and the <i>tablename</i> references a table
  that is not in the "temp" database, then the target database for the
  statement shall be "main".
}
syntaxreq {H42812} {} {} {
  The preparation of a CREATE INDEX statement shall fail with an error if the
  <i>databasename</i> of the <i>fullname</i> exists and references a database 
  that is not attached to the same [database connection].
}
syntaxreq {H42815} {} {} {
  The preparation of a CREATE INDEX statement shall fail with an error if the
  <i>tablename</i> does not reference an ordinary table in the
  database of the statement.
}
syntaxreq {H42818} {} {} {
  A successful evaluation of a CREATE INDEX statement shall create a 
  new index called <i>objectname</i>
  in the database of the statement and attached to the
  table identified by <i>tablename</i> in that same database.
}
syntaxreq {H42821} {} {} {
  An index generated by a CREATE INDEX statement that omits the
  UNIQUE keyword shall have a conflict resolution behavior
  of NONE.
}
syntaxreq {H42824} {} {} {
  An index generated by a CREATE INDEX statement that includes the
  UNIQUE keyword shall have a conflict resolution behavior
  of ABORT.
}
syntaxreq {H42830} {} {} {
  The preparation of a CREATE INDEX statement shall fail with an error if any
  <i>columnname</i> value within the <i>indexlist</i> is not the
  name of one of the columns of the <i>tablename</i> table.
}
syntaxreq {H42833} {} {
  The following rules regarding default collating sequences and
  sort order for indices applies both to indices created by CREATE INDEX
  statements
  and also by UNIQUE or PRIMARY KEY constraints on the table definition.
} {
  The collating sequence for each column of an index shall be the
  collating sequence specified in the <i>indexlist</i>.
}
syntaxreq {H42836} {} {} {
  If an index column does not specify a collating sequence then
  the collating sequence shall be
  the default collating sequence of the corresponding table column.
}
syntaxreq {H42839} {} {} {
  The sort order for an index column shall be descending if and only
  if the DESC keyword is used in the <i>indexlist</i> entry for that
  term.
}
syntaxreq {H42842} {} {} {
  The preparation of a CREATE INDEX statement shall fail with an error
  if the <i>tablename</i> refers to a system table.
}

</tcl>

<h3>3.4 DROP INDEX</h3>

<tcl>
syntaxreq {H42900} {} {} {
  The SQLite parser shall accept DROP INDEX statements 
  that conform to the following syntax:
} {
  cmd ::= DROP INDEX ifexists fullname.
}
syntaxreq {H42910} {} {} {
  The preparation of a DROP INDEX statement shall fail with an
  error if the statement lacks an IF EXISTS clause and the
  <i>fullname</i> does not reference a existing index.
}
syntaxreq {H42913} {} {} {
  The evaluation of a DROP INDEX statement shall be a silent no-op
  if the the statement has an IF EXISTS clause and the
  <i>fullname</i> does not reference a existing index.
}
syntaxreq {H42916} {} {} {
  The successful evaluation of a DROP INDEX statement shall cause
  the index identified by <i>fullname</i> to be removed from its
  database and discarded.
}
</tcl>

<h3>3.5 CREATE VIEW</h3>

<tcl>
syntaxreq {H43100} {} {} {
  The SQLite parser shall accept CREATE VIEW statements 
  that conform to the following syntax:
} {
  cmd ::= CREATE temp VIEW ifnotexists fullname AS select.
}
syntaxreq {H43113} {} {} {
  When the TEMP keyword appears in a CREATE VIEW statement and the
  <i>databasename</i> exists and is something other than "temp", then
  the preparation of the CREATE VIEW statement shall fail with an error.
}
syntaxreq {H43116} {} {} {
  When the TEMP keyword appears in a CREATE VIEW statement the behavior
  shall be as if the <i>databasename</i> where "temp".
}
syntaxreq {H43119} {} {} {
  The successful evaluation of a CREATE VIEW statement shall cause
  a new view whose name is given by the <i>objectname</i> and is located
  in the schema of the database whose name is given by the
  <i>databasename</i>.
}
syntaxreq {H43122} {} {} {
  If a CREATE VIEW statement specifies no <i>databasename</i> and omits
  the TEMP keyword then the behavior shall be as if a <i>databasename</i>
  of "main" where used.
}
syntaxreq {H43125} {} {} {
  The preparation of a CREATE VIEW statement shall fail with an 
  error if the IF NOT EXISTS clause is omitted and the <i>objectname</i>
  is the same as the name of a table or view
  in the same database.
}
syntaxreq {H43128} {} {} {
  The evaluation of a CREATE VIEW statement shall be a silent no-op if the
  IF NOT EXISTS clause is present and the <i>objectname</i>
  is the same as the name of a table or view
  in the same database.
}
syntaxreq {H43131} {} {} {
  The preparation of a CREATE VIEW statement shall fail with an error if the
  the <i>objectname</i> is the same as the name of an index
  in any database attached to the same [database connection].
}
syntaxreq {H43234} {} {} {
  The preparation of a CREATE VIEW statement shall fail with an error if the
  the <i>databasename</i> references a database that is not
  attached to the same [database connection].
}
syntaxreq {H43237} {} {} {
  The view generated by a CREATE VIEW statement shall have the
  same number of columns as the result set of the SELECT.
}
syntaxreq {H43241} {} {} {
  The names of the columns in a view generated by a CREATE VIEW
  statement shall have base names which are the names of the columns
  in the result set of the SELECT statement
}
syntaxreq {H43244} {} {} {
  Each column name in a table generated by a CREATE VIEW
  statement shall have an arbitrary suffix appended to its basename
  if and only if such a suffix is necessary to make the name
  distinct from all preceding column names in the view.
}
</tcl>

<h3>3.6 DROP VIEW</h3>

<tcl>
syntaxreq {H43200} {} {} {
  The SQLite parser shall accept DROP VIEW statements
  that conform to the following syntax:
} {
  cmd ::= DROP VIEW ifexists fullname.
}
syntaxreq {H43204} {} {} {
  The preparation of a DROP VIEW statement shall fail with an
  error if the statement lacks an IF EXISTS clause and the
  <i>fullname</i> does not reference a existing view.
}
syntaxreq {H43207} {} {} {
  The evaluation of a DROP VIEW statement shall be a silent no-op
  if the the statement has an IF EXISTS clause and the
  <i>fullname</i> does not reference a existing view.
}
syntaxreq {H43211} {} {} {
  The successful evaluation of a DROP VIEW statement shall cause
  the view identified by <i>fullname</i> to be removed from its
  database and discarded.
}
syntaxreq {H43214} {} {} {
  The successful evaluation of a DROP VIEW statement shall cause
  all triggers attached to the view identified by <i>fullname</i>
  to be removed from their database and discarded.
}
</tcl>

<h3>3.7 CREATE TRIGGER</h3>

<tcl>
syntaxreq {H43300} {} {} {
  The SQLite parser shall accept CREATE TRIGGER statements
  that conform to the following syntax:
} {
  cmd ::= CREATE temp TRIGGER ifnotexists fullname trigger trigger_body.
  trigger ::= trigger_time trigger_event foreach_clause when_clause.
  trigger_body ::= BEGIN trigger_cmd_list END.
  trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI.
  trigger_cmd_list ::= trigger_cmd_list.
  trigger_cmd ::= DELETE FROM tablename where.
  trigger_cmd ::= update_cmd tablename SET setlist where.
  trigger_cmd ::= insert_cmd INTO tablename columnlist_opt VALUES LP exprlist RP.
  trigger_cmd ::= insert_cmd INTO tablename columnlist_opt select.
  trigger_cmd ::= select.
  trigger_event ::= DELETE ON trigger_target.
  trigger_event ::= INSERT ON trigger_target.
  trigger_event ::= UPDATE OF columnlist ON trigger_target.
  trigger_event ::= UPDATE ON trigger_target.
  trigger_target ::= fullname.
  trigger_time ::= AFTER.
  trigger_time ::= BEFORE.
  trigger_time ::= INSTEAD OF.
  trigger_time ::=.
  foreach_clause ::= FOR EACH ROW.
  foreach_clause ::=.
  when_clause ::= WHEN expr.
  when_clause ::=.
}
syntaxreq {H43303} {} {} {
  When the TEMP keyword appears in a CREATE TRIGGER statement and the
  <i>databasename</i> of the <i>fullname</i> exists
  then the preparation of the statement
  shall fail with an error.
}
syntaxreq {H43306} {} {} {
  When the TEMP keyword appears in a CREATE TRIGGER statement 
  the target database of the trigger shall be "temp".
}
syntaxreq {H43309} {} {} {
  When the TEMP keyword is omitted in a CREATE TRIGGER statement and the
  <i>databasename</i> of the <i>fullname</i> is
  omitted then the target database of the trigger shall be "main".
}
syntaxreq {H43312} {} {} {
  When the <i>databasename</i> of <i>fullname</i> in a CREATE TRIGGER
  statement exists, then the target database shall be the database
  named by <i>databasename</i>.
}
syntaxreq {H43315} {} {} {
  If a CREATE TRIGGER does not specify a <i>trigger_time</i> then
  the <i>trigger_time</i> shall be BEFORE.
}
syntaxreq {H43318} {} {
  An INSTEAD OF trigger may be used only on views.  Other kinds of triggers
  may be used on tables only.
} {
  The preparation of a CREATE TRIGGER statement shall fail with an error
  the <i>trigger_time</i> is INSTEAD OF and <i>trigger_target</i> is not
  the name of view in the target database.
}
syntaxreq {H43321} {} {} {
  The preparation of a CREATE TRIGGER statement shall fail with an error
  the <i>trigger_time</i> is not INSTEAD OF and <i>trigger_target</i> is not
  the name of an ordinary table in the target database.
}
syntaxreq {H43324} {} {} {
  The preparation of a CREATE TRIGGER statement shall fail with an error
  if the <i>trigger_target</i> is a system table.
}

</tcl>


<h3>3.8 DROP TRIGGER</h3>

<tcl>
syntaxreq {H43500} {} {} {
  The SQLite parser shall accept DROP TRIGGER statements
  that conform to the following syntax:
} {
  cmd ::= DROP TRIGGER ifexists fullname.
}
syntaxreq {H43504} {} {} {
  The preparation of a DROP TRIGGER statement shall fail with an
  error if the statement lacks an IF EXISTS clause and the
  <i>fullname</i> does not reference a existing trigger.
}
syntaxreq {H43507} {} {} {
  The evaluation of a DROP TRIGGER statement shall be a silent no-op
  if the the statement has an IF EXISTS clause and the
  <i>fullname</i> does not reference a existing trigger.
}
syntaxreq {H43511} {} {} {
  The successful evaluation of a DROP TRIGGER statement shall cause
  the trigger identified by <i>fullname</i> to be removed from its
  database and discarded.
}
syntaxreq {H43514} {} {} {
  The successful evaluation of a DROP TRIGGER statement shall cause
  all triggers attached to the trigger identified by <i>fullname</i>
  to be removed from their database and discarded.
}
</tcl>

<h3>3.9 CREATE VIRTUAL TABLE</h3>

<tcl>
syntaxreq {H43600} {} {} {
  The SQLite parser shall accept CREATE VIRTUAL TABLE statements
  that conform to the following syntax.
} {
  cmd ::= CREATE VIRTUAL TABLE fullname USING name vtab_arg_list.
  vtab_arg_list ::= .
  vtab_arg_list ::= LP vtab_arg_token RP.
  vtab_arg_token ::= ANY.
  vtab_arg_token ::= LP anylist RP.
  anylist ::= .
  anylist ::= anylist ANY.
}
</tcl>

<h3>3.10 ALTER TABLE</h3>
<h4>3.11 ALTER TABLE RENAME</h4>

<tcl>
syntaxreq {H43700} {} {} {
  The SQLite parser shall accept ALTER TABLE RENAME statements
  that conform to the following syntax:
} {
  cmd ::= ALTER TABLE fullname RENAME TO name.
}
</tcl>

<h4>3.12 ALTER TABLE ADD COLUMN</h4>

<tcl>
syntaxreq {H43750} {} {} {
  The SQLite parser shall accept ALTER TABLE ADD COLUMN statements
  that conform to the following syntax:
} {
  cmd ::= ALTER TABLE fullname ADD column_keyword column.
  column_keyword ::= .
  column_keyword ::= COLUMNKW.
}
</tcl>

<h2>4.0 Data Manipulation Language (DML)</h2>

<h3>4.1 INSERT</h3>
<tcl>
syntaxreq {H43810} {} {} {
  The SQLite parser shall accept INSERT statements that
  conform to the following syntax:
} {
  cmd ::= insert_cmd INTO fullname columnlist_opt insert_content.
  insert_cmd ::= INSERT.
  insert_cmd ::= REPLACE.
  insert_cmd ::= INSERT OR REPLACE.
  insert_cmd ::= INSERT OR IGNORE.
  insert_cmd ::= INSERT OR ABORT.
  insert_cmd ::= INSERT OR FAIL.
  insert_cmd ::= INSERT OR ROLLBACK.
  columnlist_opt ::= .
  columnlist_opt ::= LP columnlist RP.
  columnlist ::= columnname.
  columnlist ::= columnlist COMMA columnname.
}
syntaxreq {H43813} {} {} {
  The preparation of an INSERT statement shall fail with an error
  if the <i>instcolist</i> contains a reference to a column which
  is not a column in the table identified by <i>fullname</i> and is
  not one of the special column named "ROWID", "OID", or "_ROWID_".
}
syntaxreq {H43816} {} {} {
  The preparation of an INSERT statement shall fail with an error
  if <i>fullname</i> does not identify either a view with an
  INSTEAD OF INSERT trigger or a table.
}
syntaxreq {H43819} {} {} {
  The preparation of an INSERT statement shall fail with an error
  if the <i>objectname</i> of the <i>fullname</i> is "sqlite_master"
  or "sqlite_temp_master" and the database connection is not in
  writeable schema mode.
}
syntaxreq {H43821} {} {} {
  When the form of an INSERT statement is simply "INSERT" then the
  default null- and uniqueness-conflict resolution algorithms shall
  be used.
}
syntaxreq {H43824} {} {} {
  When the form of an INSERT statement is simply "REPLACE" then the
  null- and uniqueness-conflict resolution algorithms shall all
  change to REPLACE.
}
syntaxreq {H43827} {} {} {
  When the form of an INSERT statement is "INSERT OR <i>algorithm</i>" 
  then the null- and uniqueness-conflict resolution algorithms shall all
  change to <i>algorithm</i>.
}
syntaxreq {H43831} {} {} {
  Name resolution in the <i>insert_content</i> term of an INSERT statement
  shall be carried out using a name context
  with an empty result set and a source set holding
  single source element that is the <i>fullname</i> table.
}
</tcl>

<h4>4.1.1 INSERT VALUE</h4>
<tcl>
syntaxreq {H43840} {} {} {
  The SQLite parser shall accept INSERT VALUE statements that
  conform to the following syntax:
} {
  insert_content ::= VALUES LP exprlist RP.
}
syntaxreq {H43843} {} {} {
  The preparation of an INSERT VALUE statement shall fail with an
  error if the <i>columnlist</i> element exists and the number of 
  entries in the <i>instcollist</i> is different
  from the number of entries in the <i>exprlist</i>.
}
syntaxreq {H43846} {} {} {
  The preparation of an INSERT VALUE statement shall fail with an
  error if the <i>columnlist</i> element does not exists and the number of 
  entries in the <i>exprlist</i> is different
  from the number of columns in the table or view identified by
  <i>fullname</i>.
}
</tcl>

<h4>4.1.2 INSERT SELECT</h4>
syntaxreq {H43870} {} {} {
  The SQLite parser shall accept INSERT SELECT statements that
  conform to the following syntax:
} {
  insert_contents ::= select.
}
syntaxreq {H43873} {} {} {
  The preparation of an INSERT SELECT statement shall fail with an
  error if the <i>columnlist</i> element exists and the number of 
  entries in the <i>instcollist</i> is different
  from the number of columns in the result set of <i>select</i>.
}
syntaxreq {H43876} {} {} {
  The preparation of an INSERT SELECT statement shall fail with an
  error if the <i>columnlist</i> element does not exists and the number of 
  columns in the result set of the <i>select</i> is different
  from the number of columns in the table or view identified by
  <i>fullname</i>.
}
</tcl>
<h4>4.1.3 INSERT DEFAULT</h4>
<tcl>
syntaxreq {H43890} {} {} {
  The SQLite parser shall accept INSERT DEFAULT statements that
  conform to the following syntax:
} {
  insert_contents ::= DEFAULT VALUES.
}
</tcl>

<h3>4.2 DELETE</h3>

<tcl>
syntaxreq {H43900} {} {} {
  The SQLite parser shall accept DELETE statements that
  conform to the following syntax:
} {
  cmd ::= DELETE FROM fullname where.
  where ::= .
  where ::= WHERE expr.
}
syntaxreq {H43904} {} {} {
  The preparation of a DELETE statement shall fail with an error if
  the <i>fullname</i> element does not identify a view with an
  INSTEAD OF DELETE trigger or a table.
}
syntaxreq {H43907} {} {} {
  The preparation of a DELETE statement shall fail with an error if
  the <i>objectname</i> of the <i>fullname</i> element is "sqlite_master"
  or "sqlite_temp_master" and the database connection is not in
  writeable_schema mode.
}
syntaxreq {H43911} {} {} {
  Name resolution in the <i>where</i> term of a DELETE statement
  shall be carried out using a name context
  with an empty result set and a source set holding
  single source element that is the <i>fullname</i> table.
}
</tcl>

<h3>4.3 UPDATE</h3>

<tcl>
syntaxreq {H44100} {} {} {
  The SQLite parser shall accept UPDATE statements that
  conform to the following syntax:
} {
  cmd ::= update_cmd fullname SET setlist where.
  update_cmd ::= UPDATE.
  update_cmd ::= UPDATE OR IGNORE.
  update_cmd ::= UPDATE OR REPLACE.
  update_cmd ::= UPDATE OR ABORT.
  update_cmd ::= UPDATE OR FAIL.
  update_cmd ::= UPDATE OR ROLLBACK.
  setlist ::= setting.
  setlist ::= setlist COMMA setting.
  setting ::= columnname EQ expr.
}
syntaxreq {H44113} {} {} {
  The preparation of an UPDATE statement shall fail with an error
  if any <i>columnname</i>
  is not a column in the table identified by <i>fullname</i> and is
  not one of the special columns named "ROWID", "OID", or "_ROWID_".
}
syntaxreq {H44116} {} {} {
  The preparation of an UPDATE statement shall fail with an error
  if <i>fullname</i> does not identify either a view with an
  INSTEAD OF UPDATE trigger that covers all <i>columnname</i>s or a table.
}
syntaxreq {H44119} {} {} {
  The preparation of an UPDATE statement shall fail with an error
  if the <i>objectname</i> of the <i>fullname</i> is "sqlite_master"
  or "sqlite_temp_master" and the database connection is not in
  writeable schema mode.
}
syntaxreq {H44121} {} {} {
  When the form of an UPDATE statement is simply "UPDATE" then the
  default null- and uniqueness-conflict resolution algorithms shall
  be used.
}
syntaxreq {H44127} {} {} {
  When the form of an UPDATE statement is "UPDATE OR <i>algorithm</i>" 
  then the null- and uniqueness-conflict resolution algorithms shall all
  change to <i>algorithm</i>.
}
syntaxreq {H44131} {} {} {
  Name resolution in the <i>where</i> term of a DELETE statement
  shall be carried out using a name context
  with an empty result set and a source set holding
  single source element that is the <i>fullname</i> table.
}
</tcl>

<h3>4.4 SELECT</h3>

<tcl>
syntaxreq {H45000} {} {} {
  The SQLite parser shall accept SELECT statements that
  conform to the following syntax:
} {
  cmd ::= select.
  select ::= query.
  select ::= select UNION query.
  select ::= select UNION ALL query.
  select ::= select EXCEPT query.
  select ::= select INTERSECT query.
  query ::= SELECT distinct resultset from where groupby having orderby limit.
  distinct ::= .
  distinct ::= DISTINCT.
  groupby ::= .
  groupby ::= GROUP BY exprlist.
  having ::= .
  having ::= HAVING expr.
  orderby ::= .
  orderby ::= ORDER BY exprlist.
  limit ::=.
  limit ::= LIMIT expr.
  limit ::= LIMIT expr COMMA expr.
  limit ::= LIMIT expr OFFSET expr.
  resultset ::= result.
  resultset ::= resultset COMMA result.
  result ::= STAR.
  result ::= tablename DOT STAR.
  result ::= expr as.
  from ::= .
  from ::= FROM sourceset.
  sourceset ::= source.
  sourceset ::= sourceset joinop source.
  source ::= fullname as on using.
  source ::= LP select RP as on using.
  as ::= .
  as ::= AS name.
  as ::= identifier.
  on ::= .
  on ::= ON expr.
  using ::= .
  using ::= USING LP columnlist RP.
  joinop ::= COMMA.
  joinop ::= JOIN.
  joinop ::= JOIN_KW JOIN.
  joinop ::= JOIN_KW JOIN_KW JOIN.
  joinop ::= JOIN_KW JOIN_KW JOIN_KW JOIN.
}
syntaxreq {H45003} {} {
  A sequence of <i>query</i> terms connected by UNION, UNION ALL, EXCEPT,
  and/or INTERSECT operators is called a "compound query" and the individual
  <i>query</i> terms are call "terms of the compound query".
} {
  The preparation of a statement containing a <i>select</i>
  shall fail with an error if the <i>select</i> contains
  two terms of the same compound query having a different number of columns
  in their result sets.
}
syntaxreq {H45006} {} {} {
  The preparation of a statement containing a <i>select</i>
  shall fail with an error if the <i>select</i> contains a compound query that
  has an ORDER BY, GROUP BY, HAVING, or LIMIT clause on any term of than
  the right-most.
}
syntaxreq {H45009} {} {} {
  The preparation of a statement containing a <i>select</i>
  shall fail with an error if the <i>select</i> contains a compound query with
  an ORDER BY or GROUP BY clause with a term that is not either
  a token-by-token duplicate of the result columns of one of the
  compound query terms, or the "AS" name of one of the compound
  query terms, or a compile-time integer between 1 and N where N is
  the number of columns in each compound query term.
}
syntaxreq {H45012} {} {} {
  The preparation of a statement containing a <i>select</i>
  shall fail with an error if the <i>select</i> contains a join with two
  or more of the following properties:
  <ol>
  <li> The NATURAL keyword in the <i>joinop</i> </li>
  <li> An ON clause </li>
  <li> A USING clause</li>
  </ol>
}
syntaxreq {H45015} {} {} {
  The preparation of a statement containing a <i>select</i>
  shall fail with an error if the <i>select</i> contains a <i>joinop</i>
  that uses the keywords RIGHT or FULL.
}
syntaxreq {H45018} {} {} {
  The preparation of a statement containing a <i>select</i>
  shall fail with an error if the <i>select</i> contains a <i>joinop</i>
  that uses either of the keywords OUTER or LEFT
  together with either INNER or CROSS.
}
syntaxreq {H45021} {} {} {
  The preparation of a statement containing a <i>select</i>
  shall fail with an error if the <i>select</i> contains a <i>using</i>
  that names columns that are not found in both the table to the
  immediate right of the join and in the result set of all tables
  to the left of the join.
}
syntaxreq {H45024} {} {} {
  The preparation of a statement containing a <i>select</i>
  shall fail with an error if the <i>fullname</i> of a <i>source</i>
  does not refer to an existing table or view.
}
syntaxreq {H45027} {} {} {
  The preparation of a statement containing a <i>limit</i>
  shall fail with an error if any <i>expr</i> within the <i>limit</i>
  does not evaluate to a compile-time integer.
}
</tcl>

<h4>4.4.1 Name resolution with SELECT statements</h4>

<tcl>
syntaxreq {H45103} {} {} {
  Name resolution of a top-level SELECT statement shall use an
  empty name context.
}
syntaxreq {H45106} {} {} {
  Name context of a <i>query</i> term shall be
  constructed by adding a new inner name context layer
  to the name context of the construct containing the <i>query</i>
  term.
}
syntaxreq {H45109} {} {} {
  Name resolution of the <i>resultset</i> of a <i>query</i> shall
  use the name context of the <i>query</i> with an empty result
  set and the source set
  configured to the <i>from</i> clause of the query.
}
syntaxreq {H45112} {} {} {
  Name resolution of all child terms of a <i>query</i> other than
  <i>resultset</i> child shall use the name context of the <i>query</i>
  with the result set configured to be the <i>resultset</i> clause of the
  <i>query</i> and with the source set configured to be the
  <i>from</i> clause of the query.
}
</tcl>

<h2>5.0 Other Language Elements</h2>

<h3>5.1 VACUUM</h3>

<tcl>
syntaxreq {H44200} {} {} {
  The SQLite parser shall accept VACUUM statements that
  conform to the following syntax:
} {
  cmd ::= VACUUM.
  cmd ::= VACUUM name.
}
</tcl>

<h3>5.2 ANALYZE</h3>

<tcl>
syntaxreq {H44300} {} {} {
  The SQLite parser shall accept ANALYZE statements
  that conform to the following syntax:
} {
  cmd ::= ANALYZE.
  cmd ::= ANALYZE fullname.
}
syntaxreq {H44303} {} {} {
  The preparation of an ANALYZE statement
  shall fail with an error if
  the <i>fullname</i> is included and does not evaluate to
  either an individual table name or the name of a database.
}
</tcl>

<h3>5.3 REINDEX</h3>

<tcl>
syntaxreq {H44400} {} {} {
  The SQLite parser shall accept REINDEX statements
  that conform to the following syntax:
} {
  cmd ::= REINDEX.
  cmd ::= REINDEX fullname.
}
syntaxreq {H44403} {} {} {
  The preparation of an ANALYZE statement
  shall fail with an error if
  the <i>fullname</i> is included and does not evaluate to
  either an individual table name or the name of a database
  or the name of a collating sequence.	
}
</tcl>

<h3>5.4 PRAGMA</h3>

<tcl>
syntaxreq {H46000} {} {} {
  The SQLite parser shall accept PRAGMA statements
  that conform to the following syntax:
} {
  cmd ::= PRAGMA fullname EQ DELETE.
  cmd ::= PRAGMA fullname EQ ON.
  cmd ::= PRAGMA fullname EQ name.
  cmd ::= PRAGMA fullname EQ expr.
  cmd ::= PRAGMA fullname LP name RP.
  cmd ::= PRAGMA fullname LP expr RP.
  cmd ::= PRAGMA fullname.
}
syntaxreq {H46003} {} {
  The <i>objectname</i> of the <i>fullname</i> of a PRAGMA is called
  the PRAGMA verb.
} {
  The evaluation of a PRAGMA statement with an unknown verb shall
  be a silent no-op.
}
</tcl>

<h3>5.5 ATTACH</h3>

<tcl>
syntaxreq {H44500} {} {
  The SQLite parser shall accept ATTACH statements
  that conform to the following syntax:
} {
  cmd ::= ATTACH database_kw expr AS expr.
  database_kw ::= .
  database_kw ::= DATABASE.
}
syntaxreq {H44503} {} {} {
  The <i>expr</i> terms of an ATTACH statement that are
  identifiers shall be interpreted as string literals.
}
syntaxreq {H44506} {} {} {
  The preparation of an ATTACH statement shall fail with an error
  if either <i>expr</i> is not a constant expression.
}
syntaxreq {H44509} {} {} {
  The preparation of an ATTACH statement shall fail with an error
  if the second <i>expr</i> evaluates to the name of a database
  that is already attached to the database connection.
}
</tcl>

<h3>5.6 DETACH</h3>

<tcl>
syntaxreq {H44600} {} {} {
  The SQLite parser shall accept DETACH statements
  that conform to the following syntax:
} {
  cmd ::= DETACH database_kw expr.
}
syntaxreq {H44603} {} {} {
  The <i>expr</i> term of an DETACH statement that is an
  identifier shall be interpreted as string literals.
}
syntaxreq {H44606} {} {} {
  The preparation of an DETACH statement shall fail with an error
  if the <i>expr</i> is not a constant expression.
}
syntaxreq {H44609} {} {} {
  The preparation of an DETACH statement shall fail with an error
  if the <i>expr</i> does not evaluate to the 
  name of an attached database other than "temp" or "main".
}
</tcl>

<h3>5.7 EXPLAIN</h3>

<tcl>
syntaxreq {H44700} {} {} {
  The SQLite parser shall accept the EXPLAIN keyword as a prefix
  to other valid SQL statements, as shown by the following syntax:
} {
  sql_statement ::= EXPLAIN cmd SEMI.
}
</tcl>

<h3>5.8 EXPLAIN QUERY PLAN</h3>

<tcl>
syntaxreq {H44800} {} {} {
  The SQLite parser shall accept EXPLAIN QUERY PLAY as a prefix
  to other valid SQL statements, as shown by the following syntax:
} {
  sql_statement ::= EXPLAIN QUERY PLAN cmd SEMI.
}
</tcl>

<h2>6.0 Common Language Subelements</h2>

<h3>6.1 Expressions</h3>

<tcl>
syntaxreq {H47000} {} {} {
  The SQLite parser shall accept expressions that
  conform to the following syntax:
} {
  expr ::= BITNOT expr.
  expr ::= CASE case_operand case_exprlist case_else END.
  expr ::= CAST LP expr AS typetoken RP.
  expr ::= EXISTS LP select RP.
  expr ::= function_name LP STAR RP.
  expr ::= function_name LP distinct exprlist RP.
  expr ::= LP expr RP.
  expr ::= LP select RP.
  expr ::= MINUS expr.
  expr ::= NOT expr.
  expr ::= PLUS expr.
  expr ::= RAISE LP IGNORE RP.
  expr ::= RAISE LP ABORT COMMA name RP.
  expr ::= RAISE LP FAIL COMMA name RP.
  expr ::= RAISE LP ROLLBACK COMMA name RP.
  expr ::= VARIABLE.
  expr ::= expr AND expr.
  expr ::= expr BITAND expr.
  expr ::= expr BITOR expr.
  expr ::= expr LSHIFT expr.
  expr ::= expr RSHIFT expr.
  expr ::= expr COLLATE ids.
  expr ::= expr CONCAT expr.
  expr ::= expr EQ expr.
  expr ::= expr NE expr.
  expr ::= expr IS NOT NULL.
  expr ::= expr IS NULL.
  expr ::= expr ISNULL
  expr ::= expr NOTNULL.
  expr ::= expr LT expr.
  expr ::= expr GT expr.
  expr ::= expr GE expr.
  expr ::= expr LE expr.
  expr ::= expr NOT NULL.
  expr ::= expr OR expr.
  expr ::= expr PLUS expr.
  expr ::= expr MINUS expr.
  expr ::= expr STAR expr.
  expr ::= expr SLASH expr.
  expr ::= expr REM expr.
  expr ::= expr BETWEEN expr AND expr.
  expr ::= expr NOT BETWEEN expr AND expr.
  expr ::= expr IN LP exprlist RP.
  expr ::= expr IN LP select RP.
  expr ::= expr IN fullname.
  expr ::= expr NOT IN LP exprlist RP.
  expr ::= expr NOT IN LP select RP.
  expr ::= expr NOT IN fullname.
  expr ::= expr LIKE_KW expr escape.
  expr ::= expr MATCH expr escape.
  expr ::= expr NOT LIKE_KW expr escape.
  expr ::= expr NOT MATCH expr escape.
  expr ::= rtvalue.
  expr ::= term.
  term ::= CTIME_KW.
  term ::= INTEGER.
  term ::= FLOAT
  term ::= BLOB.
  term ::= NULL.
  term ::= STRING.
  exprlist ::= expr.
  exprlist ::= exprlist COMMA expr.
  case_else ::= ELSE expr.
  case_else ::= .
  case_exprlist ::= WHEN expr THEN expr.
  case_exprlist ::= case_exprlist WHEN expr THEN expr.
  case_operand ::= expr.
  case_operand ::= .
  function_name ::= ID.
  escape ::= .
  escape ::= ESCAPE expr.
}
syntaxreq {H47003} {} {} {
  The unary PLUS, unary MINUS, and BITNOT operators shall have
  precedence over the COLLATE operator.
}
syntaxreq {H47006} {} {} {
  The COLLATE operator shall have precedence over the CONCAT
  operator.
}
syntaxreq {H47009} {} {} {
  The CONCAT operator shall have precedence over the STAR, SLASH,
  and REM operators.
}
syntaxreq {H47012} {} {} {
  The STAR, SLASH, and REM operator shall have equal precedence.
}
syntaxreq {H47015} {} {} {
  The STAR, SLASH, and REM operators shall have precedence over the
  binary PLUS and binary MINUS operators.
}
syntaxreq {H47018} {} {} {
  The binary PLUS and binary MINUS operators shall have equal precedence.
}
syntaxreq {H47021} {} {} {
  The binary PLUS and binary MINUS operators shall have precedence
  over the BITAND, BITOR, LSHIFT, and RSHIFT operators.
}
syntaxreq {H47024} {} {} {
  The BITAND, BITOR, LSHIFT, and RSHIFT operators shall have equal
  precendence.
}
syntaxreq {H47027} {} {} {
  The BITAND, BITOR, LSHIFT, and RSHIFT operators shall have precedence
  over the ESCAPE operator.
}
syntaxreq {H47029} {} {} {
  The ESCAPE operator shall have precedence over
  the GT, LE, LT, and GE operators.
}
syntaxreq {H47033} {} {} {
  The GT, LE, LT, and GE operators shall have equal precedence.
}
syntaxreq {H47036} {} {} {
  The GT, LE, LT, and GE operators shall have precedence over
  the IS, MATCH, LIKE_KW, BETWEEN, IN, ISNULL, NOTNULL, NE, and EQ
  operators shall have equal precedence.
}
syntaxreq {H47039} {} {} {
  The IS, MATCH, LIKE_KW, BETWEEN, IN, ISNULL, NOTNULL, NE, and EQ
  operators shall have equal precedence.
}
syntaxreq {H47042} {} {} {
  The IS, MATCH, LIKE_KW, BETWEEN, IN, ISNULL, NOTNULL, NE, and EQ
  operators shall have precedence over the unary NOT operator.
}
syntaxreq {H47045} {} {} {
  The unary NOT operator shall have precedence over the AND operator.
}
syntaxreq {H47048} {} {} {
  The AND operator shall have precedence over the OR operator.
}
syntaxreq {H47051} {} {} {
  Operators of equal precedence shall group from right to left.
}
</tcl>

<h3>6.2 Symbolic Names</h3>

<tcl>
syntaxreq {H49100} {} {} {
  The SQLite parser shall accept names, fullnames, and identifiers
  that conform to the following syntax:
} {
  name ::= ID.
  name ::= JOIN_KW.
  name ::= STRING.
  fullname ::= objectname.
  fullname ::= databasename DOT objectname.
  objectname ::= name.
  databasename ::= name.
  columnname ::= name.
  identifier ::= ID.
  identifier ::= STRING.
}
syntaxreq {H49103} {} {} {
  The SQLite parser shall accept <i>rtvalue</i> elements of an
  <i>expr</i> that conform to the following syntax:
} {
  rtvalue ::= databasename DOT tablename DOT columnname.
  rtvalue ::= tablename DOT columnname.
  rtvalue ::= ID.
  rtvalue ::= JOIN_KW.
}
</tcl>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Changes to pages/sysreq.in.
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
<title>SQLite System Requirements</title>
<tcl>
unset -nocomplain sysreq_list
proc sysreq {id derivedfrom explaination text} {
  global sysreq_list
  lappend sysreq_list $id $derivedfrom $text
  hd_fragment $id $id
  set dlist {}
  foreach d $derivedfrom {
    append dlist <$d>
  }
  hd_requirement $id $text$dlist
  if {[string length $explaination]} {
    hd_resolve "<p>$explaination</p>"
  }
  hd_puts "<blockquote><b>$id:</b>"
  hd_resolve $text
  hd_puts {</blockquote>}
}
</tcl>

<h1>System Requirements For SQLite</h1>

<p>This document outlines the high-level objectives of the SQLite
library.
All of the features and capabilities of SQLite can be traced back


to one of the requirements specified here.</p>

<p>SQLite is not a complete system and so the requirements
provided by this document are not system requirements in the
strict sense.  Perhaps "sub-system requirements" would be a better
term, since SQLite is always a sub-component of a larger system.</p>

<p>This document is targeted primarily at developers who are
working within a waterfall development model that uses detailed
requirements written with the modal auxiliary verb "shall".  
However, this document is also useful as a general-purpose high-level 
description of SQLite for developers who are not working under
different development paradigms.</p>

<h2>1.0 SQLite is a translator from SQL into low-level disk I/O</h2>

<tcl>
sysreq S10000 {} {
  SQLite is an SQL database engine.  And the fundamental task of
  every SQL database engine it to translate the abstract SQL statements
  readily understood by humans into sequences of I/O operations readily
  understood by computer hardware.  This requirement expresses the
  essense of SQLite.
} {
  The SQLite library shall translate high-level SQL statements into
  low-level I/O calls to persistent storage.
}

sysreq S10100 S10000 {
  SQL is one of the worlds most widely known programming languages,
  but it is also one of the most ill-defined.  There are various SQL
  standards documents available.  However the SQL standards documents are 
  obtuse to the point of being incomprehensible.  And the standards 
  allow for so much "implementation defined" behavior that there exist
  two SQL database engines understand exactly the same language.</p>
  
  <p>SQLite does not attempt to obtain strict compliance with any
  one of the various SQL standards.
  Instead, SQLite tries to be as compatible as possible with other SQL
  database engines.  SQLite attempts to operate on the principle of
  least surprise.  That is to say, experienced SQL programmers should
  find SQLite's dialect intuitive and natural.</p>
  
  <p>SQLite may omit some obscure features of SQLite.  And the SQL
  dialect that SQLite understands might contain some enhancements not
  found in some standards documents.  Nevertheless, applications
  written for other SQL database engines should be portable to SQLite
  with little to no change.  And programmers writing code for SQLite
  should not encounter anything unexpected.
} {
  The SQLite library shall accepts a well-defined dialect of SQL
  that conforms to published SQL standards.
}

sysreq S10110 S10100 {
  SQLite is able to hold content in various datatypes and sizes.
} {
  The SQLite library shall support BLOB, CLOB, integer, and floating-point
  datatypes.
}

sysreq S10120 S10100 {
  SQLite handles NULLs in accordance with SQL standards.  In cases where
  published standards are ambiguous, SQLite will follow the practice of
  other popular database engines.
} {
  The SQLite library shall implement the standard SQL interpretation
  of NULL values.
}


sysreq S10200 S10000 {
  Most other database
  engines implement a client/server model in which a small client library
  is linked with the application and the client communicates with a separate
  server process using interprocess communication (IPC).  SQLite avoids
  the complication of having a separate server process by doing direct
  I/O directly to the underlying filesystem.
} {  
  The SQLite library shall communicate directly with database files
  in persistent storage.
}


sysreq S10300 S10000 {
  In the database world, "ACID" is an acronym for Atomic, Consistent,
  Isolated, and Durable.  Atomic means that a change to the database
  happens either entirely or not at all.  Consistent means that if the
  database file is well-formed before the start of a transaction then
  it is guaranteed to be well-formed after the transaction commits.  
  Isolated means that when two or more threads are
  processes are working with the same database, uncommitted changes 
  made by one are not visible to the other.  Durable means that once
  a transaction commits, it stays committed even if there is a subsequent
  software crash or power failure.
} {
  The SQLite library shall implement ACID transactions.
}


sysreq S10500 S10000 {
  An operating system crash or an unexpected power loss can
  sometimes damage
  the underlying persistent storage in ways that no software can defend
  against.  (For example, the content of a disk drive might be completely
  erased and become unrecoverable.)
  Nevertheless, software can take steps to defend against the kinds
  of damage that typically occurs following operating system crashes and 
  power failures.  The usual damage is that some writes are missing
  or incomplete and that writes have occurred out of order.  We say
  that software is "robust" if it defines against the common kinds of
  damage seen following an operating system crash or power loss.</p>
} {
  The SQLite library shall implement transactions that are robust
  across application crashes, operating-system crashes, and power
  failures.
}


sysreq S10600 S10000 {
  Many applications benefit from being about to access multiple
  database file using the same database connection, so that 
  information can be transfered from from one database to another 
  atomically, or so that queries can join data across multiple
  databases.
} {  
  The SQLite library shall support simultaneous access to multiple
  database files on the same database connection.
}

sysreq S10700 S10000 {
  A database is of little practical use if one is unable to obtain
  information from the database.  Hence:
} {
  The SQLite library shall provide interfaces that allow the application
  to obtain the status and results of SQL operations.
}

</tcl>
<h2>2.0 SQLite is designed to be extensible by the application</h2>
<tcl>

sysreq S20000 {} {
  SQLite is intended to be an embedded database that functions well
  in resource-limited systems.  For that reason we desire to keep the
  size of the library small.  That choices argues against a large
  default function set.  Instead of having many built-in features, SQLite is
  designed to be extensible at compile-time and run-time with new
  application-defined functions and behaviors.
} {
  The SQLite library shall be extensible and configurable.
}

sysreq S20100 S20000 {
  SQLite works on common workstations and in embedded systems.
  Sometimes these devices, particularly embedded systems,
  have odd and unusual operating systems.  In order to support
  this level of portability, SQLite allows the interface to the operating
  system to be defined at run-time.
} {
  The SQLite library shall provide interfaces that permit the application
  to override interfaces to the platform on which the application is running.
}
sysreq S20110 S20100 {} {
  The SQLite library shall provide interfaces that permit the application
  to override the interfaces used to read and write persistent storage.
}
sysreq S20120 S20100 {} {
  The SQLite library shall provide interfaces that permit the application
  to override the interfaces used for memory allocation.
}
sysreq S20130 S20100 {} {
  The SQLite library shall provide interfaces that permit the application
  to override the interfaces used for controlling mutexes.
}

sysreq S20200 S20000 {
  Most SQL database engines support a rich set of SQL functions.
  SQLite, in contrast, supports only a select few SQL functions.
  But SQLite makes up for its dearth of built-in SQL functions by 
  allowing the application to create new SQL function easily.
} {
  The SQLite library shall provide interfaces that permit the application
  to create new SQL functions.
}


sysreq S20300 S20000 {
  By default, SQLite only understands ASCII text.  The tables needed
  to do proper comparisons and case folding
  of full unicode text are huge - much larger
  than the SQLite library itself.  And, any application that is dealing
  with unicode already probably already has those tables built in.  For
  SQLite to include unicode comparison tables would be redundant and wasteful.
  As a compromise, SQLite allows the application to specify alternative
  collating sequences for things such as unicode text,
  so that for applications that need such comparison sequences can have
  them easily while other applications that are content with ASCII are
  not burdened with unnecessary tables.
} {
  The SQLite library shall provide interfaces that permit the application
  to create new text collating sequences.
}

sysreq S20400 S20000 {
  A virtual table is an SQL object that appears to be an ordinary
  SQL table for the purposes of INSERT, UPDATE, DELETE, and SELECT statements.
  But instead of being backed by persistent storage, the virtual table is
  an object that responds programmatically to INSERT, UPDATE, DELETE, and
  SELECT requests.  Virtual tables have been used to implement full-text
  search and R-Tree indices, among other things.
} {
  The SQLite library shall provide interfaces that permit the application
  to create new classes of virtual SQL tables.
}

sysreq S20500 S20000 {
  Some applications choose to package extensions in separate
  shared library files and load those extensions at run-time on
  an as-needed basis.  Depending on the nature of the application,
  this can be an aid to configuration management, since it allows
  the extension to be updated without having to replace the core
  application.
} {
  The SQLite library shall provide interfaces that permit the application
  to load extensions at run-time using shared libraries.
}

sysreq S20600 S20000 {
  SQLite has finite limits.  For example, there is a maximum size BLOB
  or CLOB that SQLite will store, a maximum size to a database file,
  a maximum number of columns in a table or query, and a maximum depth
  of an expression parse tree.  All of these have default values that
  are sufficiently large that a typical application is very unlikely to 
  ever reach the limits.  But some applications (for example, applications
  that process content from untrusted and possibly hostile sources)
  might want to define much lower limits on some database connections for
  the purpose of preventing denial-of-service attacks.  Or, an application
  might want to select much lower limits in order to prevent over-utilization
  of limited resources on an embedded device.  Whatever the rationale, SQLite
  permits limits to be queried and set at run-time.
} {
  The SQLite library shall provide interfaces that permit the application
  to dynamically query and modify size limits.
}

</tcl>
<h2>3.0 SQLite is lightweight and leak-free</h2>
<tcl>

sysreq S30000 {} {
  SQLite is designed to work well within embedded devices with 
  very limited resources.  To this end, it expects to confront situations
  where memory is unavailable and where I/O operations fail and it is designed
  to handle such situations with ease and grace.  SQLite also avoids aggravating
  low-resource situations by correctly freeing rather than leaking 
  resources it uses itself.
} {
  The SQLite library shall be safe for use in long-running,
  low-resource, high-reliability applications.
}

sysreq S30100 S30000 {
  A "Proper shutdown" means that all resources that the application
  has allocated from SQLite have been released by the application.
  The leak-free operation guarantee of SQLite applies even if there
  have been memory allocation errors or I/O errors during operation.
} {
  The SQLite library shall release all system resources it holds
  when it is properly shutdown.
}

sysreq S30200 S30000 {
  Safety-critical systems typically disallow the use of malloc() and
  free() because one never knows when they might fail due to memory
  fragmentation.  However, SQLite makes extensive use of dynamic objects
  and so it must be able to allocate and deallocate memory
  to hold those objects.</p>
  
  <p>In order to be acceptable for use in safety critical systems,
  SQLite can be configured to use its own internal memory allocator
  which, subject to proper usage by the application, guarantees that
  memory allocation will never fail either due to memory fragmentation
  or any other cause.  The proof of correctness is due to J. M. Robson:
  "Bounds for Some Functions Concerning Dynamic Storage Allocations",
  Journal of the ACM, Volume 21, Number 3, July 1974.</p>
  
  <p>The internal memory allocator is seeded with a large contiguous
  block of memory at application start.  SQLite makes all of its
  internal memory allocations from this initial seed.  
  The Robson proof depends on SQLite being coupled to a well-behaved
  application.  The application must not try to use more than a
  precomputed fraction of the available memory - that fraction depending
  on the size ratio between the largest and smallest memory allocations.
  Additional details are provided elsewhere.
  For the purposes of this document, it is sufficient
  to state:
} {
  The SQLite library shall be configurable so that it is guaranteed
  to never fail a memory allocation as long as the application does
  not request resources in excess of reasonable and published limits.
}

sysreq S30210 S30200 {
  To help insure that an
  application never fails a memory allocation call, SQLite provides
  interfaces that can inform the application if its memory usage
  is growing close to or has exceeded the critical Robson limits.  
  In practice, the memory used by an application can exceed the 
  limits of the Robson proof by a wide margin with no harmful effect.  
  There is plenty of safety margin.  But the Robson proof does break 
  down once the limits are exceeded  
  and the guarantee that no memory allocation will fail is lost.  Hence
  it is important to be able to track how close an application has come
  to reaching critical limits.
} {
  The SQLite library shall be provide instrumentation that can alert
  the application when its resource usages nears or exceeds the limits
  of the memory breakdown guarantee.
}

sysreq S30220 S30200 {
  When SQLite comes under memory pressure, it can be configured to
  recycle memory from one use to another, thus helping to reduce the
  pressure.  "Memory pressure" means that memory available for 
  allocation is becoming less plentiful.  In a safety-critical application,
  memory pressure might mean that the amount of allocated memory is
  getting close to the point where the Robson proof
  breaks down.  On a workstation, memory pressure might mean that
  available virtual memory is running low.
} {
  The SQLite library shall be provide facilities to automatically
  recycle memory when usage nears preset limits.
}

sysreq S30230 S30200 {
  SQLite provides the ability to read and write megabyte
  or gigabyte blobs and text strings without having to allocate
  enough memory to hold the entire blob and string in memory all
  at once.  This enables SQLite to read and write BLOBs that
  are actually larger than the available memory on the device.
  It also helps reduce the size of the maximum memory allocation
  which helps keep memory usage below Robson limits and thus helps
  to guarantee failure-free memory allocation.
} {
  The SQLite library shall be permit BLOB and CLOB objects to be
  read and written incrementally using small memory buffers.
}

sysreq S30300 S30000 {
  Memory allocation problems do not cause SQLite to fail
  catastrophically.
  SQLite recognizes all memory allocation failures and either works 
  around them, or
  cleanly aborts what it is doing and returns to the application
  with an error that indicates insufficient memory was available.
  Assuming new memory becomes available, SQLite is able to continue 
  operating normally after a memory allocation failure.
} {
  When a memory allocation fails, SQLite shall either silently make
  due without the requested memory or else it shall report the error
  back to the application.
}

sysreq S30400 S30000 {
  SQLite responses sanely to disk I/O errors.  If it is unable
  to work around the problem, SQLite might have to report the error
  back up to the application.  In either case, SQLite is able to
  continue functioning, assuming of course that the I/O error was
  transient.
} {
  When a I/O operation fails, SQLite shall either silently 
  recover or else it shall report the error
  back to the application.
}

sysreq S30500 S30000 {
  SQLite is able to cleanly abort an operation in progress and
  afterwards continue functioning normally without any memory or
  other resource leaks.  An example of where this functionality is
  used occurs in the command-line interface (CLI) program for SQLite.
  If the user enters a query that has millions of result rows, those
  rows begin pouring out onto the screen.  The operator can then
  hit the interrupt key sequence (which varies from one operating
  system to another but it often Control-C) which causes the query
  to be aborted.
} {
  SQLite shall provide the capability to monitor
  the progress and interrupt the evaluation of a long-running query.
}

sysreq S30600 S30000 {
  When information is deleted from an SQLite database, the default
  action is for SQLite to mark the space as unused and then to reuse
  the space at the next opportune INSERT.  On devices where persistent 
  storage is scarce, however, it is sometime desirable to return the
  unused space back to the operating system.  SQLite supports this.
} {
  All unused portions of a well-formed SQLite database file shall
  be available for reuse.
}
sysreq S30700 S30000 {} {
  SQLite shall provide the capability to incrementally decrease the
  size of the persistent storage file as information is removed from
  the database.
}

sysreq S30800 S30000 {
  In consumer-grade software, it is often acceptable to run tests
  on an instrumented version of the code.  But for high-reliability
  systems, it is better to test the code exactly as it is deployed.
  The saying at NASA is "test what you fly and fly what you test."
  In support of this goal, SQLite includes interfaces whose only purpose
  is to observe internal state and to place SQLite into internal states
  for the testing.
} {
  SQLite shall provide the interfaces that support testing and
  validation of the library code in an as-delivered configuration.
}

sysreq S30900 S30000 {
  On resource-constrained devices, it is desirable to get double-duty
  out of resources where possible.
} {
  SQLite shall provide the ability for separate database connections
  within the same process to share resources.
}

</tcl>
<h2>4.0 SQLite is safe to use in multi-thread and multi-process
applications.</h2>
<tcl>

sysreq S40000 {} {
  In nearly all modern digital systems, there are many things happening
  at once.  And many of those things involve SQLite.
} {
  The SQLite library shall be safe for use in applications that
  make concurrent access to the underlying database from different
  threads and/or processes.
}

sysreq S40100 S40000 {
  The developers of SQLite believe that "thread-safe" is a
  self contradiction.  No application that includes multiple threads
  of control within the same address space is every truly "safe".
  And yet it is recognized that many developers want to
  create multithreaded applications and to use SQLite in those
  applications.  Therefore, SQLite is engineered to be "thread-safe".
} {
  The SQLite library shall be configurable to operate correctly in
  a multi-threaded application.
}

sysreq S40200 S40000 {
  Multiple database connections can be created and operated
  independently within the same thread or process.
} {
  The SQLite library shall support multiple independent database
  connections per thread and per process.
}

sysreq S40300 S40000 {
  SQLite uses both internal mutexes and external file locking to 
  ensure that two or more threads or processes working
  on the same database file play nicely with one another.
} {
  The SQLite library shall automatically control access to common
  databases from different connections in different threads or processes.
}
sysreq S40400 S40000 {} {
  The SQLite library shall notify the application if an operation can
  not be completed due to concurrent access constraints.
}
sysreq S40410 S40000 {
  If an SQL statement cannot be completed because another process is
  holding a lock on the database, then the application needs to be able
  to take corrective action, such waiting for the lock to clear.
} {
  The SQLite library shall provide interfaces to assist the application
  in responding appropriately when an operation can
  not be completed due to concurrent access constraints.
}

</tcl>
<h2>5.0 SQLite is cross-platform</h2>
<tcl>

sysreq S50000 {} {
  Cross-platform in this context means that the SQLite 
  can be used on a wide variety of operating systems and processors,
  ranging from small, special-purpose embedded systems, to workstations,
  to servers.  Platforms can be 32- or 64-bit, big-endian or little-endian.
  Cross-platform refers to the source code.  Obviously the SQLite would
  need to be recompiled in order to run on processors with different
  instruction sets.
} {
  The SQLite library shall be cross-platform.
}

sysreq S50100 S50000 {
  C has been called the "universal assembly language".
  Nearly all computer systems accept code written in C.
  Thus, to help make SQLite cross-platform:
} {
  The SQLite library shall be implemented in ANSI-C.
}

sysreq S50200 S50000 {
  SQLite stores text data as unicode.  Three separate unicode 
  representations are allowed:
} {
  The SQLite library shall support text encoded as UTF-8,
  UTF-16le, or UTF-16be.
}

sysreq S50300 S50000 {
  An SQLite database file can be freely moved between machine
  with different operating systems, different processors,
  different size integers, and different byte orders.  The same
  database file should work on any machine.
} {
  SQLite database files shall be processor and byte-order independent.
}

</tcl>
<h2>6.0 Introspection</h2>
<tcl>

sysreq S60000 {} {
  Some applications need to be able to discover characteristics of
  their environment at run-time and to make appropriate adjustments to
  their processing to accommodate the environment they find themselves in.
  SQLite attempts to support this need.
} {
  The SQLite library shall provide introspection capabilities to the
  application.
}

sysreq S60100 S60000 {
  Some applications are designed to work with different versions
  of SQLite which may or may not enable selected features.  For example,
  SQLite can be compiled to be threadsafe or not.  The threadsafe version
  works in multi-threaded applications.  The non-threadsafe build runs
  faster.  When an application is using an unknown version of SQLite
  it is important that it be able to determine the characteristics of
  the particular SQLite build it is using.
} {
  The SQLite library shall provide interfaces that an application can
  use to discover fixed, compile-time characteristics of the 
  SQLite library.
}

sysreq S60200 S60000 {
  In addition to the compile-time characteristics, SQLite allows
  the run-time settings of the library and of the underlying
  database file to be interrogated.
} {
  The SQLite library shall provide interfaces that an application can
  use to find run-time performance characteristics and status of the
  SQLite library.
}
sysreq S60300 S60000 {} {
  The SQLite library shall provide interfaces that permit an application
  to query the schema of a database.
}
sysreq S60400 S60000 {} {
  The SQLite library shall provide interfaces that allow an application
  to monitor sequence of queries and progress of submitted to SQLite.
}
sysreq S60500 S60000 {} {
  The SQLite library shall provide interfaces that allow an application
  to discover the algorithms that SQLite has chosen to implement specific
  SQL statements.
}

sysreq S60600 {S60000 S20200} {
  SQLite objects are often related.  For example, every prepared
  statement is associated with a database connection.  And every
  function context is associated with a prepared statement.  
  Applications and extensions frequently find it useful to be able
  to discover these relationships at runtime.  Hence:
} {
  The SQLite library shall provide interfaces that allow an application
  to discover relationships between SQLite objects.
}

</tcl>
<h2>7.0 Features to promote safe and robust application coding practices</h2>
<tcl>

sysreq S70000 {} {
  Many applications need to be able to safely process data or
  even SQL statements that are received from untrusted sources.
  An "SQL Injection Attack" occurs when an adversary intentionally
  introduces data that is designed to have undesirable side effects
  on the database files.  For example, suppose an application generates
  an INSERT statement as follows:</p>
  
  <blockquote><pre>
  snprintf(z, n, "INSERT INTO table1 VALUES('%s')", zUserData);
  </pre></blockquote>
  
  <p>If a hostile user supplies data that reads:</p>
  
  <blockquote><pre>
  beginning'); DELETE FROM table1; INSERT INTO table1 VALUES('
  </pre></blockquote>
  
  <p>Then the constructed INSERT statement would be transformed into
  three statements, the second of which is an undesired deletion of
  all prior content from the table.  SQLite contains interfaces that
  are designed to help applications avoid SQL injection attacks and
  similar problems.
} {
  The SQLite library shall provide interfaces that promote the safe
  construction and processing of SQL statements and data from
  untrusted sources.
}

sysreq S70100 S70000 {
  Some applications (for example
  <a href="http://www.cvstrac.org/">CVSTrac</a> and
  <a href="http://www.fossil-scm.org/">Fossil</a>) will run SELECT
  statements entered by anonymous users on the internet.  Such 
  applications want to be able to guarantee that a hostile users does
  not access restricted tables (such as the PASSWORD column of the USER
  table) or modify the database in any way.  SQLite supports the ability
  to analyze an arbitrary SQL statement to insure that it does not
  perform undesired operations.
} {
  The SQLite library shall provide the application means by which the
  application can test and enforce compliance with database access
  policies for any particular SQL statement.
}

sysreq S70200 S70000 {
  <p>Applications such as the command-line interface (CLI) for SQLite
  will prompt the user to enter SQL statements and will evaluate those
  statements as they are entered.  But sometimes an SQL statement spans
  multiple lines.  The CLI needs to know to issue a continuation prompt
  and await additional input if the input received so far is incomplete.
  SQLite supports interfaces that allow the CLI and similar applications
  to know if the input it has gathered so far is complete or if it needs
  to await additional input before processing the SQL.
} {
  The SQLite library shall provide interfaces that test to see if an
  SQL statement being received incrementally is complete.
}

sysreq S70300 {S70000 S30000} {
  The concept of a "prepared statement" allows an SQL statement to be
  parsed and compiled once and then reused many times.  This is a performance
  advantage in many applications.  In addition, binding values to variables
  in the prepared statement is safer than embedding values as literals because
  bound values do not need to be quoted in order to avoid an SQL injection
  attack.
} {
  The SQLite library shall support prepared statement objects with
  late parameter binding
}

</tcl>
<h2>8.0 Ductile Failure</h2>

<tcl>
sysreq S80000 {} {
  A common characteristic of digital systems (as opposed to analog
  systems) is that digital systems tend to be brittle.  In other words,
  digital systems tend to work perfectly with no sign of stress until 
  they fail utterly and completely.  The behavior is like a
  physical object that holds its shape as external
  loads increase, until it shatters without warning.</p>
  
  <p>In most circumstances, ductile failure is preferred over brittle
  failure.  A ductile device begins showing signs of
  trouble well in advance of failure.  Physical objects bend and/or crack,
  providing operators with warnings of overload and an opportunity
  to take corrective action, while continuing to function for as long
  as possible.</p>
  
  <p>Digital systems have a reputation for being brittle, yet brittleness
  is not an intrinsic property of digital systems.  Digital systems can
  be designed to continuing functioning outside their design parameters
  while providing operators with warning of possible trouble.  But there
  most be focused effort on the part of the designers to make digital
  systems ductile.  With analog systems, the ductileness tends to be
  inherent in the medium, but with digital systems ductileness needs
  to be explicitly added.
} {
  SQLite shall exhibit ductile failure characteristics
}

sysreq S80100 {S80000} {
  SQLite strives to deal gracefully with anomalous behavior by
  the application or by its own internal subsystems.  Yet graceful
  handling of out-of-band inputs is of no value if the anomaly goes
  unreported.  The problems must be visible to the
  application so that warnings and alarms can be propagated to operators.
  The useful aspect of ductile failure is that it gives advance warning.
  Ductile behavior is of no use to anyone if nobody can see the part
  bending.
} {
  SQLite shall make anomalies visible to the application
}

</tcl>
<h2>9.0 Summary Of System Requirements</h2>

<p>The foregoing contained both system requirements and explanatory
text interspersed.  The following is a reproduction of the system
requirements without the explanatory text, as a convenient reference.
The top-level system requirements are shown first, followed by lower-level
system requirements that provide additional detail.</p>

<h3>9.1 Top-level System Requirements</h3>

<tcl>
foreach {id derivedfrom text} $sysreq_list {
  if {[llength $derivedfrom]>0} continue
  hd_puts "<blockquote><b>$id:</b>"
  hd_resolve $text
  hd_puts </blockquote>
}
</tcl>

<h3>9.2 Derived System Requirements</h3>

<tcl>
foreach {id derivedfrom text} $sysreq_list {
  if {[llength $derivedfrom]==0} continue
  hd_puts "<blockquote><b>$id:</b>"
  hd_resolve $text
  hd_puts </blockquote>
}
</tcl>

<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<


|
<
|
>
>
|













<
|

<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|


<
<
<
<
<
<
<
<
<
<
|
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
<title>SQLite System Requirements</title>




















<h1>System Requirements For SQLite</h1>

<p>This document outlines the chief goals and objectives of the SQLite

library. All of the features and capabilities of SQLite (that is to say,
<a href="requirements.html">all requirements</a> of SQLite) can 
ultimately be traced back to one of the broad and general
requirements specified here.</p>

<p>SQLite is not a complete system and so the requirements
provided by this document are not system requirements in the
strict sense.  Perhaps "sub-system requirements" would be a better
term, since SQLite is always a sub-component of a larger system.</p>

<p>This document is targeted primarily at developers who are
working within a waterfall development model that uses detailed
requirements written with the modal auxiliary verb "shall".  
However, this document is also useful as a general-purpose high-level 
description of SQLite for developers who are not working under
different development paradigms.</p>


<dl>
<tcl>










# Actual requirements text is stored separately.  Read and render it.







#

















































































unset -nocomplain SYSREQ
hd_read_requirement_file $::DOC/req/asysreq.txt SYSREQ










foreach id $SYSREQ(*) {









































































  hd_puts "\n<dt><b>"











  hd_fragment $id $id











  hd_puts "$id</b></dt>\n"

















  hd_puts "<dd><p>\n"








































  hd_resolve [lindex $SYSREQ($id) 1]\n















  set comment [lindex $SYSREQ($id) 2]

















  if {$comment!=""} {













    hd_puts "</p>\n<p>"













    hd_resolve $comment\n


























  }


























































































































































































































































































































































  hd_puts "</p></dd>\n"
}
</tcl>










</dl>
Deleted pages/tokenreq.in.
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
<title>SQLite Tokenizer Requirements</title>

<h1>Requirements For The SQLite Tokenizer</h1>

<p>When processing SQL statements, SQLite (as does every other SQL
database engine) breaks the SQL statement up into tokens which are
then forwarded to the parser component.  SQL statements are split
into tokens by the "tokenizer" component of SQLite. This document specifies
requirements that precisely define the operation of the SQLite tokenizer.</p>

<h2>Character classes</h2>

<p>SQL statements are composed of unicode characters.  Specific
individual characters many be described using a notation consisting of
the character "u" followed by four hexadecimal digits.  For
example, the lower-case letter "a" can be expressed as "u0061"
and the dollar sign can be expressed as "u0024". 
For notational convenience, the following character classes are
defined:</p>

<blockquote>
<dl>
<dt><b>WHITESPACE</b></dt>
<dd><p>One of these five characters:  u0009, u000a, u000c, u000d, or u0020
</p></dd>

<dt><b>ALPHABETIC</b></dt>
<dd><p>Any of the characters in the range u0041 through u005a (letters "A" 
    through "Z") or in the range u0061 through u007a (letters "a" through
    "z") or the character u005f ("_") or any other character larger than
    u007f.</p></dd>

<dt><b>NUMERIC</b></dt>
<dd><p>Any of the characters in the range u0030 through u0039 (digits "0"
    through "9")</p></dd>

<dt><b>ALPHANUMERIC</b></dt>
<dd><p>Any character which is either ALPHABETIC or NUMERIC</p></dd>

<dt><b>HEXADECIMAL</b></dt>
<dd><p>Any NUMERIC character or a characters in the range u0041 through u0046
    ("A" through "F") or in the range u0061 through u0066 ("a" through "f")</p>
</dd>

<dt><b>SPECIAL</b></dt>
<dd></p>Any character that is not WHITESPACE, ALPHABETIC, nor NUMERIC</p></dd>
</dl>
</blockquote>

<h2>Token requirements</h2>

<tcl>
proc tokenreq {id derivedfrom explaination text} {
  hd_fragment $id $id
  set dlist {}
  foreach d $derivedfrom {
    append dlist <$d>
  }
  hd_requirement $id $text$dlist
  if {[string length $explaination]} {
    hd_resolve "<p>$explaination</p>"
  }
  hd_puts "<blockquote><b>$id:</b>"
  hd_resolve $text
  hd_puts {</b></blockquote>}
}

tokenreq H41010 {} {
  Processing is left-to-right.  This seems obvious, but it needs to be
  explicitly stated.
} {
  SQLite shall divide input SQL text into tokens working from left to
  right.
}

tokenreq H41020 {} {
  The standard practice in SQL, as with most context-free grammar based
  programming languages, is to resolve ambiguities in tokenizing by
  selecting the option that results in the longest tokens.
} {
  At each step in the SQL tokenization process, SQLite shall extract
  the longest possible token from the remaining input text.
}

tokenreq H41030 {} {
  The tokenizer recognizes tokens one by one and passes them on to the
  parser.  Except whitespace is ignored.  The only use for whitespace
  is as a separator between tokens.
} {
  The tokenizer shall pass each non-WHITESPACE token seen on to the
  parser in the order in which the tokens are seen.
}

tokenreq H41040 {} {
  The tokenizer appends a semicolon to the end of input if necessary.
  This ensures that every SQL statement is terminated by a semicolon.
} {
  When the tokenizer reaches the end of input where the last token sent
  to the parser was not a SEMI token, it shall 
  send a SEMI token to the parser.
}

tokenreq H41050 {} {
  An unrecognized token generates an immediate error and aborts the parse.
} {
  When the tokenizer encounters text that is not a valid token, it shall
  cause an error to be returned to the application.
}

</tcl>
<h3>Whitespace tokens</h3>
<tcl>

tokenreq H41100 {} {
  Whitespace has the usual definition.
} {
  SQLite shall recognize a sequence of one or more WHITESPACE characters
  as a WHITESPACE token.
}

tokenreq H41110 {} {
  An SQL comment is "--" through the end of line and is understood as
  whitespace.
} {
  SQLite shall recognize as a WHITESPACE token the two-character sequence "--" 
  (u002d, u002d) followed by any sequence of non-zero characters up through and
  including the first u000a character or until end of input.
}

tokenreq H41120 {} {
  A C-style comment "/*...*/" is also recognized as white-space.
} {
  SQLite shall recognize as a WHITESPACE token the two-character sequence "/*"
  (u002f, u002a) followed by any sequence of zero or more 
  non-zero characters through with the first "*/" (u002a, u002f) sequence or 
  until end of input.
}

</tcl>
<h3>Identifier tokens</h3>
<tcl>

tokenreq H41130 {} {
  Identifiers follow the usual rules with the exception that SQLite
  allows the dollar-sign symbol in the interior of an identifier.
  The dollar-sign is for compatibility with Microsoft SQL-Server
  and is not part of the SQL standard.
} {
  SQLite shall recognize as an ID token 
  any sequence of characters that begins with
  an ALPHABETIC character and continue with zero or more
  ALPHANUMERIC characters and/or "$" (u0024) characters and which is
  not a keyword token.
}

tokenreq H41140 {} {
  Identifiers can be arbitrary character strings within square brackets.
  This feature is also for compatibility with Microsoft SQL-Server
  and not a part of the SQL standard.
} {
  SQLite shall recognize as an ID token
  any sequence of non-zero characters that begins with "&#91;" (u005b) and
  continuing through the first "&#93;" (u005d) character.
}

tokenreq H41150 {} {
  The standard way of quoting SQL identifiers is to use double-quotes.
} {
  SQLite shall recognize as an ID token
  any sequence of characters
  that begins with a double-quote (u0022), is followed by zero or
  more non-zero characters and/or pairs of double-quotes (u0022)
  and terminates with a double-quote (u0022) that
  is not part of a pair.
}

tokenreq H41160 {} {
  MySQL allows identifiers to be quoted using the grave accent character.
  SQLite supports this for interoperability.
} {
  SQLite shall recognize as an ID token
  any sequence of characters
  that begins with a grave accent (u0060), is followed by zero or
  more non-zero characters and/or pairs ofgrave accents (u0060)
  and terminates with a grave accent (u0022) that
  is not part of a pair.
}

</tcl>
<h3>Literals</h3>
<tcl>

tokenreq H41200 {} {
  This is the usual definition of string literals for SQL.
  SQL uses the classic Pascal string literal format.
} {
  SQLite shall recognize as a STRING token a sequence of characters
  that begins with a single-quote (u0027), is followed by zero or
  more non-zero characters and/or pairs of single-quotes (u0027)
  and terminates with a single-quote (u0027) that
  is not part of a pair.
}

tokenreq H41210 {} {
  Blob literals are similar to string literals except that they
  begin with a single "X" character and contain hexadecimal data.
} {
  SQLite shall recognize as a BLOB token an upper or lower-case "X"
  (u0058 or u0078) followed by a single-quote (u0027) followed by
  a number of HEXADECIMAL character that is a multiple of two and
  terminated by a single-quote (u0027).
}

tokenreq H41220 {} {
  Integer literals are a string of digits.  The plus or minus sign
  that might optionally preceed an integer is not part of the integer
  token.
} {
  SQLite shall recognize as an INTEGER token any squence of
  one or more NUMERIC characters.
}

tokenreq H41230 {} {
  An "exponentiation suffix" is defined to be an upper or lower
  case "E" (u0045 or u0065) followed by one or more NUMERIC
  characters.  The "E" and the NUMERIC characters may optionally
  be separated by a plus-sign (u002b) or a minus-sign (u002d).
  An exponentiation suffix is part of the definition of a FLOAT
  token:
} {
  SQLite shall recognize as a FLOAT token a sequence of one
  or more NUMERIC characters together with zero or one period
  (u002e) and followed by an exponentiation suffix.
}
tokenreq H41240 {} {} {
  SQLite shall recognize as a FLOAT token a sequence of one
  or more NUMERIC characters that includes exactly one period
  (u002e) character.
}

</tcl>
<h3>Variables</h3>
<tcl>

tokenreq H40310 {} {
  Variables are used as placeholders in SQL statements for constant
  values that are to be bound at start-time.
} {
  SQLite shall recognize as a VARIABLE token the a question-mark (u003f)
  followed by zero or more NUMERIC characters.
}

tokenreq H40320 {} {
  A "parameter name" is defined to be a sequence of one or more
  characters that consists of
  ALPHANUMERIC characters and/or dollar-signs (u0025) intermixed with
  pairs of colons (u003a) and optionally followed by any sequence
  of non-zero, non-WHITESPACE characters enclosed in parentheses
  (u0028 and u0029).
} {
  SQLite shall recognize as a VARIABLE token one of the characters
  at-sign (u0040), dollar-sign (u0024), or colon (u003a) followed
  by a parameter name.
}
tokenreq H40330 {} {} {
  SQLite shall recognize as a VARIABLE token the shape-sign (u0023)
  followed by a parameter name that does not begin with a
  NUMERIC character.
}

tokenreq L42040 {} {
  The REGISTER token is a special token used internally.  It does not
  appear as part of the published user interface.  Hence, the following
  is a low-level requirement:
} {
  SQLite shall recognize as a REGISTER token a sharp-sign (u0023)
  followed by one or more NUMERIC characters.
}

</tcl>
<h3>Operator tokens</h3>

<p>The following sequences of special characters are recognized as
tokens:</p>
<tcl>

set id 41400
foreach {charseq tname} {
  - MINUS
  ( LP
  ) RP
  ; SEMI
  + PLUS
  * STAR
  / SLASH
  % REM
  = EQ
  == EQ
  <= LE
  <> NE
  << LSHIFT
  < LT
  >= GE
  >> RSHIFT
  > GT
  != NE
  , COMMA
  & BITAND
  ~ BITNOT
  | BITOR
  || CONCAT
  . DOT
} {
  incr id 3
  set n [string length $charseq]
  set body " SQLite shall recognize the $n-character sequenence "
  append body "\"$charseq\""
  set sep " ("
  for {set i 0} {$i<$n} {incr i} {
    set c [string index $charseq $i]
    scan $c %c x
    append body [format ${sep}u%04x $x]
    set sep " "
  }
  append body ") as token $tname"
  tokenreq H$id {} {} $body
}

</tcl>
<h3>Keyword tokens</h3>

<p>The following keywords are recognized as distinct tokens:</p>
<tcl>

set id 41500
foreach {charseq tname} {
   ABORT ABORT
   ADD ADD
   AFTER AFTER
   ALL ALL
   ALTER ALTER
   ANALYZE ANALYZE
   AND AND
   AS AS
   ASC ASC
   ATTACH ATTACH
   AUTOINCREMENT AUTOINCR
   BEFORE BEFORE
   BEGIN BEGIN
   BETWEEN BETWEEN
   BY BY
   CASCADE CASCADE
   CASE CASE
   CAST CAST
   CHECK CHECK
   COLLATE COLLATE
   COLUMN COLUMNKW
   COMMIT COMMIT
   CONFLICT CONFLICT
   CONSTRAINT CONSTRAINT
   CREATE CREATE
   CROSS JOIN_KW
   CURRENT_DATE CTIME_KW
   CURRENT_TIME CTIME_KW
   CURRENT_TIMESTAMP CTIME_KW
   DATABASE DATABASE
   DEFAULT DEFAULT
   DEFERRED DEFERRED
   DEFERRABLE DEFERRABLE
   DELETE DELETE
   DESC DESC
   DETACH DETACH
   DISTINCT DISTINCT
   DROP DROP
   END END
   EACH EACH
   ELSE ELSE
   ESCAPE ESCAPE
   EXCEPT EXCEPT
   EXCLUSIVE EXCLUSIVE
   EXISTS EXISTS
   EXPLAIN EXPLAIN
   FAIL FAIL
   FOR FOR
   FOREIGN FOREIGN
   FROM FROM
   FULL JOIN_KW
   GLOB LIKE_KW
   GROUP GROUP
   HAVING HAVING
   IF IF
   IGNORE IGNORE
   IMMEDIATE IMMEDIATE
   IN IN
   INDEX INDEX
   INITIALLY INITIALLY
   INNER JOIN_KW
   INSERT INSERT
   INSTEAD INSTEAD
   INTERSECT INTERSECT
   INTO INTO
   IS IS
   ISNULL ISNULL
   JOIN JOIN
   KEY KEY
   LEFT JOIN_KW
   LIKE LIKE_KW
   LIMIT LIMIT
   MATCH MATCH
   NATURAL JOIN_KW
   NOT NOT
   NOTNULL NOTNULL
   NULL NULL
   OF OF
   OFFSET OFFSET
   ON ON
   OR OR
   ORDER ORDER
   OUTER JOIN_KW
   PLAN PLAN
   PRAGMA PRAGMA
   PRIMARY PRIMARY
   QUERY QUERY
   RAISE RAISE
   REFERENCES REFERENCES
   REGEXP LIKE_KW
   REINDEX REINDEX
   RENAME RENAME
   REPLACE REPLACE
   RESTRICT RESTRICT
   RIGHT JOIN_KW
   ROLLBACK ROLLBACK
   ROW ROW
   SELECT SELECT
   SET SET
   TABLE TABLE
   TEMP TEMP
   TEMPORARY TEMP
   THEN THEN
   TO TO
   TRANSACTION TRANSACTION
   TRIGGER TRIGGER
   UNION UNION
   UNIQUE UNIQUE
   UPDATE UPDATE
   USING USING
   VACUUM VACUUM
   VALUES VALUES
   VIEW VIEW
   VIRTUAL VIRTUAL
   WHEN WHEN
   WHERE WHERE
} {
  incr id 3
  set n [string length $charseq]
  set body " SQLite shall recognize the $n-character sequenence "
  append body "\"$charseq\" in any combination of upper and lower case "
  append body "letters as the keyword token $tname."
  tokenreq H$id {} {} $body
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































































































































































































































































































































































































































































































































































































































































































































































































































Added req/asysreq.txt.




































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
SYSREQ S10000 
The SQLite library shall translate high-level SQL statements into
low-level I/O calls to persistent storage.

  SQLite is an SQL database engine.  And the fundamental task of
  every SQL database engine it to translate the abstract SQL statements
  readily understood by humans into sequences of I/O operations readily
  understood by computer hardware.  This requirement expresses the
  essense of SQLite.


SYSREQ S10100 S10000
The SQLite library shall accepts a well-defined dialect of SQL
that conforms to published SQL standards.

  SQL is one of the worlds most widely known programming languages,
  but it is also one of the most ill-defined.  There are various SQL
  standards documents available.  However the SQL standards documents are 
  obtuse to the point of being incomprehensible.  And the standards 
  allow for so much "implementation defined" behavior that there exist
  two SQL database engines understand exactly the same language.</p>
  
  <p>SQLite does not attempt to obtain strict compliance with any
  one of the various SQL standards.
  Instead, SQLite tries to be as compatible as possible with other SQL
  database engines.  SQLite attempts to operate on the principle of
  least surprise.  That is to say, experienced SQL programmers should
  find SQLite's dialect intuitive and natural.</p>
  
  <p>SQLite may omit some obscure features of SQL.  And the SQL
  dialect that SQLite understands might contain some enhancements not
  found in some standards documents.  Nevertheless, applications
  written for other SQL database engines should be portable to SQLite
  with little to no change.  And programmers writing code for SQLite
  should not encounter anything unexpected.

SYSREQ S10110 S10100
The SQLite library shall support BLOB, CLOB, integer, and floating-point
datatypes.

SYSREQ S10120 S10100
The SQLite library shall implement the standard SQL interpretation
of NULL values.

  In cases where
  published standards are ambiguous, SQLite will follow the practice of
  other popular database engines.

SYSREQ S10200 S10000
The SQLite library shall communicate directly with database files
in persistent storage.

  Most other database
  engines implement a client/server model in which a small client library
  is linked with the application and the client communicates with a separate
  server process using interprocess communication (IPC).  SQLite avoids
  the complication of having a separate server process by doing direct
  I/O directly to the underlying filesystem.

SYSREQ S10300 S10000
The SQLite library shall implement ACID transactions.

  In the database world, "ACID" is an acronym for Atomic, Consistent,
  Isolated, and Durable.  Atomic means that a change to the database
  happens either entirely or not at all.  Consistent means that if the
  database file is well-formed before the start of a transaction then
  it is guaranteed to be well-formed after the transaction commits.  
  Isolated means that when two or more threads are
  processes are working with the same database, uncommitted changes 
  made by one are not visible to the other.  Durable means that once
  a transaction commits, it stays committed even if there is a subsequent
  software crash or power failure.

SYSREQ S10500 S10000
The SQLite library shall implement transactions that are robust
across application crashes, operating-system crashes, and power
failures.

  An operating system crash or an unexpected power loss can
  sometimes damage
  the underlying persistent storage in ways that no software can defend
  against.  (For example, the content of a disk drive might be completely
  erased and become unrecoverable.)
  Nevertheless, software can take steps to defend against the kinds
  of damage that typically occurs following operating system crashes and 
  power failures.  The usual damage is that some writes are missing
  or incomplete and that writes have occurred out of order.  We say
  that software is "robust" if it defines against the common kinds of
  damage seen following an operating system crash or power loss.</p>


SYSREQ S10600 S10000
The SQLite library shall support simultaneous access to multiple
database files on the same database connection.

  Many applications benefit from being about to access multiple
  database file using the same database connection, so that 
  information can be transfered from from one database to another 
  atomically, or so that queries can join data across multiple
  databases.

SYSREQ S10700 S10000
The SQLite library shall provide interfaces that allow the application
to obtain the status and results of SQL operations.

SYSREQ S20000 
The SQLite library shall be extensible and configurable.

  SQLite is intended to be an embedded database that functions well
  in resource-limited systems.  For that reason we desire to keep the
  size of the library small.  That choices argues against a large
  default function set.  Instead of having many built-in features, SQLite is
  designed to be extensible at compile-time and run-time with new
  application-defined functions and behaviors.

SYSREQ S20100 S20000
The SQLite library shall provide interfaces that permit the application
to override interfaces to the platform on which the application is running.

  SQLite works on common workstations and in embedded systems.
  Sometimes these devices, particularly embedded systems,
  have odd and unusual operating systems.  In order to support
  this level of portability, SQLite allows the interface to the operating
  system to be defined at run-time.

SYSREQ S20110 S20100
The SQLite library shall provide interfaces that permit the application
to override the interfaces used to read and write persistent storage.

SYSREQ S20120 S20100
The SQLite library shall provide interfaces that permit the application
to override the interfaces used for memory allocation.

SYSREQ S20130 S20100
The SQLite library shall provide interfaces that permit the application
to override the interfaces used for controlling mutexes.

SYSREQ S20200 S20000
The SQLite library shall provide interfaces that permit the application
to create new SQL functions.

  Most SQL database engines support a rich set of SQL functions.
  SQLite, in contrast, supports only a select few SQL functions.
  But SQLite makes up for its dearth of built-in SQL functions by 
  allowing the application to create new SQL function easily.

SYSREQ S20300 S20000
The SQLite library shall provide interfaces that permit the application
to create new text collating sequences.

  By default, SQLite only understands ASCII text.  The tables needed
  to do proper comparisons and case folding
  of full unicode text are huge - much larger
  than the SQLite library itself.  And, any application that is dealing
  with unicode already probably already has those tables built in.  For
  SQLite to include unicode comparison tables would be redundant and wasteful.
  As a compromise, SQLite allows the application to specify alternative
  collating sequences for things such as unicode text,
  so that for applications that need such comparison sequences can have
  them easily while other applications that are content with ASCII are
  not burdened with unnecessary tables.

SYSREQ S20400 S20000
The SQLite library shall provide interfaces that permit the application
to create new classes of virtual SQL tables.

  A virtual table is an SQL object that appears to be an ordinary
  SQL table for the purposes of INSERT, UPDATE, DELETE, and SELECT statements.
  But instead of being backed by persistent storage, the virtual table is
  an object that responds programmatically to INSERT, UPDATE, DELETE, and
  SELECT requests.  Virtual tables have been used to implement full-text
  search and R-Tree indices, among other things.

SYSREQ S20500 S20000
The SQLite library shall provide interfaces that permit the application
to load extensions at run-time using shared libraries.

  Some applications choose to package extensions in separate
  shared library files and load those extensions at run-time on
  an as-needed basis.  Depending on the nature of the application,
  this can be an aid to configuration management, since it allows
  the extension to be updated without having to replace the core
  application.

SYSREQ S20600 S20000
The SQLite library shall provide interfaces that permit the application
to dynamically query and modify size limits.

  SQLite has finite limits.  For example, there is a maximum size BLOB
  or CLOB that SQLite will store, a maximum size to a database file,
  a maximum number of columns in a table or query, and a maximum depth
  of an expression parse tree.  All of these have default values that
  are sufficiently large that a typical application is very unlikely to 
  ever reach the limits.  But some applications (for example, applications
  that process content from untrusted and possibly hostile sources)
  might want to define much lower limits on some database connections for
  the purpose of preventing denial-of-service attacks.  Or, an application
  might want to select much lower limits in order to prevent over-utilization
  of limited resources on an embedded device.  Whatever the rationale, SQLite
  permits limits to be queried and set at run-time.

SYSREQ S30000 
The SQLite library shall be safe for use in long-running,
low-resource, high-reliability applications.

  SQLite is designed to work well within embedded devices with 
  very limited resources.  To this end, it expects to confront situations
  where memory is unavailable and where I/O operations fail and it is designed
  to handle such situations with ease and grace.  SQLite also avoids aggravating
  low-resource situations by correctly freeing rather than leaking 
  resources it uses itself.

SYSREQ S30100 S30000
The SQLite library shall release all system resources it holds
when it is properly shutdown.

  A "Proper shutdown" means that all resources that the application
  has allocated from SQLite have been released by the application.
  The leak-free operation guarantee of SQLite applies even if there
  have been memory allocation errors or I/O errors during operation.

SYSREQ S30200 S30000
The SQLite library shall be configurable so that it is guaranteed
to never fail a memory allocation as long as the application does
not request resources in excess of reasonable and published limits.

  Safety-critical systems typically disallow the use of malloc() and
  free() because one never knows when they might fail due to memory
  fragmentation.  However, SQLite makes extensive use of dynamic objects
  and so it must be able to allocate and deallocate memory
  to hold those objects.</p>
  
  <p>In order to be acceptable for use in safety critical systems,
  SQLite can be configured to use its own internal memory allocator
  which, subject to proper usage by the application, guarantees that
  memory allocation will never fail either due to memory fragmentation
  or any other cause.  The proof of correctness is due to J. M. Robson:
  "Bounds for Some Functions Concerning Dynamic Storage Allocations",
  Journal of the ACM, Volume 21, Number 3, July 1974.</p>
  
  <p>The internal memory allocator is seeded with a large contiguous
  block of memory at application start.  SQLite makes all of its
  internal memory allocations from this initial seed.  
  The Robson proof depends on SQLite being coupled to a well-behaved
  application.  The application must not try to use more than a
  precomputed fraction of the available memory - that fraction depending
  on the size ratio between the largest and smallest memory allocations.
  Additional details are provided elsewhere.

SYSREQ S30210 S30200
The SQLite library shall be provide instrumentation that can alert
the application when its resource usages nears or exceeds the limits
of the memory breakdown guarantee.

  To help insure that an
  application never fails a memory allocation call, SQLite provides
  interfaces that can inform the application if its memory usage
  is growing close to or has exceeded the critical Robson limits.  
  In practice, the memory used by an application can exceed the 
  limits of the Robson proof by a wide margin with no harmful effect.  
  There is plenty of safety margin.  But the Robson proof does break 
  down once the limits are exceeded  
  and the guarantee that no memory allocation will fail is lost.  Hence
  it is important to be able to track how close an application has come
  to reaching critical limits.

SYSREQ S30220 S30200
The SQLite library shall be provide facilities to automatically
recycle memory when usage nears preset limits.

  When SQLite comes under memory pressure, it can be configured to
  recycle memory from one use to another, thus helping to reduce the
  pressure.  "Memory pressure" means that memory available for 
  allocation is becoming less plentiful.  In a safety-critical application,
  memory pressure might mean that the amount of allocated memory is
  getting close to the point where the Robson proof
  breaks down.  On a workstation, memory pressure might mean that
  available virtual memory is running low.

SYSREQ S30230 S30200
The SQLite library shall be permit BLOB and CLOB objects to be
read and written incrementally using small memory buffers.

  SQLite provides the ability to read and write megabyte
  or gigabyte blobs and text strings without having to allocate
  enough memory to hold the entire blob and string in memory all
  at once.  This enables SQLite to read and write BLOBs that
  are actually larger than the available memory on the device.
  It also helps reduce the size of the maximum memory allocation
  which helps keep memory usage below Robson limits and thus helps
  to guarantee failure-free memory allocation.

SYSREQ S30300 S30000
When a memory allocation fails, SQLite shall either silently make
due without the requested memory or else it shall report the error
back to the application.

  Memory allocation problems do not cause SQLite to fail
  catastrophically.
  SQLite recognizes all memory allocation failures and either works 
  around them, or
  cleanly aborts what it is doing and returns to the application
  with an error that indicates insufficient memory was available.
  Assuming new memory becomes available, SQLite is able to continue 
  operating normally after a memory allocation failure.

SYSREQ S30400 S30000
When a I/O operation fails, SQLite shall either silently
recover or else it shall report the error
back to the application.

  SQLite responses sanely to disk I/O errors.  If it is unable
  to work around the problem, SQLite might have to report the error
  back up to the application.  In either case, SQLite is able to
  continue functioning, assuming of course that the I/O error was
  transient.

SYSREQ S30500 S30000
SQLite shall provide the capability to monitor
the progress and interrupt the evaluation of a long-running query.

  SQLite is able to cleanly abort an operation in progress and
  afterwards continue functioning normally without any memory or
  other resource leaks.  An example of where this functionality is
  used occurs in the command-line interface (CLI) program for SQLite.
  If the user enters a query that has millions of result rows, those
  rows begin pouring out onto the screen.  The operator can then
  hit the interrupt key sequence (which varies from one operating
  system to another but it often Control-C) which causes the query
  to be aborted.

SYSREQ S30600 S30000
All unused portions of a well-formed SQLite database file shall
be available for reuse.

  When information is deleted from an SQLite database, the default
  action is for SQLite to mark the space as unused and then to reuse
  the space at the next opportune INSERT.  On devices where persistent 
  storage is scarce, however, it is sometime desirable to return the
  unused space back to the operating system.  SQLite supports this.

SYSREQ S30700 S30000
SQLite shall provide the capability to incrementally decrease the
size of the persistent storage file as information is removed from
the database.

SYSREQ S30800 S30000
SQLite shall provide the interfaces that support testing and
validation of the library code in an as-delivered configuration.

  In consumer-grade software, it is often acceptable to run tests
  on an instrumented version of the code.  But for high-reliability
  systems, it is better to test the code exactly as it is deployed.
  The saying at NASA is "test what you fly and fly what you test."
  In support of this goal, SQLite includes interfaces whose only purpose
  is to observe internal state and to place SQLite into internal states
  for the testing.

SYSREQ S30900 S30000
SQLite shall provide the ability for separate database connections
within the same process to share resources.

  On resource-constrained devices, it is desirable to get double-duty
  out of resources where possible.

SYSREQ S40000 
The SQLite library shall be safe for use in applications that
make concurrent access to the underlying database from different
threads and/or processes.

  In nearly all modern digital systems, there are many things happening
  at once.  And many of those things involve SQLite.

SYSREQ S40100 S40000
The SQLite library shall be configurable to operate correctly in
a multi-threaded application.

  The developers of SQLite believe that "thread-safe" is a
  self contradiction.  No application that includes multiple threads
  of control within the same address space is every truly "safe".
  And yet it is recognized that many developers want to
  create multithreaded applications and to use SQLite in those
  applications.  Therefore, SQLite is engineered to be "thread-safe".

SYSREQ S40200 S40000
The SQLite library shall support multiple independent database
connections per thread and per process.

SYSREQ S40300 S40000
The SQLite library shall automatically control access to common
databases from different connections in different threads or processes.

  SQLite uses both internal mutexes and external file locking to 
  ensure that two or more threads or processes working
  on the same database file play nicely with one another.

SYSREQ S40400 S40000
The SQLite library shall notify the application if an operation can
not be completed due to concurrent access constraints.

SYSREQ S40410 S40000
The SQLite library shall provide interfaces to assist the application
in responding appropriately when an operation can
not be completed due to concurrent access constraints.

  If an SQL statement cannot be completed because another process is
  holding a lock on the database, then the application needs to be able
  to take corrective action, such waiting for the lock to clear.


SYSREQ S50000 
The SQLite library shall be cross-platform.

  Cross-platform in this context means that the SQLite 
  can be used on a wide variety of operating systems and processors,
  ranging from small, special-purpose embedded systems, to workstations,
  to servers.  Platforms can be 32- or 64-bit, big-endian or little-endian.
  Cross-platform refers to the source code.  Obviously the SQLite would
  need to be recompiled in order to run on processors with different
  instruction sets.

SYSREQ S50100 S50000
The SQLite library shall be implemented in ANSI-C.

  C has been called the "universal assembly language".
  Nearly all computer systems accept code written in C.
  Thus, to help make SQLite cross-platform:

SYSREQ S50200 S50000
The SQLite library shall support text encoded as UTF-8,
UTF-16le, or UTF-16be.

SYSREQ S50300 S50000
SQLite database files shall be processor and byte-order independent.

  An SQLite database file can be freely moved between machine
  with different operating systems, different processors,
  different size integers, and different byte orders.  The same
  database file should work on any machine.

SYSREQ S60000 
The SQLite library shall provide introspection capabilities to the
application.

  Some applications need to be able to discover characteristics of
  their environment at run-time and to make appropriate adjustments to
  their processing to accommodate the environment they find themselves in.
  SQLite attempts to support this need.

SYSREQ S60100 S60000
The SQLite library shall provide interfaces that an application can
use to discover fixed, compile-time characteristics of the
SQLite library.

  Some applications are designed to work with different versions
  of SQLite which may or may not enable selected features.  For example,
  SQLite can be compiled to be threadsafe or not.  The threadsafe version
  works in multi-threaded applications.  The non-threadsafe build runs
  faster.  When an application is using an unknown version of SQLite
  it is important that it be able to determine the characteristics of
  the particular SQLite build it is using.

SYSREQ S60200 S60000
The SQLite library shall provide interfaces that an application can
use to find run-time performance characteristics and status of the
SQLite library.

SYSREQ S60300 S60000
The SQLite library shall provide interfaces that permit an application
to query the schema of a database.

SYSREQ S60400 S60000
The SQLite library shall provide interfaces that allow an application
to monitor sequence of queries and progress of submitted to SQLite.

SYSREQ S60500 S60000
The SQLite library shall provide interfaces that allow an application
to discover the algorithms that SQLite has chosen to implement specific
SQL statements.

SYSREQ S60600 S60000 S20200
The SQLite library shall provide interfaces that allow an application
to discover relationships between SQLite objects.

  SQLite objects are often related.  For example, every prepared
  statement is associated with a database connection.  And every
  function context is associated with a prepared statement.  
  Applications and extensions frequently find it useful to be able
  to discover these relationships at runtime.

SYSREQ S70000 
The SQLite library shall provide interfaces that promote the safe
construction and processing of SQL statements and data from
untrusted sources.

  Many applications need to be able to safely process data or
  even SQL statements that are received from untrusted sources.
  An "SQL Injection Attack" occurs when an adversary intentionally
  introduces data that is designed to have undesirable side effects
  on the database files.  For example, suppose an application generates
  an INSERT statement as follows:</p>
  
  <blockquote><pre>
  snprintf(z, n, "INSERT INTO table1 VALUES('%s')", zUserData);
  </pre></blockquote>
  
  <p>If a hostile user supplies data that reads:</p>
  
  <blockquote><pre>
  beginning'); DELETE FROM table1; INSERT INTO table1 VALUES('
  </pre></blockquote>
  
  <p>Then the constructed INSERT statement would be transformed into
  three statements, the second of which is an undesired deletion of
  all prior content from the table.  SQLite contains interfaces that
  are designed to help applications avoid SQL injection attacks and
  similar problems.

SYSREQ S70100 S70000
The SQLite library shall provide the application means by which the
application can test and enforce compliance with database access
policies for any particular SQL statement.

  Some applications (for example
  <a href="http://www.cvstrac.org/">CVSTrac</a> and
  <a href="http://www.fossil-scm.org/">Fossil</a>) will run SELECT
  statements entered by anonymous users on the internet.  Such 
  applications want to be able to guarantee that a hostile users does
  not access restricted tables (such as the PASSWORD column of the USER
  table) or modify the database in any way.  SQLite supports the ability
  to analyze an arbitrary SQL statement to insure that it does not
  perform undesired operations.

SYSREQ S70200 S70000
The SQLite library shall provide interfaces that test to see if an
SQL statement being received incrementally is complete.

  <p>Applications such as the command-line interface (CLI) for SQLite
  will prompt the user to enter SQL statements and will evaluate those
  statements as they are entered.  But sometimes an SQL statement spans
  multiple lines.  The CLI needs to know to issue a continuation prompt
  and await additional input if the input received so far is incomplete.
  SQLite supports interfaces that allow the CLI and similar applications
  to know if the input it has gathered so far is complete or if it needs
  to await additional input before processing the SQL.

SYSREQ S70300 S70000 S30000
The SQLite library shall support prepared statement objects with
late parameter binding

  The concept of a "prepared statement" allows an SQL statement to be
  parsed and compiled once and then reused many times.  This is a performance
  advantage in many applications.  In addition, binding values to variables
  in the prepared statement is safer than embedding values as literals because
  bound values do not need to be quoted in order to avoid an SQL injection
  attack.

SYSREQ S80000 
SQLite shall exhibit ductile failure characteristics

  A common characteristic of digital systems (as opposed to analog
  systems) is that digital systems tend to be brittle.  In other words,
  digital systems tend to work perfectly with no sign of stress until 
  they fail utterly and completely.  The behavior is like a
  physical object that holds its shape as external
  loads increase, until it shatters without warning.</p>
  
  <p>In most circumstances, ductile failure is preferred over brittle
  failure.  A ductile device begins showing signs of
  trouble well in advance of failure.  Physical objects bend and/or crack,
  providing operators with warnings of overload and an opportunity
  to take corrective action, while continuing to function for as long
  as possible.</p>
  
  <p>Digital systems have a reputation for being brittle, yet brittleness
  is not an intrinsic property of digital systems.  Digital systems can
  be designed to continuing functioning outside their design parameters
  while providing operators with warning of possible trouble.  But there
  most be focused effort on the part of the designers to make digital
  systems ductile.  With analog systems, the ductileness tends to be
  inherent in the medium, but with digital systems ductileness needs
  to be explicitly added.

SYSREQ S80100 S80000
SQLite shall make anomalies visible to the application

  SQLite strives to deal gracefully with anomalous behavior by
  the application or by its own internal subsystems.  Yet graceful
  handling of out-of-band inputs is of no value if the anomaly goes
  unreported.  The problems must be visible to the
  application so that warnings and alarms can be propagated to operators.
  The useful aspect of ductile failure is that it gives advance warning.
  Ductile behavior is of no use to anyone if nobody can see the part
  bending.
Added req/hlr10000.txt.








































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
HLR H10010 S60100
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_VERSION         "3.6.6"
#define SQLITE_VERSION_NUMBER  3006006
</pre></blockquote>

HLR H10011 S60100
The SQLITE_VERSION #define in the sqlite3.h header file shall
evaluate to a string literal that is the SQLite version
with which the header file is associated.

HLR H10014 S60100
The SQLITE_VERSION_NUMBER #define shall resolve to an integer
with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z
are the major version, minor version, and release number.

HLR H10020 S60100
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
SQLITE_EXTERN const char sqlite3_version[];
const char *sqlite3_libversion(void);
int sqlite3_libversion_number(void);
</pre></blockquote>

HLR H10021 S60100
The [sqlite3_libversion_number()] interface shall return
an integer equal to [SQLITE_VERSION_NUMBER].

HLR H10022 S60100
The [sqlite3_version] string constant shall contain
the text of the [SQLITE_VERSION] string.

HLR H10023 S60100
The [sqlite3_libversion()] function shall return
a pointer to the [sqlite3_version] string constant.

HLR H10100 S60100
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_threadsafe(void);
</pre></blockquote>

HLR H10101 S60100
The [sqlite3_threadsafe()] function shall return zero if
and only if SQLite was compiled with mutexing code omitted.

HLR H10102 S60100
The value returned by the [sqlite3_threadsafe()] function
shall remain the same across calls to [sqlite3_config()].

HLR H10130 S20000 S30100
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_initialize(void);
int sqlite3_shutdown(void);
int sqlite3_os_init(void);
int sqlite3_os_end(void);
</pre></blockquote>

HLR H10155 S20120
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
typedef struct sqlite3_mem_methods sqlite3_mem_methods;
struct sqlite3_mem_methods {
void *(*xMalloc)(int);         /* Memory allocation function */
void (*xFree)(void*);          /* Free a prior allocation */
void *(*xRealloc)(void*,int);  /* Resize an allocation */
int (*xSize)(void*);           /* Return the size of an allocation */
int (*xRoundup)(int);          /* Round up request size to allocation size */
int (*xInit)(void*);           /* Initialize the memory allocator */
void (*xShutdown)(void*);      /* Deinitialize the memory allocator */
void *pAppData;                /* Argument to xInit() and xShutdown() */
};
</pre></blockquote>

HLR H10160 S20000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_CONFIG_SINGLETHREAD  1  /* nil */
#define SQLITE_CONFIG_MULTITHREAD   2  /* nil */
#define SQLITE_CONFIG_SERIALIZED    3  /* nil */
#define SQLITE_CONFIG_MALLOC        4  /* sqlite3_mem_methods* */
#define SQLITE_CONFIG_GETMALLOC     5  /* sqlite3_mem_methods* */
#define SQLITE_CONFIG_SCRATCH       6  /* void*, int sz, int N */
#define SQLITE_CONFIG_PAGECACHE     7  /* void*, int sz, int N */
#define SQLITE_CONFIG_HEAP          8  /* void*, int nByte, int min */
#define SQLITE_CONFIG_MEMSTATUS     9  /* boolean */
#define SQLITE_CONFIG_MUTEX        10  /* sqlite3_mutex_methods* */
#define SQLITE_CONFIG_GETMUTEX     11  /* sqlite3_mutex_methods* */
/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
#define SQLITE_CONFIG_LOOKASIDE    13  /* int int */
#define SQLITE_CONFIG_PCACHE       14  /* sqlite3_pcache_methods* */
#define SQLITE_CONFIG_GETPCACHE    15  /* sqlite3_pcache_methods* */
</pre></blockquote>

HLR H10170 S20000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_DBCONFIG_LOOKASIDE    1001  /* void* int int */
</pre></blockquote>

HLR H10200 S10110
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#ifdef SQLITE_INT64_TYPE
typedef SQLITE_INT64_TYPE sqlite_int64;
typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
#elif defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 sqlite_int64;
typedef unsigned __int64 sqlite_uint64;
#else
typedef long long int sqlite_int64;
typedef unsigned long long int sqlite_uint64;
#endif
typedef sqlite_int64 sqlite3_int64;
typedef sqlite_uint64 sqlite3_uint64;
</pre></blockquote>

HLR H10201 S10110
The [sqlite_int64] and [sqlite3_int64] type shall specify
a 64-bit signed integer.

HLR H10202 S10110
The [sqlite_uint64] and [sqlite3_uint64] type shall specify
a 64-bit unsigned integer.

HLR H10210 S10700
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_OK           0   /* Successful result */
/* beginning-of-error-codes */
#define SQLITE_ERROR        1   /* SQL error or missing database */
#define SQLITE_INTERNAL     2   /* Internal logic error in SQLite */
#define SQLITE_PERM         3   /* Access permission denied */
#define SQLITE_ABORT        4   /* Callback routine requested an abort */
#define SQLITE_BUSY         5   /* The database file is locked */
#define SQLITE_LOCKED       6   /* A table in the database is locked */
#define SQLITE_NOMEM        7   /* A malloc() failed */
#define SQLITE_READONLY     8   /* Attempt to write a readonly database */
#define SQLITE_INTERRUPT    9   /* Operation terminated by sqlite3_interrupt()*/
#define SQLITE_IOERR       10   /* Some kind of disk I/O error occurred */
#define SQLITE_CORRUPT     11   /* The database disk image is malformed */
#define SQLITE_NOTFOUND    12   /* NOT USED. Table or record not found */
#define SQLITE_FULL        13   /* Insertion failed because database is full */
#define SQLITE_CANTOPEN    14   /* Unable to open the database file */
#define SQLITE_PROTOCOL    15   /* NOT USED. Database lock protocol error */
#define SQLITE_EMPTY       16   /* Database is empty */
#define SQLITE_SCHEMA      17   /* The database schema changed */
#define SQLITE_TOOBIG      18   /* String or BLOB exceeds size limit */
#define SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */
#define SQLITE_MISMATCH    20   /* Data type mismatch */
#define SQLITE_MISUSE      21   /* Library used incorrectly */
#define SQLITE_NOLFS       22   /* Uses OS features not supported on host */
#define SQLITE_AUTH        23   /* Authorization denied */
#define SQLITE_FORMAT      24   /* Auxiliary database format error */
#define SQLITE_RANGE       25   /* 2nd parameter to sqlite3_bind out of range */
#define SQLITE_NOTADB      26   /* File opened that is not a database file */
#define SQLITE_ROW         100  /* sqlite3_step() has another row ready */
#define SQLITE_DONE        101  /* sqlite3_step() has finished executing */
/* end-of-error-codes */
</pre></blockquote>

HLR H10220 S10700
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_IOERR_READ              (SQLITE_IOERR | (1&lt;&lt;8))
#define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2&lt;&lt;8))
#define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3&lt;&lt;8))
#define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4&lt;&lt;8))
#define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5&lt;&lt;8))
#define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6&lt;&lt;8))
#define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7&lt;&lt;8))
#define SQLITE_IOERR_UNLOCK            (SQLITE_IOERR | (8&lt;&lt;8))
#define SQLITE_IOERR_RDLOCK            (SQLITE_IOERR | (9&lt;&lt;8))
#define SQLITE_IOERR_DELETE            (SQLITE_IOERR | (10&lt;&lt;8))
#define SQLITE_IOERR_BLOCKED           (SQLITE_IOERR | (11&lt;&lt;8))
#define SQLITE_IOERR_NOMEM             (SQLITE_IOERR | (12&lt;&lt;8))
#define SQLITE_IOERR_ACCESS            (SQLITE_IOERR | (13&lt;&lt;8))
#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14&lt;&lt;8))
#define SQLITE_IOERR_LOCK              (SQLITE_IOERR | (15&lt;&lt;8))
#define SQLITE_IOERR_CLOSE             (SQLITE_IOERR | (16&lt;&lt;8))
#define SQLITE_IOERR_DIR_CLOSE         (SQLITE_IOERR | (17&lt;&lt;8))
</pre></blockquote>

HLR H10223 S10700
The symbolic name for an extended result code shall contains
a related primary result code as a prefix.

HLR H10224 S10700
Primary result code names shall contain a single "_" character.

HLR H10225 S10700
Extended result code names shall contain two or more "_" characters.

HLR H10226 S10700
The numeric value of an extended result code shall contain the
numeric value of its corresponding primary result code in
its least significant 8 bits.

HLR H10230 H11120 H12700
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_OPEN_READONLY         0x00000001
#define SQLITE_OPEN_READWRITE        0x00000002
#define SQLITE_OPEN_CREATE           0x00000004
#define SQLITE_OPEN_DELETEONCLOSE    0x00000008
#define SQLITE_OPEN_EXCLUSIVE        0x00000010
#define SQLITE_OPEN_MAIN_DB          0x00000100
#define SQLITE_OPEN_TEMP_DB          0x00000200
#define SQLITE_OPEN_TRANSIENT_DB     0x00000400
#define SQLITE_OPEN_MAIN_JOURNAL     0x00000800
#define SQLITE_OPEN_TEMP_JOURNAL     0x00001000
#define SQLITE_OPEN_SUBJOURNAL       0x00002000
#define SQLITE_OPEN_MASTER_JOURNAL   0x00004000
#define SQLITE_OPEN_NOMUTEX          0x00008000
#define SQLITE_OPEN_FULLMUTEX        0x00010000
</pre></blockquote>

HLR H10240 H11120
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_IOCAP_ATOMIC          0x00000001
#define SQLITE_IOCAP_ATOMIC512       0x00000002
#define SQLITE_IOCAP_ATOMIC1K        0x00000004
#define SQLITE_IOCAP_ATOMIC2K        0x00000008
#define SQLITE_IOCAP_ATOMIC4K        0x00000010
#define SQLITE_IOCAP_ATOMIC8K        0x00000020
#define SQLITE_IOCAP_ATOMIC16K       0x00000040
#define SQLITE_IOCAP_ATOMIC32K       0x00000080
#define SQLITE_IOCAP_ATOMIC64K       0x00000100
#define SQLITE_IOCAP_SAFE_APPEND     0x00000200
#define SQLITE_IOCAP_SEQUENTIAL      0x00000400
</pre></blockquote>

HLR H10250 H11120 H11310
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_LOCK_NONE          0
#define SQLITE_LOCK_SHARED        1
#define SQLITE_LOCK_RESERVED      2
#define SQLITE_LOCK_PENDING       3
#define SQLITE_LOCK_EXCLUSIVE     4
</pre></blockquote>

HLR H10260 H11120
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_SYNC_NORMAL        0x00002
#define SQLITE_SYNC_FULL          0x00003
#define SQLITE_SYNC_DATAONLY      0x00010
</pre></blockquote>

HLR H10265 S10110 S10120
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_INTEGER  1
#define SQLITE_FLOAT    2
#define SQLITE_BLOB     4
#define SQLITE_NULL     5
#ifdef SQLITE_TEXT
# undef SQLITE_TEXT
#else
# define SQLITE_TEXT     3
#endif
#define SQLITE3_TEXT     3
</pre></blockquote>

HLR H10267 S50200 H16100
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_UTF8           1
#define SQLITE_UTF16LE        2
#define SQLITE_UTF16BE        3
#define SQLITE_UTF16          4    /* Use native byte order */
#define SQLITE_ANY            5    /* sqlite3_create_function only */
#define SQLITE_UTF16_ALIGNED  8    /* sqlite3_create_collation only */
</pre></blockquote>

HLR H10280 S30100
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
typedef void (*sqlite3_destructor_type)(void*);
#define SQLITE_STATIC      ((sqlite3_destructor_type)0)
#define SQLITE_TRANSIENT   ((sqlite3_destructor_type)-1)
</pre></blockquote>

HLR H10310 S20000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
SQLITE_EXTERN char *sqlite3_temp_directory;
</pre></blockquote>

HLR H10330 S30900
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_enable_shared_cache(int);
</pre></blockquote>

HLR H10331 S30900
A successful invocation of [sqlite3_enable_shared_cache(B)]
will enable or disable shared cache mode for any subsequently
created [database connection] in the same process.

HLR H10336 S30900
When shared cache is enabled, the [sqlite3_create_module()]
interface will always return an error.

HLR H10337 S30900
The [sqlite3_enable_shared_cache(B)] interface returns
[SQLITE_OK] if shared cache was enabled or disabled successfully.

HLR H10339 S30900
Shared cache is disabled by default.

HLR H10510 S70200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_complete(const char *sql);
int sqlite3_complete16(const void *sql);
</pre></blockquote>

HLR H10511 S70200
A successful evaluation of [sqlite3_complete()] or
[sqlite3_complete16()] functions shall
return a numeric 1 if and only if the last non-whitespace
token in their input is a semicolon that is not in between
the BEGIN and END of a CREATE TRIGGER statement.

HLR H10512 S70200
If a memory allocation error occurs during an invocation
of [sqlite3_complete()] or [sqlite3_complete16()] then the
routine shall return [SQLITE_NOMEM].

HLR H10530 S40410
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_sleep(int);
</pre></blockquote>

HLR H10533 S40410
The [sqlite3_sleep(M)] interface invokes the xSleep
method of the default [sqlite3_vfs|VFS] in order to
suspend execution of the current thread for at least
M milliseconds.

HLR H10536 S40410
The [sqlite3_sleep(M)] interface returns the number of
milliseconds of sleep actually requested of the operating
system, which might be larger than the parameter M.

HLR H11110 S20110
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
typedef struct sqlite3_file sqlite3_file;
struct sqlite3_file {
const struct sqlite3_io_methods *pMethods;  /* Methods for an open file */
};
</pre></blockquote>

HLR H11120 S20110
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
typedef struct sqlite3_io_methods sqlite3_io_methods;
struct sqlite3_io_methods {
int iVersion;
int (*xClose)(sqlite3_file*);
int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);
int (*xTruncate)(sqlite3_file*, sqlite3_int64 size);
int (*xSync)(sqlite3_file*, int flags);
int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize);
int (*xLock)(sqlite3_file*, int);
int (*xUnlock)(sqlite3_file*, int);
int (*xCheckReservedLock)(sqlite3_file*, int *pResOut);
int (*xFileControl)(sqlite3_file*, int op, void *pArg);
int (*xSectorSize)(sqlite3_file*);
int (*xDeviceCharacteristics)(sqlite3_file*);
/* Additional methods may be added in future releases */
};
</pre></blockquote>

HLR H11140 S20100
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
typedef struct sqlite3_vfs sqlite3_vfs;
struct sqlite3_vfs {
int iVersion;            /* Structure version number */
int szOsFile;            /* Size of subclassed sqlite3_file */
int mxPathname;          /* Maximum file pathname length */
sqlite3_vfs *pNext;      /* Next registered VFS */
const char *zName;       /* Name of this virtual file system */
void *pAppData;          /* Pointer to application-specific data */
int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
int flags, int *pOutFlags);
int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut);
void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename);
void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg);
void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
void (*xDlClose)(sqlite3_vfs*, void*);
int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut);
int (*xSleep)(sqlite3_vfs*, int microseconds);
int (*xCurrentTime)(sqlite3_vfs*, double*);
int (*xGetLastError)(sqlite3_vfs*, int, char *);
/* New fields may be appended in figure versions.  The iVersion
** value will increment whenever this happens. */
};
</pre></blockquote>

HLR H11190 H11140
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_ACCESS_EXISTS    0
#define SQLITE_ACCESS_READWRITE 1
#define SQLITE_ACCESS_READ      2
</pre></blockquote>

HLR H11200 S20100
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
int sqlite3_vfs_unregister(sqlite3_vfs*);
</pre></blockquote>

HLR H11203 S20100
The [sqlite3_vfs_find(N)] interface returns a pointer to the
registered [sqlite3_vfs] object whose name exactly matches
the zero-terminated UTF-8 string N, or it returns NULL if
there is no match.

HLR H11206 S20100
If the N parameter to [sqlite3_vfs_find(N)] is NULL then
the function returns a pointer to the default [sqlite3_vfs]
object if there is one, or NULL if there is no default
[sqlite3_vfs] object.

HLR H11209 S20100
The [sqlite3_vfs_register(P,F)] interface registers the
well-formed [sqlite3_vfs] object P using the name given
by the zName field of the object.

HLR H11212 S20100
Using the [sqlite3_vfs_register(P,F)] interface to register
the same [sqlite3_vfs] object multiple times is a harmless no-op.

HLR H11215 S20100
The [sqlite3_vfs_register(P,F)] interface makes the [sqlite3_vfs]
object P the default [sqlite3_vfs] object if F is non-zero.

HLR H11218 S20100
The [sqlite3_vfs_unregister(P)] interface unregisters the
[sqlite3_vfs] object P so that it is no longer returned by
subsequent calls to [sqlite3_vfs_find()].

HLR H11300 S30800
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
</pre></blockquote>

HLR H11302 S70300
The [sqlite3_finalize(S)] interface destroys the
[prepared statement] S and releases all
memory and file resources held by that object.

HLR H11304 S70300
If the most recent call to [sqlite3_step(S)] for the
[prepared statement] S returned an error,
then [sqlite3_finalize(S)] returns that same error.

HLR H11310 S30800
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_FCNTL_LOCKSTATE        1
#define SQLITE_GET_LOCKPROXYFILE      2
#define SQLITE_SET_LOCKPROXYFILE      3
#define SQLITE_LAST_ERRNO             4
</pre></blockquote>

HLR H11400 S30800
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_test_control(int op, ...);
</pre></blockquote>

HLR H11410 H11400
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_TESTCTRL_PRNG_SAVE                5
#define SQLITE_TESTCTRL_PRNG_RESTORE             6
#define SQLITE_TESTCTRL_PRNG_RESET               7
#define SQLITE_TESTCTRL_BITVEC_TEST              8
#define SQLITE_TESTCTRL_FAULT_INSTALL            9
#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS     10
</pre></blockquote>

HLR H12000 S40200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
typedef struct sqlite3 sqlite3;
</pre></blockquote>

HLR H12010 S30100 S40200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_close(sqlite3 *);
</pre></blockquote>

HLR H12011 S30100
A successful call to [sqlite3_close(C)] shall destroy the
[database connection] object C.

HLR H12012 S30100
A successful call to [sqlite3_close(C)] shall return SQLITE_OK.

HLR H12013 S30100
A successful call to [sqlite3_close(C)] shall release all
memory and system resources associated with [database connection]
C.

HLR H12014 S30100
A call to [sqlite3_close(C)] on a [database connection] C that
has one or more open [prepared statements] shall fail with
an [SQLITE_BUSY] error code.

HLR H12015 S30100
A call to [sqlite3_close(C)] where C is a NULL pointer shall
be a harmless no-op returning SQLITE_OK.

HLR H12019 S30100
When [sqlite3_close(C)] is invoked on a [database connection] C
that has a pending transaction, the transaction shall be
rolled back.

HLR H12100 S10000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_exec(
sqlite3*,                                  /* An open database */
const char *sql,                           /* SQL to be evaluated */
int (*callback)(void*,int,char**,char**),  /* Callback function */
void *,                                    /* 1st argument to callback */
char **errmsg                              /* Error msg written here */
);
</pre></blockquote>

HLR H12101 S10000
A successful invocation of [sqlite3_exec(D,S,C,A,E)]
shall sequentially evaluate all of the UTF-8 encoded,
semicolon-separated SQL statements in the zero-terminated
string S within the context of the [database connection] D.

HLR H12102 S10000
If the S parameter to [sqlite3_exec(D,S,C,A,E)] is NULL then
the actions of the interface shall be the same as if the
S parameter were an empty string.

HLR H12104 S10000
The return value of [sqlite3_exec()] shall be [SQLITE_OK] if all
SQL statements run successfully and to completion.

HLR H12105 S10000
The return value of [sqlite3_exec()] shall be an appropriate
non-zero [error code] if any SQL statement fails.

HLR H12107 S10000
If one or more of the SQL statements handed to [sqlite3_exec()]
return results and the 3rd parameter is not NULL, then
the callback function specified by the 3rd parameter shall be
invoked once for each row of result.

HLR H12110 S10000
If the callback returns a non-zero value then [sqlite3_exec()]
shall abort the SQL statement it is currently evaluating,
skip all subsequent SQL statements, and return [SQLITE_ABORT].

HLR H12113 S10000
The [sqlite3_exec()] routine shall pass its 4th parameter through
as the 1st parameter of the callback.

HLR H12116 S10000
The [sqlite3_exec()] routine shall set the 2nd parameter of its
callback to be the number of columns in the current row of
result.

HLR H12119 S10000
The [sqlite3_exec()] routine shall set the 3rd parameter of its
callback to be an array of pointers to strings holding the
values for each column in the current result set row as
obtained from [sqlite3_column_text()].

HLR H12122 S10000
The [sqlite3_exec()] routine shall set the 4th parameter of its
callback to be an array of pointers to strings holding the
names of result columns as obtained from [sqlite3_column_name()].

HLR H12125 S10000
If the 3rd parameter to [sqlite3_exec()] is NULL then
[sqlite3_exec()] shall silently discard query results.

HLR H12131 S10000
If an error occurs while parsing or evaluating any of the SQL
statements in the S parameter of [sqlite3_exec(D,S,C,A,E)] and if
the E parameter is not NULL, then [sqlite3_exec()] shall store
in *E an appropriate error message written into memory obtained
from [sqlite3_malloc()].

HLR H12134 S10000
The [sqlite3_exec(D,S,C,A,E)] routine shall set the value of
*E to NULL if E is not NULL and there are no errors.

HLR H12137 S10000
The [sqlite3_exec(D,S,C,A,E)] function shall set the [error code]
and message accessible via [sqlite3_errcode()],
[sqlite3_extended_errcode()],
[sqlite3_errmsg()], and [sqlite3_errmsg16()].

HLR H12138 S10000
If the S parameter to [sqlite3_exec(D,S,C,A,E)] is NULL or an
empty string or contains nothing other than whitespace, comments,
and/or semicolons, then results of [sqlite3_errcode()],
[sqlite3_extended_errcode()],
[sqlite3_errmsg()], and [sqlite3_errmsg16()]
shall reset to indicate no errors.

HLR H12200 S10700
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_extended_result_codes(sqlite3*, int onoff);
</pre></blockquote>

HLR H12201 S10700
Each new [database connection] shall have the
[extended result codes] feature disabled by default.

HLR H12202 S10700
The [sqlite3_extended_result_codes(D,F)] interface shall enable
[extended result codes] for the  [database connection] D
if the F parameter is true, or disable them if F is false.

HLR H12220 S10700
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
</pre></blockquote>

HLR H12221 S10700
The [sqlite3_last_insert_rowid()] function shall return the rowid
of the most recent successful [INSERT] performed on the same
[database connection] and within the same or higher level
trigger context, or zero if there have been no qualifying
[INSERT] statements.

HLR H12223 S10700
The [sqlite3_last_insert_rowid()] function shall return the
same value when called from the same trigger context
immediately before and after a [ROLLBACK].

HLR H12240 S10600
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_changes(sqlite3*);
</pre></blockquote>

HLR H12241 S10600
The [sqlite3_changes()] function shall return the number of
row changes caused by the most recent INSERT, UPDATE,
or DELETE statement on the same database connection and
within the same or higher trigger context, or zero if there have
not been any qualifying row changes.

HLR H12243 S10600
Statements of the form "DELETE FROM tablename" with no
WHERE clause shall cause subsequent calls to
[sqlite3_changes()] to return zero, regardless of the
number of rows originally in the table.

HLR H12260 S10600
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_total_changes(sqlite3*);
</pre></blockquote>

HLR H12261 S10600
The [sqlite3_total_changes()] returns the total number
of row changes caused by INSERT, UPDATE, and/or DELETE
statements on the same [database connection], in any
trigger context, since the database connection was created.

HLR H12263 S10600
Statements of the form "DELETE FROM tablename" with no
WHERE clause shall not change the value returned
by [sqlite3_total_changes()].

HLR H12270 S30500
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
void sqlite3_interrupt(sqlite3*);
</pre></blockquote>

HLR H12271 S30500
The [sqlite3_interrupt()] interface will force all running
SQL statements associated with the same database connection
to halt after processing at most one additional row of data.

HLR H12272 S30500
Any SQL statement that is interrupted by [sqlite3_interrupt()]
will return [SQLITE_INTERRUPT].

HLR H12280 S60400
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
void *sqlite3_profile(sqlite3*,
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
</pre></blockquote>

HLR H12281 S60400
The callback function registered by [sqlite3_trace()]
shall be invoked
whenever an SQL statement first begins to execute and
whenever a trigger subprogram first begins to run.

HLR H12282 S60400
Each call to [sqlite3_trace()] shall override the previously
registered trace callback.

HLR H12283 S60400
A NULL trace callback shall disable tracing.

HLR H12284 S60400
The first argument to the trace callback shall be a copy of
the pointer which was the 3rd argument to [sqlite3_trace()].

HLR H12285 S60400
The second argument to the trace callback is a
zero-terminated UTF-8 string containing the original text
of the SQL statement as it was passed into [sqlite3_prepare_v2()]
or the equivalent, or an SQL comment indicating the beginning
of a trigger subprogram.

HLR H12287 S60400
The callback function registered by [sqlite3_profile()] is invoked
as each SQL statement finishes.

HLR H12288 S60400
The first parameter to the profile callback is a copy of
the 3rd parameter to [sqlite3_profile()].

HLR H12289 S60400
The second parameter to the profile callback is a
zero-terminated UTF-8 string that contains the complete text of
the SQL statement as it was processed by [sqlite3_prepare_v2()]
or the equivalent.

HLR H12290 S60400
The third parameter to the profile callback is an estimate
of the number of nanoseconds of wall-clock time required to
run the SQL statement from start to finish.

HLR H12310 S40400
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
</pre></blockquote>

HLR H12311 S40400
The [sqlite3_busy_handler(D,C,A)] function shall replace
busy callback in the [database connection] D with a new
a new busy handler C and application data pointer A.

HLR H12312 S40400
Newly created [database connections] shall have a busy
handler of NULL.

HLR H12314 S40400
When two or more [database connections] share a
[sqlite3_enable_shared_cache | common cache],
the busy handler for the database connection currently using
the cache shall be invoked when the cache encounters a lock.

HLR H12316 S40400
If a busy handler callback returns zero, then the SQLite interface
that provoked the locking event shall return [SQLITE_BUSY].

HLR H12318 S40400
SQLite shall invokes the busy handler with two arguments which
are a copy of the pointer supplied by the 3rd parameter to
[sqlite3_busy_handler()] and a count of the number of prior
invocations of the busy handler for the same locking event.

HLR H12340 S40410
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_busy_timeout(sqlite3*, int ms);
</pre></blockquote>

HLR H12341 S40410
The [sqlite3_busy_timeout()] function shall override any prior
[sqlite3_busy_timeout()] or [sqlite3_busy_handler()] setting
on the same [database connection].

HLR H12343 S40410
If the 2nd parameter to [sqlite3_busy_timeout()] is less than
or equal to zero, then the busy handler shall be cleared so that
all subsequent locking events immediately return [SQLITE_BUSY].

HLR H12344 S40410
If the 2nd parameter to [sqlite3_busy_timeout()] is a positive
number N, then a busy handler shall be set that repeatedly calls
the xSleep() method in the [sqlite3_vfs | VFS interface] until
either the lock clears or until the cumulative sleep time
reported back by xSleep() exceeds N milliseconds.

HLR H12370 S10000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_get_table(
sqlite3 *db,          /* An open database */
const char *zSql,     /* SQL to be evaluated */
char ***pazResult,    /* Results of the query */
int *pnRow,           /* Number of result rows written here */
int *pnColumn,        /* Number of result columns written here */
char **pzErrmsg       /* Error msg written here */
);
void sqlite3_free_table(char **result);
</pre></blockquote>

HLR H12371 S10000
If a [sqlite3_get_table()] fails a memory allocation, then
it shall free the result table under construction, abort the
query in process, skip any subsequent queries, set the
*pazResult output pointer to NULL and return [SQLITE_NOMEM].

HLR H12373 S10000
If the pnColumn parameter to [sqlite3_get_table()] is not NULL
then a successful invocation of [sqlite3_get_table()] shall
write the number of columns in the
result set of the query into *pnColumn.

HLR H12374 S10000
If the pnRow parameter to [sqlite3_get_table()] is not NULL
then a successful invocation of [sqlite3_get_table()] shall
writes the number of rows in the
result set of the query into *pnRow.

HLR H12376 S10000
A successful invocation of [sqlite3_get_table()] that computes
N rows of result with C columns per row shall make *pazResult
point to an array of pointers to (N+1)*C strings where the first
C strings are column names as obtained from
[sqlite3_column_name()] and the rest are column result values
obtained from [sqlite3_column_text()].

HLR H12379 S10000
The values in the pazResult array returned by [sqlite3_get_table()]
shall remain valid until cleared by [sqlite3_free_table()].

HLR H12382 S10000
When an error occurs during evaluation of [sqlite3_get_table()]
the function shall set *pazResult to NULL, write an error message
into memory obtained from [sqlite3_malloc()], make
**pzErrmsg point to that error message, and return a
appropriate [error code].

HLR H12500 S70100
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_set_authorizer(
sqlite3*,
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
void *pUserData
);
</pre></blockquote>

HLR H12501 S70100
The [sqlite3_set_authorizer(D,...)] interface registers a
authorizer callback with database connection D.

HLR H12502 S70100
The authorizer callback is invoked as SQL statements are
being parseed and compiled.

HLR H12503 S70100
If the authorizer callback returns any value other than
[SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY], then
the application interface call that caused
the authorizer callback to run shall fail with an
[SQLITE_ERROR] error code and an appropriate error message.

HLR H12504 S70100
When the authorizer callback returns [SQLITE_OK], the operation
described is processed normally.

HLR H12505 S70100
When the authorizer callback returns [SQLITE_DENY], the
application interface call that caused the
authorizer callback to run shall fail
with an [SQLITE_ERROR] error code and an error message
explaining that access is denied.

HLR H12506 S70100
If the authorizer code (the 2nd parameter to the authorizer
callback) is [SQLITE_READ] and the authorizer callback returns
[SQLITE_IGNORE], then the prepared statement is constructed to
insert a NULL value in place of the table column that would have
been read if [SQLITE_OK] had been returned.

HLR H12507 S70100
If the authorizer code (the 2nd parameter to the authorizer
callback) is anything other than [SQLITE_READ], then
a return of [SQLITE_IGNORE] has the same effect as [SQLITE_DENY].

HLR H12510 S70100
The first parameter to the authorizer callback is a copy of
the third parameter to the [sqlite3_set_authorizer()] interface.

HLR H12511 S70100
The second parameter to the callback is an integer
[SQLITE_COPY | action code] that specifies the particular action
to be authorized.

HLR H12512 S70100
The third through sixth parameters to the callback are
zero-terminated strings that contain
additional details about the action to be authorized.

HLR H12520 S70100
Each call to [sqlite3_set_authorizer()] overrides
any previously installed authorizer.

HLR H12521 S70100
A NULL authorizer means that no authorization
callback is invoked.

HLR H12522 S70100
The default authorizer is NULL.

HLR H12550 H12500
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
/******************************************* 3rd ************ 4th ***********/
#define SQLITE_CREATE_INDEX          1   /* Index Name      Table Name      */
#define SQLITE_CREATE_TABLE          2   /* Table Name      NULL            */
#define SQLITE_CREATE_TEMP_INDEX     3   /* Index Name      Table Name      */
#define SQLITE_CREATE_TEMP_TABLE     4   /* Table Name      NULL            */
#define SQLITE_CREATE_TEMP_TRIGGER   5   /* Trigger Name    Table Name      */
#define SQLITE_CREATE_TEMP_VIEW      6   /* View Name       NULL            */
#define SQLITE_CREATE_TRIGGER        7   /* Trigger Name    Table Name      */
#define SQLITE_CREATE_VIEW           8   /* View Name       NULL            */
#define SQLITE_DELETE                9   /* Table Name      NULL            */
#define SQLITE_DROP_INDEX           10   /* Index Name      Table Name      */
#define SQLITE_DROP_TABLE           11   /* Table Name      NULL            */
#define SQLITE_DROP_TEMP_INDEX      12   /* Index Name      Table Name      */
#define SQLITE_DROP_TEMP_TABLE      13   /* Table Name      NULL            */
#define SQLITE_DROP_TEMP_TRIGGER    14   /* Trigger Name    Table Name      */
#define SQLITE_DROP_TEMP_VIEW       15   /* View Name       NULL            */
#define SQLITE_DROP_TRIGGER         16   /* Trigger Name    Table Name      */
#define SQLITE_DROP_VIEW            17   /* View Name       NULL            */
#define SQLITE_INSERT               18   /* Table Name      NULL            */
#define SQLITE_PRAGMA               19   /* Pragma Name     1st arg or NULL */
#define SQLITE_READ                 20   /* Table Name      Column Name     */
#define SQLITE_SELECT               21   /* NULL            NULL            */
#define SQLITE_TRANSACTION          22   /* NULL            NULL            */
#define SQLITE_UPDATE               23   /* Table Name      Column Name     */
#define SQLITE_ATTACH               24   /* Filename        NULL            */
#define SQLITE_DETACH               25   /* Database Name   NULL            */
#define SQLITE_ALTER_TABLE          26   /* Database Name   Table Name      */
#define SQLITE_REINDEX              27   /* Index Name      NULL            */
#define SQLITE_ANALYZE              28   /* Table Name      NULL            */
#define SQLITE_CREATE_VTABLE        29   /* Table Name      Module Name     */
#define SQLITE_DROP_VTABLE          30   /* Table Name      Module Name     */
#define SQLITE_FUNCTION             31   /* NULL            Function Name   */
#define SQLITE_COPY                  0   /* No longer used */
</pre></blockquote>

HLR H12551 H12500
The second parameter to an
[sqlite3_set_authorizer | authorizer callback] shall be an integer
[SQLITE_COPY | authorizer code] that specifies what action
is being authorized.

HLR H12552 H12500
The 3rd and 4th parameters to the
[sqlite3_set_authorizer | authorization callback]
shall be parameters or NULL depending on which
[SQLITE_COPY | authorizer code] is used as the second parameter.

HLR H12553 H12500
The 5th parameter to the
[sqlite3_set_authorizer | authorizer callback] shall be the name
of the database (example: "main", "temp", etc.) if applicable.

HLR H12554 H12500
The 6th parameter to the
[sqlite3_set_authorizer | authorizer callback] shall be the name
of the inner-most trigger or view that is responsible for
the access attempt or NULL if this access attempt is directly from
top-level SQL code.

HLR H12590 H12500
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_DENY   1   /* Abort the SQL statement with an error */
#define SQLITE_IGNORE 2   /* Don't allow access, but don't generate an error */
</pre></blockquote>

HLR H12600 S20500
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_load_extension(
sqlite3 *db,          /* Load the extension into this database connection */
const char *zFile,    /* Name of the shared library containing extension */
const char *zProc,    /* Entry point.  Derived from zFile if 0 */
char **pzErrMsg       /* Put error message here if not 0 */
);
</pre></blockquote>

HLR H12620 S20500
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
</pre></blockquote>

HLR H12640 S20500
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_auto_extension(void (*xEntryPoint)(void));
</pre></blockquote>

HLR H12660 S20500
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
void sqlite3_reset_auto_extension(void);
</pre></blockquote>

HLR H12700 S40200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_open(
const char *filename,   /* Database filename (UTF-8) */
sqlite3 **ppDb          /* OUT: SQLite db handle */
);
int sqlite3_open16(
const void *filename,   /* Database filename (UTF-16) */
sqlite3 **ppDb          /* OUT: SQLite db handle */
);
int sqlite3_open_v2(
const char *filename,   /* Database filename (UTF-8) */
sqlite3 **ppDb,         /* OUT: SQLite db handle */
int flags,              /* Flags */
const char *zVfs        /* Name of VFS module to use */
);
</pre></blockquote>

HLR H12701 S40200
The [sqlite3_open()], [sqlite3_open16()], and
[sqlite3_open_v2()] interfaces create a new
[database connection] associated with
the database file given in their first parameter.

HLR H12702 S40200
The filename argument is interpreted as UTF-8
for [sqlite3_open()] and [sqlite3_open_v2()] and as UTF-16
in the native byte order for [sqlite3_open16()].

HLR H12703 S40200
A successful invocation of [sqlite3_open()], [sqlite3_open16()],
or [sqlite3_open_v2()] writes a pointer to a new
[database connection] into *ppDb.

HLR H12704 S40200
The [sqlite3_open()], [sqlite3_open16()], and
[sqlite3_open_v2()] interfaces return [SQLITE_OK] upon success,
or an appropriate [error code] on failure.

HLR H12706 S40200
The default text encoding for a new database created using
[sqlite3_open()] or [sqlite3_open_v2()] will be UTF-8.

HLR H12707 S40200
The default text encoding for a new database created using
[sqlite3_open16()] will be UTF-16.

HLR H12709 S40200
The [sqlite3_open(F,D)] interface is equivalent to
[sqlite3_open_v2(F,D,G,0)] where the G parameter is
[SQLITE_OPEN_READWRITE]|[SQLITE_OPEN_CREATE].

HLR H12711 S40200
If the G parameter to [sqlite3_open_v2(F,D,G,V)] contains the
bit value [SQLITE_OPEN_READONLY] then the database is opened
for reading only.

HLR H12712 S40200
If the G parameter to [sqlite3_open_v2(F,D,G,V)] contains the
bit value [SQLITE_OPEN_READWRITE] then the database is opened
reading and writing if possible, or for reading only if the
file is write protected by the operating system.

HLR H12713 S40200
If the G parameter to [sqlite3_open_v2(F,D,G,V)] omits the
bit value [SQLITE_OPEN_CREATE] and the database does not
previously exist, an error is returned.

HLR H12714 S40200
If the G parameter to [sqlite3_open_v2(F,D,G,V)] contains the
bit value [SQLITE_OPEN_CREATE] and the database does not
previously exist, then an attempt is made to create and
initialize the database.

HLR H12717 S40200
If the filename argument to [sqlite3_open()], [sqlite3_open16()],
or [sqlite3_open_v2()] is ":memory:", then an private,
ephemeral, in-memory database is created for the connection.
<todo>Is SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE required
in sqlite3_open_v2()?</todo>

HLR H12719 S40200
If the filename is NULL or an empty string, then a private,
ephemeral on-disk database will be created.
<todo>Is SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE required
in sqlite3_open_v2()?</todo>

HLR H12721 S40200
The [database connection] created by [sqlite3_open_v2(F,D,G,V)]
will use the [sqlite3_vfs] object identified by the V parameter,
or the default [sqlite3_vfs] object if V is a NULL pointer.

HLR H12723 S40200
Two [database connections] will share a common cache if both were
opened with the same VFS while [shared cache mode] was enabled and
if both filenames compare equal using memcmp() after having been
processed by the [sqlite3_vfs | xFullPathname] method of the VFS.

HLR H12760 S20600
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_limit(sqlite3*, int id, int newVal);
</pre></blockquote>

HLR H12762 S20600
A successful call to [sqlite3_limit(D,C,V)] where V is
positive changes the limit on the size of construct C in the
[database connection] D to the lesser of V and the hard upper
bound on the size of C that is set at compile-time.

HLR H12766 S20600
A successful call to [sqlite3_limit(D,C,V)] where V is negative
leaves the state of the [database connection] D unchanged.

HLR H12769 S20600
A successful call to [sqlite3_limit(D,C,V)] returns the
value of the limit on the size of construct C in the
[database connection] D as it was prior to the call.

HLR H12790 H12760
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_LIMIT_LENGTH                    0
#define SQLITE_LIMIT_SQL_LENGTH                1
#define SQLITE_LIMIT_COLUMN                    2
#define SQLITE_LIMIT_EXPR_DEPTH                3
#define SQLITE_LIMIT_COMPOUND_SELECT           4
#define SQLITE_LIMIT_VDBE_OP                   5
#define SQLITE_LIMIT_FUNCTION_ARG              6
#define SQLITE_LIMIT_ATTACHED                  7
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH       8
#define SQLITE_LIMIT_VARIABLE_NUMBER           9
</pre></blockquote>

HLR H12800 S60200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_errcode(sqlite3 *db);
int sqlite3_extended_errcode(sqlite3 *db);
const char *sqlite3_errmsg(sqlite3*);
const void *sqlite3_errmsg16(sqlite3*);
</pre></blockquote>

HLR H12801 S60200
The [sqlite3_errcode(D)] interface returns the numeric
[result code] or [extended result code] for the most recently
failed interface call associated with the [database connection] D.

HLR H12802 S60200
The [sqlite3_extended_errcode(D)] interface returns the numeric
[extended result code] for the most recently
failed interface call associated with the [database connection] D.

HLR H12803 S60200
The [sqlite3_errmsg(D)] and [sqlite3_errmsg16(D)]
interfaces return English-language text that describes
the error in the mostly recently failed interface call,
encoded as either UTF-8 or UTF-16 respectively.

HLR H12807 S60200
The strings returned by [sqlite3_errmsg()] and [sqlite3_errmsg16()]
are valid until the next SQLite interface call.

HLR H12808 S60200
Calls to API routines that do not return an error code
(example: [sqlite3_data_count()]) do not
change the error code or message returned by
[sqlite3_errcode()], [sqlite3_extended_errcode()],
[sqlite3_errmsg()], or [sqlite3_errmsg16()].

HLR H12809 S60200
Interfaces that are not associated with a specific
[database connection] (examples:
[sqlite3_mprintf()] or [sqlite3_enable_shared_cache()]
do not change the values returned by
[sqlite3_errcode()], [sqlite3_extended_errcode()],
[sqlite3_errmsg()], or [sqlite3_errmsg16()].

HLR H12850 S60300
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_table_column_metadata(
sqlite3 *db,                /* Connection handle */
const char *zDbName,        /* Database name or NULL */
const char *zTableName,     /* Table name */
const char *zColumnName,    /* Column name */
char const **pzDataType,    /* OUTPUT: Declared data type */
char const **pzCollSeq,     /* OUTPUT: Collation sequence name */
int *pNotNull,              /* OUTPUT: True if NOT NULL constraint exists */
int *pPrimaryKey,           /* OUTPUT: True if column part of PK */
int *pAutoinc               /* OUTPUT: True if column is auto-increment */
);
</pre></blockquote>

HLR H12910 S60400
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
</pre></blockquote>

HLR H12911 S60400
The callback function registered by sqlite3_progress_handler()
is invoked periodically during long running calls to
[sqlite3_step()].

HLR H12912 S60400
The progress callback is invoked once for every N virtual
machine opcodes, where N is the second argument to
the [sqlite3_progress_handler()] call that registered
the callback.  If N is less than 1, sqlite3_progress_handler()
acts as if a NULL progress handler had been specified.

HLR H12913 S60400
The progress callback itself is identified by the third
argument to sqlite3_progress_handler().

HLR H12914 S60400
The fourth argument to sqlite3_progress_handler() is a
void pointer passed to the progress callback
function each time it is invoked.

HLR H12915 S60400
If a call to [sqlite3_step()] results in fewer than N opcodes
being executed, then the progress callback is never invoked.

HLR H12916 S60400
Every call to [sqlite3_progress_handler()]
overwrites any previously registered progress handler.

HLR H12917 S60400
If the progress handler callback is NULL then no progress
handler is invoked.

HLR H12918 S30500 S60400
If the progress callback returns a result other than 0, then
the behavior is a if [sqlite3_interrupt()] had been called.

HLR H12930 S60200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_get_autocommit(sqlite3*);
</pre></blockquote>

HLR H12931 S60200
The [sqlite3_get_autocommit(D)] interface returns non-zero or
zero if the [database connection] D is or is not in autocommit
mode, respectively.

HLR H12932 S60200
Autocommit mode is on by default.

HLR H12933 S60200
Autocommit mode is disabled by a successful [BEGIN] statement.

HLR H12934 S60200
Autocommit mode is enabled by a successful [COMMIT] or [ROLLBACK]
statement.

HLR H12950 S60400
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
</pre></blockquote>

HLR H12951 S60400
The [sqlite3_commit_hook(D,F,P)] interface registers the
callback function F to be invoked with argument P whenever
a transaction commits on the [database connection] D.

HLR H12952 S60400
The [sqlite3_commit_hook(D,F,P)] interface returns the P argument
from the previous call with the same [database connection] D,
or NULL on the first call for a particular database connection D.

HLR H12953 S60400
Each call to [sqlite3_commit_hook()] overwrites the callback
registered by prior calls.

HLR H12954 S60400
If the F argument to [sqlite3_commit_hook(D,F,P)] is NULL
then the commit hook callback is canceled and no callback
is invoked when a transaction commits.

HLR H12955 S60400
If the commit callback returns non-zero then the commit is
converted into a rollback.

HLR H12961 S60400
The [sqlite3_rollback_hook(D,F,P)] interface registers the
callback function F to be invoked with argument P whenever
a transaction rolls back on the [database connection] D.

HLR H12962 S60400
The [sqlite3_rollback_hook(D,F,P)] interface returns the P
argument from the previous call with the same
[database connection] D, or NULL on the first call
for a particular database connection D.

HLR H12963 S60400
Each call to [sqlite3_rollback_hook()] overwrites the callback
registered by prior calls.

HLR H12964 S60400
If the F argument to [sqlite3_rollback_hook(D,F,P)] is NULL
then the rollback hook callback is canceled and no callback
is invoked when a transaction rolls back.

HLR H12970 S60400
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
void *sqlite3_update_hook(
sqlite3*,
void(*)(void *,int ,char const *,char const *,sqlite3_int64),
void*
);
</pre></blockquote>

HLR H12971 S60400
The [sqlite3_update_hook(D,F,P)] interface causes the callback
function F to be invoked with first parameter P whenever
a table row is modified, inserted, or deleted on
the [database connection] D.

HLR H12973 S60400
The [sqlite3_update_hook(D,F,P)] interface returns the value
of P for the previous call on the same [database connection] D,
or NULL for the first call.

HLR H12975 S60400
If the update hook callback F in [sqlite3_update_hook(D,F,P)]
is NULL then the no update callbacks are made.

HLR H12977 S60400
Each call to [sqlite3_update_hook(D,F,P)] overrides prior calls
to the same interface on the same [database connection] D.

HLR H12979 S60400
The update hook callback is not invoked when internal system
tables such as sqlite_master and sqlite_sequence are modified.

HLR H12981 S60400
The second parameter to the update callback
is one of [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE],
depending on the operation that caused the callback to be invoked.

HLR H12983 S60400
The third and fourth arguments to the callback contain pointers
to zero-terminated UTF-8 strings which are the names of the
database and table that is being updated.

HLR H12985 S60400
The final callback parameter is the rowid of the row after
the change occurs.

HLR H13000 H13010
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
typedef struct sqlite3_stmt sqlite3_stmt;
</pre></blockquote>

HLR H13010 S10000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_prepare(
sqlite3 *db,            /* Database handle */
const char *zSql,       /* SQL statement, UTF-8 encoded */
int nByte,              /* Maximum length of zSql in bytes. */
sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
const char **pzTail     /* OUT: Pointer to unused portion of zSql */
);
int sqlite3_prepare_v2(
sqlite3 *db,            /* Database handle */
const char *zSql,       /* SQL statement, UTF-8 encoded */
int nByte,              /* Maximum length of zSql in bytes. */
sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
const char **pzTail     /* OUT: Pointer to unused portion of zSql */
);
int sqlite3_prepare16(
sqlite3 *db,            /* Database handle */
const void *zSql,       /* SQL statement, UTF-16 encoded */
int nByte,              /* Maximum length of zSql in bytes. */
sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
const void **pzTail     /* OUT: Pointer to unused portion of zSql */
);
int sqlite3_prepare16_v2(
sqlite3 *db,            /* Database handle */
const void *zSql,       /* SQL statement, UTF-16 encoded */
int nByte,              /* Maximum length of zSql in bytes. */
sqlite3_stmt **ppStmt,  /* OUT: Statement handle */
const void **pzTail     /* OUT: Pointer to unused portion of zSql */
);
</pre></blockquote>

HLR H13011 S10000
The [sqlite3_prepare(db,zSql,...)] and
[sqlite3_prepare_v2(db,zSql,...)] interfaces interpret the
text in their zSql parameter as UTF-8.

HLR H13012 S10000
The [sqlite3_prepare16(db,zSql,...)] and
[sqlite3_prepare16_v2(db,zSql,...)] interfaces interpret the
text in their zSql parameter as UTF-16 in the native byte order.

HLR H13013 S10000
If the nByte argument to [sqlite3_prepare_v2(db,zSql,nByte,...)]
and its variants is less than zero, the SQL text is
read from zSql is read up to the first zero terminator.

HLR H13014 S10000
If the nByte argument to [sqlite3_prepare_v2(db,zSql,nByte,...)]
and its variants is non-negative, then at most nBytes bytes of
SQL text is read from zSql.

HLR H13015 S10000
In [sqlite3_prepare_v2(db,zSql,N,P,pzTail)] and its variants
if the zSql input text contains more than one SQL statement
and pzTail is not NULL, then *pzTail is made to point to the
first byte past the end of the first SQL statement in zSql.
<todo>What does *pzTail point to if there is one statement?</todo>

HLR H13016 S10000
A successful call to [sqlite3_prepare_v2(db,zSql,N,ppStmt,...)]
or one of its variants writes into *ppStmt a pointer to a new
[prepared statement] or a pointer to NULL if zSql contains
nothing other than whitespace or comments.

HLR H13019 S10000
The [sqlite3_prepare_v2()] interface and its variants return
[SQLITE_OK] or an appropriate [error code] upon failure.

HLR H13021 S10000
Before [sqlite3_prepare(db,zSql,nByte,ppStmt,pzTail)] or its
variants returns an error (any value other than [SQLITE_OK]),
they first set *ppStmt to NULL.

HLR H13100 H13000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
const char *sqlite3_sql(sqlite3_stmt *pStmt);
</pre></blockquote>

HLR H13101 H13000
If the [prepared statement] passed as the argument to
[sqlite3_sql()] was compiled using either [sqlite3_prepare_v2()] or
[sqlite3_prepare16_v2()], then [sqlite3_sql()] returns
a pointer to a zero-terminated string containing a UTF-8 rendering
of the original SQL statement.

HLR H13102 H13000
If the [prepared statement] passed as the argument to
[sqlite3_sql()] was compiled using either [sqlite3_prepare()] or
[sqlite3_prepare16()], then [sqlite3_sql()] returns a NULL pointer.

HLR H13103 H13000
The string returned by [sqlite3_sql(S)] is valid until the
[prepared statement] S is deleted using [sqlite3_finalize(S)].

HLR H13120 S60600
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
</pre></blockquote>

HLR H13123 S60600
The [sqlite3_db_handle(S)] interface returns a pointer
to the [database connection] associated with the
[prepared statement] S.

HLR H13140 S60600
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
</pre></blockquote>

HLR H13143 S60600
If D is a [database connection] that holds one or more
unfinalized [prepared statements] and S is a NULL pointer,
then [sqlite3_next_stmt(D, S)] routine shall return a pointer
to one of the prepared statements associated with D.

HLR H13146 S60600
If D is a [database connection] that holds no unfinalized
[prepared statements] and S is a NULL pointer, then
[sqlite3_next_stmt(D, S)] routine shall return a NULL pointer.

HLR H13149 S60600
If S is a [prepared statement] in the [database connection] D
and S is not the last prepared statement in D, then
[sqlite3_next_stmt(D, S)] routine shall return a pointer
to the next prepared statement in D after S.

HLR H13152 S60600
If S is the last [prepared statement] in the
[database connection] D then the [sqlite3_next_stmt(D, S)]
routine shall return a NULL pointer.

HLR H13200 S10000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_step(sqlite3_stmt*);
</pre></blockquote>

HLR H13202 S10000
If the [prepared statement] S is ready to be run, then
[sqlite3_step(S)] advances that prepared statement until
completion or until it is ready to return another row of the
result set, or until an [sqlite3_interrupt | interrupt]
or a run-time error occurs.

HLR H13300 S70300 S30100
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_finalize(sqlite3_stmt *pStmt);
</pre></blockquote>

HLR H13330 S70300
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_reset(sqlite3_stmt *pStmt);
</pre></blockquote>

HLR H13500 S70300
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
int sqlite3_bind_double(sqlite3_stmt*, int, double);
int sqlite3_bind_int(sqlite3_stmt*, int, int);
int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
int sqlite3_bind_null(sqlite3_stmt*, int);
int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
</pre></blockquote>

HLR H13506 S70300
The [SQL statement compiler] recognizes tokens of the forms
"?", "?NNN", "$VVV", ":VVV", and "@VVV" as SQL parameters,
where NNN is any sequence of one or more digits
and where VVV is any sequence of one or more alphanumeric
characters or "::" optionally followed by a string containing
no spaces and contained within parentheses.

HLR H13509 S70300
The initial value of an SQL parameter is NULL.

HLR H13512 S70300
The index of an "?" SQL parameter is one larger than the
largest index of SQL parameter to the left, or 1 if
the "?" is the leftmost SQL parameter.

HLR H13515 S70300
The index of an "?NNN" SQL parameter is the integer NNN.

HLR H13518 S70300
The index of an ":VVV", "$VVV", or "@VVV" SQL parameter is
the same as the index of leftmost occurrences of the same
parameter, or one more than the largest index over all
parameters to the left if this is the first occurrence
of this parameter, or 1 if this is the leftmost parameter.

HLR H13521 S70300
The [SQL statement compiler] fails with an [SQLITE_RANGE]
error if the index of an SQL parameter is less than 1
or greater than the compile-time SQLITE_MAX_VARIABLE_NUMBER
parameter.

HLR H13524 S70300
Calls to [sqlite3_bind_text | sqlite3_bind(S,N,V,...)]
associate the value V with all SQL parameters having an
index of N in the [prepared statement] S.

HLR H13527 S70300
Calls to [sqlite3_bind_text | sqlite3_bind(S,N,...)]
override prior calls with the same values of S and N.

HLR H13530 S70300
Bindings established by [sqlite3_bind_text | sqlite3_bind(S,...)]
persist across calls to [sqlite3_reset(S)].

HLR H13533 S70300
In calls to [sqlite3_bind_blob(S,N,V,L,D)],
[sqlite3_bind_text(S,N,V,L,D)], or
[sqlite3_bind_text16(S,N,V,L,D)] SQLite binds the first L
bytes of the BLOB or string pointed to by V, when L
is non-negative.

HLR H13536 S70300
In calls to [sqlite3_bind_text(S,N,V,L,D)] or
[sqlite3_bind_text16(S,N,V,L,D)] SQLite binds characters
from V through the first zero character when L is negative.

HLR H13539 S70300
In calls to [sqlite3_bind_blob(S,N,V,L,D)],
[sqlite3_bind_text(S,N,V,L,D)], or
[sqlite3_bind_text16(S,N,V,L,D)] when D is the special
constant [SQLITE_STATIC], SQLite assumes that the value V
is held in static unmanaged space that will not change
during the lifetime of the binding.

HLR H13542 S70300
In calls to [sqlite3_bind_blob(S,N,V,L,D)],
[sqlite3_bind_text(S,N,V,L,D)], or
[sqlite3_bind_text16(S,N,V,L,D)] when D is the special
constant [SQLITE_TRANSIENT], the routine makes a
private copy of the value V before it returns.

HLR H13545 S70300
In calls to [sqlite3_bind_blob(S,N,V,L,D)],
[sqlite3_bind_text(S,N,V,L,D)], or
[sqlite3_bind_text16(S,N,V,L,D)] when D is a pointer to
a function, SQLite invokes that function to destroy the
value V after it has finished using the value V.

HLR H13548 S70300
In calls to [sqlite3_bind_zeroblob(S,N,V,L)] the value bound
is a BLOB of L bytes, or a zero-length BLOB if L is negative.

HLR H13551 S70300
In calls to [sqlite3_bind_value(S,N,V)] the V argument may
be either a [protected sqlite3_value] object or an
[unprotected sqlite3_value] object.

HLR H13600 S70300
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_bind_parameter_count(sqlite3_stmt*);
</pre></blockquote>

HLR H13601 S70300
The [sqlite3_bind_parameter_count(S)] interface returns
the largest index of all SQL parameters in the
[prepared statement] S, or 0 if S contains no SQL parameters.

HLR H13620 S70300
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
</pre></blockquote>

HLR H13621 S70300
The [sqlite3_bind_parameter_name(S,N)] interface returns
a UTF-8 rendering of the name of the SQL parameter in
the [prepared statement] S having index N, or
NULL if there is no SQL parameter with index N or if the
parameter with index N is an anonymous parameter "?".

HLR H13640 S70300
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
</pre></blockquote>

HLR H13641 S70300
The [sqlite3_bind_parameter_index(S,N)] interface returns
the index of SQL parameter in the [prepared statement]
S whose name matches the UTF-8 string N, or 0 if there is
no match.

HLR H13660 S70300
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_clear_bindings(sqlite3_stmt*);
</pre></blockquote>

HLR H13661 S70300
The [sqlite3_clear_bindings(S)] interface resets all SQL
parameter bindings in the [prepared statement] S back to NULL.

HLR H13710 S10700
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_column_count(sqlite3_stmt *pStmt);
</pre></blockquote>

HLR H13711 S10700
The [sqlite3_column_count(S)] interface returns the number of
columns in the result set generated by the [prepared statement] S,
or 0 if S does not generate a result set.

HLR H13720 S10700
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
const char *sqlite3_column_name(sqlite3_stmt*, int N);
const void *sqlite3_column_name16(sqlite3_stmt*, int N);
</pre></blockquote>

HLR H13721 S10700
A successful invocation of the [sqlite3_column_name(S,N)]
interface returns the name of the Nth column (where 0 is
the leftmost column) for the result set of the
[prepared statement] S as a zero-terminated UTF-8 string.

HLR H13723 S10700
A successful invocation of the [sqlite3_column_name16(S,N)]
interface returns the name of the Nth column (where 0 is
the leftmost column) for the result set of the
[prepared statement] S as a zero-terminated UTF-16 string
in the native byte order.

HLR H13724 S10700
The [sqlite3_column_name()] and [sqlite3_column_name16()]
interfaces return a NULL pointer if they are unable to
allocate memory to hold their normal return strings.

HLR H13725 S10700
If the N parameter to [sqlite3_column_name(S,N)] or
[sqlite3_column_name16(S,N)] is out of range, then the
interfaces return a NULL pointer.

HLR H13726 S10700
The strings returned by [sqlite3_column_name(S,N)] and
[sqlite3_column_name16(S,N)] are valid until the next
call to either routine with the same S and N parameters
or until [sqlite3_finalize(S)] is called.

HLR H13727 S10700
When a result column of a [SELECT] statement contains
an AS clause, the name of that column is the identifier
to the right of the AS keyword.

HLR H13740 S10700
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
const char *sqlite3_column_database_name(sqlite3_stmt*,int);
const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
const char *sqlite3_column_table_name(sqlite3_stmt*,int);
const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
</pre></blockquote>

HLR H13741 S10700
The [sqlite3_column_database_name(S,N)] interface returns either
the UTF-8 zero-terminated name of the database from which the
Nth result column of the [prepared statement] S is extracted,
or NULL if the Nth column of S is a general expression
or if unable to allocate memory to store the name.

HLR H13742 S10700
The [sqlite3_column_database_name16(S,N)] interface returns either
the UTF-16 native byte order zero-terminated name of the database
from which the Nth result column of the [prepared statement] S is
extracted, or NULL if the Nth column of S is a general expression
or if unable to allocate memory to store the name.

HLR H13743 S10700
The [sqlite3_column_table_name(S,N)] interface returns either
the UTF-8 zero-terminated name of the table from which the
Nth result column of the [prepared statement] S is extracted,
or NULL if the Nth column of S is a general expression
or if unable to allocate memory to store the name.

HLR H13744 S10700
The [sqlite3_column_table_name16(S,N)] interface returns either
the UTF-16 native byte order zero-terminated name of the table
from which the Nth result column of the [prepared statement] S is
extracted, or NULL if the Nth column of S is a general expression
or if unable to allocate memory to store the name.

HLR H13745 S10700
The [sqlite3_column_origin_name(S,N)] interface returns either
the UTF-8 zero-terminated name of the table column from which the
Nth result column of the [prepared statement] S is extracted,
or NULL if the Nth column of S is a general expression
or if unable to allocate memory to store the name.

HLR H13746 S10700
The [sqlite3_column_origin_name16(S,N)] interface returns either
the UTF-16 native byte order zero-terminated name of the table
column from which the Nth result column of the
[prepared statement] S is extracted, or NULL if the Nth column
of S is a general expression or if unable to allocate memory
to store the name.

HLR H13748 S10700
The return values from
[sqlite3_column_database_name | column metadata interfaces]
are valid for the lifetime of the [prepared statement]
or until the encoding is changed by another metadata
interface call for the same prepared statement and column.

HLR H13760 S10700
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
const char *sqlite3_column_decltype(sqlite3_stmt*,int);
const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
</pre></blockquote>

HLR H13761 S10700
A successful call to [sqlite3_column_decltype(S,N)] returns a
zero-terminated UTF-8 string containing the declared datatype
of the table column that appears as the Nth column (numbered
from 0) of the result set to the [prepared statement] S.

HLR H13762 S10700
A successful call to [sqlite3_column_decltype16(S,N)]
returns a zero-terminated UTF-16 native byte order string
containing the declared datatype of the table column that appears
as the Nth column (numbered from 0) of the result set to the
[prepared statement] S.

HLR H13763 S10700
If N is less than 0 or N is greater than or equal to
the number of columns in the [prepared statement] S,
or if the Nth column of S is an expression or subquery rather
than a table column, or if a memory allocation failure
occurs during encoding conversions, then
calls to [sqlite3_column_decltype(S,N)] or
[sqlite3_column_decltype16(S,N)] return NULL.

HLR H13770 S10700
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_data_count(sqlite3_stmt *pStmt);
</pre></blockquote>

HLR H13771 S10700
After a call to [sqlite3_step(S)] that returns [SQLITE_ROW],
the [sqlite3_data_count(S)] routine will return the same value
as the [sqlite3_column_count(S)] function.

HLR H13772 S10700
After [sqlite3_step(S)] has returned any value other than
[SQLITE_ROW] or before [sqlite3_step(S)] has been called on the
[prepared statement] for the first time since it was
[sqlite3_prepare | prepared] or [sqlite3_reset | reset],
the [sqlite3_data_count(S)] routine returns zero.

HLR H13800 S10700
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
double sqlite3_column_double(sqlite3_stmt*, int iCol);
int sqlite3_column_int(sqlite3_stmt*, int iCol);
sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
int sqlite3_column_type(sqlite3_stmt*, int iCol);
sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
</pre></blockquote>

HLR H13803 S10700
The [sqlite3_column_blob(S,N)] interface converts the
Nth column in the current row of the result set for
the [prepared statement] S into a BLOB and then returns a
pointer to the converted value.

HLR H13806 S10700
The [sqlite3_column_bytes(S,N)] interface returns the
number of bytes in the BLOB or string (exclusive of the
zero terminator on the string) that was returned by the
most recent call to [sqlite3_column_blob(S,N)] or
[sqlite3_column_text(S,N)].

HLR H13809 S10700
The [sqlite3_column_bytes16(S,N)] interface returns the
number of bytes in the string (exclusive of the
zero terminator on the string) that was returned by the
most recent call to [sqlite3_column_text16(S,N)].

HLR H13812 S10700
The [sqlite3_column_double(S,N)] interface converts the
Nth column in the current row of the result set for the
[prepared statement] S into a floating point value and
returns a copy of that value.

HLR H13815 S10700
The [sqlite3_column_int(S,N)] interface converts the
Nth column in the current row of the result set for the
[prepared statement] S into a 64-bit signed integer and
returns the lower 32 bits of that integer.

HLR H13818 S10700
The [sqlite3_column_int64(S,N)] interface converts the
Nth column in the current row of the result set for the
[prepared statement] S into a 64-bit signed integer and
returns a copy of that integer.

HLR H13821 S10700
The [sqlite3_column_text(S,N)] interface converts the
Nth column in the current row of the result set for
the [prepared statement] S into a zero-terminated UTF-8
string and returns a pointer to that string.

HLR H13824 S10700
The [sqlite3_column_text16(S,N)] interface converts the
Nth column in the current row of the result set for the
[prepared statement] S into a zero-terminated 2-byte
aligned UTF-16 native byte order string and returns
a pointer to that string.

HLR H13827 S10700
The [sqlite3_column_type(S,N)] interface returns
one of [SQLITE_NULL], [SQLITE_INTEGER], [SQLITE_FLOAT],
[SQLITE_TEXT], or [SQLITE_BLOB] as appropriate for
the Nth column in the current row of the result set for
the [prepared statement] S.

HLR H13830 S10700
The [sqlite3_column_value(S,N)] interface returns a
pointer to an [unprotected sqlite3_value] object for the
Nth column in the current row of the result set for
the [prepared statement] S.

HLR H14100 S20000 S30200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_config(int, ...);
</pre></blockquote>

HLR H14103 S20000
A successful invocation of [sqlite3_config()] shall return
[SQLITE_OK].

HLR H14106 S20000
The [sqlite3_config()] interface shall return [SQLITE_MISUSE]
if it is invoked in between calls to [sqlite3_initialize()] and
[sqlite3_shutdown()].

HLR H14120 S20000
A successful call to [sqlite3_config]([SQLITE_CONFIG_SINGLETHREAD])
shall set the default [threading mode] to Single-thread.

HLR H14123 S20000
A successful call to [sqlite3_config]([SQLITE_CONFIG_MULTITHREAD])
shall set the default [threading mode] to Multi-thread.

HLR H14126 S20000
A successful call to [sqlite3_config]([SQLITE_CONFIG_SERIALIZED])
shall set the default [threading mode] to Serialized.

HLR H14129 S20000
A successful call to [sqlite3_config]([SQLITE_CONFIG_MUTEX],X)
where X is a pointer to an initialized [sqlite3_mutex_methods]
object shall cause all subsequent mutex operations performed
by SQLite to use the mutex methods that were present in X
during the call to [sqlite3_config()].

HLR H14132 S20000
A successful call to [sqlite3_config]([SQLITE_CONFIG_GETMUTEX],X)
where X is a pointer to an [sqlite3_mutex_methods] object
shall overwrite the content of [sqlite3_mutex_methods] object
with the mutex methods currently in use by SQLite.

HLR H14135 S20000
A successful call to [sqlite3_config]([SQLITE_CONFIG_MALLOC],M)
where M is a pointer to an initialized [sqlite3_mem_methods]
object shall cause all subsequent memory allocation operations
performed by SQLite to use the methods that were present in
M during the call to [sqlite3_config()].

HLR H14138 S20000
A successful call to [sqlite3_config]([SQLITE_CONFIG_GETMALLOC],M)
where M is a pointer to an [sqlite3_mem_methods] object shall
overwrite the content of [sqlite3_mem_methods] object with
the memory allocation methods currently in use by
SQLite.

HLR H14141 S20000
A successful call to [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],1)
shall enable the memory allocation status collection logic.

HLR H14144 S20000
A successful call to [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],0)
shall disable the memory allocation status collection logic.

HLR H14147 S20000
The memory allocation status collection logic shall be
enabled by default.

HLR H14150 S20000
A successful call to [sqlite3_config]([SQLITE_CONFIG_SCRATCH],S,Z,N)
where Z and N are non-negative integers and
S is a pointer to an aligned memory buffer not less than
Z*N bytes in size shall cause S to be used by the
[scratch memory allocator] for as many as N simulataneous
allocations each of size Z.

HLR H14153 S20000
A successful call to [sqlite3_config]([SQLITE_CONFIG_SCRATCH],S,Z,N)
where S is a NULL pointer shall disable the
[scratch memory allocator].

HLR H14156 S20000
A successful call to
[sqlite3_config]([SQLITE_CONFIG_PAGECACHE],S,Z,N)
where Z and N are non-negative integers and
S is a pointer to an aligned memory buffer not less than
Z*N bytes in size shall cause S to be used by the
[pagecache memory allocator] for as many as N simulataneous
allocations each of size Z.

HLR H14159 S20000
A successful call to
[sqlite3_config]([SQLITE_CONFIG_PAGECACHE],S,Z,N)
where S is a NULL pointer shall disable the
[pagecache memory allocator].

HLR H14162 S20000
A successful call to [sqlite3_config]([SQLITE_CONFIG_HEAP],H,Z,N)
where Z and N are non-negative integers and
H is a pointer to an aligned memory buffer not less than
Z bytes in size shall enable the [memsys5] memory allocator
and cause it to use buffer S as its memory source and to use
a minimum allocation size of N.

HLR H14165 S20000
A successful call to [sqlite3_config]([SQLITE_CONFIG_HEAP],H,Z,N)
where H is a NULL pointer shall disable the
[memsys5] memory allocator.

HLR H14168 S20000
A successful call to [sqlite3_config]([SQLITE_CONFIG_LOOKASIDE],Z,N)
shall cause the default [lookaside memory allocator] configuration
for new [database connections] to be N slots of Z bytes each.

HLR H14200 S20000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_db_config(sqlite3*, int op, ...);
</pre></blockquote>

HLR H14203 S20000
A call to [sqlite3_db_config(D,V,...)] shall return [SQLITE_OK]
if and only if the call is successful.

HLR H14206 S20000
If one or more slots of the [lookaside memory allocator] for
[database connection] D are in use, then a call to
[sqlite3_db_config](D,[SQLITE_DBCONFIG_LOOKASIDE],...) shall
fail with an [SQLITE_BUSY] return code.

HLR H14209 S20000
A successful call to
[sqlite3_db_config](D,[SQLITE_DBCONFIG_LOOKASIDE],B,Z,N) where
D is an open [database connection] and Z and N are positive
integers and B is an aligned buffer at least Z*N bytes in size
shall cause the [lookaside memory allocator] for D to use buffer B
with N slots of Z bytes each.

HLR H14212 S20000
A successful call to
[sqlite3_db_config](D,[SQLITE_DBCONFIG_LOOKASIDE],B,Z,N) where
D is an open [database connection] and Z and N are positive
integers and B is NULL pointer shall cause the
[lookaside memory allocator] for D to a obtain Z*N byte buffer
from the primary memory allocator and use that buffer
with N lookaside slots of Z bytes each.

HLR H14215 S20000
A successful call to
[sqlite3_db_config](D,[SQLITE_DBCONFIG_LOOKASIDE],B,Z,N) where
D is an open [database connection] and Z and N are zero shall
disable the [lookaside memory allocator] for D.

HLR H15000 S20200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
typedef struct Mem sqlite3_value;
</pre></blockquote>

HLR H15100 S20200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
const void *sqlite3_value_blob(sqlite3_value*);
int sqlite3_value_bytes(sqlite3_value*);
int sqlite3_value_bytes16(sqlite3_value*);
double sqlite3_value_double(sqlite3_value*);
int sqlite3_value_int(sqlite3_value*);
sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
const unsigned char *sqlite3_value_text(sqlite3_value*);
const void *sqlite3_value_text16(sqlite3_value*);
const void *sqlite3_value_text16le(sqlite3_value*);
const void *sqlite3_value_text16be(sqlite3_value*);
int sqlite3_value_type(sqlite3_value*);
int sqlite3_value_numeric_type(sqlite3_value*);
</pre></blockquote>

HLR H15103 S20200
The [sqlite3_value_blob(V)] interface converts the
[protected sqlite3_value] object V into a BLOB and then
returns a pointer to the converted value.

HLR H15106 S20200
The [sqlite3_value_bytes(V)] interface returns the
number of bytes in the BLOB or string (exclusive of the
zero terminator on the string) that was returned by the
most recent call to [sqlite3_value_blob(V)] or
[sqlite3_value_text(V)].

HLR H15109 S20200
The [sqlite3_value_bytes16(V)] interface returns the
number of bytes in the string (exclusive of the
zero terminator on the string) that was returned by the
most recent call to [sqlite3_value_text16(V)],
[sqlite3_value_text16be(V)], or [sqlite3_value_text16le(V)].

HLR H15112 S20200
The [sqlite3_value_double(V)] interface converts the
[protected sqlite3_value] object V into a floating point value and
returns a copy of that value.

HLR H15115 S20200
The [sqlite3_value_int(V)] interface converts the
[protected sqlite3_value] object V into a 64-bit signed integer and
returns the lower 32 bits of that integer.

HLR H15118 S20200
The [sqlite3_value_int64(V)] interface converts the
[protected sqlite3_value] object V into a 64-bit signed integer and
returns a copy of that integer.

HLR H15121 S20200
The [sqlite3_value_text(V)] interface converts the
[protected sqlite3_value] object V into a zero-terminated UTF-8
string and returns a pointer to that string.

HLR H15124 S20200
The [sqlite3_value_text16(V)] interface converts the
[protected sqlite3_value] object V into a zero-terminated 2-byte
aligned UTF-16 native byte order
string and returns a pointer to that string.

HLR H15127 S20200
The [sqlite3_value_text16be(V)] interface converts the
[protected sqlite3_value] object V into a zero-terminated 2-byte
aligned UTF-16 big-endian
string and returns a pointer to that string.

HLR H15130 S20200
The [sqlite3_value_text16le(V)] interface converts the
[protected sqlite3_value] object V into a zero-terminated 2-byte
aligned UTF-16 little-endian
string and returns a pointer to that string.

HLR H15133 S20200
The [sqlite3_value_type(V)] interface returns
one of [SQLITE_NULL], [SQLITE_INTEGER], [SQLITE_FLOAT],
[SQLITE_TEXT], or [SQLITE_BLOB] as appropriate for
the [sqlite3_value] object V.

HLR H15136 S20200
The [sqlite3_value_numeric_type(V)] interface converts
the [protected sqlite3_value] object V into either an integer or
a floating point value if it can do so without loss of
information, and returns one of [SQLITE_NULL],
[SQLITE_INTEGER], [SQLITE_FLOAT], [SQLITE_TEXT], or
[SQLITE_BLOB] as appropriate for the
[protected sqlite3_value] object V after the conversion attempt.

HLR H15304 S10000
When a call to [sqlite3_step(S)] causes the [prepared statement]
S to run to completion, the function returns [SQLITE_DONE].

HLR H15306 S10000
When a call to [sqlite3_step(S)] stops because it is ready to
return another row of the result set, it returns [SQLITE_ROW].

HLR H15308 S10000
If a call to [sqlite3_step(S)] encounters an
[sqlite3_interrupt | interrupt] or a run-time error,
it returns an appropriate error code that is not one of
[SQLITE_OK], [SQLITE_ROW], or [SQLITE_DONE].

HLR H15310 S10000
If an [sqlite3_interrupt | interrupt] or a run-time error
occurs during a call to [sqlite3_step(S)]
for a [prepared statement] S created using
legacy interfaces [sqlite3_prepare()] or
[sqlite3_prepare16()], then the function returns either
[SQLITE_ERROR], [SQLITE_BUSY], or [SQLITE_MISUSE].

HLR H16001 S20200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
typedef struct sqlite3_context sqlite3_context;
</pre></blockquote>

HLR H16100 S20200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_create_function(
sqlite3 *db,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*)
);
int sqlite3_create_function16(
sqlite3 *db,
const void *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*)
);
</pre></blockquote>

HLR H16103 S20200
The [sqlite3_create_function16(D,X,...)] interface shall behave
as [sqlite3_create_function(D,X,...)] in every way except that it
interprets the X argument as zero-terminated UTF-16
native byte order instead of as zero-terminated UTF-8.

HLR H16106 S20200
A successful invocation of the
[sqlite3_create_function(D,X,N,E,...)] interface shall register
or replaces callback functions in the [database connection] D
used to implement the SQL function named X with N parameters
and having a preferred text encoding of E.

HLR H16109 S20200
A successful call to [sqlite3_create_function(D,X,N,E,P,F,S,L)]
shall replace the P, F, S, and L values from any prior calls with
the same D, X, N, and E values.

HLR H16112 S20200
The [sqlite3_create_function(D,X,...)] interface shall fail
if the SQL function name X is
longer than 255 bytes exclusive of the zero terminator.

HLR H16118 S20200
The [sqlite3_create_function(D,X,N,E,P,F,S,L)] interface
shall fail unless either F is NULL and S and L are non-NULL or
F is non-NULL and S and L are NULL.

HLR H16121 S20200
The [sqlite3_create_function(D,...)] interface shall fails with an
error code of [SQLITE_BUSY] if there exist [prepared statements]
associated with the [database connection] D.

HLR H16124 S20200
The [sqlite3_create_function(D,X,N,...)] interface shall fail with
an error code of [SQLITE_ERROR] if parameter N is less
than -1 or greater than 127.

HLR H16127 S20200
When N is non-negative, the [sqlite3_create_function(D,X,N,...)]
interface shall register callbacks to be invoked for the
SQL function
named X when the number of arguments to the SQL function is
exactly N.

HLR H16130 S20200
When N is -1, the [sqlite3_create_function(D,X,N,...)]
interface shall register callbacks to be invoked for the SQL
function named X with any number of arguments.

HLR H16133 S20200
When calls to [sqlite3_create_function(D,X,N,...)]
specify multiple implementations of the same function X
and when one implementation has N>=0 and the other has N=(-1)
the implementation with a non-zero N shall be preferred.

HLR H16136 S20200
When calls to [sqlite3_create_function(D,X,N,E,...)]
specify multiple implementations of the same function X with
the same number of arguments N but with different
encodings E, then the implementation where E matches the
database encoding shall preferred.

HLR H16139 S20200
For an aggregate SQL function created using
[sqlite3_create_function(D,X,N,E,P,0,S,L)] the finalizer
function L shall always be invoked exactly once if the
step function S is called one or more times.

HLR H16142 S20200
When SQLite invokes either the xFunc or xStep function of
an application-defined SQL function or aggregate created
by [sqlite3_create_function()] or [sqlite3_create_function16()],
then the array of [sqlite3_value] objects passed as the
third parameter shall be [protected sqlite3_value] objects.

HLR H16210 S20200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
</pre></blockquote>

HLR H16211 S20200
The first invocation of [sqlite3_aggregate_context(C,N)] for
a particular instance of an aggregate function (for a particular
context C) causes SQLite to allocate N bytes of memory,
zero that memory, and return a pointer to the allocated memory.

HLR H16213 S20200
If a memory allocation error occurs during
[sqlite3_aggregate_context(C,N)] then the function returns 0.

HLR H16215 S20200
Second and subsequent invocations of
[sqlite3_aggregate_context(C,N)] for the same context pointer C
ignore the N parameter and return a pointer to the same
block of memory returned by the first invocation.

HLR H16217 S20200
The memory allocated by [sqlite3_aggregate_context(C,N)] is
automatically freed on the next call to [sqlite3_reset()]
or [sqlite3_finalize()] for the [prepared statement] containing
the aggregate function associated with context C.

HLR H16240 S20200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
void *sqlite3_user_data(sqlite3_context*);
</pre></blockquote>

HLR H16243 S20200
The [sqlite3_user_data(C)] interface returns a copy of the
P pointer from the [sqlite3_create_function(D,X,N,E,P,F,S,L)]
or [sqlite3_create_function16(D,X,N,E,P,F,S,L)] call that
registered the SQL function associated with [sqlite3_context] C.

HLR H16250 S60600 S20200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
</pre></blockquote>

HLR H16253 S60600
The [sqlite3_context_db_handle(C)] interface returns a copy of the
D pointer from the [sqlite3_create_function(D,X,N,E,P,F,S,L)]
or [sqlite3_create_function16(D,X,N,E,P,F,S,L)] call that
registered the SQL function associated with [sqlite3_context] C.

HLR H16270 S20200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
void *sqlite3_get_auxdata(sqlite3_context*, int N);
void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
</pre></blockquote>

HLR H16272 S20200
The [sqlite3_get_auxdata(C,N)] interface returns a pointer
to metadata associated with the Nth parameter of the SQL function
whose context is C, or NULL if there is no metadata associated
with that parameter.

HLR H16274 S20200
The [sqlite3_set_auxdata(C,N,P,D)] interface assigns a metadata
pointer P to the Nth parameter of the SQL function with context C.

HLR H16276 S20200
SQLite will invoke the destructor D with a single argument
which is the metadata pointer P following a call to
[sqlite3_set_auxdata(C,N,P,D)] when SQLite ceases to hold
the metadata.

HLR H16277 S20200
SQLite ceases to hold metadata for an SQL function parameter
when the value of that parameter changes.

HLR H16278 S20200
When [sqlite3_set_auxdata(C,N,P,D)] is invoked, the destructor
is called for any prior metadata associated with the same function
context C and parameter N.

HLR H16279 S20200
SQLite will call destructors for any metadata it is holding
in a particular [prepared statement] S when either
[sqlite3_reset(S)] or [sqlite3_finalize(S)] is called.

HLR H16342 S30220
The [sqlite3_release_memory(N)] returns the number
of bytes actually freed, which might be more or less
than the amount requested.

HLR H16351 S30220
The [sqlite3_soft_heap_limit(N)] interface places a soft limit
of N bytes on the amount of heap memory that may be allocated
using [sqlite3_malloc()] or [sqlite3_realloc()] at any point
in time.

HLR H16352 S30220
If a call to [sqlite3_malloc()] or [sqlite3_realloc()] would
cause the total amount of allocated memory to exceed the
soft heap limit, then [sqlite3_release_memory()] is invoked
in an attempt to reduce the memory usage prior to proceeding
with the memory allocation attempt.

HLR H16353 S30220
Calls to [sqlite3_malloc()] or [sqlite3_realloc()] that trigger
attempts to reduce memory usage through the soft heap limit
mechanism continue even if the attempt to reduce memory
usage is unsuccessful.

HLR H16354 S30220
A negative or zero value for N in a call to
[sqlite3_soft_heap_limit(N)] means that there is no soft
heap limit and [sqlite3_release_memory()] will only be
called when memory is completely exhausted.

HLR H16355 S30220
The default value for the soft heap limit is zero.

HLR H16358 S30220
Each call to [sqlite3_soft_heap_limit(N)] overrides the
values set by all prior calls.

HLR H16400 S20200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
void sqlite3_result_double(sqlite3_context*, double);
void sqlite3_result_error(sqlite3_context*, const char*, int);
void sqlite3_result_error16(sqlite3_context*, const void*, int);
void sqlite3_result_error_toobig(sqlite3_context*);
void sqlite3_result_error_nomem(sqlite3_context*);
void sqlite3_result_error_code(sqlite3_context*, int);
void sqlite3_result_int(sqlite3_context*, int);
void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
void sqlite3_result_null(sqlite3_context*);
void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
void sqlite3_result_zeroblob(sqlite3_context*, int n);
</pre></blockquote>

HLR H16403 S20200
The default return value from any SQL function is NULL.

HLR H16406 S20200
The [sqlite3_result_blob(C,V,N,D)] interface changes the
return value of function C to be a BLOB that is N bytes
in length and with content pointed to by V.

HLR H16409 S20200
The [sqlite3_result_double(C,V)] interface changes the
return value of function C to be the floating point value V.

HLR H16412 S20200
The [sqlite3_result_error(C,V,N)] interface changes the return
value of function C to be an exception with error code
[SQLITE_ERROR] and a UTF-8 error message copied from V up to the
first zero byte or until N bytes are read if N is positive.

HLR H16415 S20200
The [sqlite3_result_error16(C,V,N)] interface changes the return
value of function C to be an exception with error code
[SQLITE_ERROR] and a UTF-16 native byte order error message
copied from V up to the first zero terminator or until N bytes
are read if N is positive.

HLR H16418 S20200
The [sqlite3_result_error_toobig(C)] interface changes the return
value of the function C to be an exception with error code
[SQLITE_TOOBIG] and an appropriate error message.

HLR H16421 S20200
The [sqlite3_result_error_nomem(C)] interface changes the return
value of the function C to be an exception with error code
[SQLITE_NOMEM] and an appropriate error message.

HLR H16424 S20200
The [sqlite3_result_error_code(C,E)] interface changes the return
value of the function C to be an exception with error code E.
The error message text is unchanged.

HLR H16427 S20200
The [sqlite3_result_int(C,V)] interface changes the
return value of function C to be the 32-bit integer value V.

HLR H16430 S20200
The [sqlite3_result_int64(C,V)] interface changes the
return value of function C to be the 64-bit integer value V.

HLR H16433 S20200
The [sqlite3_result_null(C)] interface changes the
return value of function C to be NULL.

HLR H16436 S20200
The [sqlite3_result_text(C,V,N,D)] interface changes the
return value of function C to be the UTF-8 string
V up to the first zero if N is negative
or the first N bytes of V if N is non-negative.

HLR H16439 S20200
The [sqlite3_result_text16(C,V,N,D)] interface changes the
return value of function C to be the UTF-16 native byte order
string V up to the first zero if N is negative
or the first N bytes of V if N is non-negative.

HLR H16442 S20200
The [sqlite3_result_text16be(C,V,N,D)] interface changes the
return value of function C to be the UTF-16 big-endian
string V up to the first zero if N is negative
or the first N bytes or V if N is non-negative.

HLR H16445 S20200
The [sqlite3_result_text16le(C,V,N,D)] interface changes the
return value of function C to be the UTF-16 little-endian
string V up to the first zero if N is negative
or the first N bytes of V if N is non-negative.

HLR H16448 S20200
The [sqlite3_result_value(C,V)] interface changes the
return value of function C to be the [unprotected sqlite3_value]
object V.

HLR H16451 S20200
The [sqlite3_result_zeroblob(C,N)] interface changes the
return value of function C to be an N-byte BLOB of all zeros.

HLR H16454 S20200
The [sqlite3_result_error()] and [sqlite3_result_error16()]
interfaces make a copy of their error message strings before
returning.

HLR H16457 S20200
If the D destructor parameter to [sqlite3_result_blob(C,V,N,D)],
[sqlite3_result_text(C,V,N,D)], [sqlite3_result_text16(C,V,N,D)],
[sqlite3_result_text16be(C,V,N,D)], or
[sqlite3_result_text16le(C,V,N,D)] is the constant [SQLITE_STATIC]
then no destructor is ever called on the pointer V and SQLite
assumes that V is immutable.

HLR H16460 S20200
If the D destructor parameter to [sqlite3_result_blob(C,V,N,D)],
[sqlite3_result_text(C,V,N,D)], [sqlite3_result_text16(C,V,N,D)],
[sqlite3_result_text16be(C,V,N,D)], or
[sqlite3_result_text16le(C,V,N,D)] is the constant
[SQLITE_TRANSIENT] then the interfaces makes a copy of the
content of V and retains the copy.

HLR H16463 S20200
If the D destructor parameter to [sqlite3_result_blob(C,V,N,D)],
[sqlite3_result_text(C,V,N,D)], [sqlite3_result_text16(C,V,N,D)],
[sqlite3_result_text16be(C,V,N,D)], or
[sqlite3_result_text16le(C,V,N,D)] is some value other than
the constants [SQLITE_STATIC] and [SQLITE_TRANSIENT] then
SQLite will invoke the destructor D with V as its only argument
when it has finished with the V value.

HLR H16600 S20300
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_create_collation(
sqlite3*,
const char *zName,
int eTextRep,
void*,
int(*xCompare)(void*,int,const void*,int,const void*)
);
int sqlite3_create_collation_v2(
sqlite3*,
const char *zName,
int eTextRep,
void*,
int(*xCompare)(void*,int,const void*,int,const void*),
void(*xDestroy)(void*)
);
int sqlite3_create_collation16(
sqlite3*,
const void *zName,
int eTextRep,
void*,
int(*xCompare)(void*,int,const void*,int,const void*)
);
</pre></blockquote>

HLR H16603 S20300
A successful call to the
[sqlite3_create_collation_v2(B,X,E,P,F,D)] interface
registers function F as the comparison function used to
implement collation X on the [database connection] B for
databases having encoding E.

HLR H16604 S20300
SQLite understands the X parameter to
[sqlite3_create_collation_v2(B,X,E,P,F,D)] as a zero-terminated
UTF-8 string in which case is ignored for ASCII characters and
is significant for non-ASCII characters.

HLR H16606 S20300
Successive calls to [sqlite3_create_collation_v2(B,X,E,P,F,D)]
with the same values for B, X, and E, override prior values
of P, F, and D.

HLR H16609 S20300
If the destructor D in [sqlite3_create_collation_v2(B,X,E,P,F,D)]
is not NULL then it is called with argument P when the
collating function is dropped by SQLite.

HLR H16612 S20300
A collating function is dropped when it is overloaded.

HLR H16615 S20300
A collating function is dropped when the database connection
is closed using [sqlite3_close()].

HLR H16618 S20300
The pointer P in [sqlite3_create_collation_v2(B,X,E,P,F,D)]
is passed through as the first parameter to the comparison
function F for all subsequent invocations of F.

HLR H16621 S20300
A call to [sqlite3_create_collation(B,X,E,P,F)] is exactly
the same as a call to [sqlite3_create_collation_v2()] with
the same parameters and a NULL destructor.

HLR H16624 S20300
Following a [sqlite3_create_collation_v2(B,X,E,P,F,D)],
SQLite uses the comparison function F for all text comparison
operations on the [database connection] B on text values that
use the collating sequence named X.

HLR H16627 S20300
The [sqlite3_create_collation16(B,X,E,P,F)] works the same
as [sqlite3_create_collation(B,X,E,P,F)] except that the
collation name X is understood as UTF-16 in native byte order
instead of UTF-8.

HLR H16630 S20300
When multiple comparison functions are available for the same
collating sequence, SQLite chooses the one whose text encoding
requires the least amount of conversion from the default
text encoding of the database.

HLR H16700 S20300
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_collation_needed(
sqlite3*,
void*,
void(*)(void*,sqlite3*,int eTextRep,const char*)
);
int sqlite3_collation_needed16(
sqlite3*,
void*,
void(*)(void*,sqlite3*,int eTextRep,const void*)
);
</pre></blockquote>

HLR H16702 S20300
A successful call to [sqlite3_collation_needed(D,P,F)]
or [sqlite3_collation_needed16(D,P,F)] causes
the [database connection] D to invoke callback F with first
parameter P whenever it needs a comparison function for a
collating sequence that it does not know about.

HLR H16704 S20300
Each successful call to [sqlite3_collation_needed()] or
[sqlite3_collation_needed16()] overrides the callback registered
on the same [database connection] by prior calls to either
interface.

HLR H16706 S20300
The name of the requested collating function passed in the
4th parameter to the callback is in UTF-8 if the callback
was registered using [sqlite3_collation_needed()] and
is in UTF-16 native byte order if the callback was
registered using [sqlite3_collation_needed16()].

HLR H17000 S20000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
sqlite3_mutex *sqlite3_mutex_alloc(int);
void sqlite3_mutex_free(sqlite3_mutex*);
void sqlite3_mutex_enter(sqlite3_mutex*);
int sqlite3_mutex_try(sqlite3_mutex*);
void sqlite3_mutex_leave(sqlite3_mutex*);
</pre></blockquote>

HLR H17001 H17000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_MUTEX_FAST             0
#define SQLITE_MUTEX_RECURSIVE        1
#define SQLITE_MUTEX_STATIC_MASTER    2
#define SQLITE_MUTEX_STATIC_MEM       3  /* sqlite3_malloc() */
#define SQLITE_MUTEX_STATIC_MEM2      4  /* sqlite3_release_memory() */
#define SQLITE_MUTEX_STATIC_PRNG      5  /* sqlite3_random() */
#define SQLITE_MUTEX_STATIC_LRU       6  /* lru page list */
#define SQLITE_MUTEX_STATIC_LRU2      7  /* lru page list */
</pre></blockquote>

HLR H17002 H17000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
</pre></blockquote>

HLR H17080 S20130 S30800
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_mutex_held(sqlite3_mutex*);
int sqlite3_mutex_notheld(sqlite3_mutex*);
</pre></blockquote>

HLR H17110 S20130
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
typedef struct sqlite3_mutex sqlite3_mutex;
</pre></blockquote>

HLR H17120 S20130
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
typedef struct sqlite3_mutex_methods sqlite3_mutex_methods;
struct sqlite3_mutex_methods {
int (*xMutexInit)(void);
int (*xMutexEnd)(void);
sqlite3_mutex *(*xMutexAlloc)(int);
void (*xMutexFree)(sqlite3_mutex *);
void (*xMutexEnter)(sqlite3_mutex *);
int (*xMutexTry)(sqlite3_mutex *);
void (*xMutexLeave)(sqlite3_mutex *);
int (*xMutexHeld)(sqlite3_mutex *);
int (*xMutexNotheld)(sqlite3_mutex *);
};
</pre></blockquote>

HLR H17200 S60200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
</pre></blockquote>

HLR H17250 H17200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_STATUS_MEMORY_USED          0
#define SQLITE_STATUS_PAGECACHE_USED       1
#define SQLITE_STATUS_PAGECACHE_OVERFLOW   2
#define SQLITE_STATUS_SCRATCH_USED         3
#define SQLITE_STATUS_SCRATCH_OVERFLOW     4
#define SQLITE_STATUS_MALLOC_SIZE          5
#define SQLITE_STATUS_PARSER_STACK         6
#define SQLITE_STATUS_PAGECACHE_SIZE       7
#define SQLITE_STATUS_SCRATCH_SIZE         8
</pre></blockquote>

HLR H17300 S20000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
void *sqlite3_malloc(int);
void *sqlite3_realloc(void*, int);
void sqlite3_free(void*);
</pre></blockquote>

HLR H17303 S20000
The [sqlite3_malloc(N)] interface returns either a pointer to
a newly checked-out block of at least N bytes of memory
that is 8-byte aligned, or it returns NULL if it is unable
to fulfill the request.

HLR H17304 S20000
The [sqlite3_malloc(N)] interface returns a NULL pointer if
N is less than or equal to zero.

HLR H17305 S20000
The [sqlite3_free(P)] interface releases memory previously
returned from [sqlite3_malloc()] or [sqlite3_realloc()],
making it available for reuse.

HLR H17306 S20000
A call to [sqlite3_free(NULL)] is a harmless no-op.

HLR H17310 S20000
A call to [sqlite3_realloc(0,N)] is equivalent to a call
to [sqlite3_malloc(N)].

HLR H17312 S20000
A call to [sqlite3_realloc(P,0)] is equivalent to a call
to [sqlite3_free(P)].

HLR H17315 S20000
The SQLite core uses [sqlite3_malloc()], [sqlite3_realloc()],
and [sqlite3_free()] for all of its memory allocation and
deallocation needs.

HLR H17318 S20000
The [sqlite3_realloc(P,N)] interface returns either a pointer
to a block of checked-out memory of at least N bytes in size
that is 8-byte aligned, or a NULL pointer.

HLR H17321 S20000
When [sqlite3_realloc(P,N)] returns a non-NULL pointer, it first
copies the first K bytes of content from P into the newly
allocated block, where K is the lesser of N and the size of
the buffer P.

HLR H17322 S20000
When [sqlite3_realloc(P,N)] returns a non-NULL pointer, it first
releases the buffer P.

HLR H17323 S20000
When [sqlite3_realloc(P,N)] returns NULL, the buffer P is
not modified or released.

HLR H17340 S30220
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_release_memory(int);
</pre></blockquote>

HLR H17341 S30220
The [sqlite3_release_memory(N)] interface attempts to
free N bytes of heap memory by deallocating non-essential
memory allocations held by the database library.

HLR H17350 S30220
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
void sqlite3_soft_heap_limit(int);
</pre></blockquote>

HLR H17370 S30210
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
sqlite3_int64 sqlite3_memory_used(void);
sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
</pre></blockquote>

HLR H17371 S30210
The [sqlite3_memory_used()] routine returns the number of bytes
of memory currently outstanding (malloced but not freed).

HLR H17373 S30210
The [sqlite3_memory_highwater()] routine returns the maximum
value of [sqlite3_memory_used()] since the high-water mark
was last reset.

HLR H17374 S30210
The values returned by [sqlite3_memory_used()] and
[sqlite3_memory_highwater()] include any overhead
added by SQLite in its implementation of [sqlite3_malloc()],
but not overhead added by the any underlying system library
routines that [sqlite3_malloc()] may call.

HLR H17375 S30210
The memory high-water mark is reset to the current value of
[sqlite3_memory_used()] if and only if the parameter to
[sqlite3_memory_highwater()] is true.  The value returned
by [sqlite3_memory_highwater(1)] is the high-water mark
prior to the reset.

HLR H17390 S20000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
void sqlite3_randomness(int N, void *P);
</pre></blockquote>

HLR H17392 S20000
The [sqlite3_randomness(N,P)] interface writes N bytes of
high-quality pseudo-randomness into buffer P.

HLR H17400 S70000 S20000
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
char *sqlite3_mprintf(const char*,...);
char *sqlite3_vmprintf(const char*, va_list);
char *sqlite3_snprintf(int,char*,const char*, ...);
</pre></blockquote>

HLR H17403 S70000
The [sqlite3_mprintf()] and [sqlite3_vmprintf()] interfaces
return either pointers to zero-terminated UTF-8 strings held in
memory obtained from [sqlite3_malloc()] or NULL pointers if
a call to [sqlite3_malloc()] fails.

HLR H17406 S70000
The [sqlite3_snprintf()] interface writes a zero-terminated
UTF-8 string into the buffer pointed to by the second parameter
provided that the first parameter is greater than zero.

HLR H17407 S70000
The [sqlite3_snprintf()] interface does not write slots of
its output buffer (the second parameter) outside the range
of 0 through N-1 (where N is the first parameter)
regardless of the length of the string
requested by the format specification.

HLR H17500 S60200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
</pre></blockquote>

HLR H17520 H17500
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_DBSTATUS_LOOKASIDE_USED     0
</pre></blockquote>

HLR H17550 S60200
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
</pre></blockquote>

HLR H17570 H17550
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
#define SQLITE_STMTSTATUS_FULLSCAN_STEP     1
#define SQLITE_STMTSTATUS_SORT              2
</pre></blockquote>

HLR H17800 S30230
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
typedef struct sqlite3_blob sqlite3_blob;
</pre></blockquote>

HLR H17810 S30230
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_blob_open(
sqlite3*,
const char *zDb,
const char *zTable,
const char *zColumn,
sqlite3_int64 iRow,
int flags,
sqlite3_blob **ppBlob
);
</pre></blockquote>

HLR H17813 S30230
A successful invocation of the [sqlite3_blob_open(D,B,T,C,R,F,P)]
interface shall open an [sqlite3_blob] object P on the BLOB
in column C of the table T in the database B on
the [database connection] D.

HLR H17814 S30230
A successful invocation of [sqlite3_blob_open(D,...)] shall start
a new transaction on the [database connection] D if that
connection is not already in a transaction.

HLR H17816 S30230
The [sqlite3_blob_open(D,B,T,C,R,F,P)] interface shall open
the BLOB for read and write access if and only if the F
parameter is non-zero.

HLR H17819 S30230
The [sqlite3_blob_open()] interface shall return [SQLITE_OK] on
success and an appropriate [error code] on failure.

HLR H17821 S30230
If an error occurs during evaluation of [sqlite3_blob_open(D,...)]
then subsequent calls to [sqlite3_errcode(D)],
[sqlite3_extended_errcode()],
[sqlite3_errmsg(D)], and [sqlite3_errmsg16(D)] shall return
information appropriate for that error.

HLR H17824 S30230
If any column in the row that a [sqlite3_blob] has open is
changed by a separate [UPDATE] or [DELETE] statement or by
an [ON CONFLICT] side effect, then the [sqlite3_blob] shall
be marked as invalid.

HLR H17830 S30230
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_blob_close(sqlite3_blob *);
</pre></blockquote>

HLR H17833 S30230
The [sqlite3_blob_close(P)] interface closes an [sqlite3_blob]
object P previously opened using [sqlite3_blob_open()].

HLR H17836 S30230
Closing an [sqlite3_blob] object using
[sqlite3_blob_close()] shall cause the current transaction to
commit if there are no other open [sqlite3_blob] objects
or [prepared statements] on the same [database connection] and
the database connection is in [autocommit mode].

HLR H17839 S30230
The [sqlite3_blob_close(P)] interfaces shall close the
[sqlite3_blob] object P unconditionally, even if
[sqlite3_blob_close(P)] returns something other than [SQLITE_OK].

HLR H17840 S30230
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_blob_bytes(sqlite3_blob *);
</pre></blockquote>

HLR H17843 S30230
The [sqlite3_blob_bytes(P)] interface returns the size
in bytes of the BLOB that the [sqlite3_blob] object P
refers to.

HLR H17850 S30230
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
</pre></blockquote>

HLR H17853 S30230
A successful invocation of [sqlite3_blob_read(P,Z,N,X)]
shall reads N bytes of data out of the BLOB referenced by
[BLOB handle] P beginning at offset X and store those bytes
into buffer Z.

HLR H17856 S30230
In [sqlite3_blob_read(P,Z,N,X)] if the size of the BLOB
is less than N+X bytes, then the function shall leave the
Z buffer unchanged and return [SQLITE_ERROR].

HLR H17859 S30230
In [sqlite3_blob_read(P,Z,N,X)] if X or N is less than zero
then the function shall leave the Z buffer unchanged
and return [SQLITE_ERROR].

HLR H17862 S30230
The [sqlite3_blob_read(P,Z,N,X)] interface shall return [SQLITE_OK]
if N bytes are successfully read into buffer Z.

HLR H17863 S30230
If the [BLOB handle] P is expired and X and N are within bounds
then [sqlite3_blob_read(P,Z,N,X)] shall leave the Z buffer
unchanged and return [SQLITE_ABORT].

HLR H17865 S30230
If the requested read could not be completed,
the [sqlite3_blob_read(P,Z,N,X)] interface shall return an
appropriate [error code] or [extended error code].

HLR H17868 S30230
If an error occurs during evaluation of [sqlite3_blob_read(P,...)]
then subsequent calls to [sqlite3_errcode(D)],
[sqlite3_extended_errcode()],
[sqlite3_errmsg(D)], and [sqlite3_errmsg16(D)] shall return
information appropriate for that error, where D is the
[database connection] that was used to open the [BLOB handle] P.

HLR H17870 S30230
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
</pre></blockquote>

HLR H17873 S30230
A successful invocation of [sqlite3_blob_write(P,Z,N,X)]
shall write N bytes of data from buffer Z into the BLOB
referenced by [BLOB handle] P beginning at offset X into
the BLOB.

HLR H17874 S30230
In the absence of other overridding changes, the changes
written to a BLOB by [sqlite3_blob_write()] shall
remain in effect after the associated [BLOB handle] expires.

HLR H17875 S30230
If the [BLOB handle] P was opened for reading only then
an invocation of [sqlite3_blob_write(P,Z,N,X)] shall leave
the referenced BLOB unchanged and return [SQLITE_READONLY].

HLR H17876 S30230
If the size of the BLOB referenced by [BLOB handle] P is
less than N+X bytes then [sqlite3_blob_write(P,Z,N,X)] shall
leave the BLOB unchanged and return [SQLITE_ERROR].

HLR H17877 S30230
If the [BLOB handle] P is expired and X and N are within bounds
then [sqlite3_blob_read(P,Z,N,X)] shall leave the BLOB
unchanged and return [SQLITE_ABORT].

HLR H17879 S30230
If X or N are less than zero then [sqlite3_blob_write(P,Z,N,X)]
shall leave the BLOB referenced by [BLOB handle] P unchanged
and return [SQLITE_ERROR].

HLR H17882 S30230
The [sqlite3_blob_write(P,Z,N,X)] interface shall return
[SQLITE_OK] if N bytes where successfully written into the BLOB.

HLR H17885 S30230
If the requested write could not be completed,
the [sqlite3_blob_write(P,Z,N,X)] interface shall return an
appropriate [error code] or [extended error code].

HLR H17888 S30230
If an error occurs during evaluation of [sqlite3_blob_write(D,...)]
then subsequent calls to [sqlite3_errcode(D)],
[sqlite3_extended_errcode()],
[sqlite3_errmsg(D)], and [sqlite3_errmsg16(D)] shall return
information appropriate for that error.

HLR H18000 S20400
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
struct sqlite3_module {
int iVersion;
int (*xCreate)(sqlite3*, void *pAux,
int argc, const char *const*argv,
sqlite3_vtab **ppVTab, char**);
int (*xConnect)(sqlite3*, void *pAux,
int argc, const char *const*argv,
sqlite3_vtab **ppVTab, char**);
int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*);
int (*xDisconnect)(sqlite3_vtab *pVTab);
int (*xDestroy)(sqlite3_vtab *pVTab);
int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor);
int (*xClose)(sqlite3_vtab_cursor*);
int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr,
int argc, sqlite3_value **argv);
int (*xNext)(sqlite3_vtab_cursor*);
int (*xEof)(sqlite3_vtab_cursor*);
int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int);
int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid);
int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *);
int (*xBegin)(sqlite3_vtab *pVTab);
int (*xSync)(sqlite3_vtab *pVTab);
int (*xCommit)(sqlite3_vtab *pVTab);
int (*xRollback)(sqlite3_vtab *pVTab);
int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName,
void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
void **ppArg);
int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
};
</pre></blockquote>

HLR H18010 S20400
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
struct sqlite3_vtab {
const sqlite3_module *pModule;  /* The module for this virtual table */
int nRef;                       /* Used internally */
char *zErrMsg;                  /* Error message from sqlite3_mprintf() */
/* Virtual table implementations will typically add additional fields */
};
</pre></blockquote>

HLR H18020 S20400
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
struct sqlite3_vtab_cursor {
sqlite3_vtab *pVtab;      /* Virtual table of this cursor */
/* Virtual table implementations will typically add additional fields */
};
</pre></blockquote>

HLR H18100 S20400
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
struct sqlite3_index_info {
/* Inputs */
int nConstraint;           /* Number of entries in aConstraint */
struct sqlite3_index_constraint {
int iColumn;              /* Column on left-hand side of constraint */
unsigned char op;         /* Constraint operator */
unsigned char usable;     /* True if this constraint is usable */
int iTermOffset;          /* Used internally - xBestIndex should ignore */
} *aConstraint;            /* Table of WHERE clause constraints */
int nOrderBy;              /* Number of terms in the ORDER BY clause */
struct sqlite3_index_orderby {
int iColumn;              /* Column number */
unsigned char desc;       /* True for DESC.  False for ASC. */
} *aOrderBy;               /* The ORDER BY clause */
/* Outputs */
struct sqlite3_index_constraint_usage {
int argvIndex;           /* if &gt;0, constraint is part of argv to xFilter */
unsigned char omit;      /* Do not code a test for this constraint */
} *aConstraintUsage;
int idxNum;                /* Number used to identify the index */
char *idxStr;              /* String, possibly obtained from sqlite3_malloc */
int needToFreeIdxStr;      /* Free idxStr using sqlite3_free() if true */
int orderByConsumed;       /* True if output is already ordered */
double estimatedCost;      /* Estimated cost of using this index */
};
#define SQLITE_INDEX_CONSTRAINT_EQ    2
#define SQLITE_INDEX_CONSTRAINT_GT    4
#define SQLITE_INDEX_CONSTRAINT_LE    8
#define SQLITE_INDEX_CONSTRAINT_LT    16
#define SQLITE_INDEX_CONSTRAINT_GE    32
#define SQLITE_INDEX_CONSTRAINT_MATCH 64
</pre></blockquote>

HLR H18200 S20400
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_create_module(
sqlite3 *db,               /* SQLite connection to register module with */
const char *zName,         /* Name of the module */
const sqlite3_module *,    /* Methods for the module */
void *                     /* Client data for xCreate/xConnect */
);
</pre></blockquote>

HLR H18210 S20400
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_create_module_v2(
sqlite3 *db,               /* SQLite connection to register module with */
const char *zName,         /* Name of the module */
const sqlite3_module *,    /* Methods for the module */
void *,                    /* Client data for xCreate/xConnect */
void(*xDestroy)(void*)     /* Module destructor function */
);
</pre></blockquote>

HLR H18280 S20400
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_declare_vtab(sqlite3*, const char *zCreateTable);
</pre></blockquote>

HLR H18300 S20400
The sqlite3.h header file shall define the
the following interfaces:
<blockquote><pre>
int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
</pre></blockquote>

Added req/hlr20000.txt.






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
HLR H21001 
Except for the read operation required by H21007 and those reads made
as part of opening a read-only transaction, SQLite shall ensure that
a <i>database connection</i> has an open read-only or read/write
transaction when any data is read from the <i>database file</i>.

HLR H21002 
Aside from those read operations described by H21007 and H21XXX, SQLite
shall read data from the database file in aligned blocks of
<i>page-size</i> bytes, where <i>page-size</i> is the database page size
used by the database file.

HLR H21003 
While opening a <i>read-only transaction</i>, after successfully
obtaining a <i>shared lock</i> on the database file, SQLite shall
attempt to detect and roll back a <i>hot journal file</i> associated
with the same database file.

HLR H21004 
Assuming no errors have occured, then after attempting to detect and
roll back a <i>hot journal file</i>, if the <i>page cache</i> contains
any entries associated with the current <i>database connection</i>,
then SQLite shall validate the contents of the <i>page cache</i> by
testing the <i>file change counter</i>.  This procedure is known as
<i>cache validiation</i>.

HLR H21005 
If the cache validiate procedure prescribed by H21004 is required and
does not prove that the <i>page cache</i> entries associated with the
current <i>database connection</i> are valid, then SQLite shall discard
all entries associated with the current <i>database connection</i> from
the <i>page cache</i>.

HLR H21006 
When a new <i>database connection</i> is required, SQLite shall attempt
to open a file-handle on the database file. If the attempt fails, then
no new <i>database connection</i> is created and an error returned.

HLR H21007 
When a new <i>database connection</i> is required, after opening the
new file-handle, SQLite shall attempt to read the first 100 bytes
of the database file. If the attempt fails for any other reason than
that the opened file is less than 100 bytes in size, then
the file-handle is closed, no new <i>database connection</i> is created
and an error returned instead.

HLR H21008 
If the <i>database file header</i> is successfully read from a newly
opened database file, the connections <i>expected page-size</i> shall
be set to the value stored in the <i>page-size field</i> of the
database header.

HLR H21009 
If the <i>database file header</i> cannot be read from a newly opened
database file (because the file is less than 100 bytes in size), the
connections <i>expected page-size</i> shall be set to the compile time
value of the SQLITE_DEFAULT_PAGESIZE option.

HLR H21010 
When required to open a <i>read-only transaction</i> using a
<i>database connection</i>, SQLite shall first attempt to obtain
a <i>shared-lock</i> on the file-handle open on the database file.

HLR H21011 
If, while opening a <i>read-only transaction</i>, SQLite fails to obtain
the <i>shared-lock</i> on the database file, then the process is
abandoned, no transaction is opened and an error returned to the user.

HLR H21012 
If, while opening a <i>read-only transaction</i>, SQLite encounters
an error while attempting to detect or roll back a <i>hot journal
file</i>, then the <i>shared-lock</i> on the database file is released,
no transaction is opened and an error returned to the user.

HLR H21013 
When required to end a <i>read-only transaction</i>, SQLite shall
relinquish the <i>shared lock</i> held on the database file by
calling the xUnlock() method of the file-handle.

HLR H21014 
When required to attempt to detect a <i>hot-journal file</i>, SQLite
shall first use the xAccess() method of the VFS layer to check if a
journal file exists in the file-system.

HLR H21015 
When required to attempt to detect a <i>hot-journal file</i>, if the
call to xAccess() required by H21014 indicates that a journal file does
not exist, then SQLite shall conclude that there is no <i>hot-journal
file</i> in the file system and therefore that no <i>hot journal
rollback</i> is required.

HLR H21016 
When required to attempt to detect a <i>hot-journal file</i>, if the
call to xAccess() required by H21014 indicates that a journal file
is present, then the xCheckReservedLock() method of the database file
file-handle is invoked to determine whether or not some other
process is holding a <i>reserved</i> or greater lock on the database
file.

HLR H21017 
If the call to xCheckReservedLock() required by H21016 indicates that
some other <i>database connection</i> is holding a <i>reserved</i>
or greater lock on the database file, then SQLite shall conclude that
there is no <i>hot journal file</i>. In this case the attempt to detect
a <i>hot journal file</i> is concluded.

HLR H21018 
When a file-handle open on a database file is unlocked, if the
<i>page cache</i> contains one or more entries belonging to the
associated <i>database connection</i>, SQLite shall store the value
of the <i>file change counter</i> internally.

HLR H21019 
When required to perform <i>cache validation</i> as part of opening
a <i>read transaction</i>, SQLite shall read a 16 byte block
starting at byte offset 24 of the <i>database file</i> using the xRead()
method of the <i>database connections</i> file handle.

HLR H21020 
While performing <i>cache validation</i>, after loading the 16 byte
block as required by H21019, SQLite shall compare the 32-bit big-endian
integer stored in the first 4 bytes of the block to the most
recently stored value of the <i>file change counter</i> (see H21018).
If the values are not the same, then SQLite shall conclude that
the contents of the cache are invalid.

HLR H21021 
During the conclusion of a <i>read transaction</i>, before unlocking
the database file, SQLite shall set the connections
<i>expected page size</i> to the current database <i>page-size</i>.

HLR H21022 
As part of opening a new <i>read transaction</i>, immediately after
performing <i>cache validation</i>, if there is no data for database
page 1 in the <i>page cache</i>, SQLite shall read <i>N</i> bytes from
the start of the database file using the xRead() method of the
connections file handle, where <i>N</i> is the connections current
<i>expected page size</i> value.

HLR H21023 
If page 1 data is read as required by H21023, then the value of the
<i>page-size</i> field that appears in the database file header that
consumes the first 100 bytes of the read block is not the same as the
connections current <i>expected page size</i>, then the
<i>expected page size</i> is set to this value, the database file is
unlocked and the entire procedure to open a <i>read transaction</i>
is repeated.

HLR H21024 
If page 1 data is read as required by H21023, then the value of the
<i>page-size</i> field that appears in the database file header that
consumes the first 100 bytes of the read block is the same as the
connections current <i>expected page size</i>, then the block of data
read is stored in the <i>page cache</i> as page 1.

HLR H21027 
When required to <i>journal a database page</i>, SQLite shall first
append the <i>page number</i> of the page being journalled to the
<i>journal file</i>, formatted as a 4-byte big-endian unsigned integer,
using a single call to the xWrite method of the file-handle opened
on the journal file.

HLR H21028 
When required to <i>journal a database page</i>, if the attempt to
append the <i>page number</i> to the journal file is successful,
then the current page data (<i>page-size</i> bytes) shall be appended
to the journal file, using a single call to the xWrite method of the
file-handle opened on the journal file.

HLR H21029 
When required to <i>journal a database page</i>, if the attempt to
append the current page data to the journal file is successful,
then SQLite shall append a 4-byte big-endian integer checksum value
to the to the journal file, using a single call to the xWrite method
of the file-handle opened on the journal file.

HLR H21030 
The checksum value written to the <i>journal file</i> by the write
required by H21029 shall be equal to the sum of the <i>checksum
initializer</i> field stored in the <i>journal header</i> (H21070) and
every 200th byte of the page data, beginning with the
(<i>page-size</i> % 200)th byte.

HLR H21035 
When required to open a <i>write transaction</i> on the database,
SQLite shall first open a <i>read transaction</i>, if the <i>database
connection</i> in question has not already opened one.

HLR H21036 
When required to open a <i>write transaction</i> on the database, after
ensuring a <i>read transaction</i> has already been opened, SQLite
shall obtain a <i>reserved lock</i> on the database file by calling
the xLock method of the file-handle open on the database file.

HLR H21037 
When required to open a <i>write transaction</i> on the database, after
obtaining a <i>reserved lock</i> on the database file, SQLite shall
open a read/write file-handle on the corresponding <i>journal file</i>.

HLR H21038 
When required to open a <i>write transaction</i> on the database, after
opening a file-handle on the <i>journal file</i>, SQLite shall append
a <i>journal header</i> to the (currently empty) <i>journal file</i>.

HLR H21040 
When a <i>database connection</i> is closed, SQLite shall close the
associated file handle at the VFS level.

HLR H21042 
SQLite shall ensure that a <i>database connection</i> has an open
read-only or read/write transaction before using data stored in the <i>page
cache</i> to satisfy user queries.

HLR H21043 
When a <i>database connection</i> is closed, all associated <i>page
cache</i> entries shall be discarded.

HLR H21044 
If while attempting to detect a <i>hot-journal file</i> the call to
xCheckReservedLock() indicates that no process holds a <i>reserved</i>
or greater lock on the <i>database file</i>, then SQLite shall open
a file handle on the potentially hot journal file using the VFS xOpen()
method.

HLR H21045 
After successfully opening a file-handle on a potentially hot journal
file, SQLite shall query the file for its size in bytes using the
xFileSize() method of the open file handle.

HLR H21046 
If the size of a potentially hot journal file is revealed to be zero
bytes by a query required by H21045, then SQLite shall close the
file handle opened on the journal file and delete the journal file using
a call to the VFS xDelete() method. In this case SQLite shall conclude
that there is no <i>hot journal file</i>.

HLR H21047 
If the size of a potentially hot journal file is revealed to be greater
than zero bytes by a query required by H21045, then SQLite shall attempt
to upgrade the <i>shared lock</i> held by the <i>database connection</i>
on the <i>database file</i> directly to an <i>exclusive lock</i>.

HLR H21048 
If an attempt to upgrade to an <i>exclusive lock</i> prescribed by
H21047 fails for any reason, then SQLite shall release all locks held by
the <i>database connection</i> and close the file handle opened on the
<i>journal file</i>. The attempt to open a <i>read-only transaction</i>
shall be deemed to have failed and an error returned to the user.

HLR H21049 
If, as part of the <i>hot journal file</i> detection process, the
attempt to upgrade to an <i>exclusive lock</i> mandated by H21047 is
successful, then SQLite shall query the file-system using the xAccess()
method of the VFS implementation to test whether or not the journal
file is still present in the file-system.

HLR H21050 
If the xAccess() query required by H21049 reveals that the journal
file is still present in the file system, then SQLite shall conclude
that the journal file is a <i>hot journal file</i> that needs to
be rolled back. SQLite shall immediately begin <i>hot journal
rollback</i>.

HLR H21051 
If the call to xAccess() required by H21014 fails (due to an IO error or
similar), then SQLite shall abandon the attempt to open a <i>read-only
transaction</i>, relinquish the <i>shared lock</i> held on the database
file and return an error to the user.

HLR H21052 
If the call to xCheckReservedLock() required by H21016 fails (due to an
IO or other internal VFS error), then SQLite shall abandon the attempt
to open a <i>read-only transaction</i>, relinquish the <i>shared lock</i>
held on the database file and return an error to the user.

HLR H21053 
If the call to xOpen() required by H21044 fails (due to an IO or other
internal VFS error), then SQLite shall abandon the attempt to open a
<i>read-only transaction</i>, relinquish the <i>shared lock</i> held on
the database file and return an error to the user.

HLR H21054 
If the call to xFileSize() required by H21045 fails (due to an IO or
other internal VFS error), then SQLite shall abandon the attempt to open
a <i>read-only transaction</i>, relinquish the <i>shared lock</i> held on
the database file, close the file handle opened on the journal file and
return an error to the user.

HLR H21055 
If the call to xDelete() required by H21045 fails (due to an IO or
other internal VFS error), then SQLite shall abandon the attempt to open
a <i>read-only transaction</i>, relinquish the <i>shared lock</i> held on
the database file and return an error to the user.

HLR H21056 
If the call to xAccess() required by H21049 fails (due to an IO or
other internal VFS error), then SQLite shall abandon the attempt to open
a <i>read-only transaction</i>, relinquish the lock held on the
database file, close the file handle opened on the journal file and
return an error to the user.

HLR H21057 
If the call to xAccess() required by H21049 reveals that the journal
file is no longer present in the file system, then SQLite shall abandon
the attempt to open a <i>read-only transaction</i>, relinquish the
lock held on the database file, close the file handle opened on the
journal file and return an SQLITE_BUSY error to the user.

HLR H21058 
If an attempt to acquire a <i>reserved lock</i> prescribed by
requirement H21036 fails, then SQLite shall deem the attempt to
open a <i>write transaction</i> to have failed and return an error
to the user.

HLR H21059 
When required to modify the contents of an existing database page that
existed and was not a <i>free-list leaf page</i> when the <i>write
transaction</i> was opened, SQLite shall journal the page if it has not
already been journalled within the current <i>write transaction</i>.

HLR H21060 
When required to modify the contents of an existing database page,
SQLite shall update the cached version of the database page content
stored as part of the <i>page cache entry</i> associated with the page.

HLR H21061 
When required to append a new database page to the database file,
SQLite shall create a new <i>page cache entry</i> corresponding to
the new page and insert it into the <i>page cache</i>. The <i>dirty
flag</i> of the new <i>page cache entry</i> shall be set.

HLR H21062 
When required to truncate (remove) a database page that existed and was
not a <i>free-list leaf page</i> when the <i>write transaction</i> was
opened from the end of a database file, SQLite shall journal the page if
it has not already been journalled within the current <i>write
transaction</i>.

HLR H21063 
When required to truncate a database page from the end of the database
file, SQLite shall discard the associated <i>page cache entry</i>
from the page cache.

HLR H21064 
When required to purge a <i>non-writable dirty page</i> from the
<i>page cache</i>, SQLite shall <i>sync the journal file</i> before
proceding with the write operation required by H21067.

HLR H21066 
After <i>syncing the journal file</i> as required by H21064, SQLite
shall append a new <i>journal header</i> to the <i>journal file</i>
before proceding with the write operation required by H21067.

HLR H21067 
When required to purge a <i>page cache entry</i> that is a
<i>dirty page</i> SQLite shall write the page data into the database
file, using a single call to the xWrite method of the <i>database
connection</i> file handle.

HLR H21068 
When required to append a <i>journal header</i> to the <i>journal
file</i>, SQLite shall do so by writing a block of <i>sector-size</i>
bytes using a single call to the xWrite method of the file-handle
open on the <i>journal file</i>. The block of data written shall begin
at the smallest sector-size aligned offset at or following the current
end of the <i>journal file</i>.

HLR H21069 
The first 8 bytes of the <i>journal header</i> required to be written
by H21068 shall contain the following values, in order from byte offset 0
to 7: 0xd9, 0xd5, 0x05, 0xf9, 0x20, 0xa1, 0x63 and 0xd7.

HLR H21070 
Bytes 8-11 of the <i>journal header</i> required to be written by
H21068 shall contain 0x00.

HLR H21071 
Bytes 12-15 of the <i>journal header</i> required to be written by
H21068 shall contain the number of pages that the database file
contained when the current <i>write-transaction</i> was started,
formatted as a 4-byte big-endian unsigned integer.

HLR H21072 
Bytes 16-19 of the <i>journal header</i> required to be written by
H21068 shall contain pseudo-randomly generated values.

HLR H21073 
Bytes 20-23 of the <i>journal header</i> required to be written by
H21068 shall contain the <i>sector size</i> used by the VFS layer,
formatted as a 4-byte big-endian unsigned integer.

HLR H21074 
Bytes 24-27 of the <i>journal header</i> required to be written by
H21068 shall contain the <i>page size</i> used by the database at
the start of the <i>write transaction</i>, formatted as a 4-byte
big-endian unsigned integer.

HLR H21075 
When required to <i>sync the journal file</i>, SQLite shall invoke the
xSync method of the file handle open on the <i>journal file</i>.

HLR H21076 
When required to <i>sync the journal file</i>, after invoking the
xSync method as required by H21075, SQLite shall update the <i>record
count</i> of the <i>journal header</i> most recently written to the
<i>journal file</i>. The 4-byte field shall be updated to contain
the number of <i>journal records</i> that have been written to the
<i>journal file</i> since the <i>journal header</i> was written,
formatted as a 4-byte big-endian unsigned integer.

HLR H21077 
When required to <i>sync the journal file</i>, after updating the
<i>record count</i> field of a <i>journal header</i> as required by
H21076, SQLite shall invoke the xSync method of the file handle open
on the <i>journal file</i>.

HLR H21078 
When required to upgrade to an <i>exclusive lock</i> as part of a write
transaction, SQLite shall first attempt to obtain a <i>pending lock</i>
on the database file if one is not already held by invoking the xLock
method of the file handle opened on the <i>database file</i>.

HLR H21079 
When required to upgrade to an <i>exclusive lock</i> as part of a write
transaction, after successfully obtaining a <i>pending lock</i> SQLite
shall attempt to obtain an <i>exclusive lock</i> by invoking the
xLock method of the file handle opened on the <i>database file</i>.

HLR H21080 
When required to <i>commit a write-transaction</i>, SQLite shall
modify page 1 to increment the value stored in the <i>change counter</i>
field of the <i>database file header</i>.

HLR H21081 
When required to <i>commit a write-transaction</i>, after incrementing
the <i>change counter</i> field, SQLite shall <i>sync the journal
file</i>.

HLR H21082 
When required to <i>commit a write-transaction</i>, after <i>syncing
the journal file</i> as required by H21081, if an <i>exclusive lock</i>
on the database file is not already held, SQLite shall attempt to
<i>upgrade to an exclusive lock</i>.

HLR H21083 
When required to <i>commit a write-transaction</i>, after <i>syncing
the journal file</i> as required by H21081 and ensuring that an
<i>exclusive lock</i> is held on the database file as required by
H21083, SQLite shall copy the contents of all <i>dirty page</i>
stored in the <i>page cache</i> into the <i>database file</i> using
calls to the xWrite method of the <i>database connection</i> file
handle. Each call to xWrite shall write the contents of a single
<i>dirty page</i> (<i>page-size</i> bytes of data) to the database
file. Dirty pages shall be written in order of <i>page number</i>,
from lowest to highest.

HLR H21084 
When required to <i>commit a write-transaction</i>, after copying the
contents of any <i>dirty pages</i> to the database file as required
by H21083, SQLite shall sync the database file by invoking the xSync
method of the <i>database connection</i> file handle.

HLR H21085 
When required to <i>commit a write-transaction</i>, after syncing
the database file as required by H21084, SQLite shall close the
file-handle opened on the <i>journal file</i> and delete the
<i>journal file</i> from the file system via a call to the VFS
xDelete method.

HLR H21086 
When required to <i>commit a write-transaction</i>, after deleting
the <i>journal file</i> as required by H21085, SQLite shall relinquish
all locks held on the <i>database file</i> by invoking the xUnlock
method of the <i>database connection</i> file handle.

Added req/hlr40000.txt.




































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
HLR H40310 
SQLite shall recognize as a VARIABLE token the a question-mark (u003f)
followed by zero or more NUMERIC characters.

HLR H40320 
SQLite shall recognize as a VARIABLE token one of the characters
at-sign (u0040), dollar-sign (u0024), or colon (u003a) followed
by a parameter name.

HLR H40330 
SQLite shall recognize as a VARIABLE token the shape-sign (u0023)
followed by a parameter name that does not begin with a
NUMERIC character.

HLR H41010 
SQLite shall divide input SQL text into tokens working from left to
right.

HLR H41020 
At each step in the SQL tokenization process, SQLite shall extract
the longest possible token from the remaining input text.

HLR H41030 
The tokenizer shall pass each non-WHITESPACE token seen on to the
parser in the order in which the tokens are seen.

HLR H41040 
When the tokenizer reaches the end of input where the last token sent
to the parser was not a SEMI token, it shall
send a SEMI token to the parser.

HLR H41050 
When the tokenizer encounters text that is not a valid token, it shall
cause an error to be returned to the application.

HLR H41100 
SQLite shall recognize a sequence of one or more WHITESPACE characters
as a WHITESPACE token.

HLR H41110 
SQLite shall recognize as a WHITESPACE token the two-character sequence "--"
(u002d, u002d) followed by any sequence of non-zero characters up through and
including the first u000a character or until end of input.

HLR H41120 
SQLite shall recognize as a WHITESPACE token the two-character sequence "/*"
(u002f, u002a) followed by any sequence of zero or more
non-zero characters through with the first "*/" (u002a, u002f) sequence or
until end of input.

HLR H41130 
SQLite shall recognize as an ID token
any sequence of characters that begins with
an ALPHABETIC character and continue with zero or more
ALPHANUMERIC characters and/or "$" (u0024) characters and which is
not a keyword token.

HLR H41140 
SQLite shall recognize as an ID token
any sequence of non-zero characters that begins with "&#91;" (u005b) and
continuing through the first "&#93;" (u005d) character.

HLR H41150 
SQLite shall recognize as an ID token
any sequence of characters
that begins with a double-quote (u0022), is followed by zero or
more non-zero characters and/or pairs of double-quotes (u0022)
and terminates with a double-quote (u0022) that
is not part of a pair.

HLR H41160 
SQLite shall recognize as an ID token
any sequence of characters
that begins with a grave accent (u0060), is followed by zero or
more non-zero characters and/or pairs ofgrave accents (u0060)
and terminates with a grave accent (u0022) that
is not part of a pair.

HLR H41200 
SQLite shall recognize as a STRING token a sequence of characters
that begins with a single-quote (u0027), is followed by zero or
more non-zero characters and/or pairs of single-quotes (u0027)
and terminates with a single-quote (u0027) that
is not part of a pair.

HLR H41210 
SQLite shall recognize as a BLOB token an upper or lower-case "X"
(u0058 or u0078) followed by a single-quote (u0027) followed by
a number of HEXADECIMAL character that is a multiple of two and
terminated by a single-quote (u0027).

HLR H41220 
SQLite shall recognize as an INTEGER token any squence of
one or more NUMERIC characters.

HLR H41230 
SQLite shall recognize as a FLOAT token a sequence of one
or more NUMERIC characters together with zero or one period
(u002e) and followed by an exponentiation suffix.

HLR H41240 
SQLite shall recognize as a FLOAT token a sequence of one
or more NUMERIC characters that includes exactly one period
(u002e) character.

HLR H41403 
SQLite shall recognize the 1-character sequenence "-" (u002d) as token MINUS

HLR H41406 
SQLite shall recognize the 1-character sequenence "(" (u0028) as token LP

HLR H41409 
SQLite shall recognize the 1-character sequenence ")" (u0029) as token RP

HLR H41412 
SQLite shall recognize the 1-character sequenence ";" (u003b) as token SEMI

HLR H41415 
SQLite shall recognize the 1-character sequenence "+" (u002b) as token PLUS

HLR H41418 
SQLite shall recognize the 1-character sequenence "*" (u002a) as token STAR

HLR H41421 
SQLite shall recognize the 1-character sequenence "/" (u002f) as token SLASH

HLR H41424 
SQLite shall recognize the 1-character sequenence "%" (u0025) as token REM

HLR H41427 
SQLite shall recognize the 1-character sequenence "=" (u003d) as token EQ

HLR H41430 
SQLite shall recognize the 2-character sequenence "==" (u003d u003d) as token EQ

HLR H41433 
SQLite shall recognize the 2-character sequenence "<=" (u003c u003d) as token LE

HLR H41436 
SQLite shall recognize the 2-character sequenence "<>" (u003c u003e) as token NE

HLR H41439 
SQLite shall recognize the 2-character sequenence "<<" (u003c u003c) as token LSHIFT

HLR H41442 
SQLite shall recognize the 1-character sequenence "<" (u003c) as token LT

HLR H41445 
SQLite shall recognize the 2-character sequenence ">=" (u003e u003d) as token GE

HLR H41448 
SQLite shall recognize the 2-character sequenence ">>" (u003e u003e) as token RSHIFT

HLR H41451 
SQLite shall recognize the 1-character sequenence ">" (u003e) as token GT

HLR H41454 
SQLite shall recognize the 2-character sequenence "!=" (u0021 u003d) as token NE

HLR H41457 
SQLite shall recognize the 1-character sequenence "," (u002c) as token COMMA

HLR H41460 
SQLite shall recognize the 1-character sequenence "&" (u0026) as token BITAND

HLR H41463 
SQLite shall recognize the 1-character sequenence "~" (u007e) as token BITNOT

HLR H41466 
SQLite shall recognize the 1-character sequenence "|" (u007c) as token BITOR

HLR H41469 
SQLite shall recognize the 2-character sequenence "||" (u007c u007c) as token CONCAT

HLR H41472 
SQLite shall recognize the 1-character sequenence "." (u002e) as token DOT

HLR H41503 
SQLite shall recognize the 5-character sequenence "ABORT" in any combination of upper and lower case letters as the keyword token ABORT.

HLR H41506 
SQLite shall recognize the 3-character sequenence "ADD" in any combination of upper and lower case letters as the keyword token ADD.

HLR H41509 
SQLite shall recognize the 5-character sequenence "AFTER" in any combination of upper and lower case letters as the keyword token AFTER.

HLR H41512 
SQLite shall recognize the 3-character sequenence "ALL" in any combination of upper and lower case letters as the keyword token ALL.

HLR H41515 
SQLite shall recognize the 5-character sequenence "ALTER" in any combination of upper and lower case letters as the keyword token ALTER.

HLR H41518 
SQLite shall recognize the 7-character sequenence "ANALYZE" in any combination of upper and lower case letters as the keyword token ANALYZE.

HLR H41521 
SQLite shall recognize the 3-character sequenence "AND" in any combination of upper and lower case letters as the keyword token AND.

HLR H41524 
SQLite shall recognize the 2-character sequenence "AS" in any combination of upper and lower case letters as the keyword token AS.

HLR H41527 
SQLite shall recognize the 3-character sequenence "ASC" in any combination of upper and lower case letters as the keyword token ASC.

HLR H41530 
SQLite shall recognize the 6-character sequenence "ATTACH" in any combination of upper and lower case letters as the keyword token ATTACH.

HLR H41533 
SQLite shall recognize the 13-character sequenence "AUTOINCREMENT" in any combination of upper and lower case letters as the keyword token AUTOINCR.

HLR H41536 
SQLite shall recognize the 6-character sequenence "BEFORE" in any combination of upper and lower case letters as the keyword token BEFORE.

HLR H41539 
SQLite shall recognize the 5-character sequenence "BEGIN" in any combination of upper and lower case letters as the keyword token BEGIN.

HLR H41542 
SQLite shall recognize the 7-character sequenence "BETWEEN" in any combination of upper and lower case letters as the keyword token BETWEEN.

HLR H41545 
SQLite shall recognize the 2-character sequenence "BY" in any combination of upper and lower case letters as the keyword token BY.

HLR H41548 
SQLite shall recognize the 7-character sequenence "CASCADE" in any combination of upper and lower case letters as the keyword token CASCADE.

HLR H41551 
SQLite shall recognize the 4-character sequenence "CASE" in any combination of upper and lower case letters as the keyword token CASE.

HLR H41554 
SQLite shall recognize the 4-character sequenence "CAST" in any combination of upper and lower case letters as the keyword token CAST.

HLR H41557 
SQLite shall recognize the 5-character sequenence "CHECK" in any combination of upper and lower case letters as the keyword token CHECK.

HLR H41560 
SQLite shall recognize the 7-character sequenence "COLLATE" in any combination of upper and lower case letters as the keyword token COLLATE.

HLR H41563 
SQLite shall recognize the 6-character sequenence "COLUMN" in any combination of upper and lower case letters as the keyword token COLUMNKW.

HLR H41566 
SQLite shall recognize the 6-character sequenence "COMMIT" in any combination of upper and lower case letters as the keyword token COMMIT.

HLR H41569 
SQLite shall recognize the 8-character sequenence "CONFLICT" in any combination of upper and lower case letters as the keyword token CONFLICT.

HLR H41572 
SQLite shall recognize the 10-character sequenence "CONSTRAINT" in any combination of upper and lower case letters as the keyword token CONSTRAINT.

HLR H41575 
SQLite shall recognize the 6-character sequenence "CREATE" in any combination of upper and lower case letters as the keyword token CREATE.

HLR H41578 
SQLite shall recognize the 5-character sequenence "CROSS" in any combination of upper and lower case letters as the keyword token JOIN_KW.

HLR H41581 
SQLite shall recognize the 12-character sequenence "CURRENT_DATE" in any combination of upper and lower case letters as the keyword token CTIME_KW.

HLR H41584 
SQLite shall recognize the 12-character sequenence "CURRENT_TIME" in any combination of upper and lower case letters as the keyword token CTIME_KW.

HLR H41587 
SQLite shall recognize the 17-character sequenence "CURRENT_TIMESTAMP" in any combination of upper and lower case letters as the keyword token CTIME_KW.

HLR H41590 
SQLite shall recognize the 8-character sequenence "DATABASE" in any combination of upper and lower case letters as the keyword token DATABASE.

HLR H41593 
SQLite shall recognize the 7-character sequenence "DEFAULT" in any combination of upper and lower case letters as the keyword token DEFAULT.

HLR H41596 
SQLite shall recognize the 8-character sequenence "DEFERRED" in any combination of upper and lower case letters as the keyword token DEFERRED.

HLR H41599 
SQLite shall recognize the 10-character sequenence "DEFERRABLE" in any combination of upper and lower case letters as the keyword token DEFERRABLE.

HLR H41602 
SQLite shall recognize the 6-character sequenence "DELETE" in any combination of upper and lower case letters as the keyword token DELETE.

HLR H41605 
SQLite shall recognize the 4-character sequenence "DESC" in any combination of upper and lower case letters as the keyword token DESC.

HLR H41608 
SQLite shall recognize the 6-character sequenence "DETACH" in any combination of upper and lower case letters as the keyword token DETACH.

HLR H41611 
SQLite shall recognize the 8-character sequenence "DISTINCT" in any combination of upper and lower case letters as the keyword token DISTINCT.

HLR H41614 
SQLite shall recognize the 4-character sequenence "DROP" in any combination of upper and lower case letters as the keyword token DROP.

HLR H41617 
SQLite shall recognize the 3-character sequenence "END" in any combination of upper and lower case letters as the keyword token END.

HLR H41620 
SQLite shall recognize the 4-character sequenence "EACH" in any combination of upper and lower case letters as the keyword token EACH.

HLR H41623 
SQLite shall recognize the 4-character sequenence "ELSE" in any combination of upper and lower case letters as the keyword token ELSE.

HLR H41626 
SQLite shall recognize the 6-character sequenence "ESCAPE" in any combination of upper and lower case letters as the keyword token ESCAPE.

HLR H41629 
SQLite shall recognize the 6-character sequenence "EXCEPT" in any combination of upper and lower case letters as the keyword token EXCEPT.

HLR H41632 
SQLite shall recognize the 9-character sequenence "EXCLUSIVE" in any combination of upper and lower case letters as the keyword token EXCLUSIVE.

HLR H41635 
SQLite shall recognize the 6-character sequenence "EXISTS" in any combination of upper and lower case letters as the keyword token EXISTS.

HLR H41638 
SQLite shall recognize the 7-character sequenence "EXPLAIN" in any combination of upper and lower case letters as the keyword token EXPLAIN.

HLR H41641 
SQLite shall recognize the 4-character sequenence "FAIL" in any combination of upper and lower case letters as the keyword token FAIL.

HLR H41644 
SQLite shall recognize the 3-character sequenence "FOR" in any combination of upper and lower case letters as the keyword token FOR.

HLR H41647 
SQLite shall recognize the 7-character sequenence "FOREIGN" in any combination of upper and lower case letters as the keyword token FOREIGN.

HLR H41650 
SQLite shall recognize the 4-character sequenence "FROM" in any combination of upper and lower case letters as the keyword token FROM.

HLR H41653 
SQLite shall recognize the 4-character sequenence "FULL" in any combination of upper and lower case letters as the keyword token JOIN_KW.

HLR H41656 
SQLite shall recognize the 4-character sequenence "GLOB" in any combination of upper and lower case letters as the keyword token LIKE_KW.

HLR H41659 
SQLite shall recognize the 5-character sequenence "GROUP" in any combination of upper and lower case letters as the keyword token GROUP.

HLR H41662 
SQLite shall recognize the 6-character sequenence "HAVING" in any combination of upper and lower case letters as the keyword token HAVING.

HLR H41665 
SQLite shall recognize the 2-character sequenence "IF" in any combination of upper and lower case letters as the keyword token IF.

HLR H41668 
SQLite shall recognize the 6-character sequenence "IGNORE" in any combination of upper and lower case letters as the keyword token IGNORE.

HLR H41671 
SQLite shall recognize the 9-character sequenence "IMMEDIATE" in any combination of upper and lower case letters as the keyword token IMMEDIATE.

HLR H41674 
SQLite shall recognize the 2-character sequenence "IN" in any combination of upper and lower case letters as the keyword token IN.

HLR H41677 
SQLite shall recognize the 5-character sequenence "INDEX" in any combination of upper and lower case letters as the keyword token INDEX.

HLR H41680 
SQLite shall recognize the 9-character sequenence "INITIALLY" in any combination of upper and lower case letters as the keyword token INITIALLY.

HLR H41683 
SQLite shall recognize the 5-character sequenence "INNER" in any combination of upper and lower case letters as the keyword token JOIN_KW.

HLR H41686 
SQLite shall recognize the 6-character sequenence "INSERT" in any combination of upper and lower case letters as the keyword token INSERT.

HLR H41689 
SQLite shall recognize the 7-character sequenence "INSTEAD" in any combination of upper and lower case letters as the keyword token INSTEAD.

HLR H41692 
SQLite shall recognize the 9-character sequenence "INTERSECT" in any combination of upper and lower case letters as the keyword token INTERSECT.

HLR H41695 
SQLite shall recognize the 4-character sequenence "INTO" in any combination of upper and lower case letters as the keyword token INTO.

HLR H41698 
SQLite shall recognize the 2-character sequenence "IS" in any combination of upper and lower case letters as the keyword token IS.

HLR H41701 
SQLite shall recognize the 6-character sequenence "ISNULL" in any combination of upper and lower case letters as the keyword token ISNULL.

HLR H41704 
SQLite shall recognize the 4-character sequenence "JOIN" in any combination of upper and lower case letters as the keyword token JOIN.

HLR H41707 
SQLite shall recognize the 3-character sequenence "KEY" in any combination of upper and lower case letters as the keyword token KEY.

HLR H41710 
SQLite shall recognize the 4-character sequenence "LEFT" in any combination of upper and lower case letters as the keyword token JOIN_KW.

HLR H41713 
SQLite shall recognize the 4-character sequenence "LIKE" in any combination of upper and lower case letters as the keyword token LIKE_KW.

HLR H41716 
SQLite shall recognize the 5-character sequenence "LIMIT" in any combination of upper and lower case letters as the keyword token LIMIT.

HLR H41719 
SQLite shall recognize the 5-character sequenence "MATCH" in any combination of upper and lower case letters as the keyword token MATCH.

HLR H41722 
SQLite shall recognize the 7-character sequenence "NATURAL" in any combination of upper and lower case letters as the keyword token JOIN_KW.

HLR H41725 
SQLite shall recognize the 3-character sequenence "NOT" in any combination of upper and lower case letters as the keyword token NOT.

HLR H41728 
SQLite shall recognize the 7-character sequenence "NOTNULL" in any combination of upper and lower case letters as the keyword token NOTNULL.

HLR H41731 
SQLite shall recognize the 4-character sequenence "NULL" in any combination of upper and lower case letters as the keyword token NULL.

HLR H41734 
SQLite shall recognize the 2-character sequenence "OF" in any combination of upper and lower case letters as the keyword token OF.

HLR H41737 
SQLite shall recognize the 6-character sequenence "OFFSET" in any combination of upper and lower case letters as the keyword token OFFSET.

HLR H41740 
SQLite shall recognize the 2-character sequenence "ON" in any combination of upper and lower case letters as the keyword token ON.

HLR H41743 
SQLite shall recognize the 2-character sequenence "OR" in any combination of upper and lower case letters as the keyword token OR.

HLR H41746 
SQLite shall recognize the 5-character sequenence "ORDER" in any combination of upper and lower case letters as the keyword token ORDER.

HLR H41749 
SQLite shall recognize the 5-character sequenence "OUTER" in any combination of upper and lower case letters as the keyword token JOIN_KW.

HLR H41752 
SQLite shall recognize the 4-character sequenence "PLAN" in any combination of upper and lower case letters as the keyword token PLAN.

HLR H41755 
SQLite shall recognize the 6-character sequenence "PRAGMA" in any combination of upper and lower case letters as the keyword token PRAGMA.

HLR H41758 
SQLite shall recognize the 7-character sequenence "PRIMARY" in any combination of upper and lower case letters as the keyword token PRIMARY.

HLR H41761 
SQLite shall recognize the 5-character sequenence "QUERY" in any combination of upper and lower case letters as the keyword token QUERY.

HLR H41764 
SQLite shall recognize the 5-character sequenence "RAISE" in any combination of upper and lower case letters as the keyword token RAISE.

HLR H41767 
SQLite shall recognize the 10-character sequenence "REFERENCES" in any combination of upper and lower case letters as the keyword token REFERENCES.

HLR H41770 
SQLite shall recognize the 6-character sequenence "REGEXP" in any combination of upper and lower case letters as the keyword token LIKE_KW.

HLR H41773 
SQLite shall recognize the 7-character sequenence "REINDEX" in any combination of upper and lower case letters as the keyword token REINDEX.

HLR H41776 
SQLite shall recognize the 6-character sequenence "RENAME" in any combination of upper and lower case letters as the keyword token RENAME.

HLR H41779 
SQLite shall recognize the 7-character sequenence "REPLACE" in any combination of upper and lower case letters as the keyword token REPLACE.

HLR H41782 
SQLite shall recognize the 8-character sequenence "RESTRICT" in any combination of upper and lower case letters as the keyword token RESTRICT.

HLR H41785 
SQLite shall recognize the 5-character sequenence "RIGHT" in any combination of upper and lower case letters as the keyword token JOIN_KW.

HLR H41788 
SQLite shall recognize the 8-character sequenence "ROLLBACK" in any combination of upper and lower case letters as the keyword token ROLLBACK.

HLR H41791 
SQLite shall recognize the 3-character sequenence "ROW" in any combination of upper and lower case letters as the keyword token ROW.

HLR H41794 
SQLite shall recognize the 6-character sequenence "SELECT" in any combination of upper and lower case letters as the keyword token SELECT.

HLR H41797 
SQLite shall recognize the 3-character sequenence "SET" in any combination of upper and lower case letters as the keyword token SET.

HLR H41800 
SQLite shall recognize the 5-character sequenence "TABLE" in any combination of upper and lower case letters as the keyword token TABLE.

HLR H41803 
SQLite shall recognize the 4-character sequenence "TEMP" in any combination of upper and lower case letters as the keyword token TEMP.

HLR H41806 
SQLite shall recognize the 9-character sequenence "TEMPORARY" in any combination of upper and lower case letters as the keyword token TEMP.

HLR H41809 
SQLite shall recognize the 4-character sequenence "THEN" in any combination of upper and lower case letters as the keyword token THEN.

HLR H41812 
SQLite shall recognize the 2-character sequenence "TO" in any combination of upper and lower case letters as the keyword token TO.

HLR H41815 
SQLite shall recognize the 11-character sequenence "TRANSACTION" in any combination of upper and lower case letters as the keyword token TRANSACTION.

HLR H41818 
SQLite shall recognize the 7-character sequenence "TRIGGER" in any combination of upper and lower case letters as the keyword token TRIGGER.

HLR H41821 
SQLite shall recognize the 5-character sequenence "UNION" in any combination of upper and lower case letters as the keyword token UNION.

HLR H41824 
SQLite shall recognize the 6-character sequenence "UNIQUE" in any combination of upper and lower case letters as the keyword token UNIQUE.

HLR H41827 
SQLite shall recognize the 6-character sequenence "UPDATE" in any combination of upper and lower case letters as the keyword token UPDATE.

HLR H41830 
SQLite shall recognize the 5-character sequenence "USING" in any combination of upper and lower case letters as the keyword token USING.

HLR H41833 
SQLite shall recognize the 6-character sequenence "VACUUM" in any combination of upper and lower case letters as the keyword token VACUUM.

HLR H41836 
SQLite shall recognize the 6-character sequenence "VALUES" in any combination of upper and lower case letters as the keyword token VALUES.

HLR H41839 
SQLite shall recognize the 4-character sequenence "VIEW" in any combination of upper and lower case letters as the keyword token VIEW.

HLR H41842 
SQLite shall recognize the 7-character sequenence "VIRTUAL" in any combination of upper and lower case letters as the keyword token VIRTUAL.

HLR H41845 
SQLite shall recognize the 4-character sequenence "WHEN" in any combination of upper and lower case letters as the keyword token WHEN.

HLR H41848 
SQLite shall recognize the 5-character sequenence "WHERE" in any combination of upper and lower case letters as the keyword token WHERE.

HLR H42000 
The SQLite parser shall accept SQL statements consisting of an SQL command
followed by a semicolon.
<blockquote><pre>
sql_statement ::= cmd SEMI.
</pre></blockquote>

HLR H42002 
The preparation of an SQL statement that is not accepted by
the SQLite parser shall fail with an error.

HLR H42004 
SQLite shall use the built-in NOCASE collating sequence when comparing
identifiers and datatype names within SQL statements during
statement preparation.

HLR H42008 
A token received by the parser shall be converted into an ID token
if the original token value would have resulted in a syntax error,
a token value of ID will allow the parse to continue,
and if the original token value was one of:
ABORT
AFTER
ANALYZE
ASC
ATTACH
BEFORE
BEGIN
CASCADE
CAST
CONFLICT
CTIME_KW
DATABASE
DEFERRED
DESC
DETACH
EACH
END
EXCEPT
EXCLUSIVE
EXPLAIN
FAIL
FOR
IF
IGNORE
IMMEDIATE
INITIALLY
INSTEAD
INTERSECT
KEY
LIKE_KW
MATCH
OF
OFFSET
PLAN
PRAGMA
QUERY
RAISE
REINDEX
RENAME
REPLACE
RESTRICT
ROW
TEMP
TRIGGER
UNION
VACUUM
VIEW
VIRTUAL

HLR H42010 
The SQLite parser shall accept BEGIN statements
that conform to the following syntax:
<blockquote><pre>
cmd ::= BEGIN transaction_type transaction_name.
transaction_type ::= .
transaction_type ::= DEFERRED.
transaction_type ::= IMMEDIATE.
transaction_type ::= EXCLUSIVE.
transaction_name ::= .
transaction_name ::= TRANSACTION.
transaction_name ::= TRANSACTION name.
</pre></blockquote>

HLR H42012 
A token received by the parser shall be converted into an ANY token
if the original token value would have resulted in a syntax error
and if a token value of ANY will allow the parse to continue.

HLR H42013 
The successful evaluation of a BEGIN statement shall
cause the [database connection] to exit autocommit mode.

HLR H42016 
The evaluation of a BEGIN TRANSACTION statement shall fail with an error
if the [database connection] is not in autocommit mode at the
start of evaluation.

HLR H42019 
If the <i>transaction_type</i> keyword is omitted from a
BEGIN TRANSACTION statement then the behavior shall be the same
as if the DEFERRED keyword were used.

HLR H42022 
When the DEFERRED keyword appears in a BEGIN statement
the locking state of the underlying database files shall be
the same before and after the statement is evaluated.

HLR H42025 
When the IMMEDIATE keyword appears in a BEGIN statement
then successful evaluation of the statement shall cause a RESERVED
lock to be obtained for all underlying database files.

HLR H42028 
When the EXCLUSIVE keyword appears in a BEGIN statement
then successful evaluation of the statement shall cause a EXCLUSIVE
lock to be obtained for all underlying database files.

HLR H42110 
SQLite shall accept the following COMMIT statement syntax:
<blockquote><pre>
cmd ::= COMMIT transaction_name.
cmd ::= END transaction_name.
</pre></blockquote>

HLR H42113 
The successful evaluation of COMMIT statement places the
[database connection] in autocommit mode.

HLR H42116 
If a [database connection] is already in autocommit mode when
a COMMIT statement is evaluated, then the statement shall fail
with an error.

HLR H42210 
The SQLite parser shall accept ROLLBACK statements
that conform to the following syntax:
<blockquote><pre>
cmd ::= ROLLBACK transaction_name.
</pre></blockquote>

HLR H42213 
The successful evaluation of ROLLBACK statement places the
[database connection] in autocommit mode.

HLR H42216 
If a [database connection] is already in autocommit mode when
a ROLLBACK statement is invoked, then the statement invocation
shall fail with an error.

HLR H42222 
Other pending statements on the same [database connection]
as a successfully evaluated ROLLBACK statement shall be aborted.

HLR H42225 
The successful evaluation of a ROLLBACK statement causes the
current transaction on the [database connection] to roll back.

HLR H42310 
The SQLite parser shall accept CREATE TABLE statements
that conform to the following syntax:
<blockquote><pre>
cmd ::= CREATE temp TABLE ifnotexists fullname table_definition.
temp ::= .
temp ::= TEMP.
ifnotexists ::= .
ifnotexists ::= IF NOT EXISTS.
</pre></blockquote>

HLR H42313 
When the TEMP keyword appears in a CREATE TABLE statement and the
<i>databasename</i> exists and is something other than "temp", then
the preparation of the CREATE TABLE statement shall fail with an error.

HLR H42316 
When the TEMP keyword appears in a CREATE TABLE statement the behavior
shall be as if the <i>databasename</i> where "temp".

HLR H42319 
The successful evaluation of a CREATE TABLE statement shall cause
a new SQL table whose name is given by the <i>objectname</i> to be
created in the schema of the database whose name is given by the
<i>databasename</i>.

HLR H42322 
If a CREATE TABLE statement specifies no <i>databasename</i> and omits
the TEMP keyword then the behavior shall be as if a <i>databasename</i>
of "main" where used.

HLR H42325 
The preparation of a CREATE TABLE statement shall fail with an
error if the IF NOT EXISTS clause is omitted and the <i>objectname</i>
is the same as the name of a table or view
in the same database.

HLR H42328 
The evaluation of a CREATE TABLE statement shall be a silent no-op if the
IF NOT EXISTS clause is present and the <i>objectname</i>
is the same as the name of a table or view
in the same database.

HLR H42331 
The preparation of a CREATE TABLE statement shall fail with an error if the
the <i>objectname</i> is the same as the name of an index
in any database attached to the same [database connection].

HLR H42334 
The preparation of a CREATE TABLE statement shall fail with an error if the
the <i>databasename</i> references a database that is not
attached to the same [database connection].

HLR H42410 
The SQLite parser shall accept the following syntax for the
<i>table_definition</i> section of a CREATE TABLE statement:
<blockquote><pre>
table_definition ::= LP columnlist constraint_opt RP.
columnlist ::= column.
columnlist ::= columnlist COMMON column.
constraint_opt ::= .
constraint_opt ::= COMMA constraint_list.
</pre></blockquote>

HLR H42413 
The SQLite parser shall accept the following syntax
for the <i>column</i> component of a <i>table_definition</i>.
<blockquote><pre>
column ::= name column_type column_constraint_list.
column_type ::= .
column_type ::= typename.
column_type ::= typename LP signed_int RP.
column_type ::= typename LP signed_int COMMA signed_int RP.
typename ::= identifier.
typename ::= typename identifier.
signed_int ::= INTEGER.
signed_int ::= MINUS INTEGER.
signed_int ::= PLUS INTEGER.
</pre></blockquote>

HLR H42416 
The preparation of an ordinary [CREATE TABLE] statement shall fail
with an error if it specifies two or more columns with the same name.

HLR H42419 
The datatype affinity of each column in a table generate by an
ordinary [CREATE TABLE] statement
shall be determined from the <i>column_type</i>
text using the following 5-step algorithm:
<ol>
<li><p> If the <i>column_type</i> contains the string "INT"
then the affinity is INTEGER.</p></li>
<li><p> Else if the <i>column_type</i> contains one of the strings
"CHAR", "CLOB", or "TEXT" then the affinity is TEXT. </p></li>
<li><p> Else if the <i>column_type</i> contains the string "BLOB"
or is omitted then the affinity is NONE. </p></li>
<li><p> Else if the <i>column_type</i> constains one of the strings
"REAL", "FLOA", or "DOUB" then the affinity
is REAL. </p></li>
<li><p> Otherwise the affinity is NUMERIC. </p></li>
</ol>

HLR H42450 
The SQLite parser shall accept the following syntax for the list of column
constraints and modifiers that follows a column definition in
an ordinary [CREATE TABLE] statement.
<blockquote><pre>
column_constraint_list ::= .
column_constraint_list ::= column_constraint_list named_column_constraint.
named_column_constraint ::= CONSTRAINT name column_constraint.
named_column_constraint ::= column_constraint.
column_constraint ::= DEFAULT term.
column_constraint ::= DEFAULT identifier.
column_constraint ::= DEFAULT PLUS term.
column_constraint ::= DEFAULT MINUS term.
column_constraint ::= DEFAULT LP expr RP.
column_constraint ::= NULL conflict.
column_constraint ::= NOT NULL conflict.
column_constraint ::= PRIMARY KEY sortorder conflict autoincr.
column_constraint ::= UNIQUE conflict.
column_constraint ::= CHECK LP expr RP.
column_constraint ::= COLLATE identifier.
column_constraint ::= foreign_key_constraint.
column_constraint ::= deferrable_constraint.
autoincr ::= .
autoincr ::= AUTOINCR.
indexlist_opt ::= .
indexlist_opt ::= LP indexlist RP.
conflict ::= .
conflict ::= ON CONFLICT IGNORE.
conflict ::= ON CONFLICT REPLACE.
conflict ::= ON CONFLICT ABORT.
conflict ::= ON CONFLICT FAIL.
conflict ::= ON CONFLICT ROLLBACK.
</pre></blockquote>

HLR H42453 
When a column as a DEFAULT constraint, the default value for the
column shall be the value specified by that constraint.

HLR H42456 
If a column has no DEFAULT constraint then the default value for
that column shall be NULL.

HLR H42459 
If a column has no NOT NULL constraint then the NULL conflict
resolution behavior for the column shall be NONE.

HLR H42462 
If a column has a NOT NULL constraint and that constrait lacks
an ON CONFLICT clause
then the null-conflict resolution behavior for the column shall
be ABORT.

HLR H42465 
If a column has a NOT NULL constraint and that constraint
has an ON CONFLICT clause
then the null-conflict resolution behavior for the column shall
be the behavior specified by the ON CONFLICT clause.

HLR H42467 
A column without a COLLATE constraint shall have a default
collating sequence of BINARY.

HLR H42468 
A column with a COLLATE constraint shall have a default
collating sequence as specified by the COLLATE constraint.

HLR H42470 
If the datatype of a single-column PRIMARY KEY is
exactly "INTEGER" then the name of that column shall be
an alias for the table rowid.

HLR H42472 
If a table contains no column named "ROWID" then "ROWID" shall be
an alias for the table rowid.

HLR H42474 
If a table contains no column named "OID" then "OID" shall be
an alias for the table rowid.

HLR H42476 
If a table contains no column named "_ROWID_" then "_ROWID_" shall be
an alias for the table rowid.

HLR H42478 
A table shall have an autoincrementing rowid if and only if
the PRIMARY KEY for the table is an alias for the rowid and
the PRIMARY KEY declaration uses the AUTOINCR keyword.

HLR H42480 
Successful evaluation of a CREATE TABLE statement shall create
an index for every UNIQUE constraint where the created index has
a conflict resolution algorithm as specified by the ON CONFLICT
clause of the UNIQUE constraint or a conflict resolution algorithm
of ABORT if there is no ON CONFLICT clause on the constraint.

HLR H42510 
The SQLite parser shall accept the following syntax for the list of table
contraints that occurs at the end of an ordinary [CREATE TABLE] statement.
<blockquote><pre>
constraint_list ::= constraint.
constraint_list ::= constraint_list constraint.
constraint_list ::= constraint_list COMMA constraint.
constraint ::= CHECK LP expr RP conflict.
constraint ::= CONSTRAINT name.
constraint ::= FOREIGN KEY LP columnlist RP foreign_key_constraint defer_opt.
constraint ::= PRIMARY KEY LP indexlist autoinc RP conflict.
constraint ::= UNIQUE LP indexlist RP conflict.
</pre></blockquote>

HLR H42513 
The preparation of a CREATE TABLE statement that contains more
than one PRIMARY KEY constraint shall fail with an error.

HLR H42516 
The preparation of a CREATE TABLE statement that contains a
CHECK constraint that uses a subquery shall fail with an error.

HLR H42517 
The preparation of a CREATE TABLE statement that contains a
CHECK constraint that uses a parameter shall fail with an error.

HLR H42518 
Name resolution of the <i>expr</i> with each CHECK constraint of
a CREATE TABLE statement shall be carried out using a name context
with an empty result set and a source set holding
single source element that is the
table being created.

HLR H42521 
The preparation of a CREATE TABLE statement that contains a
DEFAULT constraint with an non-constant expression
shall fail with an error.

HLR H42536 
A PRIMARY KEY constraint that does not result in a rowid alias
shall have the same effect as a UNIQUE constraint.

HLR H42539 
Preparation of a CREATE TABLE statement shall fail with an
error if the <i>indexlist</i> of either a table PRIMARY KEY
or a table UNIQUE constraint references a column that is not
a column in the table.

HLR H42570 
The SQLite parser shall accept the following syntax for a foreign
key constraint as either a separate constraint or as part of a
column constraint in an ordinary [CREATE TABLE] statement.
<blockquote><pre>
foreign_key_constraint ::= REFERENCES name indexlist_opt fkarglist.
defer_opt ::= .
defer_opt ::= deferrable_constraint.
deferrable_constraint ::= NOT DEFERRABLE initially_deferred_clause.
deferrable_constraint ::= DEFERRABLE initially_deferred_clause.
fkarglist ::= .
fkarglist ::= fkarglist fkarg.
fkarg ::= MATCH name.
fkarg ::= ON DELETE fkaction.
fkarg ::= ON UPDATE fkaction.
fkarg ::= ON INSERT fkaction.
fkaction ::= SET NULL.
fkaction ::= SET DEFAULT.
fkaction ::= CASCADE.
fkaction ::= RESTRICT.
initially_deferred_clause ::= .
initially_deferred_clause ::= INITIALLY DEFERRED.
initially_deferred_clause ::= INITIALLY IMMEDIATE.
</pre></blockquote>

HLR H42610 
The SQLite parser shall accept the following syntax for creating new
database tables from the result set of SELECT statements.
<blockquote><pre>
table_definition ::= AS select.
</pre></blockquote>

HLR H42613 
The table generated by a CREATE TABLE AS statement shall have the
same number of columns as the result set of the SELECT.

HLR H42616 
The names of the columns in a table generated by a CREATE TABLE AS
statement shall have base names which are the names of the columns
in the result set of the SELECT statement

HLR H42617 
Each column name in a table generated by a CREATE TABLE AS
statement shall have an arbitrary suffix appended to its basename
if and only if such a suffix is necessary to make the name
distinct from all preceding column names in the table.

HLR H42619 
All columns in a table generated by a CREATE TABLE AS statement
shall have a default value of NULL.

HLR H42622 
All columns in a table generated by a CREATE TABLE AS statement
shall have a NULL conflict resolution behavior of NONE.

HLR H42625 
All columns in a table generated by a CREATE TABLE AS statement
shall have an affinity of NONE.

HLR H42628 
All columns in a table generated by a CREATE TABLE AS statement
shall have a default collating sequence of BINARY.

HLR H42700 
The SQLite parser shall accept DROP TABLE statements
that conform to the following syntax.
<blockquote><pre>
cmd ::= DROP TABLE ifexists fullname.
ifexists ::= .
ifexists ::= IF EXISTS.
</pre></blockquote>

HLR H42710 
The preparation of a DROP TABLE statement shall fail with an
error if the statement lacks an IF EXISTS clause and the
<i>fullname</i> does not reference a existing table.

HLR H42713 
The evaluation of a DROP TABLE statement shall be a silent no-op
if the the statement has an IF EXISTS clause and the
<i>fullname</i> does not reference a existing table.

HLR H42716 
The successful evaluation of a DROP TABLE statement shall cause
the table identified by <i>fullname</i> to be removed from its
database and discarded.

HLR H42719 
The successful evaluation of a DROP TABLE statement shall cause
all indices attached to the table identified by <i>fullname</i>
to be removed from their database and discarded.

HLR H42721 
The successful evaluation of a DROP TABLE statement shall cause
all triggers attached to the table identified by <i>fullname</i>
to be removed from their database and discarded.

HLR H42724 
The preparation of a DROP TABLE statement shall fail with an
error if <i>fullname</i> is a system table.

HLR H42800 
The SQLite parser shall accept CREATE INDEX statements that
conform to the following syntax:
<blockquote><pre>
cmd ::= CREATE unique INDEX ifnotexists fullname ON tablename LP indexlist RP.
tablename ::= name.
indexlist ::= indexlist COMMA columnname collate sortorder.
indexlist ::= columnname collate sortorder.
columnname ::= name.
collate ::= .
collate ::= COLLATE identifier.
sortorder ::= .
sortorder ::= ASC.
sortorder ::= DESC.
</pre></blockquote>

HLR H42803 
The target database of a CREATE INDEX statement shall be the
<i>databasename</i> specified in the <i>fullname</i> term of the
statement if the <i>databasename</i> exists.

HLR H42806 
If the <i>fullname</i> term of a CREATE INDEX statement does not
specify a <i>databasename</i> and the <i>tablename</i> references a table
that is in the "temp" database, then the target database for the statement
shall be "temp".

HLR H42809 
If the <i>fullname</i> term of a CREATE INDEX statement does not
specify a <i>databasename</i> and the <i>tablename</i> references a table
that is not in the "temp" database, then the target database for the
statement shall be "main".

HLR H42812 
The preparation of a CREATE INDEX statement shall fail with an error if the
<i>databasename</i> of the <i>fullname</i> exists and references a database
that is not attached to the same [database connection].

HLR H42815 
The preparation of a CREATE INDEX statement shall fail with an error if the
<i>tablename</i> does not reference an ordinary table in the
database of the statement.

HLR H42818 
A successful evaluation of a CREATE INDEX statement shall create a
new index called <i>objectname</i>
in the database of the statement and attached to the
table identified by <i>tablename</i> in that same database.

HLR H42821 
An index generated by a CREATE INDEX statement that omits the
UNIQUE keyword shall have a conflict resolution behavior
of NONE.

HLR H42824 
An index generated by a CREATE INDEX statement that includes the
UNIQUE keyword shall have a conflict resolution behavior
of ABORT.

HLR H42830 
The preparation of a CREATE INDEX statement shall fail with an error if any
<i>columnname</i> value within the <i>indexlist</i> is not the
name of one of the columns of the <i>tablename</i> table.

HLR H42833 
The collating sequence for each column of an index shall be the
collating sequence specified in the <i>indexlist</i>.

HLR H42836 
If an index column does not specify a collating sequence then
the collating sequence shall be
the default collating sequence of the corresponding table column.

HLR H42839 
The sort order for an index column shall be descending if and only
if the DESC keyword is used in the <i>indexlist</i> entry for that
term.

HLR H42842 
The preparation of a CREATE INDEX statement shall fail with an error
if the <i>tablename</i> refers to a system table.

HLR H42900 
The SQLite parser shall accept DROP INDEX statements
that conform to the following syntax:
<blockquote><pre>
cmd ::= DROP INDEX ifexists fullname.
</pre></blockquote>

HLR H42910 
The preparation of a DROP INDEX statement shall fail with an
error if the statement lacks an IF EXISTS clause and the
<i>fullname</i> does not reference a existing index.

HLR H42913 
The evaluation of a DROP INDEX statement shall be a silent no-op
if the the statement has an IF EXISTS clause and the
<i>fullname</i> does not reference a existing index.

HLR H42916 
The successful evaluation of a DROP INDEX statement shall cause
the index identified by <i>fullname</i> to be removed from its
database and discarded.

HLR H43100 
The SQLite parser shall accept CREATE VIEW statements
that conform to the following syntax:
<blockquote><pre>
cmd ::= CREATE temp VIEW ifnotexists fullname AS select.
</pre></blockquote>

HLR H43113 
When the TEMP keyword appears in a CREATE VIEW statement and the
<i>databasename</i> exists and is something other than "temp", then
the preparation of the CREATE VIEW statement shall fail with an error.

HLR H43116 
When the TEMP keyword appears in a CREATE VIEW statement the behavior
shall be as if the <i>databasename</i> where "temp".

HLR H43119 
The successful evaluation of a CREATE VIEW statement shall cause
a new view whose name is given by the <i>objectname</i> and is located
in the schema of the database whose name is given by the
<i>databasename</i>.

HLR H43122 
If a CREATE VIEW statement specifies no <i>databasename</i> and omits
the TEMP keyword then the behavior shall be as if a <i>databasename</i>
of "main" where used.

HLR H43125 
The preparation of a CREATE VIEW statement shall fail with an
error if the IF NOT EXISTS clause is omitted and the <i>objectname</i>
is the same as the name of a table or view
in the same database.

HLR H43128 
The evaluation of a CREATE VIEW statement shall be a silent no-op if the
IF NOT EXISTS clause is present and the <i>objectname</i>
is the same as the name of a table or view
in the same database.

HLR H43131 
The preparation of a CREATE VIEW statement shall fail with an error if the
the <i>objectname</i> is the same as the name of an index
in any database attached to the same [database connection].

HLR H43200 
The SQLite parser shall accept DROP VIEW statements
that conform to the following syntax:
<blockquote><pre>
cmd ::= DROP VIEW ifexists fullname.
</pre></blockquote>

HLR H43204 
The preparation of a DROP VIEW statement shall fail with an
error if the statement lacks an IF EXISTS clause and the
<i>fullname</i> does not reference a existing view.

HLR H43207 
The evaluation of a DROP VIEW statement shall be a silent no-op
if the the statement has an IF EXISTS clause and the
<i>fullname</i> does not reference a existing view.

HLR H43211 
The successful evaluation of a DROP VIEW statement shall cause
the view identified by <i>fullname</i> to be removed from its
database and discarded.

HLR H43214 
The successful evaluation of a DROP VIEW statement shall cause
all triggers attached to the view identified by <i>fullname</i>
to be removed from their database and discarded.

HLR H43234 
The preparation of a CREATE VIEW statement shall fail with an error if the
the <i>databasename</i> references a database that is not
attached to the same [database connection].

HLR H43237 
The view generated by a CREATE VIEW statement shall have the
same number of columns as the result set of the SELECT.

HLR H43241 
The names of the columns in a view generated by a CREATE VIEW
statement shall have base names which are the names of the columns
in the result set of the SELECT statement

HLR H43244 
Each column name in a table generated by a CREATE VIEW
statement shall have an arbitrary suffix appended to its basename
if and only if such a suffix is necessary to make the name
distinct from all preceding column names in the view.

HLR H43300 
The SQLite parser shall accept CREATE TRIGGER statements
that conform to the following syntax:
<blockquote><pre>
cmd ::= CREATE temp TRIGGER ifnotexists fullname trigger trigger_body.
trigger ::= trigger_time trigger_event foreach_clause when_clause.
trigger_body ::= BEGIN trigger_cmd_list END.
trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI.
trigger_cmd_list ::= trigger_cmd_list.
trigger_cmd ::= DELETE FROM tablename where.
trigger_cmd ::= update_cmd tablename SET setlist where.
trigger_cmd ::= insert_cmd INTO tablename columnlist_opt VALUES LP exprlist RP.
trigger_cmd ::= insert_cmd INTO tablename columnlist_opt select.
trigger_cmd ::= select.
trigger_event ::= DELETE ON trigger_target.
trigger_event ::= INSERT ON trigger_target.
trigger_event ::= UPDATE OF columnlist ON trigger_target.
trigger_event ::= UPDATE ON trigger_target.
trigger_target ::= fullname.
trigger_time ::= AFTER.
trigger_time ::= BEFORE.
trigger_time ::= INSTEAD OF.
trigger_time ::=.
foreach_clause ::= FOR EACH ROW.
foreach_clause ::=.
when_clause ::= WHEN expr.
when_clause ::=.
</pre></blockquote>

HLR H43303 
When the TEMP keyword appears in a CREATE TRIGGER statement and the
<i>databasename</i> of the <i>fullname</i> exists
then the preparation of the statement
shall fail with an error.

HLR H43306 
When the TEMP keyword appears in a CREATE TRIGGER statement
the target database of the trigger shall be "temp".

HLR H43309 
When the TEMP keyword is omitted in a CREATE TRIGGER statement and the
<i>databasename</i> of the <i>fullname</i> is
omitted then the target database of the trigger shall be "main".

HLR H43312 
When the <i>databasename</i> of <i>fullname</i> in a CREATE TRIGGER
statement exists, then the target database shall be the database
named by <i>databasename</i>.

HLR H43315 
If a CREATE TRIGGER does not specify a <i>trigger_time</i> then
the <i>trigger_time</i> shall be BEFORE.

HLR H43318 
The preparation of a CREATE TRIGGER statement shall fail with an error
the <i>trigger_time</i> is INSTEAD OF and <i>trigger_target</i> is not
the name of view in the target database.

HLR H43321 
The preparation of a CREATE TRIGGER statement shall fail with an error
the <i>trigger_time</i> is not INSTEAD OF and <i>trigger_target</i> is not
the name of an ordinary table in the target database.

HLR H43324 
The preparation of a CREATE TRIGGER statement shall fail with an error
if the <i>trigger_target</i> is a system table.

HLR H43500 
The SQLite parser shall accept DROP TRIGGER statements
that conform to the following syntax:
<blockquote><pre>
cmd ::= DROP TRIGGER ifexists fullname.
</pre></blockquote>

HLR H43504 
The preparation of a DROP TRIGGER statement shall fail with an
error if the statement lacks an IF EXISTS clause and the
<i>fullname</i> does not reference a existing trigger.

HLR H43507 
The evaluation of a DROP TRIGGER statement shall be a silent no-op
if the the statement has an IF EXISTS clause and the
<i>fullname</i> does not reference a existing trigger.

HLR H43511 
The successful evaluation of a DROP TRIGGER statement shall cause
the trigger identified by <i>fullname</i> to be removed from its
database and discarded.

HLR H43514 
The successful evaluation of a DROP TRIGGER statement shall cause
all triggers attached to the trigger identified by <i>fullname</i>
to be removed from their database and discarded.

HLR H43600 
The SQLite parser shall accept CREATE VIRTUAL TABLE statements
that conform to the following syntax.
<blockquote><pre>
cmd ::= CREATE VIRTUAL TABLE fullname USING name vtab_arg_list.
vtab_arg_list ::= .
vtab_arg_list ::= LP vtab_arg_token RP.
vtab_arg_token ::= ANY.
vtab_arg_token ::= LP anylist RP.
anylist ::= .
anylist ::= anylist ANY.
</pre></blockquote>

HLR H43700 
The SQLite parser shall accept ALTER TABLE RENAME statements
that conform to the following syntax:
<blockquote><pre>
cmd ::= ALTER TABLE fullname RENAME TO name.
</pre></blockquote>

HLR H43750 
The SQLite parser shall accept ALTER TABLE ADD COLUMN statements
that conform to the following syntax:
<blockquote><pre>
cmd ::= ALTER TABLE fullname ADD column_keyword column.
column_keyword ::= .
column_keyword ::= COLUMNKW.
</pre></blockquote>

HLR H43810 
The SQLite parser shall accept INSERT statements that
conform to the following syntax:
<blockquote><pre>
cmd ::= insert_cmd INTO fullname columnlist_opt insert_content.
insert_cmd ::= INSERT.
insert_cmd ::= REPLACE.
insert_cmd ::= INSERT OR REPLACE.
insert_cmd ::= INSERT OR IGNORE.
insert_cmd ::= INSERT OR ABORT.
insert_cmd ::= INSERT OR FAIL.
insert_cmd ::= INSERT OR ROLLBACK.
columnlist_opt ::= .
columnlist_opt ::= LP columnlist RP.
columnlist ::= columnname.
columnlist ::= columnlist COMMA columnname.
</pre></blockquote>

HLR H43813 
The preparation of an INSERT statement shall fail with an error
if the <i>instcolist</i> contains a reference to a column which
is not a column in the table identified by <i>fullname</i> and is
not one of the special column named "ROWID", "OID", or "_ROWID_".

HLR H43816 
The preparation of an INSERT statement shall fail with an error
if <i>fullname</i> does not identify either a view with an
INSTEAD OF INSERT trigger or a table.

HLR H43819 
The preparation of an INSERT statement shall fail with an error
if the <i>objectname</i> of the <i>fullname</i> is "sqlite_master"
or "sqlite_temp_master" and the database connection is not in
writeable schema mode.

HLR H43821 
When the form of an INSERT statement is simply "INSERT" then the
default null- and uniqueness-conflict resolution algorithms shall
be used.

HLR H43824 
When the form of an INSERT statement is simply "REPLACE" then the
null- and uniqueness-conflict resolution algorithms shall all
change to REPLACE.

HLR H43827 
When the form of an INSERT statement is "INSERT OR <i>algorithm</i>"
then the null- and uniqueness-conflict resolution algorithms shall all
change to <i>algorithm</i>.

HLR H43831 
Name resolution in the <i>insert_content</i> term of an INSERT statement
shall be carried out using a name context
with an empty result set and a source set holding
single source element that is the <i>fullname</i> table.

HLR H43840 
The SQLite parser shall accept INSERT VALUE statements that
conform to the following syntax:
<blockquote><pre>
insert_content ::= VALUES LP exprlist RP.
</pre></blockquote>

HLR H43843 
The preparation of an INSERT VALUE statement shall fail with an
error if the <i>columnlist</i> element exists and the number of
entries in the <i>instcollist</i> is different
from the number of entries in the <i>exprlist</i>.

HLR H43846 
The preparation of an INSERT VALUE statement shall fail with an
error if the <i>columnlist</i> element does not exists and the number of
entries in the <i>exprlist</i> is different
from the number of columns in the table or view identified by
<i>fullname</i>.

HLR H43890 
The SQLite parser shall accept INSERT DEFAULT statements that
conform to the following syntax:
<blockquote><pre>
insert_contents ::= DEFAULT VALUES.
</pre></blockquote>

HLR H43900 
The SQLite parser shall accept DELETE statements that
conform to the following syntax:
<blockquote><pre>
cmd ::= DELETE FROM fullname where.
where ::= .
where ::= WHERE expr.
</pre></blockquote>

HLR H43904 
The preparation of a DELETE statement shall fail with an error if
the <i>fullname</i> element does not identify a view with an
INSTEAD OF DELETE trigger or a table.

HLR H43907 
The preparation of a DELETE statement shall fail with an error if
the <i>objectname</i> of the <i>fullname</i> element is "sqlite_master"
or "sqlite_temp_master" and the database connection is not in
writeable_schema mode.

HLR H43911 
Name resolution in the <i>where</i> term of a DELETE statement
shall be carried out using a name context
with an empty result set and a source set holding
single source element that is the <i>fullname</i> table.

HLR H44100 
The SQLite parser shall accept UPDATE statements that
conform to the following syntax:
<blockquote><pre>
cmd ::= update_cmd fullname SET setlist where.
update_cmd ::= UPDATE.
update_cmd ::= UPDATE OR IGNORE.
update_cmd ::= UPDATE OR REPLACE.
update_cmd ::= UPDATE OR ABORT.
update_cmd ::= UPDATE OR FAIL.
update_cmd ::= UPDATE OR ROLLBACK.
setlist ::= setting.
setlist ::= setlist COMMA setting.
setting ::= columnname EQ expr.
</pre></blockquote>

HLR H44113 
The preparation of an UPDATE statement shall fail with an error
if any <i>columnname</i>
is not a column in the table identified by <i>fullname</i> and is
not one of the special columns named "ROWID", "OID", or "_ROWID_".

HLR H44116 
The preparation of an UPDATE statement shall fail with an error
if <i>fullname</i> does not identify either a view with an
INSTEAD OF UPDATE trigger that covers all <i>columnname</i>s or a table.

HLR H44119 
The preparation of an UPDATE statement shall fail with an error
if the <i>objectname</i> of the <i>fullname</i> is "sqlite_master"
or "sqlite_temp_master" and the database connection is not in
writeable schema mode.

HLR H44121 
When the form of an UPDATE statement is simply "UPDATE" then the
default null- and uniqueness-conflict resolution algorithms shall
be used.

HLR H44127 
When the form of an UPDATE statement is "UPDATE OR <i>algorithm</i>"
then the null- and uniqueness-conflict resolution algorithms shall all
change to <i>algorithm</i>.

HLR H44131 
Name resolution in the <i>where</i> term of a DELETE statement
shall be carried out using a name context
with an empty result set and a source set holding
single source element that is the <i>fullname</i> table.

HLR H44200 
The SQLite parser shall accept VACUUM statements that
conform to the following syntax:
<blockquote><pre>
cmd ::= VACUUM.
cmd ::= VACUUM name.
</pre></blockquote>

HLR H44300 
The SQLite parser shall accept ANALYZE statements
that conform to the following syntax:
<blockquote><pre>
cmd ::= ANALYZE.
cmd ::= ANALYZE fullname.
</pre></blockquote>

HLR H44303 
The preparation of an ANALYZE statement
shall fail with an error if
the <i>fullname</i> is included and does not evaluate to
either an individual table name or the name of a database.

HLR H44400 
The SQLite parser shall accept REINDEX statements
that conform to the following syntax:
<blockquote><pre>
cmd ::= REINDEX.
cmd ::= REINDEX fullname.
</pre></blockquote>

HLR H44403 
The preparation of an ANALYZE statement
shall fail with an error if
the <i>fullname</i> is included and does not evaluate to
either an individual table name or the name of a database
or the name of a collating sequence.

HLR H44500 
cmd ::= ATTACH database_kw expr AS expr.
database_kw ::= .
database_kw ::= DATABASE.

HLR H44503 
The <i>expr</i> terms of an ATTACH statement that are
identifiers shall be interpreted as string literals.

HLR H44506 
The preparation of an ATTACH statement shall fail with an error
if either <i>expr</i> is not a constant expression.

HLR H44509 
The preparation of an ATTACH statement shall fail with an error
if the second <i>expr</i> evaluates to the name of a database
that is already attached to the database connection.

HLR H44600 
The SQLite parser shall accept DETACH statements
that conform to the following syntax:
<blockquote><pre>
cmd ::= DETACH database_kw expr.
</pre></blockquote>

HLR H44603 
The <i>expr</i> term of an DETACH statement that is an
identifier shall be interpreted as string literals.

HLR H44606 
The preparation of an DETACH statement shall fail with an error
if the <i>expr</i> is not a constant expression.

HLR H44609 
The preparation of an DETACH statement shall fail with an error
if the <i>expr</i> does not evaluate to the
name of an attached database other than "temp" or "main".

HLR H44700 
The SQLite parser shall accept the EXPLAIN keyword as a prefix
to other valid SQL statements, as shown by the following syntax:
<blockquote><pre>
sql_statement ::= EXPLAIN cmd SEMI.
</pre></blockquote>

HLR H44800 
The SQLite parser shall accept EXPLAIN QUERY PLAY as a prefix
to other valid SQL statements, as shown by the following syntax:
<blockquote><pre>
sql_statement ::= EXPLAIN QUERY PLAN cmd SEMI.
</pre></blockquote>

HLR H45000 
The SQLite parser shall accept SELECT statements that
conform to the following syntax:
<blockquote><pre>
cmd ::= select.
select ::= query.
select ::= select UNION query.
select ::= select UNION ALL query.
select ::= select EXCEPT query.
select ::= select INTERSECT query.
query ::= SELECT distinct resultset from where groupby having orderby limit.
distinct ::= .
distinct ::= DISTINCT.
groupby ::= .
groupby ::= GROUP BY exprlist.
having ::= .
having ::= HAVING expr.
orderby ::= .
orderby ::= ORDER BY exprlist.
limit ::=.
limit ::= LIMIT expr.
limit ::= LIMIT expr COMMA expr.
limit ::= LIMIT expr OFFSET expr.
resultset ::= result.
resultset ::= resultset COMMA result.
result ::= STAR.
result ::= tablename DOT STAR.
result ::= expr as.
from ::= .
from ::= FROM sourceset.
sourceset ::= source.
sourceset ::= sourceset joinop source.
source ::= fullname as on using.
source ::= LP select RP as on using.
as ::= .
as ::= AS name.
as ::= identifier.
on ::= .
on ::= ON expr.
using ::= .
using ::= USING LP columnlist RP.
joinop ::= COMMA.
joinop ::= JOIN.
joinop ::= JOIN_KW JOIN.
joinop ::= JOIN_KW JOIN_KW JOIN.
joinop ::= JOIN_KW JOIN_KW JOIN_KW JOIN.
</pre></blockquote>

HLR H45003 
The preparation of a statement containing a <i>select</i>
shall fail with an error if the <i>select</i> contains
two terms of the same compound query having a different number of columns
in their result sets.

HLR H45006 
The preparation of a statement containing a <i>select</i>
shall fail with an error if the <i>select</i> contains a compound query that
has an ORDER BY, GROUP BY, HAVING, or LIMIT clause on any term of than
the right-most.

HLR H45009 
The preparation of a statement containing a <i>select</i>
shall fail with an error if the <i>select</i> contains a compound query with
an ORDER BY or GROUP BY clause with a term that is not either
a token-by-token duplicate of the result columns of one of the
compound query terms, or the "AS" name of one of the compound
query terms, or a compile-time integer between 1 and N where N is
the number of columns in each compound query term.

HLR H45012 
The preparation of a statement containing a <i>select</i>
shall fail with an error if the <i>select</i> contains a join with two
or more of the following properties:
<ol>
<li> The NATURAL keyword in the <i>joinop</i> </li>
<li> An ON clause </li>
<li> A USING clause</li>
</ol>

HLR H45015 
The preparation of a statement containing a <i>select</i>
shall fail with an error if the <i>select</i> contains a <i>joinop</i>
that uses the keywords RIGHT or FULL.

HLR H45018 
The preparation of a statement containing a <i>select</i>
shall fail with an error if the <i>select</i> contains a <i>joinop</i>
that uses either of the keywords OUTER or LEFT
together with either INNER or CROSS.

HLR H45021 
The preparation of a statement containing a <i>select</i>
shall fail with an error if the <i>select</i> contains a <i>using</i>
that names columns that are not found in both the table to the
immediate right of the join and in the result set of all tables
to the left of the join.

HLR H45024 
The preparation of a statement containing a <i>select</i>
shall fail with an error if the <i>fullname</i> of a <i>source</i>
does not refer to an existing table or view.

HLR H45027 
The preparation of a statement containing a <i>limit</i>
shall fail with an error if any <i>expr</i> within the <i>limit</i>
does not evaluate to a compile-time integer.

HLR H45103 
Name resolution of a top-level SELECT statement shall use an
empty name context.

HLR H45106 
Name context of a <i>query</i> term shall be
constructed by adding a new inner name context layer
to the name context of the construct containing the <i>query</i>
term.

HLR H45109 
Name resolution of the <i>resultset</i> of a <i>query</i> shall
use the name context of the <i>query</i> with an empty result
set and the source set
configured to the <i>from</i> clause of the query.

HLR H45112 
Name resolution of all child terms of a <i>query</i> other than
<i>resultset</i> child shall use the name context of the <i>query</i>
with the result set configured to be the <i>resultset</i> clause of the
<i>query</i> and with the source set configured to be the
<i>from</i> clause of the query.

HLR H46000 
The SQLite parser shall accept PRAGMA statements
that conform to the following syntax:
<blockquote><pre>
cmd ::= PRAGMA fullname EQ DELETE.
cmd ::= PRAGMA fullname EQ ON.
cmd ::= PRAGMA fullname EQ name.
cmd ::= PRAGMA fullname EQ expr.
cmd ::= PRAGMA fullname LP name RP.
cmd ::= PRAGMA fullname LP expr RP.
cmd ::= PRAGMA fullname.
</pre></blockquote>

HLR H46003 
The evaluation of a PRAGMA statement with an unknown verb shall
be a silent no-op.

HLR H47000 
The SQLite parser shall accept expressions that
conform to the following syntax:
<blockquote><pre>
expr ::= BITNOT expr.
expr ::= CASE case_operand case_exprlist case_else END.
expr ::= CAST LP expr AS typetoken RP.
expr ::= EXISTS LP select RP.
expr ::= function_name LP STAR RP.
expr ::= function_name LP distinct exprlist RP.
expr ::= LP expr RP.
expr ::= LP select RP.
expr ::= MINUS expr.
expr ::= NOT expr.
expr ::= PLUS expr.
expr ::= RAISE LP IGNORE RP.
expr ::= RAISE LP ABORT COMMA name RP.
expr ::= RAISE LP FAIL COMMA name RP.
expr ::= RAISE LP ROLLBACK COMMA name RP.
expr ::= VARIABLE.
expr ::= expr AND expr.
expr ::= expr BITAND expr.
expr ::= expr BITOR expr.
expr ::= expr LSHIFT expr.
expr ::= expr RSHIFT expr.
expr ::= expr COLLATE ids.
expr ::= expr CONCAT expr.
expr ::= expr EQ expr.
expr ::= expr NE expr.
expr ::= expr IS NOT NULL.
expr ::= expr IS NULL.
expr ::= expr ISNULL
expr ::= expr NOTNULL.
expr ::= expr LT expr.
expr ::= expr GT expr.
expr ::= expr GE expr.
expr ::= expr LE expr.
expr ::= expr NOT NULL.
expr ::= expr OR expr.
expr ::= expr PLUS expr.
expr ::= expr MINUS expr.
expr ::= expr STAR expr.
expr ::= expr SLASH expr.
expr ::= expr REM expr.
expr ::= expr BETWEEN expr AND expr.
expr ::= expr NOT BETWEEN expr AND expr.
expr ::= expr IN LP exprlist RP.
expr ::= expr IN LP select RP.
expr ::= expr IN fullname.
expr ::= expr NOT IN LP exprlist RP.
expr ::= expr NOT IN LP select RP.
expr ::= expr NOT IN fullname.
expr ::= expr LIKE_KW expr escape.
expr ::= expr MATCH expr escape.
expr ::= expr NOT LIKE_KW expr escape.
expr ::= expr NOT MATCH expr escape.
expr ::= rtvalue.
expr ::= term.
term ::= CTIME_KW.
term ::= INTEGER.
term ::= FLOAT
term ::= BLOB.
term ::= NULL.
term ::= STRING.
exprlist ::= expr.
exprlist ::= exprlist COMMA expr.
case_else ::= ELSE expr.
case_else ::= .
case_exprlist ::= WHEN expr THEN expr.
case_exprlist ::= case_exprlist WHEN expr THEN expr.
case_operand ::= expr.
case_operand ::= .
function_name ::= ID.
escape ::= .
escape ::= ESCAPE expr.
</pre></blockquote>

HLR H47003 
The unary PLUS, unary MINUS, and BITNOT operators shall have
precedence over the COLLATE operator.

HLR H47006 
The COLLATE operator shall have precedence over the CONCAT
operator.

HLR H47009 
The CONCAT operator shall have precedence over the STAR, SLASH,
and REM operators.

HLR H47012 
The STAR, SLASH, and REM operator shall have equal precedence.

HLR H47015 
The STAR, SLASH, and REM operators shall have precedence over the
binary PLUS and binary MINUS operators.

HLR H47018 
The binary PLUS and binary MINUS operators shall have equal precedence.

HLR H47021 
The binary PLUS and binary MINUS operators shall have precedence
over the BITAND, BITOR, LSHIFT, and RSHIFT operators.

HLR H47024 
The BITAND, BITOR, LSHIFT, and RSHIFT operators shall have equal
precendence.

HLR H47027 
The BITAND, BITOR, LSHIFT, and RSHIFT operators shall have precedence
over the ESCAPE operator.

HLR H47029 
The ESCAPE operator shall have precedence over
the GT, LE, LT, and GE operators.

HLR H47033 
The GT, LE, LT, and GE operators shall have equal precedence.

HLR H47036 
The GT, LE, LT, and GE operators shall have precedence over
the IS, MATCH, LIKE_KW, BETWEEN, IN, ISNULL, NOTNULL, NE, and EQ
operators shall have equal precedence.

HLR H47039 
The IS, MATCH, LIKE_KW, BETWEEN, IN, ISNULL, NOTNULL, NE, and EQ
operators shall have equal precedence.

HLR H47042 
The IS, MATCH, LIKE_KW, BETWEEN, IN, ISNULL, NOTNULL, NE, and EQ
operators shall have precedence over the unary NOT operator.

HLR H47045 
The unary NOT operator shall have precedence over the AND operator.

HLR H47048 
The AND operator shall have precedence over the OR operator.

HLR H47051 
Operators of equal precedence shall group from right to left.

HLR H49100 
The SQLite parser shall accept names, fullnames, and identifiers
that conform to the following syntax:
<blockquote><pre>
name ::= ID.
name ::= JOIN_KW.
name ::= STRING.
fullname ::= objectname.
fullname ::= databasename DOT objectname.
objectname ::= name.
databasename ::= name.
columnname ::= name.
identifier ::= ID.
identifier ::= STRING.
</pre></blockquote>

HLR H49103 
The SQLite parser shall accept <i>rtvalue</i> elements of an
<i>expr</i> that conform to the following syntax:
<blockquote><pre>
rtvalue ::= databasename DOT tablename DOT columnname.
rtvalue ::= tablename DOT columnname.
rtvalue ::= ID.
rtvalue ::= JOIN_KW.
</pre></blockquote>
Changes to wrap.tcl.
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
    set gurl {}
    if {$hd(fragment)!=""} {
      set lurl $hd(fn-main)#$hd(fragment)
    }
  }
  foreach a $args {
    if {[info exists glink($a)]} {
      puts stderr "WARNING: duplicate keyword \"$a\""
    }
    if {$gurl==""} {
      set glink($a) $lurl
    } else {
      set glink($a) $gurl
      set llink($fn:$a) $lurl
    }







|







142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
    set gurl {}
    if {$hd(fragment)!=""} {
      set lurl $hd(fn-main)#$hd(fragment)
    }
  }
  foreach a $args {
    if {[info exists glink($a)]} {
      puts stderr "WARNING: duplicate keyword \"$a\" - $glink($a) and $lurl"
    }
    if {$gurl==""} {
      set glink($a) $lurl
    } else {
      set glink($a) $gurl
      set llink($fn:$a) $lurl
    }
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
# be valid HTML with all hyperlinks already resolved.  If the "verbatim"
# argument is false (the default) then the requirement text is rendered
# using hd_render which will find an expand hyperlinks within the text.
#
# The "comment" argument is non-binding commentary and explanation that
# accompanies the requirement.
#
proc hd_requirement {id text {verbatim 0} {comment {}}} {
  global ALLREQ ALLREQ_VERBATIM ALLREQ_DERIVEDFROM ALLREQ_COM
  if {[info exists ALLREQ($id)]} {
    puts stderr "duplicate requirement label: $id"
  }
  set ALLREQ_DERIVEDFROM($id) {}
  while {[regexp {<([AHLS]\d\d\d\d\d)>} $text all df]} {
    regsub {<[AHLS]\d\d\d\d\d> *} $text {} text
    lappend ALLREQ_DERIVEDFROM($id) $df
  }
  set ALLREQ($id) $text


























  set ALLREQ_VERBATIM($id) $verbatim




  set ALLREQ_COM($id) $comment


}
















# First pass.  Process all files.  But do not render hyperlinks.
# Merely collect keyword information so that hyperlinks can be
# correctly rendered on the second pass.
#
foreach infile [lrange $argv 3 end] {
  cd $HOMEDIR







|
|



|
<
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
|
>
>

>
>
>
>
>
>
>
|
>
>
>
>
>
>
>







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
# be valid HTML with all hyperlinks already resolved.  If the "verbatim"
# argument is false (the default) then the requirement text is rendered
# using hd_render which will find an expand hyperlinks within the text.
#
# The "comment" argument is non-binding commentary and explanation that
# accompanies the requirement.
#
proc hd_requirement {id text derivedfrom comment} {
  global ALLREQ ALLREQ_DERIVEDFROM ALLREQ_COM
  if {[info exists ALLREQ($id)]} {
    puts stderr "duplicate requirement label: $id"
  }
  set ALLREQ_DERIVEDFROM($id) $derivedfrom

  set ALLREQ($id) $text
  set ALLREQ_COM($id) $comment
}

# Read a block of requirements from an ASCII text file.  Store the
# information obtained in a global variable named by the second parameter.
#
proc hd_read_requirement_file {filename varname} {
  global hd_req_rdr
  hd_reset_requirement_reader
  set in [open $filename]
  while {![eof $in]} {
    set line [gets $in]
    if {[regexp {^(HLR|UNDEF|SYSREQ) +([HSU]\d+) *(.*)} $line all type rn df]} {
      hd_add_one_requirement $varname
      set hd_req_rdr(rn) $rn
      set hd_req_rdr(derived) $df
    } elseif {[string trim $line]==""} {
      if {$hd_req_rdr(body)==""} {
        set hd_req_rdr(body) $hd_req_rdr(comment)
        set hd_req_rdr(comment) {}
      } else {
        append hd_req_rdr(comment) \n
      }
    } else {
      append hd_req_rdr(comment) $line\n
    }
  }
  hd_add_one_requirement $varname
  close $in
  
}
proc hd_reset_requirement_reader {} {
  global hd_req_rdr
  set hd_req_rdr(rn) {}
  set hd_req_rdr(comment) {}
  set hd_req_rdr(body) {}
  set hd_req_rdr(derived) {}
}
proc hd_add_one_requirement {varname} {
  global hd_req_rdr
  set rn $hd_req_rdr(rn)
  if {$rn!=""} {
    if {$hd_req_rdr(body)==""} {
      set hd_req_rdr(body) $hd_req_rdr(comment)
      set hd_req_rdr(comment) {}
    }
    set b [string trim $hd_req_rdr(body)]
    set c [string trim $hd_req_rdr(comment)]
    set ::${varname}($rn) [list $hd_req_rdr(derived) $b $c]
    lappend ::${varname}(*) $rn
  }
  hd_reset_requirement_reader
}

# First pass.  Process all files.  But do not render hyperlinks.
# Merely collect keyword information so that hyperlinks can be
# correctly rendered on the second pass.
#
foreach infile [lrange $argv 3 end] {
  cd $HOMEDIR
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
}
hd_puts "</ul><hr><ul>"
foreach y [lsort [array names revglink]] {
  hd_puts "<li><a href=\"$y\">$y</a> - [lsort $revglink($y)]</li>"
}
hd_puts "</ul>"
hd_close_main

# Record requirements information for possible use by non-public
# documentation builders.
#
set out [open $HOMEDIR/reqdata.txt w]
foreach var {ALLREQ ALLREQ_VERBATIM ALLREQ_DERIVEDFROM ALLREQ_COM} {
  foreach f [array names $var] {
    puts $out "set ${var}($f) [list [set ${var}($f)]]"
  }
}







<
<
<
<
<
<
<
<
<
<
541
542
543
544
545
546
547










}
hd_puts "</ul><hr><ul>"
foreach y [lsort [array names revglink]] {
  hd_puts "<li><a href=\"$y\">$y</a> - [lsort $revglink($y)]</li>"
}
hd_puts "</ul>"
hd_close_main