[sqlite] Race condition -- fixed?

2007-10-24 Thread Richard Klein

As I was thinking about the locking mechanism in SQLite 3,
it occurred to me that the following race condition could
occur.

Imagine a joint bank account with a balance of $10,000.
The wife makes a withdrawal of $1,000 at ATM 'A' (serviced
by process A in the bank's mainframe), while at the same
time the husband makes a deposit of $1,000 at ATM 'B'
(serviced by process B).  The steps performed by each
process are as follows:

Process A
-
BEGIN TRANSACTION;
SELECT balance FROM accounts WHERE accountId = '123-45-6789';
UPDATE accounts SET balance = 
WHERE accountId = '123-45-6789';
COMMIT;

Process B
-
BEGIN TRANSACTION;
SELECT balance FROM accounts WHERE accountId = '123-45-6789';
UPDATE accounts SET balance = 
WHERE accountId = '123-45-6789';
COMMIT;

Both processes open the accounts database, obtain SHARED
locks, and proceed at about the same pace.  Process A
updates her local cache with a new balance of $900, while
process B updates his local cache with a new balance of
$11,000.

Now suppose B gets to the COMMIT first.  He tries to get a
PENDING lock and succeeds.  He then tries to promote his
PENDING lock to EXCLUSIVE, but gets a SQLITE_BUSY instead,
because process A holds a SHARED lock.  So, he goes to sleep,
hoping that when he awakens the SHARED lock will be gone.

Meanwhile, process A reaches her COMMIT, tries to get a
PENDING lock, but gets a SQLITE_BUSY instead, because
process B already holds a PENDING lock.  Process A then
releases her SHARED lock (so that process B can be promoted
from PENDING to EXCLUSIVE and do his commit), and goes to
sleep, hoping that when she wakes up the PENDING lock will
be gone.

Process B then wakes up, finds the database UNLOCKED, obtains
his EXCLUSIVE lock, commits his local cache's balance of
$11,000 to the database, releases his lock, and exits.

Process A then wakes up, finds the database UNLOCKED, obtains
an EXCLUSIVE lock, commits her local cache's balance of $9,000
to the database, releases her lock, and exits.  *The database
now erroneously shows a balance of $9,000.*

The problem is that the moment that process B commits his local
cache's balance of $11,000 to the database, he causes process A's
local cache to become *stale*, i.e. inconsistent with the database.

After scouring the documentation, I came across the following
article:

http://www.sqlite.org/cvstrac/wiki?p=CorruptionFollowingBusyError

which seems to describe the exact scenario I described above.
According to this article, SQLite has been fixed so that if
a process encounters a SQLITE_BUSY during an explicit trans-
action, then the transaction will *automatically* be rolled
back, and the app will receive an error code of SQLITE_IOERR
*instead of* SQLITE_BUSY.

I understand this to mean that whenever coding an explicit
transaction, the programmer must always be prepared to receive
an SQLITE_IOERR when stepping through any SQL statement, and
must deal with this error by going back to the start of the
transaction and starting over.

- Richard Klein


-
To unsubscribe, send email to [EMAIL PROTECTED]
-

Re: [sqlite] How to implement xLock()?

2007-10-24 Thread Richard Klein

John Stanton wrote:
Are you certain that you need to run a full suite of tests on Sqlite 
to verify that your compatibility layer is correct?  How about 
developing a test suite for your porting layer  If it works 
identically on each platform you can have confidence that your 
overlaid software will also work.


We do have a test suite for our porting layer that we require
to execute flawlessly on each platform.

That's why I'm thinking that it would be sufficient to run the
SQLite Tcl test scripts on our WIN32 platform only:  A success-
ful test run would mean that my implementation of the SQLite
compatibility layer is correct on WIN32, and so is probably
correct on *all* platforms, since the only difference between
platforms is the porting layer, and that has already been
independently verified.

As I mentioned in a previous email, the above reasoning has
been vindicated by practical experience:  Whenever we find
a difference in behavior between the WIN32 platform and
platform 'X', the difference is almost invariably due to a
bug in the porting layer for one of those two platforms.

Thanks,
- Richard Klein


-
To unsubscribe, send email to [EMAIL PROTECTED]
-

Re: [sqlite] Lemon not reducing

2007-10-24 Thread Grzegorz Makarewicz
Gaspard Bucher wrote:
> PS: There is another reason, aside from aesthetics and simpler grammar
> to filter white spaces inside the tokenizer: you avoid all the parser
> conflicts you could get with "empty | or space" rules.
>
> 2007/10/24, Gaspard Bucher <[EMAIL PROTECTED]>:
>   
>>> Gaspard Bucher <[EMAIL PROTECTED]> wrote:
>>>   
 I do not understand why lemon waits for one more token when it has
 enough information to reduce.

 I want to recognize :
 foo = Bar()
 when the token CLOSE_PAR is received, not when an extra token is parsed..

 How can I avoid lemon waiting for the extra token before reducing ?

 
>>> I don't think you can.  Why do you want to?  Why not just go
>>> ahead and send it the next token?
>>>   
>> Most people find a way around this problem using white-space. This
>> could be a solution but then my grammar will be filled with
>> "white-space | nothing" rules and I thought Lemon could reduce when
>> there is no other way out of the current stack as it is more elegant.
>> I went into the sources and saw this comment:
>>
>> 
LA(LR) is the answer - just drop Your's tokens as their arrive and give
a chance for the parser to be LALR, not LR or SLR :)

