1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Add large file support to Windows. Change large file support for Unix so

that it compiles automatically - without requiring special options on the
compiler command line. (CVS 781)

FossilOrigin-Name: 2008b56fe11e49d52e28f47d14ccd70504e6c094
This commit is contained in:
drh
2002-11-06 14:08:11 +00:00
parent 20e9ab16d8
commit 829e802992
8 changed files with 59 additions and 46 deletions

View File

@@ -1,5 +1,5 @@
C Changes\sto\sinclude\sfiles\sso\sthat\sthe\s>2GB\sfile\spatch\swill\scompile\sunder\sBSD.\s(CVS\s780)
D 2002-11-06T00:59:45
C Add\slarge\sfile\ssupport\sto\sWindows.\s\sChange\slarge\sfile\ssupport\sfor\sUnix\sso\nthat\sit\scompiles\sautomatically\s-\swithout\srequiring\sspecial\soptions\son\sthe\ncompiler\scommand\sline.\s(CVS\s781)
D 2002-11-06T14:08:11
F Makefile.in d6c9a85c2a5e696843201d090dcf8bf2f8716f2a
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -30,9 +30,9 @@ F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
F src/insert.c 764300a0bd8074a2174946c0bf8a550bd833397a
F src/main.c b95d7eeec90f86d05b6a064d07db34b7279e06d4
F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
F src/os.c da4cd10aba649e0622b8e766a3e6717b25359703
F src/os.h c7038373d137b46da7a1da7f8f662b91fb6926dd
F src/pager.c baf50d8308c61d079086f532c70155cd22c6d07a
F src/os.c ebe65e9a1c88535e367aaaae25ef087c1486b08d
F src/os.h deac8efeac7767de931122c536ca253fdb70f2f8
F src/pager.c 7d581b201d7284fa9dafde92cd5b737e3733c984
F src/pager.h 6991c9c2dc5e4c7f2df4d4ba47d1c6458f763a32
F src/parse.y 469c9636ff713e63c00234662209f11668671ae9
F src/printf.c 5c50fc1da75c8f5bf432b1ad17d91d6653acd167
@@ -129,16 +129,16 @@ F www/arch.png 82ef36db1143828a7abc88b1e308a5f55d4336f4
F www/arch.tcl 679a0c48817f71bc91d5911ef386e5ef35d4f178
F www/audit.tcl 90e09d580f79c7efec0c7d6f447b7ec5c2dce5c0
F www/c_interface.tcl e76c9fd609326c34cd45cd040b508b0e21908800
F www/changes.tcl 9c47ef405cf8605b5ba3de4476b78d3f2420853c
F www/changes.tcl 85480df78c2b95afdbee92fdfc01dfda9918a818
F www/conflict.tcl 81dd21f9a679e60aae049e9dd8ab53d59570cda2
F www/crosscompile.tcl 3622ebbe518927a3854a12de51344673eb2dd060
F www/datatypes.tcl 0cb28565580554fa7e03e8fcb303e87ce57757ae
F www/download.tcl 0932d7f4f0e8b2adbbd22fac73132f86e43ab4a9
F www/dynload.tcl 02eb8273aa78cfa9070dd4501dca937fb22b466c
F www/faq.tcl 7692f91e0b3f7ee9bb4387bc5028cb389dcc6546
F www/faq.tcl 06276ff6c3e369374bb83034cc9d4a7d3a2a34a1
F www/fileformat.tcl a4b5c2c6e89b7d42d09f97fd4d7bbd39cbf24936
F www/formatchng.tcl b4449e065d2da38b6563bdf12cf46cfe1d4d765e
F www/index.tcl c93b864e3c7313bbe5f86eec571479d438307173
F www/index.tcl 7764032a802318a916ae747b047c9ad5149658a5
F www/lang.tcl 6be4254a751ab183ec974fe65375f50230c777f3
F www/mingw.tcl f1c7c0a7f53387dd9bb4f8c7e8571b7561510ebc
F www/nulls.tcl 29497dac2bc5b437aa7e2e94577dad4d8933ed26
@@ -149,7 +149,7 @@ F www/speed.tcl a20a792738475b68756ea7a19321600f23d1d803
F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
P 4caf624e9061fe7489a8e3c6892975036a2272d5
R 89790936c953bb945d21f542c92f53cc
P 81bb1aed5e9094a9655bd03614bb111d79896928
R 2170efe21354495bba0abb7d147e0a86
U drh
Z 58e955a4900c7a886f46bf868041833c
Z 7e2f109564ef517cfa10eb3df7a02ba0

View File

@@ -1 +1 @@
81bb1aed5e9094a9655bd03614bb111d79896928
2008b56fe11e49d52e28f47d14ccd70504e6c094

View File

@@ -14,8 +14,8 @@
** systems. The purpose of this file is to provide a uniform abstraction
** on which the rest of SQLite can operate.
*/
#include "os.h" /* Must be first to enable large file support */
#include "sqliteInt.h"
#include "os.h"
#if OS_UNIX
# include <time.h>
@@ -544,7 +544,10 @@ int sqliteOsSeek(OsFile *id, off_t offset){
return SQLITE_OK;
#endif
#if OS_WIN
SetFilePointer(id->h, offset, 0, FILE_BEGIN);
{
LONG upperBits = offset>>32;
SetFilePointer(id->h, offset, &upperBits, FILE_BEGIN);
}
return SQLITE_OK;
#endif
}
@@ -580,8 +583,11 @@ int sqliteOsTruncate(OsFile *id, off_t nByte){
return ftruncate(id->fd, nByte)==0 ? SQLITE_OK : SQLITE_IOERR;
#endif
#if OS_WIN
SetFilePointer(id->h, nByte, 0, FILE_BEGIN);
{
LONG upperBits = nByte>>32;
SetFilePointer(id->h, nByte, &upperBits, FILE_BEGIN);
SetEndOfFile(id->h);
}
return SQLITE_OK;
#endif
}
@@ -600,8 +606,10 @@ int sqliteOsFileSize(OsFile *id, off_t *pSize){
return SQLITE_OK;
#endif
#if OS_WIN
DWORD upperBits, lowerBits;
SimulateIOError(SQLITE_IOERR);
*pSize = GetFileSize(id->h, 0);
lowerBits = GetFileSize(id->h, &upperBits);
*pSize = (((off_t)upperBits)<<32) + lowerBits;
return SQLITE_OK;
#endif
}

