Documentation Source Text

Changes On Branch branch-3.26
Login

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

Changes In Branch branch-3.26 Excluding Merge-Ins

This is equivalent to a diff from 4ffbc3f635 to 0866c95aaf

2019-02-07
13:47
Merge changes from the 3.26.0 release branch. (check-in: 9d6e96fd8f user: drh tags: trunk)
2019-01-29
18:59
Fix a typo in the date-time function documentation. (Leaf check-in: 0866c95aaf user: drh tags: branch-3.26)
2019-01-28
12:16
Fix typo on the "PRAGMA database_list" documentation. (check-in: 70943cf0c8 user: drh tags: branch-3.26)
2018-12-09
22:31
Omit the sponsor links from the homepage. (check-in: 551ce8e2ad user: drh tags: branch-3.26)
22:23
Preliminary documentation for VACUUM INTO (check-in: 130193a5b9 user: drh tags: trunk)
2018-12-06
15:20
Enhanced ALTER TABLE documentation, and in particular show the dangers of not following the generalized 12-step ALTER TABLE procedure precisely. (check-in: 4ffbc3f635 user: drh tags: trunk)
2018-12-01
20:55
Adjust the date for 3.26.0 in the speed and size chart. (check-in: 41f2b76661 user: drh tags: trunk)

Changes to art/syntax/bubble-generator-data.tcl.

276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
            }
     }
     {line {optx {optx NOT} EXISTS} ( select-stmt )}
     {line CASE {optx expr} {loop {line WHEN expr THEN expr} {}}
           {optx ELSE expr} END}
     {line raise-function}
     {line /window-func ( {or {line {toploop expr ,}} {} *} ) 
           {opt filter} OVER {or {line ( window-defn )} /window-name}}
  }
  raise-function {
     line RAISE ( 
           {or IGNORE
               {line {or ROLLBACK ABORT FAIL} , /error-message }
           } )
  }







|







276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
            }
     }
     {line {optx {optx NOT} EXISTS} ( select-stmt )}
     {line CASE {optx expr} {loop {line WHEN expr THEN expr} {}}
           {optx ELSE expr} END}
     {line raise-function}
     {line /window-func ( {or {line {toploop expr ,}} {} *} ) 
           {opt filter} OVER {or window-defn /window-name}}
  }
  raise-function {
     line RAISE ( 
           {or IGNORE
               {line {or ROLLBACK ABORT FAIL} , /error-message }
           } )
  }
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
      {line /* {loop nil /anything-except-*/}
           {or */ /end-of-input}}
  }
  filter {
    line FILTER ( WHERE expr )
  }
  window-defn {
    line {opt PARTITION BY {loop expr ,}}
         {opt ORDER BY {loop ordering-term ,}}
         {opt frame-spec}
  }
  frame-spec {
    line {or RANGE ROWS} {or
       {line BETWEEN {or {line UNBOUNDED PRECEDING}
                         {line expr PRECEDING}
                         {line CURRENT ROW}
                         {line expr FOLLOWING}







|
|
|







521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
      {line /* {loop nil /anything-except-*/}
           {or */ /end-of-input}}
  }
  filter {
    line FILTER ( WHERE expr )
  }
  window-defn {
    stack {line ( {opt PARTITION BY {loop expr ,}}}
          {opt ORDER BY {loop ordering-term ,}}
          {line {optx frame-spec} )}
  }
  frame-spec {
    line {or RANGE ROWS} {or
       {line BETWEEN {or {line UNBOUNDED PRECEDING}
                         {line expr PRECEDING}
                         {line CURRENT ROW}
                         {line expr FOLLOWING}
550
551
552
553
554
555
556
557
558
559
    }
  }
  function-invocation {
     line /function-name ( {or {line {optx DISTINCT} {toploop expr ,}} {} *} )
  }
  window-function-invocation {
    line /window-func ( {or {line {toploop expr ,}} {} *} ) 
         {opt filter} OVER {or {line ( window-defn )} /window-name}
  }
}







|


550
551
552
553
554
555
556
557
558
559
    }
  }
  function-invocation {
     line /function-name ( {or {line {optx DISTINCT} {toploop expr ,}} {} *} )
  }
  window-function-invocation {
    line /window-func ( {or {line {toploop expr ,}} {} *} ) 
         {opt filter} OVER {or window-defn /window-name}
  }
}