mak


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] LIKE operator syntax for white space

2007-10-24 Thread Yuriy Martsynovskyy
These only strip lines with Space characters. I need also to filter
out also tabs, carriage returns and all series characters that
constitute a white space.

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] Re: Some Questions Regarding Access To a SQLite Database By More Than One Process

2007-10-24 Thread Lee Crain
Ken, Igor, 

I read the article you referenced. Much appreciated.
http://sqlite.org/lockingv3.html

I didn't want to complicate my original questions with the intricate
details of the application requirements which involve not allowing any
database access while certain other operations are executing. I think a
MUTEX, even with its inherent performance limitations, is the best
solution.

Thanks for your replies,

Lee Crain

P.S. Ken, I'm pretty certain that a MUTEX is both an intra- and
inter-process mutual exclusion object. 





-Original Message-
From: Ken [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 24, 2007 2:22 PM
To: sqlite-users@sqlite.org
Subject: RE: [sqlite] Re: Some Questions Regarding Access To a SQLite
Database By More Than One Process

If you are using seperate processes then a mutex will not help since it is
local to a process. A semaphore could be used however.

You can use a begin immediate around all statements that perform DML
(ins/upd/sel)

Then loop on the busy at the begin immediate command. This is a fairly
simple thing to do.

Then for selects you'll need only test the prepare/ and first step  After
the first step you should not get a sqlite busy.


Lee Crain <[EMAIL PROTECTED]> wrote: Igor,

I did say "controlled" concurrency. 

I'll rephrase question 3.

3) Would use of a MUTEX to avoid the dreaded "SQLite busy" condition be a
good solution? Or is some other method of avoiding a busy condition
recommended?

Lee Crain

__


