Re: [sqlite] SQLite: Porting to another Operating system.

2009-07-24 Thread chandan
D. Richard Hipp wrote:
> On Jul 24, 2009, at 8:37 AM, CityDev wrote:
>
>   
>> I'm new to SQLite. I would assume you would dump the tables to an  
>> external
>> format and then load them into the new database. I can't however see  
>> where
>> the documentation is for this kind of database management function.  
>> Anyone
>> know where I should look, or do you have to download the SQLite3  
>> application
>> to see it?
>> 
>
>
> SQLite database files are cross-platform.  All you have to do is copy  
> the file to the new machine.  There is no separate "external format".   
> The same database file format work on all platforms.
>
> I think the OP was asking what changes need to be made to SQLite in  
> order to get it to compile and run on a platform other than the ones  
> that are supported out of the box (unix, win32, os/2).  Here is a  
> quick summary:
>
> (1) Write a VFS implementation for the target platform.  Use the  
> os_unix.c, os_win.c, and os_os2.c files as a guide, if you like.  See  
> also the documentation on the sqlite3_vfs object.
>
> (2) Compile the amalgamation using -DSQLITE_OS_OTHER.  This disables  
> the built-in OS interface layer.
>
> (3) Before using SQLite in your application, call  
> sqlite3_vfs_register() to install your alternative OS driver.
>
>
> D. Richard Hipp
> d...@hwaci.com
>
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>   
Thanks for the reply. :-)
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] SQLite: Porting to another Operating system.

2009-07-24 Thread chandan
Hi,
I am using SQLite amalgamation package and linking the compiled 
sqlite3.o along with my application.  The application runs on x86 and 
MIPS (BIG Endian) processors  having Linux has its Operating system. 

We now have plans to port the application to a different Operating 
system. Is there any doc that offers guidelines for successfully porting 
SQLite to another operating system.

Regards,
chandan
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] writing images to an SQLite database using SQLite command line program.

2009-07-13 Thread chandan
Hi,
   I would like to know how to store images inside a SQLite database 
using the SQLite command line program.

consider the following example:

create table img_tbl (
   img_id int primary key,
   img blob);

In the above case how do I use the SQL "insert" statement to store 
images into the "img" column?

Regards,
chandan
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Value returned by sqlite3_column_bytes for strings

2009-07-03 Thread chandan
Thanks for the reply!

