Documentation Source Text

Check-in [4e973ec4bf]
Login

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

Overview
Comment:Add documentation for 8+3 filenames.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4e973ec4bf4891500af424c4e2e6149fa4c590ff
User & Date: drh 2011-05-18 13:14:50.410
Context
2011-05-18
13:31
Refinements to the 8+3 filename documentation. (check-in: 4e0a472c30 user: drh tags: trunk)
13:14
Add documentation for 8+3 filenames. (check-in: 4e973ec4bf user: drh tags: trunk)
2011-05-13
16:47
Add a requirement that CHECK constraints cannot contain subqueries. (check-in: 1f3d321253 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to misc/althttpd.c.
1064
1065
1066
1067
1068
1069
1070

1071
1072
1073
1074
1075
1076
1077
1078
  ** case, and convert all "." to "_".  Then try to find a directory
  ** with that name and the extension .website.  If not found, look
  ** for "default.website".
  */
  if( zScript[0]!='/' ) NotFound(__LINE__);
  if( strlen(zRoot)+40 >= sizeof(zLine) ) NotFound(__LINE__);
  if( zHttpHost==0 ){

    sprintf(zLine, "%s/default.website", zRoot);
  }else if( strlen(zHttpHost)+strlen(zRoot)+10 >= sizeof(zLine) ){
    NotFound(__LINE__);
  }else{
    sprintf(zLine, "%s/%s", zRoot, zHttpHost);
    for(i=strlen(zRoot)+1; zLine[i] && zLine[i]!=':'; i++){
      int c = zLine[i];
      if( !isalnum(c) ){







>
|







1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
  ** case, and convert all "." to "_".  Then try to find a directory
  ** with that name and the extension .website.  If not found, look
  ** for "default.website".
  */
  if( zScript[0]!='/' ) NotFound(__LINE__);
  if( strlen(zRoot)+40 >= sizeof(zLine) ) NotFound(__LINE__);
  if( zHttpHost==0 ){
    NotFound(__LINE__);
    /* sprintf(zLine, "%s/default.website", zRoot); */
  }else if( strlen(zHttpHost)+strlen(zRoot)+10 >= sizeof(zLine) ){
    NotFound(__LINE__);
  }else{
    sprintf(zLine, "%s/%s", zRoot, zHttpHost);
    for(i=strlen(zRoot)+1; zLine[i] && zLine[i]!=':'; i++){
      int c = zLine[i];
      if( !isalnum(c) ){
Changes to pages/changes.in.
44
45
46
47
48
49
50



51
52
53
54
55
56
57

chng {2011 June 28 (3.7.7)} {
<li> Add support for [URI filenames]
<li> Add support for [ON CONFLICT] clauses with [virtual tables].
<li> Avoid unnecessary reparsing of the database schema.
<li> Allow [WAL | WAL-mode] databases to be opened read-only as long as
     there is an existing read/write connection.



}

chng {2011 April 17 (3.7.6.2)} {
<li> Fix the function prototype for the open(2) system call to agree with
     POSIX.  Without this fix, pthreads does not work correctly on NetBSD.
<li> SQLITE_SOURCE_ID:
     "2011-04-17 17:25:17 154ddbc17120be2915eb03edc52af1225eb7cb5e"







>
>
>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

chng {2011 June 28 (3.7.7)} {
<li> Add support for [URI filenames]
<li> Add support for [ON CONFLICT] clauses with [virtual tables].
<li> Avoid unnecessary reparsing of the database schema.
<li> Allow [WAL | WAL-mode] databases to be opened read-only as long as
     there is an existing read/write connection.
<li> Added [SQLITE_ENABLE_8_3_NAMES] compile-time option
     and the 8_3_names parameter which together allow SQLite to work
     on filesystems that support only 8+3 filenames.
}

chng {2011 April 17 (3.7.6.2)} {
<li> Fix the function prototype for the open(2) system call to agree with
     POSIX.  Without this fix, pthreads does not work correctly on NetBSD.
<li> SQLITE_SOURCE_ID:
     "2011-04-17 17:25:17 154ddbc17120be2915eb03edc52af1225eb7cb5e"
Changes to pages/compile.in.
272
273
274
275
276
277
278











279
280
281
282
283
284
285

</tcl>

<a name="enablefeatures"></a>
<h2>1.4 Options To Enable Features Normally Turned Off</h2>

<tcl>











COMPILE_OPTION {SQLITE_ENABLE_ATOMIC_WRITE} {
  If this C-preprocessor macro is defined and if the
  xDeviceCharacteristics method of [sqlite3_io_methods] object for
  a database file reports (via one of the [SQLITE_IOCAP_ATOMIC] bits)
  that the filesystem supports atomic writes and if a transaction
  involves a change to only a single page of the database file,
  then the transaction commits with just a single write request of







>
>
>
>
>
>
>
>
>
>
>







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

</tcl>

<a name="enablefeatures"></a>
<h2>1.4 Options To Enable Features Normally Turned Off</h2>

<tcl>
COMPILE_OPTION {SQLITE_ENABLE_8_3_NAMES} {
  If this C-preprocessor macro is defined, then extra code is
  included that allows SQLite to function on a filesystem that
  only support 8+3 filenames.  The default behavior is to continue
  to use long filenames.  Even with this compile-time option, 
  database connections must be opened using [URI filenames] with
  the "<tt>8_3_names=1</tt>" query parameter in order for 8+3
  filenames to be used.  See the [short filenames] documentation for
  details.
}

COMPILE_OPTION {SQLITE_ENABLE_ATOMIC_WRITE} {
  If this C-preprocessor macro is defined and if the
  xDeviceCharacteristics method of [sqlite3_io_methods] object for
  a database file reports (via one of the [SQLITE_IOCAP_ATOMIC] bits)
  that the filesystem supports atomic writes and if a transaction
  involves a change to only a single page of the database file,
  then the transaction commits with just a single write request of
Added pages/shortnames.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
<title>8+3 Filenames</title>
<tcl>hd_keywords {short filenames}</tcl>

<h1 align="center">SQLite And 8+3 Filenames</h1>

<p>
The default configuration of SQLite assumes the underlying filesystem
supports long filenames.
</p>

<p>
SQLite does not impose any naming requirements on database files.
SQLite will happily work with a database file that has any filename extension
or with no extension at all.
When auxiliary files are needed for a [rollback journal] or
a [write-ahead log] or for one of the other kinds of
[temporary disk files], then the name for the auxiliary file is normally
constructed by appending a suffix onto the end of the database file name.
For example, if the original database is call "<tt>app.db</tt>" then
the [rollback journal] will be called "<tt>app.db-journal</tt>"
and the [write-ahead log] will be called "<tt>app.db-wal</tt>".
This approach to auxiliary file naming works great on systems that
support long filenames.  But on systems that impose 8+3 filename
constraints, the auxiliary files do not fit the 8+3 format even though
the original database file does.
</p>


<h2>Changing Filesystems</h2>

<p>
The recommended fix for this problem is to select a different
filesystem.  These days, there is a huge selection of high-performance, 
reliable, patent-free filesystems that support long filenames.  
Where possible, it is recommended that embedded devices use one
of these modern filesystems.
</p>

<h2>Adjusting SQLite To Use 8+3 Filenames</h2>

<p>
Some systems are compelled to use an older filesystem with 8+3
filename restructions in order to be compatible with legacy, or due
to other non-technical factors.  In such situations, SQLite can be
coerced into using auxiliary files that fit the 8+3 pattern as follows:
</p>

<ol>
<li><p>Compile the SQLite library with the [SQLITE_ENABLE_8_3_NAMES]
       compile-time option.
       Support for 8+3 filenames is not included in SQLite by default
       because it does introduce some overhead.  The overhead is tiny,
       but even so, we do not want to burden the billions of SQLite
       applications that do not need 8+3 filename support.</p>

<li><p>Use [URI filenames] when [sqlite3_open | opening] or
       [ATTACH | ATTACH-ing] database files and include the
       "<tt>8_3_names=1</tt>" query parameter in the URI.</p>

<li><p>Make sure that database filenames follow the 8+3 filename
       format and that they do not have an empty name or extension.
       In other words, the database filename must not contain between
       1 and 8 characters in the base name and between 1 and 3 characters
       in the extension.  Blank extensions are not allows.</p>
</ol>

<p>
When the steps above are used, SQLite will shorten filename extensions
by only using the last 3 characters of
the extension.  Thus, for example, a file that would normally be called
"<tt>app.db-journal</tt>" is shortened to just "<tt>app.nal</tt>".
Similarly, "<tt>app.db-wal</tt>" will become "<tt>app.wal</tt>" and
"<tt>app.db-shm</tt>" becomes "<tt>app.shm</tt>".
</p>

<p>
Note that it is very important that the database filename have some kind
of extension.  If there is no extension, then SQLite creates auxiliary
filenames by appending to the base name of the file.  Thus, a database
named "<tt>db01</tt>" would have a [rollback journal] file named
"<tt>db01-journal</tt>".  And as this filename has no extension to shorten
to 3 characters, it will be used as-is, and will violate 8+3 naming rules.
</p>

<h2>Database Corruption Warning</h2>

<p>
If a database file is accessed using 8+3 naming rather than the default
long filename, then it must be consistently accessed 
using 8+3 naming by every database
connection every time it is opened, or else there is a risk of database
corruption.
The auxiliary [rollback journal] and [write-ahead log] files are essential
to SQLite for being about to recover from a crash.  If an application is
using 8+3 names and crashes, then the information needed to safely recover
from the crash is stored in files with the "<tt>.nal</tt>" or
"<tt>.wal</tt>" extension.  If the next application to open the database
does not specify the "<tt>8_3_names=1</tt>" URI parameter, then SQLite
will use the long filenames to try to locate the rollback journal or
write-ahead log files.  It will not find them, since they were saved using
8+3 names by the application that crashed, and hence the database will not
be properly recovered and will likely go corrupt.
</p>
Changes to pages/tempfiles.in.
1

2
3
4
5
6
7
8
<title>Temporary Files Used By SQLite</title>


<h1 align="center">SQLite's Use Of Temporary Disk Files</h1>

<h2>1.0 Introduction</h2>

<p>
On of the <a href="different.html">distinctive features</a> of

>







1
2
3
4
5
6
7
8
9
<title>Temporary Files Used By SQLite</title>
<tcl>hd_keywords {temporary disk files}</tcl>

<h1 align="center">SQLite's Use Of Temporary Disk Files</h1>

<h2>1.0 Introduction</h2>

<p>
On of the <a href="different.html">distinctive features</a> of