-Original Message-
From: Igor Tandetnik [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 24, 2007 1:36 PM
To: SQLite
Subject: [sqlite] Re: Some Questions Regarding Access To a SQLite Database
By More Than One Process

Lee Crain  wrote:
> 1. Can multiple processes "concurrently" access the same SQLite
> database?

Yes.

> 2. If so, can multiple processes maintain an open connection to the
> database? Or must the connection be opened and closed, before and
> after,
> respectively, each database access?

You can have multiple open connections, from the same or different 
processes, at any given time. You can keep a connection open as long as 
necessary.

> 3. Would the use of a MUTEX as access protection be adequate to
> successfully implement controlled "concurrency"?

I'm not sure I understand this question. Mutexes are all about _not_ 
allowing concurrency.

Igor Tandetnik 


--
---
To unsubscribe, send email to [EMAIL PROTECTED]
--
---



--
---
To unsubscribe, send email to [EMAIL PROTECTED]
--
---




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Lemon not reducing

2007-10-24 Thread Gaspard Bucher
PS: There is another reason, aside from aesthetics and simpler grammar
to filter white spaces inside the tokenizer: you avoid all the parser
conflicts you could get with "empty | or space" rules.

2007/10/24, Gaspard Bucher <[EMAIL PROTECTED]>:
> > Gaspard Bucher <[EMAIL PROTECTED]> wrote:
> > > I do not understand why lemon waits for one more token when it has
> > > enough information to reduce.
> > >
> > > I want to recognize :
> > > foo = Bar()
> > > when the token CLOSE_PAR is received, not when an extra token is parsed..
> > >
> > > How can I avoid lemon waiting for the extra token before reducing ?
> > >
> >
> > I don't think you can.  Why do you want to?  Why not just go
> > ahead and send it the next token?
> Most people find a way around this problem using white-space. This
> could be a solution but then my grammar will be filled with
> "white-space | nothing" rules and I thought Lemon could reduce when
> there is no other way out of the current stack as it is more elegant.
> I went into the sources and saw this comment:
>
> I think I might find something to do here:
> in yy_find_shift_action :
> when we find the action:
>
> // return yy_action[i];
> result = yy_action[i];
> printf("==> next : %i\n", result);
> printf("==> next_next: %i\n", yy_shift_ofst[result % (YYNSTATE+YYNRULE)]);
> // if the shift results in a default action do this action now.
> if (result < (YYNSTATE+YYNRULE) && yy_shift_ofst[result] ==
> YY_SHIFT_USE_DFLT) {
>   // do the change ourself
>
>   YYMINORTYPE yyminorunion;
>   yy_shift(pParser,result,iLookAhead,);
>   pParser->yyerrcnt--;
>   return yy_default[result];
> } else
>   return result;
>
> This works except when the reduction reaches state '1'. Somehow, it
> should jump directly to state '0', clearing the current lookahead.
>
> > --
> > D. Richard Hipp <[EMAIL PROTECTED]>
> >
> >
> > -
> > To unsubscribe, send email to [EMAIL PROTECTED]
> > -
> >
> >
> > !DSPAM:471f82d0320381804284693!
> >
> >
>

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Lemon not reducing

2007-10-24 Thread Gaspard Bucher
> Gaspard Bucher <[EMAIL PROTECTED]> wrote:
> > I do not understand why lemon waits for one more token when it has
> > enough information to reduce.
> >
> > I want to recognize :
> > foo = Bar()
> > when the token CLOSE_PAR is received, not when an extra token is parsed..
> >
> > How can I avoid lemon waiting for the extra token before reducing ?
> >
>
> I don't think you can.  Why do you want to?  Why not just go
> ahead and send it the next token?
Most people find a way around this problem using white-space. This
could be a solution but then my grammar will be filled with
"white-space | nothing" rules and I thought Lemon could reduce when
there is no other way out of the current stack as it is more elegant.
I went into the sources and saw this comment:

I think I might find something to do here:
in yy_find_shift_action :
when we find the action:

// return yy_action[i];
result = yy_action[i];
printf("==> next : %i\n", result);
printf("==> next_next: %i\n", yy_shift_ofst[result % (YYNSTATE+YYNRULE)]);
// if the shift results in a default action do this action now.
if (result < (YYNSTATE+YYNRULE) && yy_shift_ofst[result] ==
YY_SHIFT_USE_DFLT) {
  // do the change ourself

  YYMINORTYPE yyminorunion;
  yy_shift(pParser,result,iLookAhead,);
  pParser->yyerrcnt--;
  return yy_default[result];
} else
  return result;

This works except when the reduction reaches state '1'. Somehow, it
should jump directly to state '0', clearing the current lookahead.

> --
> D. Richard Hipp <[EMAIL PROTECTED]>
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -
>
>
> !DSPAM:471f82d0320381804284693!
>
>

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Re: Re: Some Questions Regarding Access To a SQLite Database By More Than One Process

2007-10-24 Thread Igor Tandetnik

Lee Crain <[EMAIL PROTECTED]> wrote:

Igor,

I did say "controlled" concurrency.

I'll rephrase question 3.

3) Would use of a MUTEX to avoid the dreaded "SQLite busy" condition
be a
good solution?


Wouldn't it prevent multiple concurrent readers? That's usually 
something you want.



Or is some other method of avoiding a busy condition
recommended?