Changes to art/syntax/expr.gif.

cannot compute difference between binary files

Changes to art/syntax/frame-spec.gif.

cannot compute difference between binary files

Changes to art/syntax/select-core.gif.

cannot compute difference between binary files

Changes to art/syntax/select-stmt.gif.

cannot compute difference between binary files

Changes to art/syntax/window-defn.gif.

cannot compute difference between binary files

Changes to art/syntax/window-function-invocation.gif.

cannot compute difference between binary files

Changes to pages/assert.in.

199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
running off the end of the linked list in case there is an error in some
other part of the code that has corrupted the linked list.

<p>
An ALWAYS(X) or NEVER(X) sometimes verifies pre-conditions that are
subject to change if other parts of the code are modified in
subtle ways.  At [https://sqlite.org/src/artifact/18a53540aa3?ln=5512-5516]
we have a case test for two pre-conditions that are true only because
of the limited scope of use of the sqlite3BtreeRowCountEst() function.
Future enhancements to SQLite might use sqlite3BtreeRowCountEst() in
new ways where those preconditions no longer hold, and the NEVER()
macros will quickly alert the developers to that fact when the
situation arises.  But if, for some reason, the pre-conditions are
not satisfied in a release build, the program will still behave sanely
and will not do an undefined memory access.







|







199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
running off the end of the linked list in case there is an error in some
other part of the code that has corrupted the linked list.

<p>
An ALWAYS(X) or NEVER(X) sometimes verifies pre-conditions that are
subject to change if other parts of the code are modified in
subtle ways.  At [https://sqlite.org/src/artifact/18a53540aa3?ln=5512-5516]
we have a test for two pre-conditions that are true only because
of the limited scope of use of the sqlite3BtreeRowCountEst() function.
Future enhancements to SQLite might use sqlite3BtreeRowCountEst() in
new ways where those preconditions no longer hold, and the NEVER()
macros will quickly alert the developers to that fact when the
situation arises.  But if, for some reason, the pre-conditions are
not satisfied in a release build, the program will still behave sanely
and will not do an undefined memory access.

Changes to pages/codeofethics.in.

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
specific technical requirements was inserted in the place of
the old name.

<p>
This document is still sometimes used as a "Code of Conduct" on supplier
registration forms.  But it is not a Code of Conduct in the same sense
that many communities mean a Code of Conduct.  Rather,
this document describes the ethical principals upon
which SQLite is based.  Another way to look at this document is
as a succinct description of the SQLite Founder's idea of what it
means to be "virtuous".

<p>
Readers can also interpret this document as a primer on the
world-view of the SQLite Founder, to help them better understand







|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
specific technical requirements was inserted in the place of
the old name.

<p>
This document is still sometimes used as a "Code of Conduct" on supplier
registration forms.  But it is not a Code of Conduct in the same sense
that many communities mean a Code of Conduct.  Rather,
this document describes the ethical principles upon
which SQLite is based.  Another way to look at this document is
as a succinct description of the SQLite Founder's idea of what it
means to be "virtuous".

<p>
Readers can also interpret this document as a primer on the
world-view of the SQLite Founder, to help them better understand

Changes to pages/fullsql.in.

25
26
27
28
29
30
31

32
33
34
35

36
37
38
39
40
41
42
<li>[Subqueries], including [correlated subqueries]
<li>Up to 64-way joins
<li>LEFT JOIN
<li>DISTINCT, ORDER BY, GROUP BY, HAVING, LIMIT, and OFFSET
<li>UNION, UNION ALL, INTERSECT, and EXCEPT
<li>A rich library of [Core Functions|standard SQL functions]
<li>[Aggregate Functions|Aggregate functions] including DISTINCT aggregates

<li>[UPDATE], [DELETE], and [INSERT] (of course)
<li>[WITH|Common table expressions] including
    [recursive common table expressions]
<li>[row value|Row values]

<li>An advanced [query planner]
<li>[FTS5|Full-text search]
<li>[R-Trees|R-tree indexes]
<li>[json1|JSON support]
<li>The [IS operator]
<li>[table-valued function|Table-valued functions]
<li>[REPLACE|REPLACE INTO]







>




>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<li>[Subqueries], including [correlated subqueries]
<li>Up to 64-way joins
<li>LEFT JOIN
<li>DISTINCT, ORDER BY, GROUP BY, HAVING, LIMIT, and OFFSET
<li>UNION, UNION ALL, INTERSECT, and EXCEPT
<li>A rich library of [Core Functions|standard SQL functions]
<li>[Aggregate Functions|Aggregate functions] including DISTINCT aggregates
<li>[window functions|Window functions]
<li>[UPDATE], [DELETE], and [INSERT] (of course)
<li>[WITH|Common table expressions] including
    [recursive common table expressions]
<li>[row value|Row values]
<li>[UPSERT]
<li>An advanced [query planner]
<li>[FTS5|Full-text search]
<li>[R-Trees|R-tree indexes]
<li>[json1|JSON support]
<li>The [IS operator]
<li>[table-valued function|Table-valued functions]
<li>[REPLACE|REPLACE INTO]

Changes to pages/index.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
<title>SQLite Home Page</title>

<div class="rightsidebar desktoponly border2px">
<h3 align="center">Common Links</h3>
<tcl>common_links</tcl>
</div>




<p>SQLite is a [self-contained], [high-reliability], 
[serverless|embedded],
[full-featured SQL|full-featured], [public-domain],
SQL database engine.
SQLite is the [most used] database engine in the world.



<a class="button" href="about.html">More Info</a></p>





<hr class="xhr">
<span class="hdrfont">Latest Release:&nbsp;&nbsp;</span>
<a href="releaselog/3_26_0.html">Version 3.26.0</a> ([dateof:3.26.0]).
<a class="button" href="download.html">Download</a>
<a class="button" href="chronology.html">Prior Releases</a>

<div class="mobileonly">
<hr class="xhr">
<h3>Common Links</h3>
<tcl>common_links</tcl>
</div>

<hr class="xhr">
<h3>Sponsors</h3>
<p>Ongoing development and support of SQLite is made possible in part
by <a href="consortium.html">SQLite Consortium</a> members, including:</p>
<a name="consortium_members"></a>
<style>
#sponsors {
  margin:auto;
  width:80%;
}
.onesponsor a img {
  width:200px;
  max-width:200px;
  padding:1ex;
}
</style>
<div id="sponsors"></div>
<script>
<tcl>
set sponsors {
  {name   Mozilla
   url    https://www.mozilla.com/
   image  mozilla.gif
   blurb  "Working to preserve choice and innovation on the internet."
  }
  {name   Bloomberg
   url    https://www.bloomberg.com/
   image  bloomberg.png
   blurb  "A world leader in financial-information technology."
  }
  {name   Bentley
   url    https://www.bentley.com/
   image  bentley.gif
   blurb  "Comprehensive software solutions for Sustaining Infrastructure."
  }
  {name   NDS
   url    http://www.nds-association.org/
   image  nds.png
   blurb  "The leading map standard for automotive infotainment and autonomous driving."
  }
  {name   Expensify
   url    https://www.expensify.com/
   image  expensify.png
   width  225
   height 32
   blurb  "We power the most exciting companies in the world using SQLite."
  }
}
set sep {  var sponsors = [}
set nspons 0
foreach spons $sponsors {
  hd_putsnl $sep\173
  set sep ","
  unset -nocomplain x
  array set x $spons
  hd_putsnl "    \"name\":\"$x(name)\","
  hd_putsnl "    \"href\":\"$x(url)\","
  hd_putsnl "    \"src\":\"$x(image)\","
  if {[info exists x(width)]} {
    hd_putsnl "    \"wx\":$x(width),"
    hd_putsnl "    \"hx\":$x(height)"
  } else {
    hd_putsnl "    \"wx\":0"
  }
  hd_puts "  \175"
  incr nspons
}
unset -nocomplain x
hd_putsnl "\];"
hd_puts {
  for(var i=0; i<sponsors.length; i++){sponsors[i].idx = Math.random();}
  sponsors.sort(function(a,b){return a.idx-b.idx});
  var h = "";
  for(var i=0; i<sponsors.length; i++){
    h += "<span class='onesponsor'><a href='";
    h += sponsors[i].href;
    h += "'><img src='images/foreignlogos/";
    h += sponsors[i].src;
    h += "'></a></span>\n";
  }
  document.getElementById("sponsors").innerHTML = h;
}
</tcl>
</script>
<br clear="both">
<hr class="xhr">


<
<
<
|

>
>
>
|
|
|


>
>
>
|

>
>
>
>
|
|




<
<


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
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
























































































<title>SQLite Home Page</title>




<h3>What Is SQLite?</h3>

<p>SQLite is a C-language library that implements a
[footprint|small],
[faster than the filesystem|fast],
[self-contained], 
[high-reliability],
[full-featured SQL|full-featured],
SQL database engine.
SQLite is the [most used] database engine in the world.
It is built into all mobile phones and most computers and
comes bundled inside countless other applications that people
use every day.
<a href="about.html">More Information...</a>

<p>
SQLite [https://sqlite.org/src|source code]
is in the [public-domain] and is free to 
everyone to use for any purpose.

<h3>Latest Release</h3>
<a href="releaselog/3_26_0.html">Version 3.26.0</a> ([dateof:3.26.0]).
<a class="button" href="download.html">Download</a>
<a class="button" href="chronology.html">Prior Releases</a>



<h3>Common Links</h3>
<tcl>common_links</tcl>
























































































Changes to pages/lang.in.

3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
localtime_r() C function normally only works for years
between 1970 and 2037. For dates outside this range, SQLite 
attempts to map the year into an equivalent year within 
this range, do the calculation, then map the year back.)^</p>


<p>^(These functions only work for dates between 0000-01-01 00:00:00
and 9999-12-31 23:59:59 (julidan day numbers 1721059.5 through 5373484.5).)^
For dates outside that range, the results of these
functions are undefined.</p>

<p>Non-Vista Windows platforms only support one set of DST rules. 
Vista only supports two. Therefore, on these platforms, 
historical DST calculations will be incorrect. 
For example, in the US, in 2007 the DST rules changed. 







|







3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
localtime_r() C function normally only works for years
between 1970 and 2037. For dates outside this range, SQLite 
attempts to map the year into an equivalent year within 
this range, do the calculation, then map the year back.)^</p>


<p>^(These functions only work for dates between 0000-01-01 00:00:00
and 9999-12-31 23:59:59 (julian day numbers 1721059.5 through 5373484.5).)^
For dates outside that range, the results of these
functions are undefined.</p>

<p>Non-Vista Windows platforms only support one set of DST rules. 
Vista only supports two. Therefore, on these platforms, 
historical DST calculations will be incorrect. 
For example, in the US, in 2007 the DST rules changed. 

Changes to pages/pragma.in.

1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
    database connection.</p>)^
}