Simon Davies wrote:
> 2009/7/3 chandan <chandan.b...@globaledgesoft.com>:
>   
>> Hi all,
>>Consider the following scenario,
>>1. A table contains a column of type "text".
>>2. The value of this column for the first row is say "linux".
>>
>> If we execute the SQL statement: "select name from some_tbl where id = ?"
>> using sqlite3_step() API, then what is the value returned by
>> sqlite3_column_bytes(). Does the count include the '\0' byte (count ==
>> 6). If it does not include the '\0' byte the count should be 5.
>>
>> I executed the following program:
>>
>> /**/
>> #include 
>> #include 
>> #include 
>> #include 
>> #include "sqlite3.h"
>>
>> const char *update_db = "update some_tbl set name = ? where id = ?";
>> const char *read_db = "select name from some_tbl where id = ?";
>>
>> int32_t main(int argc, char *argv[])
>> {
>>sqlite3_stmt *stmt;
>>sqlite3 *db;
>>int32_t num_bytes;
>>char buf[100];
>>int32_t ret;
>>
>>if (argc != 2) {
>>fprintf(stderr, "Usage: %s \n", argv[0]);
>>goto out1;
>>}
>>
>>ret = sqlite3_initialize();
>>if (ret != SQLITE_OK) {
>>fprintf(stderr, "Unable to initialize db.\n");
>>goto out1;
>>}
>>
>>ret = sqlite3_open(argv[1], );
>>if (ret != SQLITE_OK) {
>>fprintf(stderr, "Unable to open database.\n");
>>goto out2;
>>}
>>
>>stmt = NULL;
>>ret = sqlite3_prepare_v2(db, update_db, strlen(update_db) + 1,
>> , NULL);
>>if (ret != SQLITE_OK) {
>>fprintf(stderr, "sqlite3_prepare_v2: %s.\n",
>>sqlite3_errmsg(db));
>>goto out3;
>>}
>>
>>ret = sqlite3_bind_text(stmt, 1, "linux", strlen("linux") + 1,
>>SQLITE_TRANSIENT);
>> 
>
> This will insert 6 bytes into the db - includes the trailing '\0'
>
>   
>>if (ret != SQLITE_OK) {
>>fprintf(stderr, "sqlite3_bind_text: %s.\n",
>>sqlite3_errmsg(db));
>>goto out4;
>>}
>>
>>ret = sqlite3_bind_int64(stmt, 2, 1);
>>if (ret != SQLITE_OK) {
>>fprintf(stderr, "sqlite3_bind_int64: %s.\n",
>>sqlite3_errmsg(db));
>>goto out4;
>>}
>>
>>ret = sqlite3_step(stmt);
>>if (ret != SQLITE_DONE) {
>>fprintf(stderr, "sqlite3_step: %s.\n",
>>sqlite3_errmsg(db));
>>goto out4;
>>}
>>
>>ret = sqlite3_finalize(stmt);
>>if (ret != SQLITE_OK) {
>>fprintf(stderr, "sqlite3_finalize: %s.\n",
>>sqlite3_errmsg(db));
>>}
>>
>>stmt = NULL;
>>ret = sqlite3_prepare_v2(db, read_db, strlen(read_db) + 1, ,
>> NULL);
>>if (ret != SQLITE_OK) {
>>fprintf(stderr, "sqlite3_prepare_v2: %s.\n",
>>sqlite3_errmsg(db));
>>goto out3;
>>}
>>
>>ret = sqlite3_bind_int64(stmt, 1, 1);
>>if (ret != SQLITE_OK) {
>>fprintf(stderr, "sqlite3_bind_int64: %s.\n",
>>sqlite3_errmsg(db));
>>goto out4;
>>}
>>
>>ret = sqlite3_step(stmt);
>>if (ret != SQLITE_ROW) {
>>fprintf(stderr, "sqlite3_step: %s.\n",
>>sqlite3_errmsg(db));
>>goto out4;
>>}
>>
>>num_bytes = sqlite3_column_bytes(stmt, 0);
>>printf("*** num_bytes = %d ***\n", num_bytes);
>>
>>memcpy(buf, sqlite3_column_text(stmt, 0), num_bytes);
>>printf("*** buf = %s ***\n", buf);
>>
>>exit(0);
>>
>>  out4:
>>ret = sqlite3_finalize(stmt);
>>  out3:
>>ret = sqlite3_close(db);
>>  out2:
>>ret = sqlite3_shutdown();
>>  out1:
>>exit(1);
>> }
>> /*/
>>
>>
>> The output shows that sqlite3_column_bytes() returns a count value that
>> includes the '\0'. Please correct me if I am arriving at the wrong
>> conclusion.
>> 
>
> This is what I would expect given that you are inserting a string that
> includes the '\0'. Your initial statement that the db contains 'linux'
> is wrong; it contains 'linux\0'.
>
> Regards,
> Simon
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>   

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Value returned by sqlite3_column_bytes for strings

2009-07-03 Thread chandan
Hi all,
Consider the following scenario,
1. A table contains a column of type "text".
2. The value of this column for the first row is say "linux".

If we execute the SQL statement: "select name from some_tbl where id = ?"
using sqlite3_step() API, then what is the value returned by 
sqlite3_column_bytes(). Does the count include the '\0' byte (count == 
6). If it does not include the '\0' byte the count should be 5.

I executed the following program:

/**/
#include 
#include 
#include 
#include 
#include "sqlite3.h"

const char *update_db = "update some_tbl set name = ? where id = ?";
const char *read_db = "select name from some_tbl where id = ?";

int32_t main(int argc, char *argv[])
{
sqlite3_stmt *stmt;
sqlite3 *db;
int32_t num_bytes;
char buf[100];
int32_t ret;
   
if (argc != 2) {
fprintf(stderr, "Usage: %s \n", argv[0]);
goto out1;
}

ret = sqlite3_initialize();
if (ret != SQLITE_OK) {
fprintf(stderr, "Unable to initialize db.\n");
goto out1;
}

ret = sqlite3_open(argv[1], );
if (ret != SQLITE_OK) {
fprintf(stderr, "Unable to open database.\n");
goto out2;
}

stmt = NULL;
ret = sqlite3_prepare_v2(db, update_db, strlen(update_db) + 1,
 , NULL);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_prepare_v2: %s.\n",
sqlite3_errmsg(db));
goto out3;
}