You can start every writing transaction with BEGIN EXCLUSIVE. In 
addition, you can use sqlite3_busy_timeout to set the timeout to a very 
large value (making the timeout so long that it can be considered 
infinite for practical purposes). With these two fixes, the behavior 
will be similar to that of a mutex-based solution, except that you would 
still allow concurrent readers.


Igor Tandetnik 



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] Re: Some Questions Regarding Access To a SQLite Database By More Than One Process

2007-10-24 Thread Lee Crain
Igor,

I did say "controlled" concurrency. 

I'll rephrase question 3.

3) Would use of a MUTEX to avoid the dreaded "SQLite busy" condition be a
good solution? Or is some other method of avoiding a busy condition
recommended?

Lee Crain

__


-Original Message-
From: Igor Tandetnik [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 24, 2007 1:36 PM
To: SQLite
Subject: [sqlite] Re: Some Questions Regarding Access To a SQLite Database
By More Than One Process

Lee Crain <[EMAIL PROTECTED]> wrote:
> 1. Can multiple processes "concurrently" access the same SQLite
> database?

Yes.

> 2. If so, can multiple processes maintain an open connection to the
> database? Or must the connection be opened and closed, before and
> after,
> respectively, each database access?

You can have multiple open connections, from the same or different 
processes, at any given time. You can keep a connection open as long as 
necessary.

> 3. Would the use of a MUTEX as access protection be adequate to
> successfully implement controlled "concurrency"?

I'm not sure I understand this question. Mutexes are all about _not_ 
allowing concurrency.

Igor Tandetnik 


--
---
To unsubscribe, send email to [EMAIL PROTECTED]
--
---



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Some Questions Regarding Access To a SQLite Database By More Than One Process

2007-10-24 Thread Ken
Lee,
1. Qualified Yes,  depending on your definition of concurrency.

2. Connections may remain open.

3. Mutexes are not required for protection.

Read the following:
http://sqlite.org/lockingv3.html



Lee Crain <[EMAIL PROTECTED]> wrote: I loosely follow this forum so I am almost 
certain this subject has come
up in the forum in the last few months. However, until Monday of this
week, this subject had not come up in my company's application
requirements so I made few mental notes on it. Now, a requirement for
having 2 or more processes accessing the same SQLite database has arisen.

Questions:
1. Can multiple processes "concurrently" access the same SQLite database?
2. If so, can multiple processes maintain an open connection to the
database? Or must the connection be opened and closed, before and after,
respectively, each database access?
3. Would the use of a MUTEX as access protection be adequate to
successfully implement controlled "concurrency"?

If my ideas on how to successfully implement this capability are not
appropriate, please advise me.

Thanks,

Lee Crain



-
To unsubscribe, send email to [EMAIL PROTECTED]
-




[sqlite] Re: Some Questions Regarding Access To a SQLite Database By More Than One Process

2007-10-24 Thread Igor Tandetnik

Lee Crain <[EMAIL PROTECTED]> wrote:

1. Can multiple processes "concurrently" access the same SQLite
database?


Yes.


2. If so, can multiple processes maintain an open connection to the
database? Or must the connection be opened and closed, before and
after,
respectively, each database access?


You can have multiple open connections, from the same or different 
processes, at any given time. You can keep a connection open as long as 
necessary.



3. Would the use of a MUTEX as access protection be adequate to
successfully implement controlled "concurrency"?


I'm not sure I understand this question. Mutexes are all about _not_ 
allowing concurrency.


Igor Tandetnik 



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Some Questions Regarding Access To a SQLite Database By More Than One Process

2007-10-24 Thread Lee Crain
I loosely follow this forum so I am almost certain this subject has come
up in the forum in the last few months. However, until Monday of this
week, this subject had not come up in my company's application
requirements so I made few mental notes on it. Now, a requirement for
having 2 or more processes accessing the same SQLite database has arisen.

Questions:
1. Can multiple processes "concurrently" access the same SQLite database?
2. If so, can multiple processes maintain an open connection to the
database? Or must the connection be opened and closed, before and after,
respectively, each database access?
3. Would the use of a MUTEX as access protection be adequate to
successfully implement controlled "concurrency"?

If my ideas on how to successfully implement this capability are not
appropriate, please advise me.

Thanks,

Lee Crain



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] primary key constraint