Pragma database_list {
    <p>^(<b>PRAGMA database_list;</b></p>
    <p>This pragma works like a query to return one row for each database
    attached to the current database connection.)^
    ^(The second column is the "main" for the main database file, "temp"
    for the database file used to store TEMP objects, or the name of the
    ATTACHed database for other database files.)^
    ^(The third column is the name of the database file itself, or an empty
    string if the database is not associated with a file.)^</p>
}

Pragma foreign_key_list {







|







1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
    database connection.</p>)^
}

Pragma database_list {
    <p>^(<b>PRAGMA database_list;</b></p>
    <p>This pragma works like a query to return one row for each database
    attached to the current database connection.)^
    ^(The second column is "main" for the main database file, "temp"
    for the database file used to store TEMP objects, or the name of the
    ATTACHed database for other database files.)^
    ^(The third column is the name of the database file itself, or an empty
    string if the database is not associated with a file.)^</p>
}

Pragma foreign_key_list {

Changes to pages/security.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
<title>Resistance To Attack</title>
<tcl>hd_keywords security {attack resistance}</tcl>

<fancy_format>

<h1>SQLite Always Validates Its Inputs</h1>

<p>
SQLite should never crash, overflow a buffer, leak memory,
or exhibit any other harmful behavior, even with presented with
maliciously malformed SQL inputs or database files.  SQLite should
always detected erroneous inputs and raise an error, not crash or
corrupt memory.
Any malfunction caused by an SQL input or database file
is considered a serious bug and will be promptly addressed when
brought to the attention of the SQLite developers.  SQLite is
extensively fuzz-tested to help ensure that it is highly resistant
to these kinds of errors.

<p>
Nevertheless, bugs happen.
If you are writing an application that sends untrusted SQL inputs
or database files to SQLite, there are additional steps you can take

to help prevent zero-day exploits caused by undetected bugs:

<h2>Untrusted SQL Inputs</h2>
<p>
Applications that accept untrusted SQL inputs should take the following
precautions:

<ol>
<li><p>
Set the [SQLITE_DBCONFIG_DEFENSIVE] flag.
This prevents ordinary SQL statements from corrupted the database
file.

<li><p>
Consider using the [sqlite3_set_authorizer()] interface to limit
the scope of SQL that will be processed.
</ol>

<h2>Untrusted SQLite Database Files</h2>

<p>Applications that accept untrusted database files should do the following:

<ol>
<li value="3"><p>
Run [PRAGMA integrity_check] or [PRAGMA quick_check] on the database

first, prior to running any other SQLite, and reject the file if any
errors are detected.

<li><p>
Enable the [PRAGMA cell_size_check=ON] setting.




</ol>

<h1>Summary</h1>

<p>
The precautions above are not required in order to use SQLite safely
with potentially hostile inputs.
However, they do provide an extra layer of defense against zero-day
exploits and are encouraged for applications that pass data from
untrusted sources into SQLite.
|
|
>






|

|




|






>
|









|














>
|
|



>
>
>
>










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
<title>Defense Against Dark Arts</title>
<tcl>hd_keywords security {attack resistance} \
  {defense against dark arts}</tcl>
<fancy_format>

<h1>SQLite Always Validates Its Inputs</h1>

<p>
SQLite should never crash, overflow a buffer, leak memory,
or exhibit any other harmful behavior, even when presented with
maliciously malformed SQL inputs or database files.  SQLite should
always detect erroneous inputs and raise an error, not crash or
corrupt memory.
Any malfunction caused by an SQL input or database file
is considered a serious bug and will be promptly addressed when
brought to the attention of the SQLite developers.  SQLite is
extensively fuzz-tested to help ensure that it is resistant
to these kinds of errors.

<p>
Nevertheless, bugs happen.
If you are writing an application that sends untrusted SQL inputs
or database files to SQLite, there are additional steps you can take
to help reduce the attack surface and
prevent zero-day exploits caused by undetected bugs.

<h2>Untrusted SQL Inputs</h2>
<p>
Applications that accept untrusted SQL inputs should take the following
precautions:

<ol>
<li><p>
Set the [SQLITE_DBCONFIG_DEFENSIVE] flag.
This prevents ordinary SQL statements from corrupting the database
file.

<li><p>
Consider using the [sqlite3_set_authorizer()] interface to limit
the scope of SQL that will be processed.
</ol>

<h2>Untrusted SQLite Database Files</h2>

<p>Applications that accept untrusted database files should do the following:

<ol>
<li value="3"><p>
Run [PRAGMA integrity_check] or [PRAGMA quick_check] on the database
as the first SQL statement after opening the database files and
prior to running any other SQL statements.  Reject and refuse to
process any database file containing errors.

<li><p>
Enable the [PRAGMA cell_size_check=ON] setting.

<li><p>
Do not enable memory-mapped I/O.
In other words, make sure that [PRAGMA mmap_size=0].
</ol>

<h1>Summary</h1>

<p>
The precautions above are not required in order to use SQLite safely
with potentially hostile inputs.
However, they do provide an extra layer of defense against zero-day
exploits and are encouraged for applications that pass data from
untrusted sources into SQLite.