ret = sqlite3_bind_text(stmt, 1, "linux", strlen("linux") + 1,
SQLITE_TRANSIENT);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_bind_text: %s.\n",
sqlite3_errmsg(db));
goto out4;
}
   
ret = sqlite3_bind_int64(stmt, 2, 1);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_bind_int64: %s.\n",
sqlite3_errmsg(db));
goto out4;
}

ret = sqlite3_step(stmt);
if (ret != SQLITE_DONE) {
fprintf(stderr, "sqlite3_step: %s.\n",
sqlite3_errmsg(db));
goto out4;
}

ret = sqlite3_finalize(stmt);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_finalize: %s.\n",
sqlite3_errmsg(db));
}

stmt = NULL;
ret = sqlite3_prepare_v2(db, read_db, strlen(read_db) + 1, ,
 NULL);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_prepare_v2: %s.\n",
sqlite3_errmsg(db));
goto out3;
}

ret = sqlite3_bind_int64(stmt, 1, 1);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_bind_int64: %s.\n",
sqlite3_errmsg(db));
goto out4;
}

ret = sqlite3_step(stmt);
if (ret != SQLITE_ROW) {
fprintf(stderr, "sqlite3_step: %s.\n",
sqlite3_errmsg(db));
goto out4;
}

num_bytes = sqlite3_column_bytes(stmt, 0);
printf("*** num_bytes = %d ***\n", num_bytes);

memcpy(buf, sqlite3_column_text(stmt, 0), num_bytes);
printf("*** buf = %s ***\n", buf);
   
exit(0);

 out4:
ret = sqlite3_finalize(stmt);
 out3:
ret = sqlite3_close(db);
 out2:
ret = sqlite3_shutdown();
 out1:
exit(1);
}
/*/


The output shows that sqlite3_column_bytes() returns a count value that 
includes the '\0'. Please correct me if I am arriving at the wrong 
conclusion.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] unable to write the string "1.0" into a database table

2009-06-27 Thread chandan
I am really sorry, The correct code is given below:

//
#include 
#include 
#include 
#include 
#include 

const char *create_and_insert = "create table some_tbl (id int primary 
key, version text check (version in (\"1.0\")));"
"insert into some_tbl (id) values (1);";
const char *update_sql = "update some_tbl set version = ? where id = ?";

int32_t main(int32_t argc, char *argv[])
{
sqlite3 *db;
char *err_msg;
sqlite3_stmt *stmt;
int32_t ret;
   
if (argc != 2) {
fprintf(stderr, "Usage: %s .\n", argv[0]);
goto out1;
}

db = NULL;
ret = sqlite3_open(argv[1], );
if (ret != SQLITE_OK) {
fprintf(stderr, "Unable to open database.\n");
goto out1;
}

err_msg = NULL;
ret = sqlite3_exec(db, create_and_insert, NULL, NULL, _msg);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_exec: %s.\n", err_msg);
sqlite3_free(err_msg);
}
   
stmt = NULL;
ret = sqlite3_prepare_v2(db, update_sql, strlen(update_sql) + 1,
 , NULL);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_stmt: %s", sqlite3_errmsg(db));
goto out2;
}

/* The second argument indicates the posistion of the column */
ret = sqlite3_bind_text(stmt, 1, "1.0", strlen("1.0") + 1,
SQLITE_TRANSIENT);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_bind_text: %s",
sqlite3_errmsg(db));
goto out3;
}

ret = sqlite3_bind_int(stmt, 2, 0);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_bind_int: %s",
sqlite3_errmsg(db));
goto out3;
}
   
ret = sqlite3_step(stmt);
if (ret != SQLITE_DONE) {
fprintf(stderr, "sqlite3_step: %s",
sqlite3_errmsg(db));
goto out3;
}

ret = sqlite3_finalize(stmt);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_finalize: %s",
sqlite3_errmsg(db));
}

ret = sqlite3_close(db);
if (ret != SQLITE_OK) {
fprintf(stderr, "Unable to close the database.\n");
}
   
exit(0);

 out3:
ret = sqlite3_finalize(stmt);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_finalize: %s",
sqlite3_errmsg(db));
}
 out2:
ret = sqlite3_close(db);
 out1:
exit(1);
}
/*/

Simon Slavin wrote:
> On 27 Jun 2009, at 8:47am, chandan wrote:
>
>   
>> const char *create_and_insert = "create table some_tbl (id int primary
>> key, version text check (version in (\"1.0\")));"
>>"insert into some_tbl (id) values (1);";
>> const char *update_sql = "update some_tbl set version = ? where id  
>> = ?";
>> 
>
> I note you then do
>
> ret = sqlite3_bind_int(stmt, 2, 0);
>
> doesn't this look for id=2 ?
>
>
>
>
> To diagnose your problem, first try the whole thing as text: execute  
> the command
>
> update some_tbl set version = '1.0' where id = 1
>
> and see if it works.  If it doesn't, try it in sqlite3 command-line  
> tool and see if that works.
>
> Simon.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>   

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] unable to write the string "1.0" into a database table

2009-06-27 Thread chandan
The code snippet is shown below:

/**/
#include 
#include 
#include 
#include 
#include 

const char *create_and_insert = "create table some_tbl (id int primary 
key, version text check (version in (\"1.0\")));"
"insert into some_tbl (id) values (1);";
const char *update_sql = "update some_tbl set version = ? where id = ?";

int32_t main(int32_t argc, char *argv[])
{
sqlite3 *db;
char *err_msg;
sqlite3_stmt *stmt;
int32_t ret;
   
if (argc != 2) {
fprintf(stderr, "Usage: %s .\n", argv[0]);
goto out1;
}

db = NULL;
ret = sqlite3_open(argv[1], );
if (ret != SQLITE_OK) {
fprintf(stderr, "Unable to open database.\n");
goto out1;
}

err_msg = NULL;
ret = sqlite3_exec(db, create_and_insert, NULL, NULL, _msg);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_exec: %s.\n", err_msg);
sqlite3_free(err_msg);
}
   
stmt = NULL;
ret = sqlite3_prepare_v2(db, update_sql, strlen(update_sql) + 1,
 , NULL);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_stmt: %s", sqlite3_errmsg(db));
goto out2;
}

ret = sqlite3_bind_text(stmt, 1, "1.1", strlen("1.1") + 1,
SQLITE_TRANSIENT);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_bind_text: %s",
sqlite3_errmsg(db));
goto out3;
}

ret = sqlite3_bind_int(stmt, 2, 0);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_bind_int: %s",
sqlite3_errmsg(db));
goto out3;
}
   
ret = sqlite3_step(stmt);
if (ret != SQLITE_DONE) {
fprintf(stderr, "sqlite3_step: %s",
sqlite3_errmsg(db));
goto out3;
}

ret = sqlite3_finalize(stmt);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_finalize: %s",
sqlite3_errmsg(db));
}

ret = sqlite3_close(db);
if (ret != SQLITE_OK) {
fprintf(stderr, "Unable to close the database.\n");
}
   
exit(0);

 out3:
ret = sqlite3_finalize(stmt);
if (ret != SQLITE_OK) {
fprintf(stderr, "sqlite3_finalize: %s",
sqlite3_errmsg(db));
}
 out2:
ret = sqlite3_close(db);
 out1:
exit(1);
}
/****/


Roger Binns wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> chandan wrote:
>   
>>I have attached the C program along this mail.
>> 
>
> This mailing list strips all attachments, so we can't see your code :-)
>
>   
>> Am i doing anything wrong in the program?
>> 
>
> Yes.  SQLite does fundamentally work.  We'd have noticed by now if a
> simple update didn't work :-)
>
> You should look over the programming documentation on the web site
> including sample programs again.
>
> Roger
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkpF0O4ACgkQmOOfHg372QQlrQCffy0JJqpxSaDR8pg9B903eofi
> DYYAnR/gOPJLgpdC1c0CLwa0rA7IOJG0
> =MP0E
> -END PGP SIGNATURE-
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>   

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] unable to write the string "1.0" into a database table

2009-06-27 Thread chandan

Hi,
   I have attached the C program along this mail. The program does the 
following:

   1. Open a database file (Indicated by the argv[1] argument).
   2. Create the table "some_tbl" and insert a row into the table.
   3. Update the second column of the new row to value "1.0".
   4. Close the database.

After executing the program, open the database file using the sqlite 
command line program:


$ sqlite3 file.db
sqlite> select * from some_tbl;
1|

As the above output shows, the second column does not seem to get 
updated with the value "1.0".

Am i doing anything wrong in the program?

Regards,
chandan

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Reducing the size of executable linked with sqlite3.c

2009-06-09 Thread chandan
Hi,
I am using the "Amalgamation" version of SQLite. I wanted to know 
the compile time options (if any) to reduce the size of the executable 
that is linked with sqlite3.c file.