2007-10-24 Thread David Nguyen
Hello, 

With php, I want to create 2 tables, userid is a
primary key in TUser and a foreign key in TRight. I
want to create a default user during database
creation.


$sql1 = 'CREATE TABLE TUser(userid UNSIGNED INTEGER
PRIMARY KEY AUTOINCREMENT NOT NULL, username TEXT,
pseudo TEXT, password TEXT, email TEXT, lang TEXT)';

$sql2 = 'CREATE TABLE TRight(userid INTEGER,
usermanager BOOL, chef BOOL, writer BOOL, reader BOOL,
root BOOL)';

$sql3 = "INSERT INTO TUser(pseudo, password) VALUES
(\''$pseudo\'',\''$password\'')";

$sql4 = "INSERT INTO TRight(userid, usermanager, chef,
writer, reader, root)
VALUES(1,TRUE,TRUE,TRUE,TRUE,TRUE)";

(as 1 is the first autoinc unsigned.)

My question is : does 'unsigned' word recognized as a
constraint ?
if it is not, how can I write the sql constraint ?

userid UNSIGNED INTEGER PRIMARY KEY AUTOINCREMENT  NOT
NULL CONSTRAINT userid > 0 

BR,
David


  
_ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Lemon not reducing

2007-10-24 Thread drh
Gaspard Bucher <[EMAIL PROTECTED]> wrote:
> I do not understand why lemon waits for one more token when it has
> enough information to reduce.
> 
> I want to recognize :
> foo = Bar()
> when the token CLOSE_PAR is received, not when an extra token is parsed.
> 
> How can I avoid lemon waiting for the extra token before reducing ?
> 

I don't think you can.  Why do you want to?  Why not just go
ahead and send it the next token?
--
D. Richard Hipp <[EMAIL PROTECTED]>


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Lemon not reducing

2007-10-24 Thread Gaspard Bucher

I do not understand why lemon waits for one more token when it has
enough information to reduce.

I want to recognize :
foo = Bar()
when the token CLOSE_PAR is received, not when an extra token is parsed.

How can I avoid lemon waiting for the extra token before reducing ?

Thanks for your help !

Gaspard

=== GRAMMAR   ==
main::= commands.
commands::= . /* can be empty  */
commands::= WHITE_SPACE.
commands::= commands command. /* many commands */

command ::= variable EQUAL class parameters. { printf("[new  
object]\n"); }

variable::= IDENTIFIER.
class   ::= CONST_IDENTIFIER.
parameters  ::= OPEN_PAR CLOSE_PAR.

===  DEBUG OUTPUT ==

Parser started.
> foo = Bar()
>>Input IDENTIFIER
>>Reduce [commands ::=].
>>Shift 1
>>Stack: commands
>>Shift 21
>>Stack: commands IDENTIFIER
>>Input EQUAL
>>Reduce [variable ::= IDENTIFIER].
>>Shift 3
>>Stack: commands variable
>>Shift 4
>>Stack: commands variable EQUAL
>>Input CONST_IDENTIFIER
>>Shift 20
>>Stack: commands variable EQUAL CONST_IDENTIFIER
>>Input OPEN_PAR
>>Reduce [class ::= CONST_IDENTIFIER].
>>Shift 5
>>Stack: commands variable EQUAL class
>>Shift 7
>>Stack: commands variable EQUAL class OPEN_PAR
>>Input CLOSE_PAR
>>Shift 8
>>Stack: commands variable EQUAL class OPEN_PAR CLOSE_PAR

At this point, lemon has all the information needed, but it waits
before reducing...

---
http://rubyk.org, scriptable multimedia controller



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] PATCH: compound (multi-row) INSERT statements

2007-10-24 Thread Ken
I see now, thanks for the clarification. Sorry for the ramblings.

And there is a .mode csv so that should take care of data loading.

Regards,
Ken

Joe Wilson <[EMAIL PROTECTED]> wrote: --- Ken  wrote:
>A new command ".imp" command could be made to use my proposed array based 
> processing. 

There's already an .import command in the shell.

