Re: [sqlite] Newbie coherency questions ... poor man's replication? Proper replication approaches?

2005-10-03 Thread Dan Kennedy

> We're building a multi-master, peer-to-peer network service,
> so we need a way to replicate changes between systems. 

Unsolicited advice:

Of course I don't understand your problem domain, but I'm a
big fan of a technology called "virtual synchrony" for this 
kind of thing. Very successful when I used it in a closed 
source project, and I believe the same technology used by 
the postgresql database for replication. (Google for Ken 
Birman, a researcher into the same).

http://www.spread.org is a very good open-source implementation
of his model. Another system is called "Ensemble", although I
found Spread to be better documented.

As I say, completely unsolicited.




__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


[sqlite] Re: Sqlite & NFS

2005-10-03 Thread gammal . sqlite
What matters for me the most actually is how sqlite will behave in a 
non-concurrent scenario in case NFS fails (the NFS mount is suddenly 
unavailable for example). Can I still assume that the ACID properties are 
maintained?

[EMAIL PROTECTED] writes:

> [EMAIL PROTECTED] wrote:
>> Hello,
>> I'm considering using sqlite in a system where the database might be
>> accessed concurrently from several machines over NFS. I'm aware of 
>> locking issues & NFS but I have a couple of questions:
>> 
>> - Could an NFS-level failure cause data inconsistency, or can 
>> sqlite handle such errors?
> 
> If NFS locks do not work correctly, you can get massive
> data corruption.  Easily.
> 
>> - I'm using Linux 2.4/2.6 machines. Anyone knows if their NFS 
>> implementation suffers from any locking issues?
>> 
> 
> I occasionally use a Linux 2.6 system with NFS and the NFS locking
> on it does not work right.  But I do not think that is a function
> of the kernel so much as it is the NFS setup on that particular
> network.
> --
> D. Richard Hipp <[EMAIL PROTECTED]>
> 






--
This message was sent from a MailNull anti-spam account.  You can get
your free account and take control over your email by visiting the
following URL.

   http://mailnull.com/


[sqlite] Newbie coherency questions ... poor man's replication? Proper replication approaches?

2005-10-03 Thread Bryan J. Smith
I've heard about this project for so many years, but I don't
know why I ignored it until now.  I was just reading the FAQ
on coherency and threading:  
  http://www.sqlite.org/faq.html#q7  

I believe this is outstanding for an embedded DB engine,
something I've never seen in anything else.  If I am assuming
correctly, while SQLite may not be a "true" multi-write DB in
the eyes of some -- I assume by having difference processes
locking control access to the DB, you can effectively have
multi-write (just one at a time), correct?

I assume that only works between programs using SQLite
methods in their code?  Or does it mean I could possibly test
for control, lock the DB and even rsync the DB file remotely?
 I assume not, but I have to ask if this "poor man's
replication" approach could work.  Assuming that would not,
so read on (and please comment on) what I believe might be
more proper design.

We're building a multi-master, peer-to-peer network service,
so we need a way to replicate changes between systems. 
Before finding SQLite, I figured I'd have to write an
"all-in-one daemon."  E.g., an application that handles the
app's data itself with client service access plus peer
replication service access to the same DB -- probably with
threads, semaphores and other internal locking issues.

But now I think SQLite solves the problem nicely, if I'm
reading the FAQ correctly.  What I'm considering is a 2
daemon approach, one for the app/client services and another
for the replication services.  I would just thread as many
daemons as configured for each (creating a new SQLite DB
connection instance to the file for each thread, per FAQ #8),
and handle client service changes and replication service
changes appropriately with a write lock.

If that is not feasible/recommended, alternatively, I was
thinking of keeping separate databases for the peer
replication, whereby the app/client services daemon and
replication services daemon never have write access to each
other's databases.  There would be incoming databases of
changes from each peer, and a single outgoing database for
all other peers (of local changes)

Or should I even be looking at maintaining local copies of
remote databases, possibly using an rsync at startup, and
then doing local resolution?  I guess there's a lot of
options/issues here, and I'm looking for suggestions/best
practices.

I know this is a broad set of questions/commentary, but any
insight into what SQLite can and can't do, and what practices
are best for setting up a multi-master, peer-replicating
service (of which, each "master" is also servicing clients,
which are where the changes initially come from) would be
ideal.

Thanx in advance.


-- 
Bryan J. Smith| Sent from Yahoo Mail
mailto:[EMAIL PROTECTED] |  (please excuse any
http://thebs413.blogspot.com/ |   missing headers)


Re: [sqlite] ANN: Sqlite3Explorer version 2.0 released

2005-10-03 Thread G. Roderick Singleton
On Mon, 2005-10-03 at 19:52 +0300, Cariotoglou Mike wrote:
> this is a major release, with a lot of changes. please see the readme at
> www.singular.gr/sqlite.
> Pls read the whole page carefully, as support for datatypes is now a lot
> more powerful, but slightly different than
> the previous versions.
> Report users : you will need to download an extra dll, it is bookmarked
> in the above link.
> 
> you can see the changes at a glance in
> www.singular.gr/sqlite/changes.htm
> 
> 

Interesting tool. Are sources available for porting to other OSes? I
would like to try on FC4.
-- 
G. Roderick Singleton <[EMAIL PROTECTED]>
PATH tech



Re: [sqlite] ANN: Sqlite3Explorer version 2.0 released

2005-10-03 Thread Bert Verhees
Mike, a very good, stable and handy tool. Especially I have a lot of pleasure 
with the querybuilder, saves me a lot of time.

Thank you very much, 

Regards
Bert Verhees.

Op maandag 3 oktober 2005 18:52, schreef Cariotoglou Mike:
> this is a major release, with a lot of changes. please see the readme at
> www.singular.gr/sqlite.
> Pls read the whole page carefully, as support for datatypes is now a lot
> more powerful, but slightly different than
> the previous versions.
> Report users : you will need to download an extra dll, it is bookmarked
> in the above link.
>
> you can see the changes at a glance in
> www.singular.gr/sqlite/changes.htm

-- 
Met vriendelijke groet
Bert Verhees
ROSA Software


RE: [sqlite] ANN: Sqlite3Explorer version 2.0 released

2005-10-03 Thread Cariotoglou Mike
Yes, this is an issue with a number of menu selections, which I forgot
to fix :) will do on the next release. For now, just open a db first.. 

> -Original Message-
> From: Dennis Cote [mailto:[EMAIL PROTECTED] 
> Sent: Monday, October 03, 2005 8:57 PM
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] ANN: Sqlite3Explorer version 2.0 released
> 
> Cariotoglou Mike wrote:
> 
> >this is a major release, with a lot of changes. please see 
> the readme 
> >at www.singular.gr/sqlite.
> >Pls read the whole page carefully, as support for datatypes is now a 
> >lot more powerful, but slightly different than the previous versions.
> >Report users : you will need to download an extra dll, it is 
> bookmarked 
> >in the above link.
> >
> >you can see the changes at a glance in
> >www.singular.gr/sqlite/changes.htm
> >
> >
> >
> >  
> >
> Hi Mike,
> 
> Trying out your new version I ran into a crash when I clicked 
> the Query Builder button on the toolbar with no database 
> open. It works correctly with a database open.
> 
> ---
> sqlite3explorer2
> ---
> Access violation at address 004B68E8 in module 
> 'sqlite3Explorer2.exe'. 
> Read of address 002C.
> ---
> OK
> ---
> 
> Dennis Cote
> 
> 
> 



Re: [sqlite] Rewriting a query

2005-10-03 Thread John LeSueur

[EMAIL PROTECTED] wrote:


Robin Breathe <[EMAIL PROTECTED]> wrote:
 


Hugh Gibson wrote:
   


I'm intrigued. How do you get SQLite to use a multi-column index as it's
primary key (i.e. B-tree hash)? Please elaborate.
   

Simply 

CREATE TABLE TransactionList (sTransactionID Text(13) DEFAULT 
'',sCommunityID Text(13) DEFAULT '',sObject Text(13) , PRIMARY KEY 
(sCommunityID, sTransactionID))
 


Ah, but it's not used for the B-tree hash (at least not according to the
documentation).

   