Regards,
chandan
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Difference between sqlite3_bind_zeroblob & sqlite3_bind_blob( , , , 0, )

2009-06-01 Thread chandan
Hi,
Is there any difference between the following code snippets:

-
ret = sqlite3_bind_zeroblob(stmt, 2, -1);
if (ret != SQLITE_OK) {
fprintf(stderr, "Unable to bind: %s", sqlite3_errmsg(db));
goto out3;
}

-
ret = sqlite3_bind_blob(stmt, 2, blob, 0, SQLITE_TRANSIENT);
if (ret != SQLITE_OK) {
fprintf(stderr, "Unable to bind: %s", sqlite3_errmsg(db));
goto out3;
}

-

Thanks & Regards,
  chandan
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Checking if an "integer" column is set to NULL

2009-05-25 Thread chandan
Thanks a lot!. The solution works :-)

Hamish Allan wrote:
> On Mon, May 25, 2009 at 1:15 PM, chandan
> <chandan.b...@globaledgesoft.com> wrote:
>
>   
>>I have used sqlite3_bind_null() API to bind an integer column with
>> NULL. When I read the value of that integer column I get the value as 0
>> (zero). Is there any way I can check if the column is set to NULL?
>> 
>
> This was something that confused me at first, so perhaps it's not
> crystal clear in the documentation:
>
> http://www.sqlite.org/capi3ref.html#sqlite3_column_blob
>
> [Annotations mine] "The sqlite3_column_type() routine returns the
> datatype code for the initial data type of the result column [NB I
> initially read this as "the initial data type of the column" rather
> than "the initial data type of the result", assuming that it would
> return the column affinity rather than the stored type]. The returned
> value is one of SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT,
> SQLITE_BLOB, or SQLITE_NULL. The value returned by
> sqlite3_column_type() is only meaningful if no type conversions have
> occurred as described below. After a type conversion, the value
> returned by sqlite3_column_type() is undefined. Future versions of
> SQLite may change the behavior of sqlite3_column_type() following a
> type conversion."
>
> In other words, if you call sqlite3_column_type() before you call
> sqlite3_column_int(), you can differentiate the two cases.
>
> Best wishes,
> Hamish
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>   

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Using amalgamation *.[ch] files on different architectures

2009-05-23 Thread chandan
Hi,
I have generated the amalgamation file using the command "make 
sqlite3.c". This was done on an x86 machine running Linux. Can I use the 
generated sqlite3.[ch] files on a different architecture machine running 
Linux?

Regards,
chandan
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] sqlite3_exec(): errmsg parameter

2009-05-19 Thread chandan
Hi,
if sqlite3_exec() returns an error code (i.e other than SQLITE_OK), 
is it guaranteed that the "errmsg" argument always contains the error 
message string. Or should i compare the value of errmsg with NULL before 
printing the value?

E.g:
ret = sqlite3_exec(db, sql, NULL, NULL, _msg);
if (ret != SQLITE_OK) {
 if (err_msg != NULL) {  /* is this checking necessary? */
   /* print err_msg */
  sqlite3_free(err_msg);
 }
}

Regards,
chandan
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] memory occupied by columns with NULL value

2009-05-19 Thread chandan
Hi,
I would like to know how much memory is used for a record field 
whose value is NULL.
Regards,
chandan
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] sqlite performance issues on Linux running on MIPS (BIG ENDIAN)

2009-05-02 Thread chandan r
Hi,
   I am planning to use sqlite in an application program. The application
will be running in Linux environment on MIPS processor (BIG ENDIAN). Are
there any sqlite performance issues when running on MIPS processor with
Linux as the OS.  In particular are there any issues regarding non-aligned
memory access (e.g. BUS errors)?
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


RE: [sqlite] unaligned access with sqlite 3.3.3 on IA64

2006-02-12 Thread Chowdhury, Chandan Dutta
 Thanks for the fix, every thing seems to work fine with sqlite-3.3.4

Regards
Chandan Dutta Chowdhury

-Original Message-
From: Chowdhury, Chandan Dutta 
Sent: Saturday, February 11, 2006 12:32 PM
To: [EMAIL PROTECTED]; sqlite-users@sqlite.org
Subject: RE: [sqlite] unaligned access with sqlite 3.3.3 on IA64

 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, February 10, 2006 7:41 PM
To: sqlite-users@sqlite.org; Chowdhury, Chandan Dutta
Subject: Re: [sqlite] unaligned access with sqlite 3.3.3 on IA64