>   I don't agree with the aproach of modify the SQL language to create a 
> generic high speed
> loading interface.

It's not my extension.
According to Wikipedia, multi-row inserts are part of SQL-92
and is supported by DB2, PostgreSQL (since version 8.2) and MySQL.

http://en.wikipedia.org/wiki/Insert_%28SQL%29#Multirow_inserts


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-
To unsubscribe, send email to [EMAIL PROTECTED]
-




RE: [sqlite] Help with an unusual query

2007-10-24 Thread Samuel R. Neff

This can be done with a custom aggregate function.  I posted an example a
week or so ago here in the list (example in C#).

SELECT key, DisplayList(data)
GROUP BY Key

where DisplayList() is a custom function that concatenates it's values.

I don't think this can be done in straight SQL.

HTH,

Sam 


---
We're Hiring! Seeking a passionate developer to join our team building
products. Position is in the Washington D.C. metro area. If interested
contact [EMAIL PROTECTED]
 
-Original Message-
From: Rich Rattanni [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 24, 2007 9:46 AM
To: sqlite-users@sqlite.org
Subject: [sqlite] Help with an unusual query

All:
I have the following table


key  data
1  'Version 1'
1  'Version 2'
1  'Version 3'
2  'Version 4'
2  'Version 5'

(obviously key is not primary)

I want to write a query that returns

key data
1 'Version 1 Version 2 Version 3'
2 ' Version 4 Version 5'


Basically I want a row returned for each unique key, but i want the
data column for each key (string data) concatenated together (and
seperated with spaces if possible :) ).

Thanks,
Rich Rattanni


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Help with an unusual query

2007-10-24 Thread Rich Rattanni
All:
I have the following table


key  data
1  'Version 1'
1  'Version 2'
1  'Version 3'
2  'Version 4'
2  'Version 5'

(obviously key is not primary)

I want to write a query that returns

key data
1 'Version 1 Version 2 Version 3'
2 ' Version 4 Version 5'


Basically I want a row returned for each unique key, but i want the
data column for each key (string data) concatenated together (and
seperated with spaces if possible :) ).

Thanks,
Rich Rattanni

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Changing journal-directory?

2007-10-24 Thread drh
Thomas Damme <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> this question was propably asked a hundred times before but I was not
> able to find a good answer for it on the web.
> 
> Is it possible to change the directory where SQLite places the
> journal-file? We have a damn-slow USB-Stick where the database resides.
> It does not fit into the fast internal memory but the small portions of
> data we change and the resulting journal file would fit.
> 
> We tried "PRAGMA temp_store" but this only effects the virtual tables.
> 
> Someone on the web also proposed to write a virtual filesystem and
> change the IO-Functions in SQLite. But I wanted to check first if there
> is another way..?
> 

Read http://www.sqlite.org/ac/atomiccommit.html and then you
will understand why moving the journal file to a different
directory will result in database corruption following a
power loss.

--
D. Richard Hipp <[EMAIL PROTECTED]>


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Changing journal-directory?

2007-10-24 Thread Thomas Damme
Hello,

this question was propably asked a hundred times before but I was not
able to find a good answer for it on the web.

Is it possible to change the directory where SQLite places the
journal-file? We have a damn-slow USB-Stick where the database resides.
It does not fit into the fast internal memory but the small portions of
data we change and the resulting journal file would fit.

We tried "PRAGMA temp_store" but this only effects the virtual tables.

Someone on the web also proposed to write a virtual filesystem and
change the IO-Functions in SQLite. But I wanted to check first if there
is another way..?

Regards,
-- 

Thomas Damme


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] syntax error

2007-10-24 Thread Markus Hoenicka

Quoting nishit sharma <[EMAIL PROTECTED]>:


Hi All,
Sending y peoples same query with some explanation.
i have a database name myds.db which is having one column as index (integer
default 0) which has no values
in complete database.
when i used to access somthing with reference to index in command than i get
the error
SQL error: near "index": syntax error



http://sqlite.org/lang_keywords.html

"index" is a reserved word. Just use a different column name which is  
not in the above list.


regards,
Markus

--
Markus Hoenicka
[EMAIL PROTECTED]
(Spam-protected email: replace the quadrupeds with "mhoenicka")
http://www.mhoenicka.de


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] syntax error