The ROWID is always used as the btree key (not hash!) on the main
database btree.  But when you have a PRIMARY KEY a separate index
btree is also created which uses the PRIMARY KEY as its key.

Question:  Why is this important to you?

(Side note: I am experimenting with a new Mail User Agent that
uses SQLite to store all its email messages.  I appologize in advance
if this message is misformatted or otherwise garbled.)
--
D. Richard Hipp <[EMAIL PROTECTED]>

 

I thought you might want to know that your new agent doesn't add 
References:  or In-Reply-To: .

This is not a big deal, but it does break discussion threading a little.

John


Re: RE: [sqlite] Bitwise comparison -- consider not getting bit

2005-10-03 Thread debra f
Thx for the opinion.  Will consider it!



 On Mon, 3 Oct 2005, Griggs, Donald
([EMAIL PROTECTED]) wrote:

>  Regarding:
> "...What's the best way to do a bitwise comparison in a
sql query...?"
> 
> Hi Debra,
> 
> Dennis Cote gave you a direct answer to your question -- since
sqlite
> supports bit operations directly in SQL.
> 
> But I wondered if you might want to evaluate dispensing with
bit-wise
> variables and using a more standard SQL approach -- a field
for each
> variable.
> 
> Even with the slightly bigger database, I should think table
scans will be
> faster, and if an index on one of these fields is ever called
for, it will
> be trivially easy to add.
> 
> You might find that, (unless you're writing an embedded tiny
app) even with
> many records in the database, only a very few pennies worth of
additional
> disk space would be required.
> 
> Increased portability and easier debugging are other bonuses. 
E.g. Imagine
> the blank stare you might encounter when you say, "Oh yes,
it's easy for you
> to run queries on the database for importing into your
spreadsheet -- just
> parse out the bit flags per our source spec."
> 
> 
> Donald Griggs
> 
> 
> Opinions are not necessarily those of Misys Healthcare Systems
nor its board
> of directors.
> 
> 
> -Original Message-
> From: debra f [mailto:[EMAIL PROTECTED] 
> Sent: Monday, October 03, 2005 12:10 PM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] Bitwise comparison
> 
> 
> 



Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag


Re: [sqlite] Rewrite of where.c without DOUBLE Values

2005-10-03 Thread John LeSueur

Sankara Narayanan wrote:


Dear Hipp and all,

We request you to provide guidelines for the implementation of where.c 
without using any of the DOUBLE values. We need to find the bestIndex 
calculation with all integer variables and integer values. We converted 
all doubles to integers by typecasting (we use #define as double 
overriding the DOUBLE definition in our C Libraries) and thus we could 
compile the library for our ARM 7 platform. 

We first open a database using sqlite3_open and this function succeeds. 
When we try to run the CREATE TABLE Command, we find that 
sqlite3WhereBegin is called, and we find that the command execution 
returns with error 0x1A (File Not a database error). 

We have modified only the values in where.c with the integer values as 
mentioned in my earlier mail but we think that this could cause problems 
as we might be messing up the bestIndex finding algorithm with these 
changes. I request you to please review the code that is sent earlier and 
provide comments/guidelines on how we could implement the bestIndex 
algorithm using integer values (to the closest possible working 
algorithm). 

Please note that in our schematics, we are also creating indices for 
tables that have VARCHAR fields. 


I request you to kindly look into this problem at the earliest.

Thank you,

With Regards,
Sankara Narayanan
Philips Innovation Campus
No 1, Murphy Road,
Ulsoor, Bangalore - 560008.
Ph - 0091-80-25579000 Extn 5121

"Utthistatha Jaagrata Praapya Varaan Nibodhatha"
 

Well, if you don't care about using indexes other than the primary key, 
it looks like you could do this:


static double bestIndex(
 Parse *pParse,  /* The parsing context */
 WhereClause *pWC,   /* The WHERE clause */
 struct SrcList_item *pSrc,  /* The FROM clause term to search */
 Bitmask notReady,   /* Mask of cursors that are not available */
 ExprList *pOrderBy, /* The order by clause */
 Index **ppIndex,/* Make *ppIndex point to the best index */
 int *pFlags,/* Put flags describing this choice in *pFlags */
 int *pnEq   /* Put the number of == or IN constraints here */
){
   ppIndex = pSrc->pTab->pIndex;
}

I'm pretty sure this is a bad idea, but you could do it for now, just to get 
started on testing and things.

John LeSueur




Re: [sqlite] ANN: Sqlite3Explorer version 2.0 released

2005-10-03 Thread Dennis Cote

Cariotoglou Mike wrote:


this is a major release, with a lot of changes. please see the readme at
www.singular.gr/sqlite.
Pls read the whole page carefully, as support for datatypes is now a lot
more powerful, but slightly different than
the previous versions.
Report users : you will need to download an extra dll, it is bookmarked
in the above link.

you can see the changes at a glance in
www.singular.gr/sqlite/changes.htm



 


Hi Mike,

Trying out your new version I ran into a crash when I clicked the Query 
Builder button on the toolbar with no database open. It works correctly 
with a database open.


---
sqlite3explorer2
---
Access violation at address 004B68E8 in module 'sqlite3Explorer2.exe'. 
Read of address 002C.

---
OK  
---


Dennis Cote


Re: [sqlite] Problem/Bug: "SELECT 5 / 2;" returns 2 ?

2005-10-03 Thread René Tegel

Hi,

May i add to that that 'order by' also seems involved, see below. This 
can lead to really unexpected errors... "order by 1.0 * b / c" as 
workaround solves it btw.
Differating between floating point operator '/' and integer operator 
'DIV' like some program languages do would lead to predictable output.


regards,

rene