"Chowdhury, Chandan Dutta" <[EMAIL PROTECTED]> wrote:
> Reading repository metadata in from local files
> yum(26535): unaligned access to 0x60404f44, 
> ip=0x24e683e0
> yum(26535): unaligned access to 0x60405094, 
> ip=0x24e683e0
> yum(26535): unaligned access to 0x60405154, 
> ip=0x24e683e0
> yum(26535): unaligned access to 0x6040e9f4, 
> ip=0x24e683e0 No Packages marked for Update/Obsoletion

I need additional clues.  Can you please recompile with -g, run this in
a debugger, and let me know exactly where the misaligned access occurs?

I am holding up the release of 3.3.4 on this issue.

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


I am not a gdb expert (not even a developer), I am more of a sysadmin,
so Plz excuse if the info is not what you want .

Here is what I could find.

The problem seems to come from sqlite3Parser and sqlite3RunParser

A call to sqlite3RunParser like this  (marked with ===)

sqlite3RunParser (pParse=0x6fff9270, 
zSql=0x60011f20 "CREATE INDEX packageId ON packages
(pkgId)",
pzErrMsg=0x6fff9370) at ./src/tokenize.c:391

Calls sqlite3Parser  like this   (marked with ===)

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=1, yyminor=
  {z = 0x60011f49 ")", dyn = 0, n = 1},
pParse=0x6fff9270) at parse.c:3185
3185

The warning is produced here  (marked with ===)
gdb)
3218  int yymx;
(gdb)
sqlite3(8812): unaligned access to 0x600145e4,
ip=0x20094d41
3303}
(gdb)


Plz get back for any more info

Regards
Chandan Dutta Chowdhury

Log of gdb(full log attached)

=
Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=13,
yyminor=
  {z = 0x60011f20 "CREATE INDEX packageId ON packages
(pkgId)", dyn = 0, n = 6},
pParse=0x6fff9270) at parse.c:3185
3185
(gdb)
Continuing.

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=132,
yyminor=
  {z = 0x60011f27 "INDEX packageId ON packages (pkgId)", dyn
= 0, n = 5},
pParse=0x6fff9270) at parse.c:3185
3185
(gdb)
Continuing.

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=23,
yyminor=
  {z = 0x60011f2d "packageId ON packages (pkgId)", dyn = 0,
n = 9},
pParse=0x6fff9270) at parse.c:3185
3185
(gdb)
Continuing.

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=97,
yyminor=
  {z = 0x60011f37 "ON packages (pkgId)", dyn = 0, n = 2},
pParse=0x6fff9270)
at parse.c:3185
3185
(gdb)
Continuing.

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=23,
yyminor=
  {z = 0x60011f3a "packages (pkgId)", dyn = 0, n = 8},
pParse=0x6fff9270)
at parse.c:3185
3185
(gdb)
Continuing.

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=19,
yyminor=
  {z = 0x60011f43 "(pkgId)", dyn = 0, n = 1},
pParse=0x6fff9270)
at parse.c:3185
3185
(gdb)
Continuing.

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=23,
yyminor=
  {z = 0x60011f44 "pkgId)", dyn = 0, n = 5},
pParse=0x6fff9270) at parse.c:3185
3185
(gdb)
Continuing.

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=20,
yyminor=
  {z = 0x60011f49 ")", dyn = 0, n = 1},
