Re: [sqlite] enum in SQLite

2006-01-05 Thread Derrell . Lipman
Michael Scharf <[EMAIL PROTECTED]> writes:

> Jim C. Nasby wrote:
>> On Thu, Jan 05, 2006 at 01:39:02PM -0600, Kurt Welgehausen wrote:
>>
>>> create trigger EnumTrg before insert on MainTbl for each row
>>> when (select count(*) from EnumVals where val = new.EnumCol) = 0 begin
>>>   select raise(rollback, 'foreign-key violation: MainTbl.EnumCol');
>>> end;
>> Wouldn't that be a lot more efficient with some kind of EXISTS test
>> rather than a count(*)?
>
> No. Because the count is at most 1 and therefore its cheaper than as exists,
> because no additional nested query is needed.
>
> However if the count(*) would be big EXISTS or LIMIT would make sense:
>   select count(*) where EXISTS (select * from TABLE where ...)
> or
>   select count(*) from (select * from TABLE where ... LIMIT 1)
>
> Michael

If you have many enum values, for slightly better efficiency (since all rows
need not be scanned), you should be able to do something like this:

 CREATE TRIGGER EnumTrg 
   BEFORE INSERT ON MainTbl
   FOR EACH ROW
 WHEN (SELECT 1
 FROM EnumVals
 WHERE val = new.EnumCol
 LIMIT 1) IS NULL
   BEGIN
 SELECT raise(rollback, 'forign-key violation: MainTbl.EnumCol');
   END;

Derrell


[sqlite] sqlite 2.8, HP-UX, Linux NFS server

2006-01-05 Thread b s
Hi,
I am trying the following program and it fails with 'database is locked'. I
have set the 'insecure_locks' option in /etc/exports of the NFS server (RH 7.3,
2.4.18-3 kernel).
It only fails for HP-UX clients (11iv1 aka 11.11).
Anybody has success with this combo?

thanks
bal

#include 
#include 

char *schema = "create table foo (bar varchar(20));";
int main()
{
sqlite *db;
char *errmsg=NULL;
char *dbname = "testdb";
if (NULL == (db = sqlite_open(dbname, 0, ))) {
fprintf(stderr, "Error opening %s err: %s\n", dbname, errmsg);
return 1;
}

if (SQLITE_OK != sqlite_exec(db, schema, NULL, NULL, )) {
fprintf(stderr, "Error creating %s err: %s\n", dbname, errmsg);
sqlite_close(db);
//unlink(dbname);
return 1;
}

sqlite_close(db);
return 0;
}




__ 
Yahoo! DSL – Something to write home about. 
Just $16.99/mo. or less. 
dsl.yahoo.com 



Re: [sqlite] [PATCH] WinCE compilation

2006-01-05 Thread Steve Lhomme

Ah, thanks for the tip. I'll have a look.

Steve

Simon Posnjak wrote:

Hi,

I do not now if you found it but there is another port of sqlite to
WinCE. You can find it at http://sqlite-wince.sourceforge.net/. 


Would it be possible if your port and the sf port could be merged
together in main line src tree?

Regards Simon

On sre, 2006-01-04 at 10:13 -1000, Steve Lhomme wrote:


Hi everyone,

I'm a happy user of SQlite for a project I just started to make a 
multimedia database (a bit like the DB in iTunes). The idea is to make 
it as cross-platform as possible and free.


I tried to make it work under Windows CE but run into a few problems 
when compiling with Embedded Visual C++ 4. Although WinCE has a very 
similar API to Windows, it lacks some of the features.


- only the unicode API is present, so I disabled all the xxxA() API calls

- localtime() is defined but doesn't exist, so I coded one with the 
existing API


- LockFile(Ex) and UnlockFile(Ex) are not supported, only the Ex API is 
available on WinCE 5 but I need bigger support so I just made the code 
blank on WinCE. Is there any drawback to that ?