2007-10-24 Thread nishit sharma
Hi All,
Sending y peoples same query with some explanation.
i have a database name myds.db which is having one column as index (integer
default 0) which has no values
in complete database.
when i used to access somthing with reference to index in command than i get
the error
SQL error: near "index": syntax error

can anybody tell me y
regards
Nishit


[sqlite] Re: Vista-IE7 problem

2007-10-24 Thread Barabbas [EMAIL PROTECTED]
Barabbas Jiang  Gmail <[EMAIL PROTECTED]> writes:
> 
> Hi all,
> 
> I found another strange problem of SQLite on Vista with IE7.
> I have an input method with SQLite. When I opened it in IE7 for
> typing Chinese, the SQLite returned nothing. However, *if IE7 is
> "run as administrator," SQLite works.*
> 
> Generally I know IE7 on Vista has a implicit security rules:
> once it thinks you're doing some guilty IPC from other DLLs,
> it drops all messages.
> 
> The strange thing is, *SQLite 3.2.5 and before worked, but
> 3.2.6 and later not.*

I revisited this problem recently, seems IE7 solved some mysterious issue and
then SQLite3 does not conflict with IE7 protected mode anymore. :)

/Mike/





-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Documentation - Downloadable?

2007-10-24 Thread Dan Kennedy
On Tue, 2007-10-23 at 19:54 -0500, Andrew Wiley wrote:
> I've been using SQLite on several minor projects now (it makes File IO so
> easy), and the one suggestion I would make would be to make the
> documentation (api reference) downloadable.
> It would be very handy for myself and probably many others to be able to
> download the API reference and keep it with our projects. For me at least,
> I'm a high school student and work with an IDE running from a flash drive in
> the Computer Science lab, where there is no internet, and documentation
> would be so much better than digging though sqlite.h
> 
> Thanks,
> Andrew

Run "../sqlite/configure && make doc" to generate the website 
html pages.

Dan.



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] syntax error

2007-10-24 Thread nishit sharma
Hi All,
i have a database in which there is a column named index (integer value).
when i m doing select index and all other stuff i m continuosly getting an
error that is:
SQL error: near "index": syntax error
and this error doesn't come if i remove index entry from my command

can anybody tell me y this is coming

waiting for reply

Regards
Nishit


Re: [sqlite] trigger a non-database event in sqlite

2007-10-24 Thread Dan Kennedy
On Tue, 2007-10-23 at 19:33 -0700, d_maniger06 wrote:
> ok..i have this sample code:
> 
> [code]
> void printIfInsert()
> {
> printf( "Insertion was done in t1\n" );
> }
> 
> void createTrigger( sqlite** db, sqlite_vm** pvm )
> {
> char* errMsg;
> const char** psql = NULL;
> const char* sql = "CREATE TRIGGER onInsertTrig AFTER INSERT on t2 BEGIN
> printIfInsert; END";

The trigger should be more like:

CREATE TRIGGER onInsertTrig AFTER INSERT on t2 BEGIN
  SELECT printIfInsert();
END;

As it is now it is a syntax error. sqlite v2 might not pick
this up until it is first executed, I can't remember that far 
back...

Dan.


> 
> if( sqlite_create_function( *db, "printIfInsert", 0, ,
> NULL ) != 0 )
> {
> printf( "hahahaha! no function was created\n" );
> exit(1);
> }
> 
> if ( sqlite_compile(*db, sql, psql, &*pvm, ) != SQLITE_OK )
> {
> printf( "CREATE TRIGGER FAILED: %s\n", errMsg );
> }
> }
> [/code]
> 
> im not really sure if this is correct..i have read a documentation of
> sqlite_create_function in sqlite.org but its not really that clear to
> me..can you please guide me on this?..what i wanted to happen is that every
> time, i insert on table t2, there should be something printed on the
> console..actually, this is just for test..what i really wanted is it to log
> in a log file every time a new record is inserted in the table..but my
> concern is just i dont know how to call that function (printIfInsert()) in
> the trigger statement..
> 
> please help me on this..
> 
> thank you and God bless!.. c",)
> 
> 
> John Stanton-3 wrote:
> > 
> > I that case you need to implenment a custom function and launch it from 
> > a trigger.
> > 
> > d_maniger06 wrote:
> >> im sorry but i havent get your point..im rather new in sqlite and i just
> >> need
> >> to make a c program, that when i insert on a table in my database,
> >> something
> >> is written on a file, or even just be printed out in the console saying
> >> that
> >> my table in my database has been updated/inserted..
> >> 
> >> 
> >> John Stanton-3 wrote:
> >> 
> >>>d_maniger06 wrote:
> >>>
> good day!..
> 
> i would just like to ask if you can set a trigger to call on a
> non-database
> event (e.g. writing to a file) whenever an update/insert has been made
> to
> the database..im using c programming language for this..if this is
> possible,
> can u give me some links or direct examples on how to do this?..
> 
> thank you and God bless!..
> >>>
> >>>If you are intercepting some event in your C program why not just make 
> >>>the event execute some SQL?
> >>>
> >>>-
> >>>To unsubscribe, send email to [EMAIL PROTECTED]
> >>>-
> >>>
> >>>
> >>>
> >> 
> >> 
> > 
> > 
> > -
> > To unsubscribe, send email to [EMAIL PROTECTED]
> > -
> > 
> > 
> > 
> 


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] what extension do you recommend

