RE: [sqlite] ColType lost

2007-09-05 Thread Andre du Plessis
Should I also try and create a sample database that illustrates the
problem?
Creating a new ticket at:

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

does not allow me to attach any file,
I wonder if I do a .dump and then import it would probably fix the
problem as it would reinsert from text, so don't really want to provide
sql inserts I should attach the database in binary form

Or should I just send a mail to this group with a file attached?

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 04 September 2007 08:11 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] ColType lost

"Andre du Plessis" <[EMAIL PROTECTED]> wrote:
> 
> I use the API as always:
> 
> ColType := sqlite3_column_type(Pointer(FHandle), I);
> 
> This has always worked fine for me and type returned was SQLITE_TEXT
> 

If sqlite3_column_type() returns SQLITE_NULL when in fact
the column really contains a text value and not a NULL, then
that is a bug.  You should report it.

Please note, however, that sqlite3_column_type() returns
the actual datatype of the content of a particular row
of a particular column.  It does *not* report on the
declared datatype of a column.  If you really asking
for the declared datatype of a column, use
sqlite3_column_decltype() instead.

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



-
To unsubscribe, send email to [EMAIL PROTECTED]

-


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



Re: [sqlite] Re: select round(98926650.50001, 1) ?

2007-09-05 Thread Serena Lien
On 9/5/07, Doug Currie <[EMAIL PROTECTED]> wrote:
>
>
> Clinger's) PLDI 1990 papers. What I don't know is why this bug appears
> in the binary from sqlite.org but not in the version I build myself
> with gcc 3.4.5 from SQLite version 3.4.2 source.
>
>
Note it also appears when I compile SQLite from 3.4.2 source code using
Microsoft Visual C++ (2003). I have not looked at using fp:precise and
_controlfp: as Kees suggested because it's only a feature in VC 2005..

Serena


Re: [sqlite] 3.5.0 alpha TryEnterCriticalSection linker error

2007-09-05 Thread Daniel Önnerby

[EMAIL PROTECTED] wrote:

- Original Message 
  

From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Tuesday, September 4, 2007 3:32:38 PM
Subject: Re: [sqlite] 3.5.0 alpha TryEnterCriticalSection linker error


=?ISO-8859-1?Q?Daniel_=D6nnerby?= <[EMAIL PROTECTED]> wrote:


Hi all!

Tried upgrading to the 3.5.0 alpha from 3.4.2 using VS 2005 on XP. I 
downloaded the ZIP with preprocessed C code.
Compiling SQLite to a .lib was no problem, but when linking it to an 
..exe I got the following:
sqlite.lib(mutex_w32.obj) : error LNK2019: unresolved external symbol 
_TryEnterCriticalSection referenced in function _sqlite3_mutex_try


I made some attempt to fix it checking all kind of possible errors on my 
side (defines, compiler/linker settings etc) without any luck.

Anyone got the same error?
BTW. SQLite 3.4.2 works just fine.

This is not a big deal for me to solve, just thought I share with the 
development team.


  

http://www.sqlite.org/cvstrac/chngview?cn=4399

--
D. Richard Hipp [EMAIL PROTECTED]

 
Isn't it time to drop the Win9X support from the default build?


I'm thinking that any optimization should be enabled for the majority of users. 
Or if it's not really an optimization, why keeping it in the code then?

If some people still need to compile for legacy OSes, they can always grab the 
source and compile without those optimizations.

An alternative is to call this function when available using "GetProcAddress" 
(this is the case for a lot of other modern calls that cannot be done right now).
  

I agree, or at least make one OS-layer for winnt and one for win9x.
I also found out what I was doing wrong. The _WIN32_WINNT should be set 
like:

_WIN32_WINNT=0x0400 (or something higher)

 
Just my 2c
 
Nicolas


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




Re: [sqlite] 3.5.0 alpha TryEnterCriticalSection linker error

2007-09-05 Thread Ralf Junker

>Isn't it time to drop the Win9X support from the default build?

I do not believe that just because Win9x is missing a single required call 
justifies dropping support for it altogether!

>I'm thinking that any optimization should be enabled for the majority of 
>users. Or if it's not really an optimization, why keeping it in the code then?

If possible, please keep the optimization.

>An alternative is to call this function when available using "GetProcAddress" 
>(this is the case for a lot of other modern calls that cannot be done right 
>now).

I second this alternative. 

According to http://msdn2.microsoft.com/en-us/library/ms686857.aspx, 
TryEnterCriticalSection() is available on all Windows NT sytems. Therefore an 
option to "GetProcAddress()" is checking for such OSes. The isNT() routine is 
already part of os_win.c and is used there frequently:

static int isNT(void){
if( sqlite3_os_type==0 ){
  OSVERSIONINFO sInfo;
  sInfo.dwOSVersionInfoSize = sizeof(sInfo);
  GetVersionEx();
  sqlite3_os_type = sInfo.dwPlatformId==VER_PLATFORM_WIN32_NT ? 2 : 1;
}
return sqlite3_os_type==2;
  }


sqlite3_mutex_try() would then extend to something like this (untested!):

int sqlite3_mutex_try(sqlite3_mutex *p){
  int rc;
  assert( p );
  assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) );
  if( isNT() && TryEnterCriticalSection(>mutex) ){
p->owner = GetCurrentThreadId();
p->nRef++;
rc = SQLITE_OK;
  }else{
rc = SQLITE_BUSY;
  }
  return rc;
}

Ralf 


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



[sqlite] Compile error sqlite 3.4.2

2007-09-05 Thread Mohd Radzi Ibrahim



I'm using Visual Studio 2005 with wxSQLite3 wrapper. I have this  
error at this line :


SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[];

the error says:

.\..\wxsqlite3\sqlite3\src\sqlite3.c(6187) : error C2133:  
'sqlite3UpperToLower' : unknown size



any suggestion on how to bypass this error?

thanks.

Radzi.


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



RE: [sqlite] ColType lost

2007-09-05 Thread Andre du Plessis
I don't want to send any of the developers on a wild goose chase, the
problem might be somewhere else, since you suggested
sqlite3_column_decltype() im thinking that it might be somewhere else in
determining the column type initially I use sqlite3_column_type so the
SQLITE_NULL may actually be on a different one than the one that
actually has data, I will keep investigating and report back, I might
have to use 

-Original Message-
From: Andre du Plessis [mailto:[EMAIL PROTECTED] 
Sent: 05 September 2007 10:08 AM
To: sqlite-users@sqlite.org
Subject: RE: [sqlite] ColType lost

Should I also try and create a sample database that illustrates the
problem?
Creating a new ticket at:

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

does not allow me to attach any file,
I wonder if I do a .dump and then import it would probably fix the
problem as it would reinsert from text, so don't really want to provide
sql inserts I should attach the database in binary form

Or should I just send a mail to this group with a file attached?

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 04 September 2007 08:11 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] ColType lost

"Andre du Plessis" <[EMAIL PROTECTED]> wrote:
> 
> I use the API as always:
> 
> ColType := sqlite3_column_type(Pointer(FHandle), I);
> 
> This has always worked fine for me and type returned was SQLITE_TEXT
> 

If sqlite3_column_type() returns SQLITE_NULL when in fact
the column really contains a text value and not a NULL, then
that is a bug.  You should report it.

Please note, however, that sqlite3_column_type() returns
the actual datatype of the content of a particular row
of a particular column.  It does *not* report on the
declared datatype of a column.  If you really asking
for the declared datatype of a column, use
sqlite3_column_decltype() instead.

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



-
To unsubscribe, send email to [EMAIL PROTECTED]

-



-
To unsubscribe, send email to [EMAIL PROTECTED]

-


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



Re: [sqlite] Re: select round(98926650.50001, 1) ?

2007-09-05 Thread Arjen Markus

Doug Currie wrote:


I suspect the bug is in the functions that convert between string and
double; that's why I keep harping on Steele and White's (and
Clinger's) PLDI 1990 papers. What I don't know is why this bug appears
in the binary from sqlite.org but not in the version I build myself
with gcc 3.4.5 from SQLite version 3.4.2 source.

 

The implementation of that algorithm is far from trivial. It actually 
requires the

use of an arbitrary-precision library (or so at least is my understanding).

Regards,

Arjen



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



Re: [sqlite] Re: select round(98926650.50001, 1) ?

2007-09-05 Thread John Stanton

John Machin wrote:

On 5/09/2007 10:13 AM, John Stanton wrote:


John Machin wrote:


On 5/09/2007 6:18 AM, John Stanton wrote:


These are regular floating point numbers, and behave accordingly.




Utter nonsense. round(98926650.5, 1) -> 98926650.501 is a BUG.



Precisely,  As I said, regular floating point.



"regular floating point" does not cause such bugs; read the remainder of 
my post. The bug is in sqlite or in some library routine that it is using.


Precisely.  To stay out of trouble treat floating point implementations 
as platform specific.




98926650.5 is representable EXACTLY in "regular" floating point.
The round function should calculate a scale factor (10.0) in this 
case, and then:


shifted = 98926650.5 * 10.0 // i.e. 989266505.0, with no loss of 
precision

floored = floor(shifted) // result: 989266505.0 (no change)
answer = floored / 10.0 // result: 98926650.5, exactly

And here, using Python as a calculator and exemplar, is what should 
happen with Selena's second case:


| >>> original = 85227887.01
| >>> original
| 85227887.01005
| >>> shifted = original * 10.0
| >>> shifted
| 852278870.1002
| >>> floored = float(int(shifted))
| >>> floored
| 852278870.0
| >>> import math
| >>> math.floor(shifted)
| 852278870.0
| >>> answer = floored / 10.0
| >>> answer
| 85227887.0
| >>>




Serena Lien wrote:

I have read some of the postings/faq about the difficulties with 
the round

function, when certain numbers do not have a finite representation in
binary, which SQLite uses. eg 9.95 is actually 9.9499...etc so that 
round(

9.95, 1) rounds down.

But, I have found several numbers which don't get rounded at all, 
and in

fact return more decimal places!

round(98926650.5, 1) -> 98926650.501




- 


To unsubscribe, send email to [EMAIL PROTECTED]
- 






- 


To unsubscribe, send email to [EMAIL PROTECTED]
- 








- 


To unsubscribe, send email to [EMAIL PROTECTED]
- 






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



[sqlite] C/C++ API

2007-09-05 Thread Severin Müller
Hi

I'm new to sqlite3, and i' have some Problems with my code. I'm trying to 
select data from a table and to save the result in a string. but i have no clue 
how to accomplish this. 

Here is a part of my code:

std::string get_user_info(const char* nick,int mode)
{
#ifdef _WIN32 
const char *filename = "db\\users.db";
#else
const char *filename = "db/users.db";
#endif
services serv;
Config conf;
sqlite3 *db;
char *zErrMsg = 0;
int rc;
char *sql = (char*) malloc(sizeof(char)*64);
rc = sqlite3_open(filename,);
if(rc)
{
std::cout << "S_ERR_USERDATABASE" << std::endl;
globops(conf.get_s_name(),S_MSG_SRVGOINGDOWN);
sqlite3_close(db);
return NULL;
}
sprintf(sql,"SELECT * FROM '%s';",nick);
if(rc!=SQLITE_OK)
{
fprintf(stderr,"SQL error: %s\n",zErrMsg);
sqlite3_free(zErrMsg);
}
user = ...// i'd like to store the db data in a string here...
return user;
}

Can anybody help me here? Thanks


Regards

Sevi


-- 
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail

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



Re: [sqlite] C/C++ API

2007-09-05 Thread nishit sharma
hi,
in sqlite3 u r having a function named callback whose third argument is used
to save the
value of a column. u can store that value in an array or in char vairiable
also.
try this

regards
Nishit


On 9/5/07, "Severin Müller" <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> I'm new to sqlite3, and i' have some Problems with my code. I'm trying to
> select data from a table and to save the result in a string. but i have no
> clue how to accomplish this.
>
> Here is a part of my code:
>
> std::string get_user_info(const char* nick,int mode)
> {
> #ifdef _WIN32
>const char *filename = "db\\users.db";
> #else
>const char *filename = "db/users.db";
> #endif
>services serv;
>Config conf;
>sqlite3 *db;
>char *zErrMsg = 0;
>int rc;
>char *sql = (char*) malloc(sizeof(char)*64);
>rc = sqlite3_open(filename,);
>if(rc)
>{
>std::cout << "S_ERR_USERDATABASE" << std::endl;
>globops(conf.get_s_name(),S_MSG_SRVGOINGDOWN);
>sqlite3_close(db);
>return NULL;
>}
>sprintf(sql,"SELECT * FROM '%s';",nick);
>if(rc!=SQLITE_OK)
>{
>fprintf(stderr,"SQL error: %s\n",zErrMsg);
>sqlite3_free(zErrMsg);
>}
>user = ...// i'd like to store the db data in a string here...
>return user;
> }
>
> Can anybody help me here? Thanks
>
>
> Regards
>
> Sevi
>
>
> --
> GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
> Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>


[sqlite] using loop in sqlite3

2007-09-05 Thread nishit sharma
Hi all,
this time i m trying
for(g=x-1000:g<=x+1000;g+=d)

where g is an integer, x is a define statement which is 2000 and d is an
column value
from database.
now i want to print specific values from database on the basis of g by
passing g in the sqlite3_exec() command.
my question is it  is possible to send variable in sqlite3_exec() command
and get the desired results or
there is different alternate to meet the requirement,

waiting for reply

regards
Nishit


Re: [sqlite] C/C++ API

2007-09-05 Thread Daniel Önnerby

This code is totaly untested. But something like this:

   std::string sUsername;
   sqlite3 *db;
   if( sqlite3_open("db/users.db",) ){

  // prepare the statement

   sqlite3_stmt *oStmt;
   if( sqlite3_prepare_v2(db,"SELECT username FROM users WHERE 
nick=?",-1,,NULL)==SQLITE_OK ){
  
   // Bind your nickname to the ?-parameter in SQL.

   sqlite3_bind_text(oStmt,1,nick,-1,SQLITE_STATIC);
  
   // Execute the statement

   if( sqlite3_step(oStmt)==SQLITE_ROW){
   sUsername.assign( sqlite3_column_text(oStmt,1) );
   }
  
   }

   sqlite3_reset(oStmt);
   sqlite3_finalize(oStmt);
  
   sqlite3_close(db);
  
   return sUsername;

   }


Severin Müller wrote:

Hi

I'm new to sqlite3, and i' have some Problems with my code. I'm trying to select data from a table and to save the result in a string. but i have no clue how to accomplish this. 


Here is a part of my code:

std::string get_user_info(const char* nick,int mode)
{
#ifdef _WIN32 
	const char *filename = "db\\users.db";

#else
const char *filename = "db/users.db";
#endif
services serv;
Config conf;
sqlite3 *db;
char *zErrMsg = 0;
int rc;
char *sql = (char*) malloc(sizeof(char)*64);
rc = sqlite3_open(filename,);
if(rc)
{
std::cout << "S_ERR_USERDATABASE" << std::endl;
globops(conf.get_s_name(),S_MSG_SRVGOINGDOWN);
sqlite3_close(db);
return NULL;
}
sprintf(sql,"SELECT * FROM '%s';",nick);
if(rc!=SQLITE_OK)
{
fprintf(stderr,"SQL error: %s\n",zErrMsg);
sqlite3_free(zErrMsg);
}
user = ...// i'd like to store the db data in a string here...
return user;
}

Can anybody help me here? Thanks


Regards

Sevi


  



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



Re: [sqlite] ColType lost

2007-09-05 Thread Kees Nuyt

On Wed, 5 Sep 2007 10:54:55 +0200, Andre wrote:

> I use sqlite3_column_type so the SQLITE_NULL
> may actually be on a different [row] than the
> one that actually has data, I will keep
> investigating and report back, I might have
> to use 

... sqlite3_column_type() on every row you sqlite3_step()
into.
-- 
  (  Kees Nuyt
  )
c[_]

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



[sqlite] sqlite 3.5.0 error on tracker

2007-09-05 Thread Halton Huo
Hello there,

I just upgrade sqlite from 3.4.1 to 3.5.0, and run tracker, which use
sqlite to save data.

I got core dump everytime like following:

[EMAIL PROTECTED] ([EMAIL PROTECTED]) signal SEGV (no mapping at the fault 
address) in t_splay at
0xfea296e2
0xfea296e2: t_splay+0x0022: movl 0x0008(%ebx),%ecx
Current function is tracker_exec_proc
 1719   rc = sqlite3_step (stmt);
(dbx 2) where
current thread: [EMAIL PROTECTED]
  [1] t_splay(0x84ce2b0), at 0xfea296e2 
  [2] t_delete(0x84ce2b0), at 0xfea295bd 
  [3] realfree(0x84ce230), at 0xfea292d0 
  [4] cleanfree(0x0), at 0xfea29930 
  [5] _malloc_unlocked(0x78, 0x0, 0x70, 0xfece8538, 0x2f, 0x81de080), at
0xfea28dba 
  [6] malloc(0x78), at 0xfea28cbf 
  [7] sqlite3_malloc(0x70), at 0xfecac661 
  [8] sqlite3MallocZero(0x70), at 0xfecac116 
  [9] allocateCursor(0x825be30, 0x0, 0x0), at 0xfecc1ad6 
  [10] sqlite3VdbeExec(0x825be30), at 0xfecc63d1 
  [11] sqlite3Step(0x825be30), at 0xfecc7377 
  [12] sqlite3_step(0x825be30), at 0xfecc74f5 
=>[13] tracker_exec_proc(db_con = 0x81c5b78, procedure = 0x80ed1e0
"GetServiceID", param_count = 2, ... = 0x84b9950, ...), line 1719 in
"tracker-db-sqlite.c"
  [14] tracker_db_get_file_info(db_con = 0x81c5b78, info = 0x824e710),
line 180 in "tracker-db.c"
  [15] process_files_thread(), line 1250 in "trackerd.c"
  [16] g_thread_create_proxy(0x81c5040), at 0xfebc03fa 
  [17] _thr_setup(0xfe870a00), at 0xfea7d952 
  [18] _lwp_start(), at 0xfea7dbb0 

I have a page http://www.sqlite.org/34to35.html, but still do not know
where to start. Any thoughts?


-- 
Halton Huo
Solaris Desktop Team, Sun Microsystems
Tel: +86-10-82618200 ext. 82113/ +86-10-626732113
Fax: +86-10-62780969
eMail: [EMAIL PROTECTED]


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



[sqlite] Re: using loop in sqlite3

2007-09-05 Thread Igor Tandetnik

nishit sharma <[EMAIL PROTECTED]>
wrote:

my question is it  is possible to send variable in sqlite3_exec()
command and get the desired results or
there is different alternate to meet the requirement,


Not with sqlite3_exec. See sqlite3_prepare, sqlite3_bind_*, 
sqlite3_step, sqlite3_column_*, sqlite3_reset, sqlite3_finalize.


Igor Tandetnik 



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



[sqlite] Re: Merging two tables

2007-09-05 Thread Igor Tandetnik

Scott Derrick <[EMAIL PROTECTED]> wrote:

Whats the procedure and rules for merging two tables?


Whatever you code them to be. There is no built-in mechanism for merging 
two tables, if that's what you are asking. You will have to design and 
implement any such mechanism yourself.


Igor Tandetnik 



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



Re: [sqlite] C/C++ API

2007-09-05 Thread Severin Müller
Hi

This won't work, because sUsername.assign... will not be accepted with 
sqlite3_column_text, because sqlite_column_text if of type const unsigned 
char...

Anyway, the other version with the callback function still gives me headache... 
how shall i access the data in my statement, when i have to call another 
function? Does somebody have another good example for this?


 Original-Nachricht 
> Datum: Wed, 05 Sep 2007 12:13:25 +0200
> Von: "Daniel Önnerby" <[EMAIL PROTECTED]>
> An: sqlite-users@sqlite.org
> Betreff: Re: [sqlite] C/C++ API

> This code is totaly untested. But something like this:
> 
> std::string sUsername;
> sqlite3 *db;
> if( sqlite3_open("db/users.db",) ){
>  
>// prepare the statement
> sqlite3_stmt *oStmt;
> if( sqlite3_prepare_v2(db,"SELECT username FROM users WHERE 
> nick=?",-1,,NULL)==SQLITE_OK ){
>
> // Bind your nickname to the ?-parameter in SQL.
> sqlite3_bind_text(oStmt,1,nick,-1,SQLITE_STATIC);
>
> // Execute the statement
> if( sqlite3_step(oStmt)==SQLITE_ROW){
> sUsername.assign( sqlite3_column_text(oStmt,1) );
> }
>
> }
> sqlite3_reset(oStmt);
> sqlite3_finalize(oStmt);
>
> sqlite3_close(db);
>
> return sUsername;
> }
> 
> 
> Severin Müller wrote:
> > Hi
> >
> > I'm new to sqlite3, and i' have some Problems with my code. I'm trying
> to select data from a table and to save the result in a string. but i have
> no clue how to accomplish this. 
> >
> > Here is a part of my code:
> >
> > std::string get_user_info(const char* nick,int mode)
> > {
> > #ifdef _WIN32 
> > const char *filename = "db\\users.db";
> > #else
> > const char *filename = "db/users.db";
> > #endif
> > services serv;
> > Config conf;
> > sqlite3 *db;
> > char *zErrMsg = 0;
> > int rc;
> > char *sql = (char*) malloc(sizeof(char)*64);
> > rc = sqlite3_open(filename,);
> > if(rc)
> > {
> > std::cout << "S_ERR_USERDATABASE" << std::endl;
> > globops(conf.get_s_name(),S_MSG_SRVGOINGDOWN);
> > sqlite3_close(db);
> > return NULL;
> > }
> > sprintf(sql,"SELECT * FROM '%s';",nick);
> > if(rc!=SQLITE_OK)
> > {
> > fprintf(stderr,"SQL error: %s\n",zErrMsg);
> > sqlite3_free(zErrMsg);
> > }
> > user = ...// i'd like to store the db data in a string here...
> > return user;
> > }
> >
> > Can anybody help me here? Thanks
> >
> >
> > Regards
> >
> > Sevi
> >
> >
> >   
> 
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -

-- 
Pt! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger

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



[sqlite] Re: C/C++ API

2007-09-05 Thread Igor Tandetnik

"Severin Müller" <[EMAIL PROTECTED]> wrote:

This won't work, because sUsername.assign... will not be accepted
with sqlite3_column_text, because sqlite_column_text if of type const
unsigned char...


Just cast it to const char*

Igor Tandetnik 



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



Re: [sqlite] Re: C/C++ API

2007-09-05 Thread Severin Müller
Hey

Naw, the entire code doesn't work properly.

I just need something where i can save my query results in a string and return 
the string...


 Original-Nachricht 
> Datum: Wed, 5 Sep 2007 08:30:12 -0400
> Von: "Igor Tandetnik" <[EMAIL PROTECTED]>
> An: "SQLite" 
> Betreff: [sqlite] Re: C/C++ API

> "Severin Müller" <[EMAIL PROTECTED]> wrote:
> > This won't work, because sUsername.assign... will not be accepted
> > with sqlite3_column_text, because sqlite_column_text if of type const
> > unsigned char...
> 
> Just cast it to const char*
> 
> Igor Tandetnik 
> 
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -

-- 
Pt! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger

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



Re: [sqlite] Re: Merging two tables

2007-09-05 Thread RaghavendraK 70574
How to plug custom search algorthim within Sqlite?
For example,

select * from table where a = 'xxx';

Instead of using normal inbuilt search can it be userDefined function?

regards
ragha



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



[sqlite] Re: Re: C/C++ API

2007-09-05 Thread Igor Tandetnik

"Severin Müller" <[EMAIL PROTECTED]> wrote:

Naw, the entire code doesn't work properly.


What's improper about the way it works? What specifically seems to be 
the problem?



I just need something where i can save my query results in a string
and return the string...


I seem to have misplaced my crystal ball today, so my mind-reading 
abilities are somewhat impaired. The results of what query? In a string 
of what format?


Igor Tandetnik 



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



[sqlite] Re: Re: Merging two tables

2007-09-05 Thread Igor Tandetnik

RaghavendraK 70574
<[EMAIL PROTECTED]> wrote:

How to plug custom search algorthim within Sqlite?
For example,

select * from table where a = 'xxx';

Instead of using normal inbuilt search can it be userDefined
function?


Yes. You can use sqlite3_create_function to create a function taking two 
parameters and returning a boolean (actually, an integer with the values 
0 or 1). Then you can say


select * from table where MyComparison(a, 'xxx');

Igor Tandetnik 



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



Re: [sqlite] Re: Re: C/C++ API

2007-09-05 Thread Severin Müller
Hey

Sorry for my unclearness. I want to access information in a sqlite database and 
store it in a std::string or const char*, so i can return it to the callin 
function. I have the following code:

std::string get_user_info(const char* nick,int mode)
{
#ifdef _WIN32 
const char *filename = "db\\users.db";
#else
const char *filename = "db/users.db";
#endif
services serv;
Config conf;
sqlite3 *db;
char *zErrMsg = 0;
int rc;
char *sql = (char*) malloc(sizeof(char)*64);
rc = sqlite3_open(filename,);
if(rc!=SQLITE_OK)
{
std::cout << "S_ERR_USERDATABASE" << std::endl;
globops(conf.get_s_name(),S_MSG_SRVGOINGDOWN);
sqlite3_close(db);
return NULL;
}
const unsigned char *userinfo = (unsigned char*) malloc(sizeof(unsigned 
char)*1024);
std::string sUsername;
sqlite3_stmt *oStmt;
switch(mode)
{
case 1:
sprintf(sql,"SELECT username FROM '%s';",nick);
case 2:
sprintf(sql,"SELECT hostname FROM '%s';",nick);
case 3:
sprintf(sql,"SELECT realname FROM '%s';",nick);
case 4:
sprintf(sql,"SELECT operline FROM '%s';",nick);
}
if(sqlite3_prepare(db,sql,-1,,NULL)==SQLITE_OK )
{
sqlite3_bind_text(oStmt,1,nick,-1,SQLITE_STATIC);
if(sqlite3_step(oStmt)==SQLITE_ROW)
{
sUsername.assign((const char*) 
sqlite3_column_text(oStmt,0));

}
}
std::cout << sUsername << std::endl;
sqlite3_reset(oStmt);
sqlite3_finalize(oStmt);
return sUsername;
}


So The std::cout << sUsername << sts::endl; is supposed to put the data out 
there from case 1 (i'm calling case 1 only)

But it just puts out a blank line... Do you have a suggestion? Thanks a lot...
-- 
Pt! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger

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



Re: [sqlite] Re: Re: Merging two tables

2007-09-05 Thread RaghavendraK 70574

Thats great.
If possible Can u please provide a sample,

Will this function receive the database column values or indexes?

regards
ragha

**
 This email and its attachments contain confidential information from HUAWEI, 
which is intended only for the person or entity whose address is listed above. 
Any use of the information contained herein in any way (including, but not 
limited to, total or partial disclosure, reproduction, or dissemination) by 
persons other than the intended recipient(s) is prohibited. If you receive this 
e-mail in error, please notify the sender by phone or email immediately and 
delete it!
 
*

- Original Message -
From: Igor Tandetnik <[EMAIL PROTECTED]>
Date: Wednesday, September 5, 2007 6:20 pm
Subject: [sqlite] Re: Re: Merging two tables

> RaghavendraK 70574
> <[EMAIL PROTECTED]> wrote:
> >> How to plug custom search algorthim within Sqlite?
> >> For example,
> >>
> >> select * from table where a = 'xxx';
> >>
> >> Instead of using normal inbuilt search can it be userDefined
> >> function?
> 
> Yes. You can use sqlite3_create_function to create a function 
> taking two 
> parameters and returning a boolean (actually, an integer with the 
> values 
> 0 or 1). Then you can say
> 
> select * from table where MyComparison(a, 'xxx');
> 
> Igor Tandetnik 
> 
> 
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> 
> -
> 
> 

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



Re: [sqlite] Re: select round(98926650.50001, 1) ?

2007-09-05 Thread Doug Currie
On Wednesday, September 05, 2007 Arjen Markus wrote: 

> Doug Currie wrote:

>>I suspect the bug is in the functions that convert between string and
>>double; that's why I keep harping on Steele and White's (and
>>Clinger's) PLDI 1990 papers. What I don't know is why this bug appears
>>in the binary from sqlite.org but not in the version I build myself
>>with gcc 3.4.5 from SQLite version 3.4.2 source.
>>
>>  
>>
> The implementation of that algorithm is far from trivial. It actually 
> requires the
> use of an arbitrary-precision library (or so at least is my understanding).

Yes, in some cases big integers are needed. In extreme cases, e.g.,
denormalized numbers, up to 160 bytes may be required.

I have implemented these algorithms, twice, but for employers with
proprietary programs. The algorithms are also implemented in glibc
based on high quality code from David Gay (Bell Labs, Lucent, Sandia,
Netlib), available with a BSD license at
http://netlib.sandia.gov/fp/index.html

e

-- 
Doug Currie
Londonderry, NH, USA


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



Re: [sqlite] Re: Re: Merging two tables

2007-09-05 Thread Scott Derrick

How can this be used to "Merge two tables"?

Scott

RaghavendraK 70574 wrote:

Thats great.
If possible Can u please provide a sample,

Will this function receive the database column values or indexes?

regards
ragha

**
 This email and its attachments contain confidential information from HUAWEI, 
which is intended only for the person or entity whose address is listed above. 
Any use of the information contained herein in any way (including, but not 
limited to, total or partial disclosure, reproduction, or dissemination) by 
persons other than the intended recipient(s) is prohibited. If you receive this 
e-mail in error, please notify the sender by phone or email immediately and 
delete it!
 
*

- Original Message -
From: Igor Tandetnik <[EMAIL PROTECTED]>
Date: Wednesday, September 5, 2007 6:20 pm
Subject: [sqlite] Re: Re: Merging two tables


RaghavendraK 70574
<[EMAIL PROTECTED]> wrote:

How to plug custom search algorthim within Sqlite?
For example,

select * from table where a = 'xxx';

Instead of using normal inbuilt search can it be userDefined
function?
Yes. You can use sqlite3_create_function to create a function 
taking two 
parameters and returning a boolean (actually, an integer with the 
values 
0 or 1). Then you can say


select * from table where MyComparison(a, 'xxx');

Igor Tandetnik 




-
To unsubscribe, send email to [EMAIL PROTECTED]

-




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




--

-
Truth : the most deadly weapon ever discovered by humanity. Capable 
of destroying entire perceptual sets, cultures, and realities. Outlawed 
by all governments everywhere. Possession is normally punishable by death.


Richard Childers

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



Re: [sqlite] Re: C/C++ API

2007-09-05 Thread John Stanton

Look up the Sqlite API.  The sqlite3_column_text call does what you want.

   sqlite3_open
   sqlite3_prepare
   loop
  sqlite3_step
  if SQLITE_ROW sqlite_column_text;
  if SQLITE_DONE sqlite3_finalize; exit
   repeat
   sqlite3_close

Add your own error tests.

Severin Müller wrote:

Hey

Naw, the entire code doesn't work properly.

I just need something where i can save my query results in a string and return 
the string...


 Original-Nachricht 


Datum: Wed, 5 Sep 2007 08:30:12 -0400
Von: "Igor Tandetnik" <[EMAIL PROTECTED]>
An: "SQLite" 
Betreff: [sqlite] Re: C/C++ API




"Severin Müller" <[EMAIL PROTECTED]> wrote:


This won't work, because sUsername.assign... will not be accepted
with sqlite3_column_text, because sqlite_column_text if of type const
unsigned char...


Just cast it to const char*

Igor Tandetnik 



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






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



Re: [sqlite] Re: Re: Merging two tables

2007-09-05 Thread John Stanton
Look in the Sqlite source for examples.  Your function gets the 
arguments you specify in the SQL and then your program does whatever you 
like with them and returns a result.  It could for example perform a 
regular expression compare etc.


You register the function with Sqlite when you open a connection.

You can compile extra functions into Sqlite if you choose so that you do 
not have to load custom functions when you open a DB connection.


RaghavendraK 70574 wrote:

Thats great.
If possible Can u please provide a sample,

Will this function receive the database column values or indexes?

regards
ragha

**
 This email and its attachments contain confidential information from HUAWEI, 
which is intended only for the person or entity whose address is listed above. 
Any use of the information contained herein in any way (including, but not 
limited to, total or partial disclosure, reproduction, or dissemination) by 
persons other than the intended recipient(s) is prohibited. If you receive this 
e-mail in error, please notify the sender by phone or email immediately and 
delete it!
 
*

- Original Message -
From: Igor Tandetnik <[EMAIL PROTECTED]>
Date: Wednesday, September 5, 2007 6:20 pm
Subject: [sqlite] Re: Re: Merging two tables



RaghavendraK 70574
<[EMAIL PROTECTED]> wrote:


How to plug custom search algorthim within Sqlite?
For example,

select * from table where a = 'xxx';

Instead of using normal inbuilt search can it be userDefined
function?


Yes. You can use sqlite3_create_function to create a function 
taking two 
parameters and returning a boolean (actually, an integer with the 
values 
0 or 1). Then you can say


select * from table where MyComparison(a, 'xxx');

Igor Tandetnik 




-
To unsubscribe, send email to [EMAIL PROTECTED]

-





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




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



Re: [sqlite] Re: Re: C/C++ API

2007-09-05 Thread Daniel Önnerby
Your SQL-strings seem a little strange. You are trying to select from a 
table named as the content of nick, this would assume that you have a 
table for each "nick" witch seems unlikely. How is your database modeled?


Severin Müller wrote:

Hey

Sorry for my unclearness. I want to access information in a sqlite database and 
store it in a std::string or const char*, so i can return it to the callin 
function. I have the following code:

std::string get_user_info(const char* nick,int mode)
{
#ifdef _WIN32 
	const char *filename = "db\\users.db";

#else
const char *filename = "db/users.db";
#endif
services serv;
Config conf;
sqlite3 *db;
char *zErrMsg = 0;
int rc;
char *sql = (char*) malloc(sizeof(char)*64);
rc = sqlite3_open(filename,);
if(rc!=SQLITE_OK)
{
std::cout << "S_ERR_USERDATABASE" << std::endl;
globops(conf.get_s_name(),S_MSG_SRVGOINGDOWN);
sqlite3_close(db);
return NULL;
}
const unsigned char *userinfo = (unsigned char*) malloc(sizeof(unsigned 
char)*1024);
std::string sUsername;
sqlite3_stmt *oStmt;
switch(mode)
{
case 1:
sprintf(sql,"SELECT username FROM '%s';",nick);
case 2:
sprintf(sql,"SELECT hostname FROM '%s';",nick);
case 3:
sprintf(sql,"SELECT realname FROM '%s';",nick);
case 4:
sprintf(sql,"SELECT operline FROM '%s';",nick);
}
if(sqlite3_prepare(db,sql,-1,,NULL)==SQLITE_OK )
{
sqlite3_bind_text(oStmt,1,nick,-1,SQLITE_STATIC);
if(sqlite3_step(oStmt)==SQLITE_ROW)
{
sUsername.assign((const char*) 
sqlite3_column_text(oStmt,0));

		}

}
std::cout << sUsername << std::endl;
sqlite3_reset(oStmt);
sqlite3_finalize(oStmt);
return sUsername;
}


So The std::cout << sUsername << sts::endl; is supposed to put the data out 
there from case 1 (i'm calling case 1 only)

But it just puts out a blank line... Do you have a suggestion? Thanks a lot...
  



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



Re: [sqlite] Re: Re: C/C++ API

2007-09-05 Thread Severin Müller
Hey


This is correct. This database is just for the users, who send commands to 
nickserv. every nickname online is a entry in the database. i plan to change 
that later, in case, sqlite encouters problems with 1000 tables in a database, 
but for now it really like this. 


 Original-Nachricht 
> Datum: Wed, 05 Sep 2007 16:28:19 +0200
> Von: "Daniel Önnerby" <[EMAIL PROTECTED]>
> An: sqlite-users@sqlite.org
> Betreff: Re: [sqlite] Re: Re: C/C++ API

> Your SQL-strings seem a little strange. You are trying to select from a 
> table named as the content of nick, this would assume that you have a 
> table for each "nick" witch seems unlikely. How is your database modeled?
> 
> Severin Müller wrote:
> > Hey
> >
> > Sorry for my unclearness. I want to access information in a sqlite
> database and store it in a std::string or const char*, so i can return it to 
> the
> callin function. I have the following code:
> >
> > std::string get_user_info(const char* nick,int mode)
> > {
> > #ifdef _WIN32 
> > const char *filename = "db\\users.db";
> > #else
> > const char *filename = "db/users.db";
> > #endif
> > services serv;
> > Config conf;
> > sqlite3 *db;
> > char *zErrMsg = 0;
> > int rc;
> > char *sql = (char*) malloc(sizeof(char)*64);
> > rc = sqlite3_open(filename,);
> > if(rc!=SQLITE_OK)
> > {
> > std::cout << "S_ERR_USERDATABASE" << std::endl;
> > globops(conf.get_s_name(),S_MSG_SRVGOINGDOWN);
> > sqlite3_close(db);
> > return NULL;
> > }
> > const unsigned char *userinfo = (unsigned char*) malloc(sizeof(unsigned
> char)*1024);
> > std::string sUsername;
> > sqlite3_stmt *oStmt;
> > switch(mode)
> > {
> > case 1:
> > sprintf(sql,"SELECT username FROM '%s';",nick);
> > case 2:
> > sprintf(sql,"SELECT hostname FROM '%s';",nick);
> > case 3:
> > sprintf(sql,"SELECT realname FROM '%s';",nick);
> > case 4:
> > sprintf(sql,"SELECT operline FROM '%s';",nick);
> > }
> > if(sqlite3_prepare(db,sql,-1,,NULL)==SQLITE_OK )
> > {
> > sqlite3_bind_text(oStmt,1,nick,-1,SQLITE_STATIC);
> > if(sqlite3_step(oStmt)==SQLITE_ROW)
> > {
> > sUsername.assign((const char*) 
> > sqlite3_column_text(oStmt,0));
> > 
> > }
> > }
> > std::cout << sUsername << std::endl;
> > sqlite3_reset(oStmt);
> > sqlite3_finalize(oStmt);
> > return sUsername;
> > }
> >
> >
> > So The std::cout << sUsername << sts::endl; is supposed to put the data
> out there from case 1 (i'm calling case 1 only)
> >
> > But it just puts out a blank line... Do you have a suggestion? Thanks a
> lot...
> >   
> 
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -

-- 
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser

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



Re: [sqlite] Re: Re: C/C++ API

2007-09-05 Thread David Bicking
One thing I note is that you have no parameters in your queries, so you
don't need to use sqlite3_bind_text.

Further, you might want to add "else" statements so you can print out
the errmsg if the prepare or step calls are failing.

David


On Wed, 2007-09-05 at 16:35 +0200, "Severin Müller" wrote:
> Hey
> 
> 
> This is correct. This database is just for the users, who send commands to 
> nickserv. every nickname online is a entry in the database. i plan to change 
> that later, in case, sqlite encouters problems with 1000 tables in a 
> database, but for now it really like this. 
> 
> 
>  Original-Nachricht 
> > Datum: Wed, 05 Sep 2007 16:28:19 +0200
> > Von: "Daniel Önnerby" <[EMAIL PROTECTED]>
> > An: sqlite-users@sqlite.org
> > Betreff: Re: [sqlite] Re: Re: C/C++ API
> 
> > Your SQL-strings seem a little strange. You are trying to select from a 
> > table named as the content of nick, this would assume that you have a 
> > table for each "nick" witch seems unlikely. How is your database modeled?
> > 
> > Severin Müller wrote:
> > > Hey
> > >
> > > Sorry for my unclearness. I want to access information in a sqlite
> > database and store it in a std::string or const char*, so i can return it 
> > to the
> > callin function. I have the following code:
> > >
> > > std::string get_user_info(const char* nick,int mode)
> > > {
> > > #ifdef _WIN32 
> > >   const char *filename = "db\\users.db";
> > > #else
> > >   const char *filename = "db/users.db";
> > > #endif
> > >   services serv;
> > >   Config conf;
> > >   sqlite3 *db;
> > >   char *zErrMsg = 0;
> > >   int rc;
> > >   char *sql = (char*) malloc(sizeof(char)*64);
> > >   rc = sqlite3_open(filename,);
> > >   if(rc!=SQLITE_OK)
> > >   {
> > >   std::cout << "S_ERR_USERDATABASE" << std::endl;
> > >   globops(conf.get_s_name(),S_MSG_SRVGOINGDOWN);
> > >   sqlite3_close(db);
> > >   return NULL;
> > >   }
> > >   const unsigned char *userinfo = (unsigned char*) malloc(sizeof(unsigned
> > char)*1024);
> > >   std::string sUsername;
> > >   sqlite3_stmt *oStmt;
> > >   switch(mode)
> > >   {
> > >   case 1:
> > >   sprintf(sql,"SELECT username FROM '%s';",nick);
> > >   case 2:
> > >   sprintf(sql,"SELECT hostname FROM '%s';",nick);
> > >   case 3:
> > >   sprintf(sql,"SELECT realname FROM '%s';",nick);
> > >   case 4:
> > >   sprintf(sql,"SELECT operline FROM '%s';",nick);
> > >   }
> > >   if(sqlite3_prepare(db,sql,-1,,NULL)==SQLITE_OK )
> > >   {
> > >   sqlite3_bind_text(oStmt,1,nick,-1,SQLITE_STATIC);
> > >   if(sqlite3_step(oStmt)==SQLITE_ROW)
> > >   {
> > >   sUsername.assign((const char*) 
> > > sqlite3_column_text(oStmt,0));
> > > 
> > >   }
> > >   }
> > >   std::cout << sUsername << std::endl;
> > >   sqlite3_reset(oStmt);
> > >   sqlite3_finalize(oStmt);
> > >   return sUsername;
> > > }
> > >
> > >
> > > So The std::cout << sUsername << sts::endl; is supposed to put the data
> > out there from case 1 (i'm calling case 1 only)
> > >
> > > But it just puts out a blank line... Do you have a suggestion? Thanks a
> > lot...
> > >   



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



Re: [sqlite] Re: select round(98926650.50001, 1) ?

2007-09-05 Thread Simon Davies
Hi All,

Here's my 2p...

on XP and VC++ (for my sins!)

The round function works.
sqlite_column_double() returns 98926650.5

The '01' on the end is introduced by calling sqlite_column_text
(in shell.c).
This results in reaching the line

sqlite3_snprintf(NBFS, z, "%!.15g", pMem->r);

in sqlite3VdbeMemStringify.
This resolves down to calling a function vxprintf, which has the following line:

   while( realvalue>=10.0 && exp<=350 ){ realvalue *= 0.1; exp++; }

When this line is reached, realvalue has value 98926650.5 and exp value 0.
realvalue then goes the following values during the loop:
9892665.050007
989266.5050012
98926.65050018
9892.665050032
989.2665050039
98.92665050051
9.892665050051

exp finishes at 7

Note the 'error' added in by the successive multiplications is 0.00051

When the rounding value (calculated earlier) is added to realvalue,
the 15th digit is now 1, and therefore within the requested precision.

The call to sqlite3_snprintf() asks for 15 digits precision, hence the
'01' gets displayed in the result to the shell.

To summarize, the successive multiplication in vxprintf introduces a
large enough error that it is representable by the precision requested
by sqlite_column_text().

Interestingly, if the line is changed to
   while( realvalue>=10.0 && exp<=350 ){ realvalue /= 10; exp++; }
then the accumulated error is less, and the correct value is printed.
Of course, this change may break other builds.

One wonders why XP/VC++ produces such a large error in its floating
point manipulations that appears to be avoided by other compilers.

Rgds,
Simon


On 05/09/07, Doug Currie <[EMAIL PROTECTED]> wrote:
> On Wednesday, September 05, 2007 Arjen Markus wrote:
>
> > Doug Currie wrote:
>
> >>I suspect the bug is in the functions that convert between string and
> >>double; that's why I keep harping on Steele and White's (and
> >>Clinger's) PLDI 1990 papers. What I don't know is why this bug appears
> >>in the binary from sqlite.org but not in the version I build myself
> >>with gcc 3.4.5 from SQLite version 3.4.2 source.
> >>
> >>
> >>
> > The implementation of that algorithm is far from trivial. It actually
> > requires the
> > use of an arbitrary-precision library (or so at least is my understanding).
>
> Yes, in some cases big integers are needed. In extreme cases, e.g.,
> denormalized numbers, up to 160 bytes may be required.
>
> I have implemented these algorithms, twice, but for employers with
> proprietary programs. The algorithms are also implemented in glibc
> based on high quality code from David Gay (Bell Labs, Lucent, Sandia,
> Netlib), available with a BSD license at
> http://netlib.sandia.gov/fp/index.html
>
> e
>
> --
> Doug Currie
> Londonderry, NH, USA
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -
>
>

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



Re: [sqlite] Re: select round(98926650.50001, 1) ?

2007-09-05 Thread Nuno Lucas
On 9/5/07, Simon Davies <[EMAIL PROTECTED]> wrote:
[...]
> in sqlite3VdbeMemStringify.
> This resolves down to calling a function vxprintf, which has the following 
> line:
>
>while( realvalue>=10.0 && exp<=350 ){ realvalue *= 0.1; exp++; }
>
[...]
> Interestingly, if the line is changed to
>while( realvalue>=10.0 && exp<=350 ){ realvalue /= 10; exp++; }
> then the accumulated error is less, and the correct value is printed.
> Of course, this change may break other builds.
>
> One wonders why XP/VC++ produces such a large error in its floating
> point manipulations that appears to be avoided by other compilers.

What about defining __STD_IEC_559 before the compilation?
Acording to this:

   http://david.tribble.com/text/cdiffs.htm#C99-iec60559

C99 allows one to force the compiler to follow the standard, so maybe
libc does it by default, but the official sqlite compiled version
(which IIRC is linked with the old Microsoft C runtime DLL) doesn't.


Regards,
~Nuno Lucas


>
> Rgds,
> Simon

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



Re: [sqlite] Re: select round(98926650.50001, 1) ?

2007-09-05 Thread Simon Davies
Hi Nuno,

Have tried your suggestion; added __STD_IEC_559 to preprocessor
definitions for the sqlite project in Visual Studio. Same result.

I noted that the preprocessor macro quoted is applicable to C99 and
not C++. So I then tried specifying that Visual Studio compile the
sqlite code as C rather than C++ (it probably was doing that anyway),
but again with the same result.

Rgds,
Simon

On 05/09/07, Nuno Lucas <[EMAIL PROTECTED]> wrote:
> On 9/5/07, Simon Davies <[EMAIL PROTECTED]> wrote:
> [...]
> > in sqlite3VdbeMemStringify.
> > This resolves down to calling a function vxprintf, which has the following 
> > line:
> >
> >while( realvalue>=10.0 && exp<=350 ){ realvalue *= 0.1; exp++; }
> >
> [...]
> > Interestingly, if the line is changed to
> >while( realvalue>=10.0 && exp<=350 ){ realvalue /= 10; exp++; }
> > then the accumulated error is less, and the correct value is printed.
> > Of course, this change may break other builds.
> >
> > One wonders why XP/VC++ produces such a large error in its floating
> > point manipulations that appears to be avoided by other compilers.
>
> What about defining __STD_IEC_559 before the compilation?
> Acording to this:
>
>   http://david.tribble.com/text/cdiffs.htm#C99-iec60559
>
> C99 allows one to force the compiler to follow the standard, so maybe
> libc does it by default, but the official sqlite compiled version
> (which IIRC is linked with the old Microsoft C runtime DLL) doesn't.
>
>
> Regards,
> ~Nuno Lucas
>
>
> >
> > Rgds,
> > Simon
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -
>
>

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



Re: [sqlite] beginner

2007-09-05 Thread Clay Dowling
Nishit,

Much as we believe in helping out new people, I think it is reasonable to
expect that before you ask for helping in using the C interface to SQLite
that you familiarize yourself with C.  Looping and logic structures are
something you should learn pretty early on, and if you haven't reached
that point yet SQLite is going to be well beyond you.

If you're truly this lost, let me recommend "The C Programming Language",
which while basic, is also very good.

Clay

nishit sharma wrote:
> thanks for this help. i have done this...
> my another problem is that i have multiple columns in my database and on
> the
> basis of
> two columns( has integer values) i have to read the database.
> but i m unable to make a loop in C.
> can u help me.
>
> regards
> Nishit
>
>
> On 9/3/07, Pavan <[EMAIL PROTECTED]> wrote:
>>
>> You should link the library when you compile .It should be gcc
>> test.c-l
>> library name should be your sqlite shared library.  Just check in
>> /usr/lib
>> directory
>>
>> Thanks,
>> Pavan.
>>
>>
>> On 8/31/07, nishit sharma <[EMAIL PROTECTED]> wrote:
>> >
>> > hey buddy can u tell me how to compile the C source code in which i
>> have
>> > used
>> > sqlite3_open() like calls.
>> > i m doing gcc test.c but it is giving me error of undefined reference.
>> > i think i am missing some thing in compiling.
>> > waiting for reply
>> >
>> > regards
>> > Nishit
>> >
>> >
>> > On 8/30/07, nishit sharma <[EMAIL PROTECTED]> wrote:
>> > >
>> > > thanks for telling the link.
>> > >
>> > > regards
>> > >
>> > >
>> > >  On 8/30/07, Pavan <[EMAIL PROTECTED]> wrote:
>> > > >
>> > > > Hi Nishit,
>> > > >
>> > > > http://www.sqlite.org/quickstart.html
>> > > >
>> > > > This is a good link to start with.
>> > > >
>> > > > Thanks,
>> > > > Pavan.
>> > > >
>> > > >
>> > > > On 8/30/07, nishit sharma <[EMAIL PROTECTED]> wrote:
>> > > > >
>> > > > > Hi,
>> > > > > i m beginner to sqlite
>> > > > > can anybody send me a link which can help me
>> > > > > in building and maintining databse
>> > > > >
>> > > >
>> > > >
>> > > >
>> > > > --
>> > > > '
>> > > > Always finish stronger than you start
>> > > > *
>> > > >
>> > >
>> > >
>> >
>>
>>
>>
>> --
>> '
>> Always finish stronger than you start
>> *
>>
>


-- 
Lazarus Registration
http://www.lazarusid.com/registration.shtml


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



Re: [sqlite] Re: select round(98926650.50001, 1) ?

2007-09-05 Thread Cory Nelson
On 9/5/07, Nuno Lucas <[EMAIL PROTECTED]> wrote:
> What about defining __STD_IEC_559 before the compilation?
> Acording to this:
>
>http://david.tribble.com/text/cdiffs.htm#C99-iec60559
>
> C99 allows one to force the compiler to follow the standard, so maybe
> libc does it by default, but the official sqlite compiled version
> (which IIRC is linked with the old Microsoft C runtime DLL) doesn't.

it is defined by the compiler to indicate that it conforms.  it is not
something that you yourself define.

-- 
Cory Nelson

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



Re: [sqlite] Re: select round(98926650.50001, 1) ?

2007-09-05 Thread Nuno Lucas
On 9/5/07, Cory Nelson <[EMAIL PROTECTED]> wrote:
> On 9/5/07, Nuno Lucas <[EMAIL PROTECTED]> wrote:
> > What about defining __STD_IEC_559 before the compilation?
> > Acording to this:
> >
> >http://david.tribble.com/text/cdiffs.htm#C99-iec60559
> >
> > C99 allows one to force the compiler to follow the standard, so maybe
> > libc does it by default, but the official sqlite compiled version
> > (which IIRC is linked with the old Microsoft C runtime DLL) doesn't.
>
> it is defined by the compiler to indicate that it conforms.  it is not
> something that you yourself define.

ugh! Don't know how I got it wrong!
Seems like I read it in a wishful thinking way. Sorry for the noise.


Regards,
~Nuno Lucas

> --
> Cory Nelson

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



[sqlite] Re: Re: Re: Merging two tables

2007-09-05 Thread Igor Tandetnik

RaghavendraK 70574
<[EMAIL PROTECTED]> wrote:

Will this function receive the database column values or indexes?


Why don't you read the fine manual?

http://sqlite.org/capi3ref.html#sqlite3_create_function

The function receives an array of sqlite3_value* pointers, one for each 
argument. There is a set of APIs for extracting information from these 
structures - see sqlite3_value_* . The function reports its return value 
by calling one of sqlite3_result_* APIs.


Igor Tandetnik 



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



Re: [sqlite] beginner

2007-09-05 Thread Pavan
Also, just to add when you reply back with a different query to the list,
pls post a seperate mail with a appropriate subject line so that more people
might be interested to help you.

Thanks,
Pavan.




On 9/5/07, Clay Dowling <[EMAIL PROTECTED]> wrote:
>
> Nishit,
>
> Much as we believe in helping out new people, I think it is reasonable to
> expect that before you ask for helping in using the C interface to SQLite
> that you familiarize yourself with C.  Looping and logic structures are
> something you should learn pretty early on, and if you haven't reached
> that point yet SQLite is going to be well beyond you.
>
> If you're truly this lost, let me recommend "The C Programming Language",
> which while basic, is also very good.
>
> Clay
>
> nishit sharma wrote:
> > thanks for this help. i have done this...
> > my another problem is that i have multiple columns in my database and on
> > the
> > basis of
> > two columns( has integer values) i have to read the database.
> > but i m unable to make a loop in C.
> > can u help me.
> >
> > regards
> > Nishit
> >
> >
> > On 9/3/07, Pavan <[EMAIL PROTECTED]> wrote:
> >>
> >> You should link the library when you compile .It should be gcc
> >> test.c-l
> >> library name should be your sqlite shared library.  Just check in
> >> /usr/lib
> >> directory
> >>
> >> Thanks,
> >> Pavan.
> >>
> >>
> >> On 8/31/07, nishit sharma <[EMAIL PROTECTED]> wrote:
> >> >
> >> > hey buddy can u tell me how to compile the C source code in which i
> >> have
> >> > used
> >> > sqlite3_open() like calls.
> >> > i m doing gcc test.c but it is giving me error of undefined
> reference.
> >> > i think i am missing some thing in compiling.
> >> > waiting for reply
> >> >
> >> > regards
> >> > Nishit
> >> >
> >> >
> >> > On 8/30/07, nishit sharma <[EMAIL PROTECTED]> wrote:
> >> > >
> >> > > thanks for telling the link.
> >> > >
> >> > > regards
> >> > >
> >> > >
> >> > >  On 8/30/07, Pavan <[EMAIL PROTECTED]> wrote:
> >> > > >
> >> > > > Hi Nishit,
> >> > > >
> >> > > > http://www.sqlite.org/quickstart.html
> >> > > >
> >> > > > This is a good link to start with.
> >> > > >
> >> > > > Thanks,
> >> > > > Pavan.
> >> > > >
> >> > > >
> >> > > > On 8/30/07, nishit sharma <[EMAIL PROTECTED]> wrote:
> >> > > > >
> >> > > > > Hi,
> >> > > > > i m beginner to sqlite
> >> > > > > can anybody send me a link which can help me
> >> > > > > in building and maintining databse
> >> > > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > > --
> >> > > > '
> >> > > > Always finish stronger than you start
> >> > > > *
> >> > > >
> >> > >
> >> > >
> >> >
> >>
> >>
> >>
> >> --
> >> '
> >> Always finish stronger than you start
> >> *
> >>
> >
>
>
> --
> Lazarus Registration
> http://www.lazarusid.com/registration.shtml
>
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>


-- 
'
Always finish stronger than you start
*


[sqlite] Assistance with getting started.

2007-09-05 Thread Robert Berman




Hi,


I am new to the world of SQLite3. I am using C++ on Windows XP. For a 
development IDE I am using MinGW Developer Studio 2.05. After 
downloading SQLite3 I began working with the sample program set and had 
no difficulty properly assigning the correct include path to the MingW 
compiler; to whit, I get no error message.



Unfortunately, linking is not nearly as easy or as self evident. The 
program source is very simple:




#include 

#include 

#include 

#include 


#include "Database.h"

#include "Query.h"


int main()

{

Database db( "database_file.db" );

Query q(db);


q.execute("delete from user");

q.execute("insert into user values(1,'First Person')");

q.execute("insert into user values(2,'Another Person')");


q.get_result("select num,name from user");

while (q.fetch_row())

{

long num = q.getval();

std::string name = q.getstr();


printf("User#%ld: %s\n", num, name.c_str() );

}

q.free_result();

}


The output generated by the linker is as follows:


Linking...
C:\slTest\Debug\ltst..o(.text+0x185): In function `main':
C:\slTest\ltst.cpp:11: undefined reference to 
`Database::Database(std::string const&, IError*)'
C:\slTest\Debug\ltst.o(.text+0x21e):C:\slTest\ltst.cpp:12: undefined 
reference to `Query::Query(Database&)'
C:\slTest\Debug\ltst.o(.text+0x26c):C:\slTest\ltst.cpp:14: undefined 
reference to `Query::execute(std::string const&)'
C:\slTest\Debug\ltst.o(.text+0x321):C:\slTest\ltst.cpp:15: undefined 
reference to `Query::execute(std::string const&)'
C:\slTest\Debug\ltst.o(.text+0x3d6):C:\slTest\ltst.cpp:16: undefined 
reference to `Query::execute(std::string const&)'
C:\slTest\Debug\ltst.o(.text+0x48b):C:\slTest\ltst.cpp:18: undefined 
reference to `Query::get_result(std::string const&)'
C:\slTest\Debug\ltst.o(.text+0x50a):C:\slTest\ltst.cpp:19: undefined 
reference to `Query::fetch_row()'
C:\slTest\Debug\ltst.o(.text+0x52b):C:\slTest\ltst..cpp:21: undefined 
reference to `Query::getval()'
C:\slTest\Debug\ltst.o(.text+0x55d):C:\slTest\ltst.cpp:22: undefined 
reference to `Query::getstr()'
C:\slTest\Debug\ltst.o(.text+0x6ec):C:\slTest\ltst.cpp:26: undefined 
reference to `Query::free_result()'
C:\slTest\Debug\ltst.o(.text+0x712):C:\slTest\ltst.cpp:26: undefined 
reference to `Query::~Query()'
C:\slTest\Debug\ltst.o(.text+0x738):C:\slTest\ltst.cpp:26: undefined 
reference to `Query::~Query()'
C:\slTest\Debug\ltst.o(.text+0x75b):C:\slTest\ltst.cpp:26: undefined 
reference to `Database::~Database()'
C:\slTest\Debug\ltst.o(.text+0x794):C:\slTest\ltst.cpp:26: undefined 
reference to `Database::~Database()'


slTest.exe - 14 error(s), 0 warning(s)

What libraries should I be including that I am not and what relative 
library paths should I be specifying. Any other tidbits of information 
you might like to pass on will be most appreciated.



Thank you for your assistance.


Robert L. Berman


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



Re: [sqlite] Assistance with getting started.

2007-09-05 Thread Joe Wilson
You're using a third-party C++ SQL wrapper library, not sqlite directly.

  #include "Database.h"
  #include "Query.h"

You have to link with that library directly, possibly in addition to
libsqlite3.a. You might get a clue as to its name by looking in the 
sample makefile provided, or examining the header files.

--- Robert Berman <[EMAIL PROTECTED]> wrote:
> I am new to the world of SQLite3. I am using C++ on Windows XP. For a 
> development IDE I am using MinGW Developer Studio 2.05. After 
> downloading SQLite3 I began working with the sample program set and had 
> no difficulty properly assigning the correct include path to the MingW 
> compiler; to whit, I get no error message.



   

Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, 
photos & more. 
http://mobile.yahoo.com/go?refer=1GNXIC

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



Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-09-05 Thread Liam Healy
OK I have posted a new version of extension-functions.tgz on
sqlite.org/contrib.  This version includes definitions for READ_UTF8,
sqlite3ReadUtf8, SKIP_UTF8, sqlite3utf8CharLen, xtra_utf8_bytes,
xtra_utf8_bits, utf_mask taken from the 3.3.13 source code, so it should
continue to work in sqlite 3.4.

Liam

On 9/1/07, Liam Healy <[EMAIL PROTECTED]> wrote:
>
> Good point.  I guess my intent is this: I'd like to use the external
> API completely if possible.  If not, I'm not sure whether to include
> source
> or use the current library (I can see advantages to each).  I guess there
> aren't external API calls that do the needed tasks, so I'll have to figure
> out what to do.
>
> Liam
>
>
> On 9/1/07, Joe Wilson < [EMAIL PROTECTED]> wrote:
> >
> > --- Liam Healy < [EMAIL PROTECTED]> wrote:
> > > Thanks.  I have  changed the use of sqlite3CreateFunc to
> > > sqlite3_create_function.  I did not need to include the source code
> > for
> > > sqlite3utf8CharLen because there's a sqlite3Utf8CharLen (note
> > different
> > > capitalization) in the library.  However, the definition
> >
> > How you intend to integrate your new SQL extension functions into
> > sqlite?
> > As a loadable module or as an sqlite3 source code patch?
> >
> > You can't use sqlite3 internal functions such as sqlite3Utf8CharLen
> > if you're making an external loadable module, which is why it was
> > suggested
> > to copy the function into your code statically. You can only use the
> > published sqlite3 external API in this case. But your library will
> > survive
> > without modifications over new sqlite3 releases.
> >
> > If you're not making an external loable module and are making an sqlite3
> > source patch, just use the script provided earlier in this thread to
> > change
> > the old extension sources to be compatible with the 3.4.x sqlite3.c
> > amalgamation. Mind you, if you're doing the patch approach you may have
> > to
> > keep updating it with every new sqlite release.
> >
> > > of sqlite3ReadUtf8 and needed definitions READ_UTF8, xtra_utf8_bytes,
> > > xtra_utf8_bits, utf_mask are not in 3.4.2, so I needed to
> > > salvage from 3.3.13 source.  This compiles and loads OK, but I'm
> > wondering
> > > if there is a 3.4 way of doing what sqlite3ReadUtf8 did
> > > so that I don't have to carry the definitions.   If anyone has a
> > suggestion
> > > I'd appreciate hearing about it.
> > >
> > > Liam
> > >
> > >
> > > On 8/31/07, Joe Wilson < [EMAIL PROTECTED]> wrote:
> > > >
> > > > --- Liam Healy <[EMAIL PROTECTED]> wrote:
> > > > > I was the one who packaged up extension-functions.tgz and posted
> > on
> > > > > contrib.  I didn't author the original code but I'd like to fix
> > this up.
> > > > > I'm not clear on what needs to be changed.  I gather that
> > > > sqlite3utf8CharLen
> > > > > and sqlite3CreateFunc shouldn't be used.  I'm not sure how to
> > convert to
> > > > use
> > > > > the external API.  Anyone have a pointer?
> > > >
> > > > See:
> > > >
> > > >   http://www.sqlite.org/capi3ref.html#sqlite3_create_function
> > > >
> > > >   http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions
> > > >
> > > > And include this statically in your code, if you require it:
> > > >
> > > > #define SQLITE_SKIP_UTF8(zIn) {\
> > > >   if( (*(zIn++))>=0xc0 ){  \
> > > > while( (*zIn & 0xc0)==0x80 ){ zIn++; } \
> > > >   }\
> > > > }
> > > >
> > > > int sqlite3Utf8CharLen(const char *zIn, int nByte){
> > > >   int r = 0;
> > > >   const u8 *z = (const u8*)zIn;
> > > >   const u8 *zTerm;
> > > >   if( nByte>=0 ){
> > > > zTerm = [nByte];
> > > >   }else{
> > > > zTerm = (const u8*)(-1);
> > > >   }
> > > >   assert( z<=zTerm );
> > > >   while( *z!=0 && z > > > SQLITE_SKIP_UTF8(z);
> > > > r++;
> > > >   }
> > > >   return r;
> > > > }
>
>


Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-09-05 Thread Joe Wilson
Hi Liam,

In func_ext.c and map.h you're including private sqlite3 header 
files: sqliteInt.h, os.h and vdbeInt.h, which change from release 
to release.

If you only use the public sqlite3.h header file instead, it has 
a greater chance of being compatible with new releases.

--- Liam Healy <[EMAIL PROTECTED]> wrote:
> OK I have posted a new version of extension-functions.tgz on
> sqlite.org/contrib.  This version includes definitions for READ_UTF8,
> sqlite3ReadUtf8, SKIP_UTF8, sqlite3utf8CharLen, xtra_utf8_bytes,
> xtra_utf8_bits, utf_mask taken from the 3.3.13 source code, so it should
> continue to work in sqlite 3.4.



   

Building a website is a piece of cake. Yahoo! Small Business gives you all the 
tools to get online.
http://smallbusiness.yahoo.com/webhosting 

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



Re: [sqlite] Re: select round(98926650.50001, 1) ?

2007-09-05 Thread Doug Currie
On Wednesday, September 05, 2007 Simon Davies wrote: 

> [...]
> This resolves down to calling a function vxprintf, which has the following 
> line:

>while( realvalue>=10.0 && exp<=350 ){ realvalue *= 0.1; exp++; }

> When this line is reached, realvalue has value 98926650.5 and exp value 0.
> realvalue then goes the following values during the loop:
> 9892665.050007
> 989266.5050012
> 98926.65050018
> 9892.665050032
> 989.2665050039
> 98.92665050051
> 9.892665050051

> exp finishes at 7

> Note the 'error' added in by the successive multiplications is 0.00051

> [...]

> One wonders why XP/VC++ produces such a large error in its floating
> point manipulations that appears to be avoided by other compilers.

...probably because VC++ uses 64 bits for long double (53 bit
mantissa) whereas gcc uses 96 bits (64 bit mantissa). Note that
realvalue above is declared as LONGDOUBLE_TYPE (long double).
http://msdn2.microsoft.com/en-us/library/9c3yd98k(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/9cx8xs15(vs.80).aspx

e

-- 
Doug Currie
Londonderry, NH, USA


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