===
#select *, b/c, 1.0 * b/c from test2 order by b/c
a   b   c   b/c 1.0 * b/c
1   3   4   0   0.75
2   5   6   0   0.833
5   6   7   0   0.857142857142857
6   6   8   0   0.75
7   7   8   0   0.875
3   7   6   1   1.17
4   6   6   1   1.0
8   8   8   1   1.0
9   9   8   1   1.125
10  10  8   1   1.25
11  9   8   1   1.125
12  8   8   1   1.0
13  11  8   1   1.375
14  13  8   1   1.625
15  12  8   1   1.5

#select *, b/c, 1.0 * b/c from test2 order by 1.0*b/c
a   b   c   b/c 1.0 * b/c
1   3   4   0   0.75
6   6   8   0   0.75
2   5   6   0   0.833
5   6   7   0   0.857142857142857
7   7   8   0   0.875
4   6   6   1   1.0
8   8   8   1   1.0
12  8   8   1   1.0
9   9   8   1   1.125
11  9   8   1   1.125
3   7   6   1   1.17
10  10  8   1   1.25
13  11  8   1   1.375
15  12  8   1   1.5
14  13  8   1   1.625




Ralf Junker wrote:

Hello DRH,


3. If the division of INTEGERs can not be stored as an INTEGER 
(i.e. if a % b != 0), the result should be returned as a REAL.




create table t1( a integer, b integer);
insert into t1 values(5,2);
update t1 set a=a/b;

If your rule above was in force, this would leave
T1.A holding 2.5, which is incompatible with the 
way other database engines work.



Well, understandable. But suppose that's exactly what one wants to do? How to 
achieve this using the current implementation of sqlite3?

On the other hand, I think that the following, currently implemented behaviour 
of sqlite3 is also incompatible with the way other database engines work. Where 
they return 2.5 for real type columns, sqlite3 does not:

  create table t1 (a real, b real);
  insert into t1 values (5,2);
  select a / b from t1;
  2

So the final question biols down to: How can I reliably guarantee a real type 
result for divisions on real typed columns even if they happen to contain 
integers? I cant't believe I always have to use a workaround like this:

  select 1.0 * a / b from t1; 


I am sure there must be a better possibility without the extra multiplication! 
Or is there not?

Regards,

Ralf  





RE: [sqlite] Problem/Bug: "SELECT 5 / 2;" returns 2 ?

2005-10-03 Thread Jackson, Douglas H
Perhaps not a solution, but a workaround:
Try coercing the data entering the table into
a value recognizable as a real:

Create trigger t_t1i after insert on t1
Begin
  Update t1 set a = 1.0 * a, b = 1.0 * b
  Where rowid = new.rowid;
End;

Create trigger t_t1u after update on t1
Begin
   Update t1 set a = 1.0 * a, b = 1.0 * b
   Where rowid = new.rowid;
End;

The table will then hold reals in all cases.

Expressions then work without change:
  Select a/b from t1;
  Update a set a = a / b;

Doug