View File

@@ -17,6 +17,18 @@
#ifndef _SQLITE_OS_H_
#define _SQLITE_OS_H_
/*
** These #defines should enable >2GB file support on Posix if the
** underlying operating system supports it. If the OS lacks
** large file support, or if the OS is windows, these should be no-ops.
*/
#define _LARGE_FILE 1
#define _FILE_OFFSET_BITS 64
#define _LARGEFILE_SOURCE 1
/*
** Figure out if we are dealing with Unix or Windows.
*/
#ifndef OS_UNIX
# ifndef OS_WIN
# if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)
@@ -64,7 +76,11 @@
HANDLE h; /* Handle for accessing the file */
int locked; /* 0: unlocked, <0: write lock, >0: read lock */
};
typedef int off_t;
# ifdef _MSC_VER
typedef __int64 off_t;
# else
typedef long long off_t;
# endif
# define SQLITE_TEMPNAME_SIZE (MAX_PATH+50)
# define SQLITE_MIN_SLEEP_MS 1
#endif

View File

@@ -18,11 +18,11 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.54 2002/11/05 23:03:03 drh Exp $
** @(#) $Id: pager.c,v 1.55 2002/11/06 14:08:11 drh Exp $
*/
#include "os.h" /* Must be first to enable large file support */
#include "sqliteInt.h"
#include "pager.h"
#include "os.h"
#include <assert.h>
#include <string.h>

View File

@@ -25,6 +25,11 @@ proc chng {date desc} {
puts "<DD><P><UL>$desc</UL></P></DD>"
}
chng {2002 Nov ?? (2.7.4)} {
<li>Database files can now grow to be up to 2^41 bytes. The old limit
was 2^31 bytes.</li>
}
chng {2002 Oct 30 (2.7.3)} {
<li>Various compiler compatibility fixes.</li>
<li>Fix a bug in the "expr IN ()" operator.</li>

View File

@@ -1,7 +1,7 @@
#
# Run this script to generated a faq.html output file
#
set rcsid {$Id: faq.tcl,v 1.20 2002/11/05 23:24:38 drh Exp $}
set rcsid {$Id: faq.tcl,v 1.21 2002/11/06 14:08:12 drh Exp $}
puts {<html>
<head>
@@ -311,21 +311,19 @@ ORDER BY name
faq {
Are there any known size limits to SQLite databases?
} {
<p>Internally, SQLite can handle databases up to 2^41 bytes (2 terabytes)
in size. But the backend interface to POSIX and Win32 limits files to
2^31 (2 gigabytes). (See the next question for instructions on how
to relax this limit under POSIX.)</p>
<p>As of version 2.7.4,
SQLite can handle databases up to 2^41 bytes (2 terabytes)
in size on both Windows and Unix. Older version of SQLite
were limited to databases of 2^31 bytes (2 gigabytes).</p>
<p>SQLite arbitrarily limits the amount of data in one row to 1 megabyte.
There is a single #define in the source code that can be changed to raise
this limit as high as 16 megabytes if desired.</p>
<p>There is a theoretical limit of about 2^32 (4 billion) rows
in a single table, but there
is no way to test this limit without exceeding the maximum file size, so
it is not really an issue. There is also a theoretical limit of about 2^32
tables and indices, but again it is not really possible to reach this
limit due to the file size constraint.</p>
in a single table, but this limit has never been tested.</p>
There is also a theoretical limit of about 2^32
tables and indices.</p>
<p>The name and "CREATE TABLE" statement for a table must fit entirely
within a 1-megabyte row of the SQLITE_MASTER table. Other than this,
@@ -338,21 +336,6 @@ faq {
may not exceed 255 characters in length.</p>
}
faq {
Are there any ways to increase the maximum database size limit above 2GB?
} {
<p>For POSIX systems that support large files, you can increase the maximum
database size of SQLite by adding the following two options to your
compiler command line:</p>
<blockquote><pre>
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
</pre></blockquote>
<p>The resulting library and "sqlite" executable should be able to work
with databases as large as 2^41 bytes (2 terabytes).</p>
}
faq {
What is the maximum size of a VARCHAR in SQLite?
} {

View File

@@ -1,7 +1,7 @@
#
# Run this TCL script to generate HTML for the index.html file.
#
set rcsid {$Id: index.tcl,v 1.69 2002/10/19 20:13:51 drh Exp $}
set rcsid {$Id: index.tcl,v 1.70 2002/11/06 14:08:12 drh Exp $}
puts {<html>
<head><title>SQLite: An Embeddable SQL Database Engine</title></head>
@@ -55,6 +55,7 @@ puts {<h2>Features</h2>
<li>Atomic commit and rollback protect data integrity.</li>
<li>Database files can be freely shared between machines with
different byte orders.</li>
<li>Supports databases up to 2 terabytes (2^41 bytes) in size.</li>
<li>Small memory footprint: less than 25K lines of C code.</li>
<li><a href="speed.html">Four times faster</a> than PostgreSQL.
Twice as fast as SQLite 1.0.</li>