pParse=0x6fff9270) at parse.c:3185
3185
(gdb) n
3189/* if( yymajor==0 ) return; // not sure why this was here...
*/
(gdb)
3190yypParser->yyidx = 0;
(gdb)
3197  sqlite3ParserARG_STORE;
(gdb)
3198
(gdb)
3199#ifndef NDEBUG
(gdb)
3208  yy_shift(yypParser,yyact,yymajor,);
(gdb)
3209  yypParser->yyerrcnt--;
(gdb)
3217}else if( yyact == YY_ERROR_ACTION ){
(gdb)
3218  int yymx;
(gdb)
3303}
(gdb)
3208  yy_shift(yypParser,yyact,yymajor,);
(gdb)
3209  yypParser->yyerrcnt--;
(gdb)
3217}else if( yyact == YY_ERROR_ACTION ){
(gdb)
3218  int yymx;
(gdb)
3303}
(gdb)
3208  yy_shift(yypParser,yyact,yymajor,);
(gdb)
3209  yypParser->yyerrcnt--;
(gdb)
3217}else if( yyact == YY_ERROR_ACTION ){
(gdb)
3

RE: [sqlite] unaligned access with sqlite 3.3.3 on IA64

2006-02-10 Thread Chowdhury, Chandan Dutta
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 10, 2006 7:41 PM
To: sqlite-users@sqlite.org; Chowdhury, Chandan Dutta
Subject: Re: [sqlite] unaligned access with sqlite 3.3.3 on IA64

"Chowdhury, Chandan Dutta" <[EMAIL PROTECTED]> wrote:
> Reading repository metadata in from local files
> yum(26535): unaligned access to 0x60404f44, 
> ip=0x24e683e0
> yum(26535): unaligned access to 0x60405094, 
> ip=0x24e683e0
> yum(26535): unaligned access to 0x60405154, 
> ip=0x24e683e0
> yum(26535): unaligned access to 0x6040e9f4, 
> ip=0x24e683e0 No Packages marked for Update/Obsoletion

I need additional clues.  Can you please recompile with -g, run this in
a debugger, and let me know exactly where the misaligned access occurs?

I am holding up the release of 3.3.4 on this issue.

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


I am not a gdb expert (not even a developer), I am more of a sysadmin,
so Plz excuse if the info is not what you want .

Here is what I could find.

The problem seems to come from sqlite3Parser and sqlite3RunParser

A call to sqlite3RunParser like this  (marked with ===)

sqlite3RunParser (pParse=0x6fff9270, 
zSql=0x60011f20 "CREATE INDEX packageId ON packages
(pkgId)",
pzErrMsg=0x6fff9370) at ./src/tokenize.c:391

Calls sqlite3Parser  like this   (marked with ===)

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=1, yyminor=
  {z = 0x60011f49 ")", dyn = 0, n = 1},
pParse=0x6fff9270) at parse.c:3185
3185

The warning is produced here  (marked with ===)
gdb)
3218  int yymx;
(gdb)
sqlite3(8812): unaligned access to 0x600145e4,
ip=0x20094d41
3303}
(gdb)


Plz get back for any more info

Regards
Chandan Dutta Chowdhury

Log of gdb(full log attached)

=
Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=13,
yyminor=
  {z = 0x60011f20 "CREATE INDEX packageId ON packages
(pkgId)", dyn = 0, n = 6},
pParse=0x6fff9270) at parse.c:3185
3185
(gdb)
Continuing.

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=132,
yyminor=
  {z = 0x60011f27 "INDEX packageId ON packages (pkgId)", dyn
= 0, n = 5},
pParse=0x6fff9270) at parse.c:3185
3185
(gdb)
Continuing.

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=23,
yyminor=
  {z = 0x60011f2d "packageId ON packages (pkgId)", dyn = 0,
n = 9},
pParse=0x6fff9270) at parse.c:3185
3185
(gdb)
Continuing.

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=97,
yyminor=
  {z = 0x60011f37 "ON packages (pkgId)", dyn = 0, n = 2},
pParse=0x6fff9270)
at parse.c:3185
3185
(gdb)
Continuing.

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=23,
yyminor=
  {z = 0x60011f3a "packages (pkgId)", dyn = 0, n = 8},
pParse=0x6fff9270)
at parse.c:3185
3185
(gdb)
Continuing.

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=19,
yyminor=
  {z = 0x60011f43 "(pkgId)", dyn = 0, n = 1},
pParse=0x6fff9270)
at parse.c:3185
3185
(gdb)
Continuing.

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=23,
yyminor=
  {z = 0x60011f44 "pkgId)", dyn = 0, n = 5},
pParse=0x6fff9270) at parse.c:3185
3185
(gdb)
Continuing.