- FILE_ATTRIBUTE_TEMPORARY and FILE_FLAG_DELETE_ON_CLOSE are not 
supported for CreateFile. So I removed the flags for WinCE. But that 
means I have to delete the auto-deleting files on close. I modified the 
API to do that when calling sqlite3OsClose(). I realise changing the API 
is not so good, so calling sqlite3OsDelete() where the close is called 
could be a better option.


All of the changes are included in the following patch.

Steve

priloga plain text document (WinCE.patch)
Index: os.h
===
--- os.h(revision 1)
+++ os.h(working copy)
@@ -182,7 +182,7 @@
int sqlite3OsSyncDirectory(const char*);
int sqlite3OsTempFileName(char*);
int sqlite3OsIsDirWritable(char*);
-int sqlite3OsClose(OsFile*);
+int sqlite3OsClose(OsFile*, const char*);
int sqlite3OsRead(OsFile*, void*, int amt);
int sqlite3OsWrite(OsFile*, const void*, int amt);
int sqlite3OsSeek(OsFile*, i64 offset);
Index: os_unix.c
===
--- os_unix.c   (revision 1)
+++ os_unix.c   (working copy)
@@ -1278,7 +1278,7 @@
/*
** Close a file.
*/
-int sqlite3OsClose(OsFile *id){
+int sqlite3OsClose(OsFile *id, const char*){
  if( !id->isOpen ) return SQLITE_OK;
  if( CHECK_THREADID(id) ) return SQLITE_MISUSE;
  sqlite3OsUnlock(id, NO_LOCK);
Index: os_win.c
===
--- os_win.c(revision 1)
+++ os_win.c(working copy)
@@ -33,6 +33,64 @@
** Include code that is common to all os_*.c files
*/
#include "os_common.h"
+
+#if defined(_WIN32_WCE)
+#include 
+struct tm * __cdecl localtime(const time_t *t)
+{
+  static struct tm y;
+  FILETIME uTm, lTm;
+  SYSTEMTIME pTm;
+  uTm.dwLowDateTime = *t & 0x;
+  uTm.dwHighDateTime= *t >> 32;
+  FileTimeToLocalFileTime(,);
+  FileTimeToSystemTime(,);
+  y.tm_year = pTm.wYear - 1900;
+  y.tm_mon = pTm.wMonth - 1;
+  y.tm_wday = pTm.wDayOfWeek;
+  y.tm_mday = pTm.wDay;
+  y.tm_hour = pTm.wHour;
+  y.tm_min = pTm.wMinute;
+  y.tm_sec = pTm.wSecond;
+  return 
+}
+
+#ifndef LOCKFILE_EXCLUSIVE_LOCK
+#define LockFileEx(a,b,c,d,e,f) (1)
+#define UnlockFileEx(a,b,c,d,e) (1)
+#endif
+
+BOOL LockFile(
+  HANDLE hFile,
+  DWORD dwFileOffsetLow,
+  DWORD dwFileOffsetHigh,
+  DWORD nNumberOfBytesToLockLow,
+  DWORD nNumberOfBytesToLockHigh
+)
+{
+  OVERLAPPED ovlp;
+  ovlp.Offset = dwFileOffsetLow;
+  ovlp.OffsetHigh = dwFileOffsetHigh;
+  ovlp.hEvent = 0;
+  return LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK|LOCKFILE_FAIL_IMMEDIATELY, 0, 
nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, );
+}
+
+
+BOOL UnlockFile(
+  HANDLE hFile,
+  DWORD dwFileOffsetLow,
+  DWORD dwFileOffsetHigh,
+  DWORD nNumberOfBytesToUnlockLow,
+  DWORD nNumberOfBytesToUnlockHigh
+)
+{
+  OVERLAPPED ovlp;
+  ovlp.Offset = dwFileOffsetLow;
+  ovlp.OffsetHigh = dwFileOffsetHigh;
+  ovlp.hEvent = 0;
+  return UnlockFileEx(hFile, 0, nNumberOfBytesToUnlockLow, 
nNumberOfBytesToUnlockHigh, );
+}
+#endif

/*
** Do not include any of the File I/O interface procedures if the
@@ -66,14 +124,18 @@
** WinNT/2K/XP so that we will know whether or not we can safely call
** the LockFileEx() API.
*/
-static int isNT(void){
+static int isNT(void){
+#if !defined(_WIN32_WCE)
  if( sqlite3_os_type==0 ){
OSVERSIONINFO sInfo;
sInfo.dwOSVersionInfoSize = sizeof(sInfo);
GetVersionEx();
sqlite3_os_type = sInfo.dwPlatformId==VER_PLATFORM_WIN32_NT ? 2 : 1;
  }
-  return sqlite3_os_type==2;
+  return sqlite3_os_type==2;
+#else
+  return 1;
+#endif
}

/*
@@ -131,9 +193,11 @@
  if( zWide ){
DeleteFileW(zWide);
sqliteFree(zWide);
+#if !defined(_WIN32_WCE)
  }else{
DeleteFileA(zFilename);
-  }
+#endif
+  }
  TRACE2("DELETE \"%s\"\n", zFilename);
  return SQLITE_OK;
}
@@ -147,8 +211,10 @@
  if( zWide ){
exists = GetFileAttributesW(zWide) 

Re: [sqlite] enum in SQLite

2006-01-05 Thread Kurt Welgehausen
> ... you'll also need to write an update trigger ...

True, and you may want to protect EnumVals with triggers after
you populate it, or put EnumVals is a separate read-only
database and attach it. On the other hand, being able to change
the allowed values without changing the schema may be an
advantage.

Regards


Re: [sqlite] enum in SQLite

2006-01-05 Thread Jim C. Nasby
On Thu, Jan 05, 2006 at 01:39:02PM -0600, Kurt Welgehausen wrote:
>  create trigger EnumTrg before insert on MainTbl for each row
>  when (select count(*) from EnumVals where val = new.EnumCol) = 0 begin
>select raise(rollback, 'foreign-key violation: MainTbl.EnumCol');
>  end;

Wouldn't that be a lot more efficient with some kind of EXISTS test
rather than a count(*)?
-- 
Jim C. Nasby, Sr. Engineering Consultant  [EMAIL PROTECTED]
Pervasive Software  http://pervasive.comwork: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf   cell: 512-569-9461


Re: [sqlite] enum in SQLite

2006-01-05 Thread Clay Dowling

Kurt Welgehausen said:
>> SQLite doesn't support enums natively.  You could emulate it using
>> triggers, although it would be somewhat hidden and definitely a pain in
>> the tucus to use.
>
> It's not really so hard.
>
>  create table MainTbl (
>  ...
>  EnumCol SomeType references EnumVals,
>  ...);
>
>  create table EnumVals (val SomeType);
>
> Now you have to enforce the foreign key with a trigger.
>
>  create trigger EnumTrg before insert on MainTbl for each row
>  when (select count(*) from EnumVals where val = new.EnumCol) = 0 begin
>select raise(rollback, 'foreign-key violation: MainTbl.EnumCol');
>  end;

That's a lot more elegant than what I had envisioned, which was a static
list of values.  Don't forget though that you'll also need to write an
update trigger, since it's pretty easy to write "UPDATE MainTbl SET
EnumCol='bogus'"

Clay Dowling
-- 
Simple Content Management
http://www.ceamus.com



Re: [sqlite] enum in SQLite

2006-01-05 Thread Kurt Welgehausen
> SQLite doesn't support enums natively.  You could emulate it using
> triggers, although it would be somewhat hidden and definitely a pain in
> the tucus to use.

It's not really so hard.

 create table MainTbl (
 ...
 EnumCol SomeType references EnumVals,
 ...);

 create table EnumVals (val SomeType);

Now you have to enforce the foreign key with a trigger.

 create trigger EnumTrg before insert on MainTbl for each row
 when (select count(*) from EnumVals where val = new.EnumCol) = 0 begin
   select raise(rollback, 'foreign-key violation: MainTbl.EnumCol');
 end;


Regards


Re: [sqlite] Feature Request: Open from fd

2006-01-05 Thread Christian Smith
On Wed, 4 Jan 2006, Steve Lhomme wrote:

>[EMAIL PROTECTED] wrote:
>> Peter Bierman <[EMAIL PROTECTED]> wrote:
>>
>>>Related to a project I'm working on, it would be useful for me to be
>>>able to open a database file via passing an already open file
>>>descriptor to the sqlite open() call. sqlite3_openfd().
>>>
>>
>> That is not possible.  SQLite needs to know the name of
>> the file so that it can create an appropriate rollback
>> journal in order to do atomic commits.
>
>But it's totally possible to do that in memory too. I would just like to
>avoid using a RamDisk. As I will probably need that feature I might
>commit it and send a patch here.


Rollback in memory? If the machine crashes or loses power half way though,
you lose rollback information.

SQLite can already use a memory database, including ACID transactions. If
all you're after is transient database functionality, this is all you
need.

If you want a fast read-only database from a disk file, just use the disk
file and let the OS and SQLite cache keep things fast. You don't need a
rollback journal for read-only operations.

Suggestion:
Write a method on top of SQLite that, given 2 SQLite database handles,
will sync the two databases:

int sqlite3_syncdb( sqlite3 * from, sqlite * to );

The symantics would be to transfer the schema and data from the 'from'
database to the 'to' database. You could use the SQLite shell .dump
command as a template on how to generate the commands required for
syncing.

When starting your program, you sync from your disk database to your empty
memory database. When exiting your program, you sync from your memory
database to your disk database. You then have the quick memory and
ACID based transactions during the life of your program, at the cost of
slow startup and shutdown while the data is synced (and the potential for
lost data if the application dies for whatever reason without syncing
back.)

>
>Steve
>

Christian

-- 
/"\
\ /ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
 X   - AGAINST MS ATTACHMENTS
/ \


Re: [sqlite] enum in SQLite

2006-01-05 Thread Clay Dowling

Rajan, Vivek K said:
> I would like to know the following:
>
> *Does SQLite support enum like MySQL? If yes, how to use it
>
> *If not, is there another way to model enumeration in SQLite?
> And/or any plans going forward to support enums natively in SQLite?

SQLite doesn't support enums natively.  You could emulate it using
triggers, although it would be somewhat hidden and definitely a pain in
the tucus to use.

If your database is only going to be accessed by applications that you
control, it's really easy to emulate enumerations in your own code, by
restricting the possible values that can be used for a field in code.  In
the languages that I'm familiar with (C, C++, Delphi, PHP) this is best
accomplished by making a data access class for each table and putting the
logic in that class.  In fact my preference is to encode the value as a
language enum where that's possible (I'm not sure if PHP handles enums).

Clay Dowling
-- 
Simple Content Management
http://www.ceamus.com



[sqlite] enum in SQLite

2006-01-05 Thread Rajan, Vivek K
I would like to know the following:

*Does SQLite support enum like MySQL? If yes, how to use it

*If not, is there another way to model enumeration in SQLite?
And/or any plans going forward to support enums natively in SQLite? 

 

Rajan



Re: [sqlite] specifying field type, any benefit?

2006-01-05 Thread shamil_daghestani
If you have "dot zero(s)"  values (such as, 4.0) do not save them in an
INTEGER column because then they will lose their float characteristics.

insert into students values(John, 4.0)
select age from students where first_name = 'John'
4  <-- got converted to integer

Regards
/sd




  
  "Mark 
  
  Wyszomierski"To:   
sqlite-users@sqlite.org  
  <[EMAIL PROTECTED]cc: 
   
  >Subject:  [sqlite] specifying 
field type, any benefit? 

  
  01/04/2006 03:54  
  
  PM
  
  Please respond to 
  
  sqlite-users  
  

  

  




Hi all,

I switched to sqlite from mysql awhile ago, I maintained the field types
in my sqlite implementation such as:

create table students (first_name TEXT, age INTEGER);

I'm just wondering if there is any point to specifying the field type as if
I try adding a string type into the age field, it seems to be accepted ok:

insert into students values('hello');

Does sqlite have any problem regarding setting a field defined as INTEGER
from a text string (any limits etc?), are there any performance gains to be
had with specifying the field type?

Thanks,
Mark




The information transmitted is intended only for the person(s)or entity 
to which it is addressed and may contain confidential and/or legally 
privileged material. Delivery of this message to any person other than 
the intended recipient(s) is not intended in any way to waive privilege 
or confidentiality. Any review, retransmission, dissemination or other 
use of , or taking of any action in reliance upon, this information by 
entities other than the intended recipient is prohibited. If you 
receive this in error, please contact the sender and delete the 
material from any computer.

For Translation:

http://www.baxter.com/email_disclaimer



Re: [sqlite] Prevent the error message box from popping up?

2006-01-05 Thread Roberto
You will need to be clearer on what error message you are seeing.
AFAIK SQLite does not display any error messages, is this a feature of
your development environment?

On 02/01/06, Tsolakos Stavros <[EMAIL PROTECTED]> wrote:
> Hi all.
>
> I am new both to this list and sqlite. Great tool.
>
> I apologize if the question is a bit stupid, but I searched the whole
> site without being able to find answer.
>
> How can I prevent this message box from popping up under Windows? I
> would like sqlite3_exec fail silently and only report the error through
> its return value.
>
> Thanks,
> Stavros
>
> PS: WinXP, sqlite327, MSVC6SP6
>


Re: [sqlite] how can I import CSV file into SQLite quickly

2006-01-05 Thread ronggui wong
sorry ,maked an mistake.
actually,the data size is 805 vars, 118519 obs.

2006/1/5, ronggui wong <[EMAIL PROTECTED]>:
> Thanks to all give response to help.
> This is my solution using the luanguage I familiar.(http://www.r-project.org).
>
> I use the code to read a 11819x807 csv file and it takes 10 minus.I think is
> not too slow .(My PC:1.7G,512M RAM)
>
> #code begins
> rm(list=ls())
> f<-file("D:\\wvsevs_sb_v4.csv","r")#134M
> i <- 0
> done <- FALSE
> library(RSQLite)
> con<-dbConnect("SQLite","c:\\sqlite\\database.db3")
> tim1<-Sys.time()
>
> while(!done){
> i<-i+1
> tt<-readLines(f,2500)
> if (length(tt)<2500) done <- TRUE
> tt<-textConnection(tt)
> if (i==1) {
> assign("dat",read.table(tt,head=T,sep=",",quote=""));
>  # to make the variable names elegent
>  nam<-names(dat);
>  nam<-gsub("^X.","",nam);
>  nam<-tolower(gsub(".$","",nam))
> names(dat)<-nam
> #
> }
> else assign("dat",read.table(tt,head=F,sep=",",quote=""))
> close(tt)
> ifelse(dbExistsTable(con, "wvs"),dbWriteTable(con,"wvs",dat,append=T),
>  dbWriteTable(con,"wvs",dat) )
> }
> close(f)
> #cal the time require
> Sys.time()-tim1
>
> #code end.
>


Re: [sqlite] How to optimize select queries

2006-01-05 Thread Ritesh Kapoor
thnx
my queries are running in 1/3rd the time now!!

ritesh

On Mon, 2006-01-02 at 22:22, Dennis Cote wrote:
> Ritesh Kapoor wrote:
> 
> >Hi,
> >
> >I need to optimize/speed up my 'select' queries.  The query creates
> >about 3 to 6 left joins from 7 different tables depending on the
> >different conditions passed.  The problem is that this is taking a lot
> >of time.
> >
> >The table column's are of both varchar and integer types - on which
> >comparisions are done to collect the final data.  Could you advise me on
> >how to create indexes to speed up my queries.
> >
> >1. A little background on how indexes work - or a link containing info
> >on this.
> >
> >2. Do I need to create an index on each column for each table or create
> >an index for each table on all of its columns?
> >
> >3. Please note that the columns on which comparisions are done are of
> >varchar type also so do indexes work on them as well?
> >
> >4. Any other suggestions which the experienced folks would have come
> >across.
> >
> >Thanks and Regards,
> >Ritesh Kapoor
> >Atrenta Pvt. Ltd.
> >
> >
> >  
> >
> Check out these pages for information on optimizing SQLite queries.
> 
> http://www.sqlite.org/php2004/page-001.html
> http://www.sqlite.org/optoverview.html
> http://www.sqlite.org/cvstrac/wiki?p=PerformanceTuning
> http://www.sqlite.org/cvstrac/wiki?p=QueryPlans
> http://www.sqlite.org/lang_explain.html
> http://www.sqlite.org/lang_analyze.html
> http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html
> 
> There is also an undocumented EXPLAIN QUERY PLAN command that can help 
> when optimizing complex queries. It work like the EXPLAIN command, but 
> displays the order that tables are scanned, and which indexes are used.
> 
> HTH
> Dennis Cote



Re: [sqlite] [PATCH] WinCE compilation

2006-01-05 Thread Simon Posnjak
Hi,

I do not now if you found it but there is another port of sqlite to
WinCE. You can find it at http://sqlite-wince.sourceforge.net/. 

Would it be possible if your port and the sf port could be merged
together in main line src tree?

Regards Simon

On sre, 2006-01-04 at 10:13 -1000, Steve Lhomme wrote:
> Hi everyone,
> 
> I'm a happy user of SQlite for a project I just started to make a 
> multimedia database (a bit like the DB in iTunes). The idea is to make 
> it as cross-platform as possible and free.
> 
> I tried to make it work under Windows CE but run into a few problems 
> when compiling with Embedded Visual C++ 4. Although WinCE has a very 
> similar API to Windows, it lacks some of the features.
> 
> - only the unicode API is present, so I disabled all the xxxA() API calls
> 
> - localtime() is defined but doesn't exist, so I coded one with the 
> existing API
> 
> - LockFile(Ex) and UnlockFile(Ex) are not supported, only the Ex API is 
> available on WinCE 5 but I need bigger support so I just made the code 
> blank on WinCE. Is there any drawback to that ?
> 
> - FILE_ATTRIBUTE_TEMPORARY and FILE_FLAG_DELETE_ON_CLOSE are not 
> supported for CreateFile. So I removed the flags for WinCE. But that 
> means I have to delete the auto-deleting files on close. I modified the 
> API to do that when calling sqlite3OsClose(). I realise changing the API 
> is not so good, so calling sqlite3OsDelete() where the close is called 
> could be a better option.
> 
> All of the changes are included in the following patch.
> 
> Steve
> 
> priloga plain text document (WinCE.patch)
> Index: os.h
> ===
> --- os.h  (revision 1)
> +++ os.h  (working copy)
> @@ -182,7 +182,7 @@
>  int sqlite3OsSyncDirectory(const char*);
>  int sqlite3OsTempFileName(char*);
>  int sqlite3OsIsDirWritable(char*);
> -int sqlite3OsClose(OsFile*);
> +int sqlite3OsClose(OsFile*, const char*);
>  int sqlite3OsRead(OsFile*, void*, int amt);
>  int sqlite3OsWrite(OsFile*, const void*, int amt);
>  int sqlite3OsSeek(OsFile*, i64 offset);
> Index: os_unix.c
> ===
> --- os_unix.c (revision 1)
> +++ os_unix.c (working copy)
> @@ -1278,7 +1278,7 @@
>  /*
>  ** Close a file.
>  */
> -int sqlite3OsClose(OsFile *id){
> +int sqlite3OsClose(OsFile *id, const char*){
>if( !id->isOpen ) return SQLITE_OK;
>if( CHECK_THREADID(id) ) return SQLITE_MISUSE;
>sqlite3OsUnlock(id, NO_LOCK);
> Index: os_win.c
> ===
> --- os_win.c  (revision 1)
> +++ os_win.c  (working copy)
> @@ -33,6 +33,64 @@
>  ** Include code that is common to all os_*.c files
>  */
>  #include "os_common.h"
> +
> +#if defined(_WIN32_WCE)
> +#include 
> +struct tm * __cdecl localtime(const time_t *t)
> +{
> +  static struct tm y;
> +  FILETIME uTm, lTm;
> +  SYSTEMTIME pTm;
> +  uTm.dwLowDateTime = *t & 0x;
> +  uTm.dwHighDateTime= *t >> 32;
> +  FileTimeToLocalFileTime(,);
> +  FileTimeToSystemTime(,);
> +  y.tm_year = pTm.wYear - 1900;
> +  y.tm_mon = pTm.wMonth - 1;
> +  y.tm_wday = pTm.wDayOfWeek;
> +  y.tm_mday = pTm.wDay;
> +  y.tm_hour = pTm.wHour;
> +  y.tm_min = pTm.wMinute;
> +  y.tm_sec = pTm.wSecond;
> +  return 
> +}
> +
> +#ifndef LOCKFILE_EXCLUSIVE_LOCK
> +#define LockFileEx(a,b,c,d,e,f) (1)
> +#define UnlockFileEx(a,b,c,d,e) (1)
> +#endif
> +
> +BOOL LockFile(
> +  HANDLE hFile,
> +  DWORD dwFileOffsetLow,
> +  DWORD dwFileOffsetHigh,
> +  DWORD nNumberOfBytesToLockLow,
> +  DWORD nNumberOfBytesToLockHigh
> +)
> +{
> +  OVERLAPPED ovlp;
> +  ovlp.Offset = dwFileOffsetLow;
> +  ovlp.OffsetHigh = dwFileOffsetHigh;
> +  ovlp.hEvent = 0;
> +  return LockFileEx(hFile, 
> LOCKFILE_EXCLUSIVE_LOCK|LOCKFILE_FAIL_IMMEDIATELY, 0, 
> nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, );
> +}
> +
> +
> +BOOL UnlockFile(
> +  HANDLE hFile,
> +  DWORD dwFileOffsetLow,
> +  DWORD dwFileOffsetHigh,
> +  DWORD nNumberOfBytesToUnlockLow,
> +  DWORD nNumberOfBytesToUnlockHigh
> +)
> +{
> +  OVERLAPPED ovlp;
> +  ovlp.Offset = dwFileOffsetLow;
> +  ovlp.OffsetHigh = dwFileOffsetHigh;
> +  ovlp.hEvent = 0;
> +  return UnlockFileEx(hFile, 0, nNumberOfBytesToUnlockLow, 
> nNumberOfBytesToUnlockHigh, );
> +}
> +#endif
>  
>  /*
>  ** Do not include any of the File I/O interface procedures if the
> @@ -66,14 +124,18 @@
>  ** WinNT/2K/XP so that we will know whether or not we can safely call
>  ** the LockFileEx() API.
>  */
> -static int isNT(void){
> +static int isNT(void){
> +#if !defined(_WIN32_WCE)
>if( sqlite3_os_type==0 ){
>  OSVERSIONINFO sInfo;
>  sInfo.dwOSVersionInfoSize = sizeof(sInfo);
>  GetVersionEx();
>  sqlite3_os_type = sInfo.dwPlatformId==VER_PLATFORM_WIN32_NT ? 2 : 1;
>}
> -  return sqlite3_os_type==2;
> +  return sqlite3_os_type==2;
> +#else
> +  return 1;
> +#endif
>  }
>  
>  /*
> @@ -131,9 +193,11 @@
>if( zWide ){
>