-Original Message-
From: Ralf Junker [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 03, 2005 7:12 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Problem/Bug: "SELECT 5 / 2;" returns 2 ?

Hello DRH,

>> 3. If the division of INTEGERs can not be stored as an INTEGER 
>>(i.e. if a % b != 0), the result should be returned as a REAL.
>> 
>
>create table t1( a integer, b integer);
>insert into t1 values(5,2);
>update t1 set a=a/b;
>
>If your rule above was in force, this would leave
>T1.A holding 2.5, which is incompatible with the 
>way other database engines work.

Well, understandable. But suppose that's exactly what one wants to do?
How to achieve this using the current implementation of sqlite3?

On the other hand, I think that the following, currently implemented
behaviour of sqlite3 is also incompatible with the way other database
engines work. Where they return 2.5 for real type columns, sqlite3 does
not:

  create table t1 (a real, b real);
  insert into t1 values (5,2);
  select a / b from t1;
  2

So the final question biols down to: How can I reliably guarantee a real
type result for divisions on real typed columns even if they happen to
contain integers? I cant't believe I always have to use a workaround
like this:

  select 1.0 * a / b from t1; 

I am sure there must be a better possibility without the extra
multiplication! Or is there not?

Regards,

Ralf  



RE: [sqlite] Bitwise comparison -- consider not getting bit

2005-10-03 Thread Griggs, Donald
 Regarding:
"...What's the best way to do a bitwise comparison in a sql query...?"

Hi Debra,

Dennis Cote gave you a direct answer to your question -- since sqlite
supports bit operations directly in SQL.

But I wondered if you might want to evaluate dispensing with bit-wise
variables and using a more standard SQL approach -- a field for each
variable.

Even with the slightly bigger database, I should think table scans will be
faster, and if an index on one of these fields is ever called for, it will
be trivially easy to add.

You might find that, (unless you're writing an embedded tiny app) even with
many records in the database, only a very few pennies worth of additional
disk space would be required.

Increased portability and easier debugging are other bonuses.  E.g. Imagine
the blank stare you might encounter when you say, "Oh yes, it's easy for you
to run queries on the database for importing into your spreadsheet -- just
parse out the bit flags per our source spec."


Donald Griggs


Opinions are not necessarily those of Misys Healthcare Systems nor its board
of directors.


-Original Message-
From: debra f [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 03, 2005 12:10 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] Bitwise comparison



Re: [sqlite] Importing NOT Working (pls)

2005-10-03 Thread Puneet Kishor


On Oct 3, 2005, at 11:44 AM, Richard wrote:


Well,

Did this:

sqlite3 test2.db
create Table T (A, B, C );
.separator ,
.import 'sqtest2.txt' T

It looks like it working, but the file size is still
4K and not 170 Megs.

Please note:
I exported this database as a Tab delimiter file,
then as a Comma, delimiter file...

** Got it to import, however it only imports the first record
ie:


it is likely that your line endings are Mac (you are on a Mac, iirc). 
Open the tab file in a text editor such as BBEdit (or Textwrangler -- 
free from Barebones) and change the line endings to Unix. Then try 
again.





sqlite> select * from T;
-180,90,NaN
sqlite>

There's a few more hundred thousands.
is there suppose to be some kinda of loop statement
like repeat again..

TKS-
Richard


--
Puneet Kishor



Re: [sqlite] Rewrite of where.c without DOUBLE Values

2005-10-03 Thread Dennis Cote

Sankara Narayanan wrote:


Dear Hipp and all,

We request you to provide guidelines for the implementation of where.c 
without using any of the DOUBLE values. We need to find the bestIndex 
calculation with all integer variables and integer values. We converted 
all doubles to integers by typecasting (we use #define as double 
overriding the DOUBLE definition in our C Libraries) and thus we could 
compile the library for our ARM 7 platform. 

We first open a database using sqlite3_open and this function succeeds. 
When we try to run the CREATE TABLE Command, we find that 
sqlite3WhereBegin is called, and we find that the command execution 
returns with error 0x1A (File Not a database error). 

We have modified only the values in where.c with the integer values as 
mentioned in my earlier mail but we think that this could cause problems 
as we might be messing up the bestIndex finding algorithm with these 
changes. I request you to please review the code that is sent earlier and 
provide comments/guidelines on how we could implement the bestIndex 
algorithm using integer values (to the closest possible working 
algorithm). 

Please note that in our schematics, we are also creating indices for 
tables that have VARCHAR fields. 


I request you to kindly look into this problem at the earliest.

Thank you,

With Regards,
Sankara Narayanan
Philips Innovation Campus
No 1, Murphy Road,
Ulsoor, Bangalore - 560008.
Ph - 0091-80-25579000 Extn 5121

"Utthistatha Jaagrata Praapya Varaan Nibodhatha"
 

Your requests sound rather urgent. Perhaps you should look at getting a 
professional support contract to deal with this issue. More information 
is available at http://www.hwaci.com/sw/sqlite/prosupport.html. This is 
the most likely way to get Richard Hipp to look at your issue immediately.


Dennis Cote


[sqlite] ANN: Sqlite3Explorer version 2.0 released

2005-10-03 Thread Cariotoglou Mike
this is a major release, with a lot of changes. please see the readme at
www.singular.gr/sqlite.
Pls read the whole page carefully, as support for datatypes is now a lot
more powerful, but slightly different than
the previous versions.
Report users : you will need to download an extra dll, it is bookmarked
in the above link.

you can see the changes at a glance in
www.singular.gr/sqlite/changes.htm




Re: [sqlite] Problem/Bug: "SELECT 5 / 2;" returns 2 ?

2005-10-03 Thread Ralf Junker
Hello DRH,

>> 3. If the division of INTEGERs can not be stored as an INTEGER 
>>(i.e. if a % b != 0), the result should be returned as a REAL.
>> 
>
>create table t1( a integer, b integer);
>insert into t1 values(5,2);
>update t1 set a=a/b;
>
>If your rule above was in force, this would leave
>T1.A holding 2.5, which is incompatible with the 
>way other database engines work.

Well, understandable. But suppose that's exactly what one wants to do? How to 
achieve this using the current implementation of sqlite3?

On the other hand, I think that the following, currently implemented behaviour 
of sqlite3 is also incompatible with the way other database engines work. Where 
they return 2.5 for real type columns, sqlite3 does not:

  create table t1 (a real, b real);
  insert into t1 values (5,2);
  select a / b from t1;
  2

So the final question biols down to: How can I reliably guarantee a real type 
result for divisions on real typed columns even if they happen to contain 
integers? I cant't believe I always have to use a workaround like this:

  select 1.0 * a / b from t1; 

I am sure there must be a better possibility without the extra multiplication! 
Or is there not?

Regards,

Ralf  



[sqlite] Importing NOT Working (pls)

2005-10-03 Thread Richard

Well,

Did this:

sqlite3 test2.db
create Table T (A, B, C );
.separator ,
.import 'sqtest2.txt' T

It looks like it working, but the file size is still
4K and not 170 Megs.

Please note:
I exported this database as a Tab delimiter file,
then as a Comma, delimiter file...

** Got it to import, however it only imports the first record
ie:

sqlite> select * from T;
-180,90,NaN
sqlite>

There's a few more hundred thousands.
is there suppose to be some kinda of loop statement
like repeat again..

TKS-
Richard


Re: [sqlite] Bitwise comparison

2005-10-03 Thread Dennis Cote

debra f wrote:


What's the best way to do a bitwise comparison in a sql query
such as the one indicated below - for example - i have one
Indicator field (currently defined as numeric) in my table which
is being used to store a variety of indicators (rather than
having a slew of boolean columns)

eg (random examples):

byte 1 indicates IsRetired (val 1)
byte 2 indicates IsOnDisability (val 2)
...
byte 4 indicates IsOverSixFeetTall (val 8)

ex: if the Indicator value = 9 (byte 1001) then IsRetired = true
,IsOnDisability = false and IsOverSixFeetTall = true

In vb - to determine whether a hex flag is on or not, we do a
bitwise comparison such as 


IsRetired = (Indicator and 1)
IsOnDisability = (Indicator and 2)
IsOverSixFeetTall = (Indicator and 8)

How do I mimic this sort of behavior in sqlite?

For example  -

Select * from MyTable Where (Indicator and 1)

Any help is appreciated.


Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag

 


Debra,

You need the bitwise operators & (and), | (or), and ~ (not).

IsRetired = (Indicator & 1)
IsOnDisability = (Indicator & 2)
IsOverSixFeetTall = (Indicator & 8)

These values will be non-zero if the condition is true.

Select * from MyTable Where Indicator & 1;

You use the | operator to set the condition and & with the complement to clear.

Update MyTable
set Indicator = Indicator | 1,  -- set IsRetired
set Indicator = Indiocator & ~2 -- clear IsOnDisability
where Indicator & 8 


HTH
Dennis Cote





[sqlite] Rewrite of where.c without DOUBLE Values

2005-10-03 Thread Sankara Narayanan
Dear Hipp and all,

We request you to provide guidelines for the implementation of where.c 
without using any of the DOUBLE values. We need to find the bestIndex 
calculation with all integer variables and integer values. We converted 
all doubles to integers by typecasting (we use #define as double 
overriding the DOUBLE definition in our C Libraries) and thus we could 
compile the library for our ARM 7 platform. 

We first open a database using sqlite3_open and this function succeeds. 
When we try to run the CREATE TABLE Command, we find that 
sqlite3WhereBegin is called, and we find that the command execution 
returns with error 0x1A (File Not a database error). 

We have modified only the values in where.c with the integer values as 
mentioned in my earlier mail but we think that this could cause problems 
as we might be messing up the bestIndex finding algorithm with these 
changes. I request you to please review the code that is sent earlier and 
provide comments/guidelines on how we could implement the bestIndex 
algorithm using integer values (to the closest possible working 
algorithm). 

Please note that in our schematics, we are also creating indices for 
tables that have VARCHAR fields. 

I request you to kindly look into this problem at the earliest.

Thank you,
 
With Regards,
Sankara Narayanan
Philips Innovation Campus
No 1, Murphy Road,
Ulsoor, Bangalore - 560008.
Ph - 0091-80-25579000 Extn 5121

"Utthistatha Jaagrata Praapya Varaan Nibodhatha"

[sqlite] Bitwise comparison

2005-10-03 Thread debra f
What's the best way to do a bitwise comparison in a sql query
such as the one indicated below - for example - i have one
Indicator field (currently defined as numeric) in my table which
is being used to store a variety of indicators (rather than
having a slew of boolean columns)

eg (random examples):

byte 1 indicates IsRetired (val 1)
byte 2 indicates IsOnDisability (val 2)
...
byte 4 indicates IsOverSixFeetTall (val 8)

ex: if the Indicator value = 9 (byte 1001) then IsRetired = true
,IsOnDisability = false and IsOverSixFeetTall = true

In vb - to determine whether a hex flag is on or not, we do a
bitwise comparison such as 

IsRetired = (Indicator and 1)
IsOnDisability = (Indicator and 2)
IsOverSixFeetTall = (Indicator and 8)

How do I mimic this sort of behavior in sqlite?

For example  -

Select * from MyTable Where (Indicator and 1)

Any help is appreciated.


Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag


Re: [sqlite] Sqlite & NFS

2005-10-03 Thread drh
[EMAIL PROTECTED] wrote:
> Hello,
> I'm considering using sqlite in a system where the database might be
> accessed concurrently from several machines over NFS. I'm aware of 
> locking issues & NFS but I have a couple of questions:
> 
> - Could an NFS-level failure cause data inconsistency, or can 
> sqlite handle such errors?

If NFS locks do not work correctly, you can get massive
data corruption.  Easily.

> - I'm using Linux 2.4/2.6 machines. Anyone knows if their NFS 
> implementation suffers from any locking issues?
> 

I occasionally use a Linux 2.6 system with NFS and the NFS locking
on it does not work right.  But I do not think that is a function
of the kernel so much as it is the NFS setup on that particular
network.
--
D. Richard Hipp <[EMAIL PROTECTED]>



Re: RE: [sqlite] SQLite kind-of memory leak (PATCH) - bug reports

2005-10-03 Thread drh
Clifford Wolf <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> On Mon, Oct 03, 2005 at 09:02:38AM -0400, [EMAIL PROTECTED] wrote:
> > You are right: this is not a real memory leak.
> > [..]
> 
> in fact, for a program which is eg. continously using mktemp() (or a
> simmilar but not unsecure api) for creating temporary databases it is a
> real memory leak, because the hash table will grow one entry for every
> temporary database created.
> 

I added a new regression test named manydb.test to prove that the
above is not a problem.

I also added code to deallocate the hash tables when their size
reaches zero.  This is pointless code that is there only to make
valgrind happy.  But I get complaints about valgrind frequently
enough that I've grown weary of reading them.  So now SQLite
is a little bigger and a little slower, but at least valgrind
doesn't complain anymore.
--
D. Richard Hipp <[EMAIL PROTECTED]>



RE: RE: [sqlite] SQLite kind-of memory leak (PATCH) - bug reports

2005-10-03 Thread Thomas Briggs

   While I can understand your general sentiment, allowing minor
problems like this to clutter the output from valgrind makes spotting
the real errors amidst the noise more difficult.  Eventually, when
enough of these types of problems exist, valgrind stops being used
altogether, because it's too time consuming to inspect the output.

   In short, I guess my point is that this kind of thing is another
example of "broken window syndrome" - keeping the small things tidy
makes everyone more likely to keep the big things tidy too.

   -Tom

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Monday, October 03, 2005 9:03 AM
> To: sqlite-users@sqlite.org
> Subject: Re: RE: [sqlite] SQLite kind-of memory leak (PATCH) 
> - bug reports
> 
> "Griggs, Donald" <[EMAIL PROTECTED]> wrote:
> > > 
> > > I'm using valgrind for checking for memory leaks in SPL. When 
> > > profiling scripts which do access SQLite databases, I've 
> found that 
> > > the lockHash and openHash data structures in os_unix.c 
> don't get freed.
> > > 
> > > I wouldn't consider that a real memory leak, but it 
> doesn't look nice 
> > > in memory profilers such as valgrind. That's why I recommend the 
> > > attached patch. Please let me know how you think about it..
> > > 
> >
> 
> You are right: this is not a real memory leak.
> 
> I am disinclined to add code to SQLite that serves no purpose
> other than to make the output of valgrind look better.  valgrind
> is a nice tool for tracking down memory allocation problems.
> (SQLite uses a different mechanism, but that should not be
> taken as a slight by valgrind.)  But I do not believe that
> valgrind should become an end in itself.  I will certainly make
> whatever changes to SQLite are necessary to fix *real* memory
> leaks.  I would even be willing to modify existing code to
> better suit valgrind as long as it doesn't add complexity
> or have a run-time cost.  But the changes submitted do have
> a run-time cost, and while that cost is very small (perhaps
> even unmeasurable) it is finite.  We have worked *very* hard
> to remove such minor costs from SQLite and it would be a shame
> to add them back, just so that the output of a diagnostic
> tool could look nicer.
> 
> --
> D. Richard Hipp <[EMAIL PROTECTED]>
> 
> 


Re: [sqlite] Speed Test not work (pt2)

2005-10-03 Thread Dennis Cote

Richard Nagle wrote:


Well,

Did this:

sqlite3 test2.db
create Table T (A, B, C );
.separator ,
.import 'sqtest2.txt' T

It looks like it working, but the file size is still
4K and not 170 Megs.

Please note:
I exported this database as a Tab delimiter file,
then as a Comma, delimiter file...

** Got it to import, however it only imports the first record
ie:

sqlite> select * from T;
-180,90,NaN
sqlite>

There's a few more hundred thousands.
is there suppose to be some kinda of loop statement
like repeat again..

TKS-




Richard


Richard,

Here is a trace of the execution on my machine with a sample file that 
has only 2 lines.


C:\Documents and Settings\DennisC>sqlite3 test2.db
SQLite version 3.2.7
Enter ".help" for instructions
sqlite> create table t(A,B,C);
sqlite> create index I on T(A);
sqlite> .separator ,
sqlite> .import test2.csv T
sqlite> .mode column
sqlite> .header on
sqlite> select * from T;
A   B   C
--  --  --
-18090  NaN
200 50  103.9
sqlite>

My CSV file has the following two lines:

-180,90,NaN
200,50,103.9

I suspect there must be something strange about your CSV file. If you 
zip it up and send it to me I will give it a try on my end.


Dennis Cote




Re: [sqlite] Redirecting stderr to a file

2005-10-03 Thread Jay Sprenkle
 cat yourfile 2>somenewfile.txt


On 10/3/05, Downey, Shawn <[EMAIL PROTECTED]> wrote:
>
> When working from the command line I can redirect the stdout to a file
> with the command .output. Is there a similar way to redirect stderr to
> a file? Thanks you.
>
>
>
> Shawn M. Downey
>
> MPR Associates
>
> 10 Maxwell Drive, Suite 204
>
> Clifton Park, NY 12065
>
> 518-371-3983 x3 (work)
>
> 860-508-5015 (cell)
>
>
>
>
>


--
---
The Castles of Dereth Calendar: a tour of the art and architecture of
Asheron's Call
http://www.lulu.com/content/77264


[sqlite] Redirecting stderr to a file

2005-10-03 Thread Downey, Shawn
When working from the command line I can redirect the stdout to a file
with the command .output.  Is there a similar way to redirect stderr to
a file?  Thanks you.

 

Shawn M. Downey

MPR Associates

10 Maxwell Drive, Suite 204

Clifton Park, NY 12065

518-371-3983 x3 (work)

860-508-5015 (cell)

 



Re: [sqlite] SQLite kind-of memory leak (PATCH) - bug reports

2005-10-03 Thread drh
Clifford Wolf <[EMAIL PROTECTED]> wrote:
> 
> > but instead start a ticket at:
> > http://www.sqlite.org/cvstrac/tktnew
> 
> what shall I do with the patch? simply copy it to the 'bug description'
> text field? i haven't seen a file upload function in the interface.
> 

There is an "[attach]" hyperlink on the upper right of the ticket
viewer page.
--
D. Richard Hipp <[EMAIL PROTECTED]>



Re: RE: [sqlite] SQLite kind-of memory leak (PATCH) - bug reports

2005-10-03 Thread Clifford Wolf
Hi,

On Mon, Oct 03, 2005 at 09:02:38AM -0400, [EMAIL PROTECTED] wrote:
> You are right: this is not a real memory leak.
> [..]

in fact, for a program which is eg. continously using mktemp() (or a
simmilar but not unsecure api) for creating temporary databases it is a
real memory leak, because the hash table will grow one entry for every
temporary database created.

> [..] just so that the output of a diagnostic tool could look nicer.

what about an sqlite3_cleanup() function which does such cleanups? then it
would add no overhead at all to the library. Right now it is impossible for
a host application to do such cleanups because the allocated memory is only
referenced by static variables in os_unix.c. I could provide a patch which
adds an sqlite3_cleanup() api.

it would even possible to put that code path into a seperate elf section so
it is not paged into the physical memory unless it actually is used by the
application, if the incrased code size would be your next argument. but I
think that this would be overkill.

yours,
 - clifford

--
    ___    _  __  _ _ www.rocklinux.org
|  _ \ / _ \ / ___| |/ / | |   (_)_ __  _   ___  __
| |_) | | | | |   | ' /  | |   | | '_ \| | | \ \/ /
|  _ <| |_| | |___| . \  | |___| | | | | |_| |>  <
|_| \_\\___/ \|_|\_\ |_|_|_| |_|\__,_/_/\_\


Re: [sqlite] SQLite kind-of memory leak (PATCH) - bug reports

2005-10-03 Thread Clifford Wolf
Hi,

thanks for the quick reply,

On Mon, Oct 03, 2005 at 08:35:10AM -0400, Griggs, Donald wrote:
> Page http://www.sqlite.org/support.html Suggests that you *not* directly
> email the (actually pretty responsive) author,

the page says:

Please do not send email directly to the author of SQLite
unless [..] You are working on an open source project.

and there are plenty of open source projects with my name on them, so I
thought it would be ok.

> but instead start a ticket at:
> http://www.sqlite.org/cvstrac/tktnew

what shall I do with the patch? simply copy it to the 'bug description'
text field? i haven't seen a file upload function in the interface.

yours,
 - clifford

--
L I N : B I T   ___
 ___ __ _  |_  |  The OSS cluster synchronization tool for
/ __(_-http://oss.linbit.com/csync2/ ] ---
   /___/
 
"This 'telephone' has too many shortcomings to be seriously considered as a
means of communication." - Western Union internal memo, 1876.
 


[sqlite] Sqlite & NFS

2005-10-03 Thread gammal . sqlite
Hello,
I'm considering using sqlite in a system where the database might be accessed 
concurrently from several machines over NFS. I'm aware of locking issues & NFS 
but I have a couple of questions:

- Could an NFS-level failure cause data inconsistency, or can sqlite handle 
such errors?
- I'm using Linux 2.4/2.6 machines. Anyone knows if their NFS implementation 
suffers from any locking issues?

Thanks a lot,
Mahmoud


--
This message was sent from a MailNull anti-spam account.  You can get
your free account and take control over your email by visiting the
following URL.

   http://mailnull.com/


Re: RE: [sqlite] SQLite kind-of memory leak (PATCH) - bug reports

2005-10-03 Thread drh
"Griggs, Donald" <[EMAIL PROTECTED]> wrote:
> > 
> > I'm using valgrind for checking for memory leaks in SPL. When 
> > profiling scripts which do access SQLite databases, I've found that 
> > the lockHash and openHash data structures in os_unix.c don't get freed.
> > 
> > I wouldn't consider that a real memory leak, but it doesn't look nice 
> > in memory profilers such as valgrind. That's why I recommend the 
> > attached patch. Please let me know how you think about it..
> > 
>

You are right: this is not a real memory leak.

I am disinclined to add code to SQLite that serves no purpose
other than to make the output of valgrind look better.  valgrind
is a nice tool for tracking down memory allocation problems.
(SQLite uses a different mechanism, but that should not be
taken as a slight by valgrind.)  But I do not believe that
valgrind should become an end in itself.  I will certainly make
whatever changes to SQLite are necessary to fix *real* memory
leaks.  I would even be willing to modify existing code to
better suit valgrind as long as it doesn't add complexity
or have a run-time cost.  But the changes submitted do have
a run-time cost, and while that cost is very small (perhaps
even unmeasurable) it is finite.  We have worked *very* hard
to remove such minor costs from SQLite and it would be a shame
to add them back, just so that the output of a diagnostic
tool could look nicer.

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



RE: [sqlite] SQLite kind-of memory leak (PATCH) - bug reports

2005-10-03 Thread Griggs, Donald
 Hi Clifford,

Page http://www.sqlite.org/support.html
Suggests that you *not* directly email the (actually pretty responsive)
author, but instead start a ticket at:

http://www.sqlite.org/cvstrac/tktnew


Donald Griggs


Opinions are not necessarily those of Misys Healthcare Systems nor its board
of directors.


-Original Message-
From: Clifford Wolf [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 03, 2005 8:00 AM
To: SQLite Users
Cc: [EMAIL PROTECTED]
Subject: [sqlite] SQLite kind-of memory leak (PATCH)

Hi,

I have sent the following mail to [EMAIL PROTECTED] about a month ago. But I got
no reply and as far as I can see my patch has not been applied in the sqlite
cvs so far.

If [EMAIL PROTECTED] is the wrong address to send sqlite development issues,
what is the right one? I can only find a pointer to this 'sqlite users'
list on the webpage.

yours,
 - clifford

On Mon, Sep 12, 2005 at 01:04:13PM +0200, Clifford Wolf wrote:
> Hi,
> 
> I'm the developer of a scripting language called SPL. This scripting 
> language also has a module for accessing sqlite databases.
> 
> I'm using valgrind for checking for memory leaks in SPL. When 
> profiling scripts which do access SQLite databases, I've found that 
> the lockHash and openHash data structures in os_unix.c don't get freed.
> 
> I wouldn't consider that a real memory leak, but it doesn't look nice 
> in memory profilers such as valgrind. That's why I recommend the 
> attached patch. Please let me know how you think about it..
> 
> yours,
>  - clifford

--snip--
Clifford Wolf:
Fixed kind-of-memory-leak in sqlite-3.2.0 for unix platforms
(This is not really a memory leak - just unfreed memory which
is confusing valgrind and other leak checkers..)

--- sqlite-3.2.0/src/os_unix.c  2005-09-09 23:21:57.0 +0200
+++ sqlite-3.2.0/src/os_unix.c  2005-09-10 22:38:29.0 +0200
@@ -231,6 +231,9 @@
 static Hash lockHash = { SQLITE_HASH_BINARY, 0, 0, 0, 0, 0 };  static Hash
openHash = { SQLITE_HASH_BINARY, 0, 0, 0, 0, 0 };
 
+static int lockHashCounter = 0;
+static int openHashCounter = 0;
+
 
 #ifdef SQLITE_UNIX_THREADS
 /*
@@ -302,6 +305,8 @@
   pLock->nRef--;
   if( pLock->nRef==0 ){
 sqlite3HashInsert(, >key, sizeof(pLock->key), 0);
+if (--lockHashCounter == 0)
+  sqlite3HashClear();
 sqliteFree(pLock);
   }
 }
@@ -313,6 +318,8 @@
   pOpen->nRef--;
   if( pOpen->nRef==0 ){
 sqlite3HashInsert(, >key, sizeof(pOpen->key), 0);
+if (--openHashCounter == 0)
+  sqlite3HashClear();
 sqliteFree(pOpen->aPending);
 sqliteFree(pOpen);
   }
@@ -360,6 +367,7 @@
 pLock->cnt = 0;
 pLock->locktype = 0;
 pOld = sqlite3HashInsert(, >key, sizeof(key1), pLock);
+lockHashCounter++;
 if( pOld!=0 ){
   assert( pOld==pLock );
   sqliteFree(pLock);
@@ -383,6 +391,7 @@
 pOpen->nPending = 0;
 pOpen->aPending = 0;
 pOld = sqlite3HashInsert(, >key, sizeof(key2), pOpen);
+openHashCounter++;
 if( pOld!=0 ){
   assert( pOld==pOpen );
   sqliteFree(pOpen);
--snap--

--
  L The SPL Programming Language
SP  P L http://www.clifford.at/spl/
  L 
   S PL An object oriented, stateful, simple, small, c-like,
 P  embeddable, feature rich, dynamic scripting language
 
Qrpelcgvat ebg13 ivbyngrf gur QZPN! Cercner gb or fhrq!!
 


RE: [sqlite] How to speed up SQLite

2005-10-03 Thread Thomas Briggs

   Given my understanding of the codebase (you get to decide what that's
worth), the value of the synchronous pragma determines decisions going
forward, so changing it mid-process should impact only transaction
handling from that point forward.  I do know, however, that there are
places in the code where special consideration is given to the
possibility of the synchronous pragma having been changed mid-process,
so it isn't necessarily a trouble-free approach, I don't think.
Changing its value only when no transaction is active would seem pretty
safe to me.

   -Tom

> -Original Message-
> From: pippi pohopper [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, October 01, 2005 12:31 PM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] How to speed up SQLite
> 
> I'm experimenting with SQLite and found there's a big 
> difference in speed depending on the setting of PRAGMA SYNCHRONOUS.
> 
> I understand that settings other than"2" for this parameter 
> don't guarantee that data is safely stored on disk when che 
> COMMIT statement terminates.
>  
> I wonder if it is possible to mix various settings of PRAGMA 
> SYNCHRONOUS in the same program, i.e. issue a "PRAGMA 
> SYNCHRONOUS 2" before performing very important transactions 
> and using a lower PRAGMA SYNCHRONOUS value before performing 
> less important transactions.
>  
> If this is not possible because PRAGMA SYNCHRONOUS can only 
> be issued once when attaching to the database, I'm 
> considering dividing to workload between two processes or 
> threads that write on the same database. One thread woud use 
> "PRAGMA SYNCHRONOUS 2" and would be responsible for critical 
> database updates and the other thread would use "PRAGMA 
> SYNCHRONOUS 0" and would be responsible for less critical updates.
>  
> Anybody knows if either of this two solutions will work 
> reliably ? Which one is the best (in terms of data safety) ?
> 
> Thank you, bye
> 
> 
>   
> -
> Yahoo! Messenger: chiamate gratuite in tutto il mondo 
> 


[sqlite] SQLite kind-of memory leak (PATCH)

2005-10-03 Thread Clifford Wolf
Hi,

I have sent the following mail to [EMAIL PROTECTED] about a month ago. But I
got no reply and as far as I can see my patch has not been applied in the
sqlite cvs so far.

If [EMAIL PROTECTED] is the wrong address to send sqlite development issues,
what is the right one? I can only find a pointer to this 'sqlite users'
list on the webpage.

yours,
 - clifford

On Mon, Sep 12, 2005 at 01:04:13PM +0200, Clifford Wolf wrote:
> Hi,
> 
> I'm the developer of a scripting language called SPL. This scripting
> language also has a module for accessing sqlite databases.
> 
> I'm using valgrind for checking for memory leaks in SPL. When profiling
> scripts which do access SQLite databases, I've found that the lockHash and
> openHash data structures in os_unix.c don't get freed.
> 
> I wouldn't consider that a real memory leak, but it doesn't look nice in
> memory profilers such as valgrind. That's why I recommend the attached
> patch. Please let me know how you think about it..
> 
> yours,
>  - clifford

--snip--
Clifford Wolf:
Fixed kind-of-memory-leak in sqlite-3.2.0 for unix platforms
(This is not really a memory leak - just unfreed memory which
is confusing valgrind and other leak checkers..)

--- sqlite-3.2.0/src/os_unix.c  2005-09-09 23:21:57.0 +0200
+++ sqlite-3.2.0/src/os_unix.c  2005-09-10 22:38:29.0 +0200
@@ -231,6 +231,9 @@
 static Hash lockHash = { SQLITE_HASH_BINARY, 0, 0, 0, 0, 0 };
 static Hash openHash = { SQLITE_HASH_BINARY, 0, 0, 0, 0, 0 };
 
+static int lockHashCounter = 0;
+static int openHashCounter = 0;
+
 
 #ifdef SQLITE_UNIX_THREADS
 /*
@@ -302,6 +305,8 @@
   pLock->nRef--;
   if( pLock->nRef==0 ){
 sqlite3HashInsert(, >key, sizeof(pLock->key), 0);
+if (--lockHashCounter == 0)
+  sqlite3HashClear();
 sqliteFree(pLock);
   }
 }
@@ -313,6 +318,8 @@
   pOpen->nRef--;
   if( pOpen->nRef==0 ){
 sqlite3HashInsert(, >key, sizeof(pOpen->key), 0);
+if (--openHashCounter == 0)
+  sqlite3HashClear();
 sqliteFree(pOpen->aPending);
 sqliteFree(pOpen);
   }
@@ -360,6 +367,7 @@
 pLock->cnt = 0;
 pLock->locktype = 0;
 pOld = sqlite3HashInsert(, >key, sizeof(key1), pLock);
+lockHashCounter++;
 if( pOld!=0 ){
   assert( pOld==pLock );
   sqliteFree(pLock);
@@ -383,6 +391,7 @@
 pOpen->nPending = 0;
 pOpen->aPending = 0;
 pOld = sqlite3HashInsert(, >key, sizeof(key2), pOpen);
+openHashCounter++;
 if( pOld!=0 ){
   assert( pOld==pOpen );
   sqliteFree(pOpen);
--snap--

--
  L The SPL Programming Language
SP  P L http://www.clifford.at/spl/
  L 
   S PL An object oriented, stateful, simple, small, c-like,
 P  embeddable, feature rich, dynamic scripting language
 
Qrpelcgvat ebg13 ivbyngrf gur QZPN! Cercner gb or fhrq!!
 


[sqlite] BestIndex function not working if all doubles are converted into integer values - Urgent help required

2005-10-03 Thread Sankara Narayanan
Hi

We are in the process of porting sqlite 3.2.5 onto an Arm7 
processor based embedded application with no FloatingPoint support. 
We are switching OFF the double variables.( We are doing a typedef of 
double to int). We are now facing some problems while
running our ported sqlite. We doubt the function bestIndex where we have 
changed the double to int. I am attaching the bestIndex modified for
integers. Please help us whether we have done the right modifications for 
switching OFF double. (double typecasted to int).
Please advise.


static double bestIndex(
  Parse *pParse,  /* The parsing context */
  WhereClause *pWC,   /* The WHERE clause */
  struct SrcList_item *pSrc,  /* The FROM clause term to search */
  Bitmask notReady,   /* Mask of cursors that are not available */
  ExprList *pOrderBy, /* The order by clause */
  Index **ppIndex,/* Make *ppIndex point to the best index */
  int *pFlags,/* Put flags describing this choice in 
*pFlags */
  int *pnEq   /* Put the number of == or IN constraints 
here */
){
  WhereTerm *pTerm;
  Index *bestIdx = 0; /* Index that gives the lowest cost */
  double lowestCost = 0; /* The cost of using bestIdx */
  int bestFlags = 0;  /* Flags associated with bestIdx */
  int bestNEq = 0;/* Best value for nEq */
  int iCur = pSrc->iCursor;   /* The cursor of the table to be accessed */
  Index *pProbe;  /* An index we are evaluating */
  int rev;/* True to scan in reverse order */
  int flags;  /* Flags associated with pProbe */
  int nEq;/* Number of == or IN constraints */
  double cost;/* Cost of using pProbe */

  TRACE(("bestIndex: tbl=%s notReady=%x\n", pSrc->pTab->zName, notReady));

  /* Check for a rowid=EXPR or rowid IN (...) constraints
  */
  pTerm = findTerm(pWC, iCur, -1, notReady, WO_EQ|WO_IN, 0);
  if( pTerm ){
Expr *pExpr;
*ppIndex = 0;
bestFlags = WHERE_ROWID_EQ;
if( pTerm->operator & WO_EQ ){
  /* Rowid== is always the best pick.  Look no further.  Because only
  ** a single row is generated, output is always in sorted order */
  *pFlags = WHERE_ROWID_EQ | WHERE_UNIQUE;
  *pnEq = 1;
  TRACE(("... best is rowid\n"));
  return 0;
}else if( (pExpr = pTerm->pExpr)->pList!=0 ){
  /* Rowid IN (LIST): cost is NlogN where N is the number of list
  ** elements.  */
  lowestCost = pExpr->pList->nExpr;
  lowestCost *= estLog(lowestCost);
}else{
  /* Rowid IN (SELECT): cost is NlogN where N is the number of rows
  ** in the result of the inner select.  We have no way to estimate
  ** that value so make a wild guess. */
  lowestCost = 200;
}
TRACE(("... rowid IN cost: %.9g\n", lowestCost));
  }

  /* Estimate the cost of a table scan.  If we do not know how many
  ** entries are in the table, use 1 million as a guess.
  */
  pProbe = pSrc->pTab->pIndex;
  cost = pProbe ? pProbe->aiRowEst[0] : 100;
  TRACE(("... table scan base cost: %.9g\n", cost));
  flags = WHERE_ROWID_RANGE;

  /* Check for constraints on a range of rowids in a table scan.
  */
  pTerm = findTerm(pWC, iCur, -1, notReady, WO_LT|WO_LE|WO_GT|WO_GE, 0);
  if( pTerm ){
if( findTerm(pWC, iCur, -1, notReady, WO_LT|WO_LE, 0) ){
  flags |= WHERE_TOP_LIMIT;
  cost = cost * (1/3);  /* Guess that rowidEXPR eliminates two-thirds 
of rows */
}
TRACE(("... rowid range reduces cost to %.9g\n", cost));
  }else{
flags = 0;
  }

  /* If the table scan does not satisfy the ORDER BY clause, increase
  ** the cost by NlogN to cover the expense of sorting. */
  if( pOrderBy ){
if( sortableByRowid(iCur, pOrderBy, ) ){
  flags |= WHERE_ORDERBY|WHERE_ROWID_RANGE;
  if( rev ){
flags |= WHERE_REVERSE;
  }
}else{
  cost += cost*estLog(cost);
  TRACE(("... sorting increases cost to %.9g\n", cost));
}
  }
  if( costpNext){
int i;   /* Loop counter */
double inMultiplier = 1;

TRACE(("... index %s:\n", pProbe->zName));

/* Count the number of columns in the index that are satisfied
** by x=EXPR constraints or x IN (...) constraints.
*/
flags = 0;
for(i=0; inColumn; i++){
  int j = pProbe->aiColumn[i];
  pTerm = findTerm(pWC, iCur, j, notReady, WO_EQ|WO_IN, pProbe);
  if( pTerm==0 ) break;
  flags |= WHERE_COLUMN_EQ;
  if( pTerm->operator & WO_IN ){
Expr *pExpr = pTerm->pExpr;
flags |= WHERE_COLUMN_IN;
if( pExpr->pSelect!=0 ){
  inMultiplier *= 100;
}else if( pExpr->pList!=0 ){
  inMultiplier *= pExpr->pList->nExpr + 1;
}
  }
}
cost = pProbe->aiRowEst[i] * inMultiplier * estLog(inMultiplier);
nEq = i;
if( pProbe->onError!=OE_None && (flags & WHERE_COLUMN_IN)==0
 && nEq==pProbe->nColumn ){
  flags |= WHERE_UNIQUE;
   

[sqlite] sqlite3-3.2.1 execution error!

2005-10-03 Thread Ajay Radhakrishnan
Hello,

I tried compiling the source sqlite3-3.2.1 with the following commands on a
i686 machine distro rehat linux 9 with the following commands,

./configure
make
make install

And the above process returns successful message

and all the lib* libraries are present in /usr/local/lib, i can also invoke
sqlite3 by typing in the same at the prompt

I have created an application which uses GTK+-1.2 and sqlite3 , the
application compiles fine without any error but while trying to execute the
binary the following error surface,,

./main(This is the binary)

error while loading shared libraries: libsqlite3.so.0: cannot open shared
object file: No such file or directory

as mentioned above, i have cross-checked and these libraries are present in
/usr/local/lib and all have executable permissions,
The above library, libsqlite3.so.0 is linked with another library
libsqlite3.so.0.8.6

But the above process works fine if i replicate them on a i386 machine with
the same distro installed..