Breakpoint 2, sqlite3Parser (yyp=0x60012fc0, yymajor=20,
yyminor=
  {z = 0x60011f49 ")", dyn = 0, n = 1},
pParse=0x6fff9270) at parse.c:3185
3185
(gdb) n
3189/* if( yymajor==0 ) return; // not sure why this was here...
*/
(gdb)
3190yypParser->yyidx = 0;
(gdb)
3197  sqlite3ParserARG_STORE;
(gdb)
3198
(gdb)
3199#ifndef NDEBUG
(gdb)
3208  yy_shift(yypParser,yyact,yymajor,);
(gdb)
3209  yypParser->yyerrcnt--;
(gdb)
3217}else if( yyact == YY_ERROR_ACTION ){
(gdb)
3218  int yymx;
(gdb)
3303}
(gdb)
3208  yy_shift(yypParser,yyact,yymajor,);
(gdb)
3209  yypParser->yyerrcnt--;
(gdb)
3217}else if( yyact == YY_ERROR_ACTION ){
(gdb)
3218  int yymx;
(gdb)
3303}
(gdb)
3208  yy_shift(yypParser,yyact,yymajor,);
(gdb)
3209  yypParser->yyerrcnt--;
(gdb)
3217}else if( yyact == YY_ERROR_ACTION ){
(gdb)
3218  int yymx;
(gdb)
3303}
(gdb)
3208  yy_shift(yypParser,yyact,yymajor,);
(gdb)
3209  yypParser->yyerrcnt--;
(gdb)
3217}else if( yyact == YY_ERROR_ACTION ){
(gdb)
3218  int yymx;
(gdb)
3303}
(gdb)
3208  yy_shift(yypParser,yyact,yymajor,);
(gdb)
3209 

[sqlite] unaligned access with sqlite 3.3.3 on IA64

2006-02-10 Thread Chowdhury, Chandan Dutta
Hello All,

I am using sqlite-3.3.3 with yam and pysqlite on a RedHat Enterprise
Linux 4 IA64 machine. I get a lot of "unaligned access" message while
using yum.

# yum update
Setting up Update Process
Setting up repositories
os100% |=|  951 B
00:00
build_tools   100% |=|  951 B
00:00
Reading repository metadata in from local files
yum(26535): unaligned access to 0x60404f44,
ip=0x24e683e0
yum(26535): unaligned access to 0x60405094,
ip=0x24e683e0
yum(26535): unaligned access to 0x60405154,
ip=0x24e683e0
yum(26535): unaligned access to 0x6040e9f4,
ip=0x24e683e0
No Packages marked for Update/Obsoletion

I have noticed some warnings while compiling sqlite-3.3.3 

./libtool --mode=compile gcc -O2 -g -DOS_UNIX=1 -DHAVE_USLEEP=1
-DHAVE_FDATASYNC=1 -I. -I./src -DNDEBUG   -DTHREADSAFE=0
-DSQLITE_OMIT_CURSOR -c ./src/vdbe.c
 gcc -O2 -g -DOS_UNIX=1 -DHAVE_USLEEP=1 -DHAVE_FDATASYNC=1 -I. -I./src
-DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/vdbe.c  -fPIC
-DPIC -o .libs/vdbe.o
./src/vdbe.c: In function `sqlite3VdbeExec':
./src/vdbe.c:2000: warning: cast to pointer from integer of different
size
./src/vdbe.c:2016: warning: cast from pointer to integer of different
size
 gcc -O2 -g -DOS_UNIX=1 -DHAVE_USLEEP=1 -DHAVE_FDATASYNC=1 -I. -I./src
-DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/vdbe.c -o vdbe.o
>/dev/null 2>&1

...
...

 gcc -O2 -g -DOS_UNIX=1 -DHAVE_USLEEP=1 -DHAVE_FDATASYNC=1 -I. -I./src
-DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/table.c  -fPIC
-DPIC -o .libs/table.o
./src/table.c: In function `sqlite3_get_table':
./src/table.c:148: warning: cast to pointer from integer of different
size
./src/table.c: In function `sqlite3_free_table':
./src/table.c:193: warning: cast from pointer to integer of different
size
 gcc -O2 -g -DOS_UNIX=1 -DHAVE_USLEEP=1 -DHAVE_FDATASYNC=1 -I. -I./src
-DNDEBUG -DTHREADSAFE=0 -DSQLITE_OMIT_CURSOR -c ./src/table.c -o table.o
>/dev/null 2>&1

The following confirms that the issue is coming from sqlite

python
Python 2.3.4 (#1, Feb  2 2005, 11:44:21)
[GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite
>>> db = sqlite.connect("//var/cache/yum/os/primary.xml.gz.sqlite")
>>> cur = db.cursor()
>>> cur.execute("select * from db_info")
python(26534): unaligned access to 0x6008dfe4,
ip=0x239503e0
python(26534): unaligned access to 0x6008e134,
ip=0x239503e0
python(26534): unaligned access to 0x6008e1f4,
ip=0x239503e0

Is this a bug in sqlite.

Thanks in advance for the help.

Regards
Chandan Dutta Chowdhury