2007-10-24 Thread Ramon Ribó


  You should consider the extension for, at least, three situations:

  - Anti virus can check files differently depending on the extension

  - Backup programs can also react on this

  - Windows takes it into account when indexing files


Compass Ing. y Sistemas Dr. Ramon Ribo
http://www.compassis.com[EMAIL PROTECTED]
c/ Tuset, 8 7-2 tel. +34 93 218 19 89
08006 Barcelona, Spain  fax. +34 93 396 97 46

Daniel Önnerby escribió:
Well... From the lack of responses I gather that you actually don't give 
a damn what file extension I use :)
I think this is fare enough and maybe a SQLite database shouldn't be 
tied to a single file extension.

Anyway.. Thanks for listening and thanks for the best database ever!

Daniel Önnerby wrote:

Hi all!

I have developed a small windows application that use a SQLite 
database as it's main format.
The file is NOT a kind of document, it's more of a settings-file 
stored in the users "Application data"-directory and the extension 
will not be associated with the application.


I know I can use any kind of extension on this file, but what 
file-extension is the most common for SQLite-files, .db, .db3, .SQLite?

What file-extensions do the SQLite management tools associate?
What do you recommend?


Best regards!
Daniel

- 


To unsubscribe, send email to [EMAIL PROTECTED]
- 





- 


To unsubscribe, send email to [EMAIL PROTECTED]
- 






-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Documentation - Downloadable?

2007-10-24 Thread Olaf Beckman Lapré
Aren't there any source documents? I assume the documentation wasn't written 
in HTML originally.


Olaf

- Original Message - 
From: "John Stanton" <[EMAIL PROTECTED]>

To: 
Sent: Wednesday, October 24, 2007 07:50
Subject: Re: [sqlite] Documentation - Downloadable?


A project for you.  Pick up the documentation, transform it to PDF and make 
it an Sqlite contribution on sqlite.org.


Olaf Beckman Lapré wrote:

Hi,

I second this request. I've been wondering for a long time why the 
documentation isn't available off-line. How about making the 
documentation available as a PDF file?


Kind regards, Olaf

- Original Message - From: "Andrew Wiley" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, October 24, 2007 02:54
Subject: [sqlite] Documentation - Downloadable?


I've been using SQLite on several minor projects now (it makes File IO 
so

easy), and the one suggestion I would make would be to make the
documentation (api reference) downloadable.
It would be very handy for myself and probably many others to be able to
download the API reference and keep it with our projects. For me at 
least,
I'm a high school student and work with an IDE running from a flash 
drive in

the Computer Science lab, where there is no internet, and documentation
would be so much better than digging though sqlite.h

Thanks,
Andrew





-

To unsubscribe, send email to [EMAIL PROTECTED]
-





-
To unsubscribe, send email to [EMAIL PROTECTED]
-






-
To unsubscribe, send email to [EMAIL PROTECTED]
-