[sqlite] SQLite openning a database

2005-01-11 Thread John Richard Moser
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
http://rafb.net/paste/results/jRFmZD25.html
This is code from a package manager I'm writing based on SQLite.  These
two functions open a database, creating it if it doesn't exist.
While most of this isn't of general interest, I'd like to point out that
I create the database by opening it with open() using O_EXCL and
O_CREAT, and then close the file.  After that I call SQLite's
sqlite3_open() to open the database.
The reason I do this is so that the database can't be raced to create
arbitrary writes.  For example, I don't want to call sqlite3_open(),
have it find the database doesn't exist, then have a normal user insert
a symlink to /etc/fstab, and have sqlite3 "create" the database.
It should be reviewed whether this is a general concern (I haven't
audited SQLite, so I don't know), and if so, whether a function such as
sqlite3_sopen() to "open or securely create" a database should be made.
~ This may just be my paranoia.
- --
All content of all messages exchanged herein are left in the
Public Domain, unless otherwise explicitly stated.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFB5FrhhDd4aOud5P8RAl8vAJ4pynnJ/yaDp7a7BgsbpS/2XyjMqwCfdxY8
ImP68bs806lxnonwptinznw=
=VEF8
-END PGP SIGNATURE-


Re: [sqlite] add new column to table

2005-01-11 Thread Lloyd Thomas
EDIT
The only working example I can see is the following.
BEGIN TRANSACTION;
CREATE TEMPORARY TABLE t1_backup(a,b);
INSERT INTO t1_backup SELECT a,b FROM t1;
DROP TABLE t1;
CREATE TABLE t1(a,b);
INSERT INTO t1 SELECT a,b FROM t1_backup;
DROP TABLE t1_backup;
COMMIT;
I can not find any help or FAQ regarding UPDATES with SUB SELECTS. What is
the URL?
Lloyd
- Original Message - 
From: "Bert Verhees" <[EMAIL PROTECTED]>
To: 
Sent: Tuesday, January 11, 2005 7:55 AM
Subject: Re: [sqlite] add new column to table

Op maandag 10 januari 2005 23:56, schreef Lloyd Thomas:
Thanks. That is going OK but I am having a problem with updating the new
column with the info I need. It seems to update with the same entry from 
my
users table to all rows.

UPDATE call_data SET caller_name = (SELECT firstname || surname AS
'caller_name' FROM users WHERE extn_no = (SELECT extn_no FROM 
call_data));

I have missed something?
The FAQ gives a working example, I used it a lot, please try that.
Bert Verhees

- Original Message -
From: "Lloyd Thomas" <[EMAIL PROTECTED]>
To: 
Sent: Monday, January 10, 2005 9:08 PM
Subject: Re: [sqlite] add new column to table
> Thanks Paul,
>I have used that example before to recreate a table. 
> Can I
> use the same thing to recreate a table and populate a new column with
> data from a select query.
> The table I wish to recreate has an ID number in it and I wish to use
> this to get the forename and surname from another table.
>
> Lloyd
> - Original Message -
> From: "Paul Dixon" <[EMAIL PROTECTED]>
> To: 
> Sent: Monday, January 10, 2005 5:50 PM
> Subject: Re: [sqlite] add new column to table
>
>> Lloyd Thomas wrote:
>>>I wish to create a new column in a table and add data, which is 
>>>queried
>>>from another table.What is the best way?
>>
>> There's no "ALTER TABLE" support in the support language, so you have 
>> to
>> recreate the entire table and re-populate it.
>>
>> Check the FAQ: http://www.sqlite.org/faq.html#q13
>>
>> Paul
--
Met vriendelijke groet
Bert Verhees
ROSA Software




Re: [sqlite] add new column to table

2005-01-11 Thread Lloyd Thomas
The only working example I can see is the following.
BEGIN TRANSACTION;
CREATE TEMPORARY TABLE t1_backup(a,b);
INSERT INTO t1_backup SELECT a,b FROM t1;
DROP TABLE t1;
CREATE TABLE t1(a,b);
INSERT INTO t1 SELECT a,b FROM t1_backup;
DROP TABLE t1_backup;
COMMIT;I can see any help or FAQ regarding UPDATES with SUB SELECTS. What is 
the URL?Lloyd- Original Message - 
From: "Bert Verhees" <[EMAIL PROTECTED]>
To: 
Sent: Tuesday, January 11, 2005 7:55 AM
Subject: Re: [sqlite] add new column to table


Op maandag 10 januari 2005 23:56, schreef Lloyd Thomas:
Thanks. That is going OK but I am having a problem with updating the new
column with the info I need. It seems to update with the same entry from 
my
users table to all rows.

UPDATE call_data SET caller_name = (SELECT firstname || surname AS
'caller_name' FROM users WHERE extn_no = (SELECT extn_no FROM 
call_data));

I have missed something?
The FAQ gives a working example, I used it a lot, please try that.
Bert Verhees

- Original Message -
From: "Lloyd Thomas" <[EMAIL PROTECTED]>
To: 
Sent: Monday, January 10, 2005 9:08 PM
Subject: Re: [sqlite] add new column to table
> Thanks Paul,
>I have used that example before to recreate a table. Can 
> I
> use the same thing to recreate a table and populate a new column with
> data from a select query.
> The table I wish to recreate has an ID number in it and I wish to use
> this to get the forename and surname from another table.
>
> Lloyd
> - Original Message -
> From: "Paul Dixon" <[EMAIL PROTECTED]>
> To: 
> Sent: Monday, January 10, 2005 5:50 PM
> Subject: Re: [sqlite] add new column to table
>
>> Lloyd Thomas wrote:
>>>I wish to create a new column in a table and add data, which is 
>>>queried
>>>from another table.What is the best way?
>>
>> There's no "ALTER TABLE" support in the support language, so you have 
>> to
>> recreate the entire table and re-populate it.
>>
>> Check the FAQ: http://www.sqlite.org/faq.html#q13
>>
>> Paul
--
Met vriendelijke groet
Bert Verhees
ROSA Software 



Re: [sqlite] excessive malloc() calls

2005-01-11 Thread David Morel
Le mardi 11 janvier 2005 à 08:13 -0500, Steve Frierdich a écrit :
> Thanks Richard. We are using Sqlite on some military projects, and its 
> on the WinCE I am most concern on using Sqlite.

I would similarly be concerned about using WinCE in military
projects :-)

ooops

D.Morel


signature.asc
Description: Ceci est une partie de message	=?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=


Re: [sqlite] excessive malloc() calls

2005-01-11 Thread Steve Frierdich
Thanks Richard. We are using Sqlite on some military projects, and its 
on the WinCE I am most concern on using Sqlite.
Steve

D. Richard Hipp wrote:
Steve Frierdich wrote:
I have been noticing all the email messages about excessive malloc 
calls. Is there a serious bug in Sqlite about malloc being called 
excessively causing memory leaks in sqlite version 3? And if there 
is, is there a way to fix it the source code?

There are no memory leaks in SQLite version 3 that I am aware
of.  The automated test suite makes an extensive search for
memory leaks using an instrumented version of malloc and reports
that there are none.
There are no serious bugs in SQLite version 3 that I am aware
of.  The ORDER BY clause might cause more malloc()s to be done
than are strictly necessary.  But on a system with a good
malloc implementation, that will normally go unnoticed.
Nevertheless, we will be fixing the problem.