Re: [sqlite] sqlite3_close ==> " library routine called out of sequence"

2010-02-25 Thread Jean-Denis Muys

On 2/24/10 19:19 , "D. Richard Hipp"  wrote:

> 
> On Feb 24, 2010, at 1:12 PM, Mike Shal wrote:
>>> 
>>> This compiler is llvm. Check it out at http://llvm.org
>>> You can test for this mistake on the demo page at http://llvm.org/
>>> demo
>>> 
> 
> 
> FWIW, there are currently two places in SQLite where we have had to
> complicate the code in order to work around bugs in LLVM.
> 
> D. Richard Hipp
> d...@hwaci.com

Yes LLVM and especially Clang are rather young. It's not surprising they do
have bugs. Hopefully, the issues that you encountered with SQLite will let
them fix those bugs and improve.

Overall however, I am very impressed by what the LLVM has been able to
accomplish in just a a few years.

For example, LLVM is behind:

- the latest Objective C 2.0 Mac OS X compiler
- the Arm compiler with Objective-C support for the iPhone
- The MacRuby interpreter and native compiler for the Ruby language
- The Smalltalk system part of the Étoilé project.

The main lacking point (for me) now is C++ support. It's planned for the end
of this year. I hope they can make it.

Jean-Denis

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


Re: [sqlite] sqlite3_close ==> " library routine called out of sequence"

2010-02-25 Thread Jean-Denis Muys

On 2/24/10 19:12 , "Mike Shal"  wrote:

> On 2/24/10, Jean-Denis Muys  wrote:
>> 
>>  On 2/24/10 9:36 , "Simon Davies"  wrote:
>> 
>>> Rogue semicolon on line
>>> 
  if( sqlite3_close( db ) != SQLITE_OK );
>>> 
>>> Regards,
>>> Simon
>> 
>> 
>> I have been bitten by such silly mistakes often enough!
>> 
>>  This is why I have switched to a compiler with sanity checks. On this line
>>  of code, it warns:
>> 
>>  "if statement has empty body"
>> 
>>  This compiler is llvm. Check it out at http://llvm.org
>>  You can test for this mistake on the demo page at http://llvm.org/demo
>> 
> 
> What compiler were you using before? Gcc warns about this too, though
> you have to explicitly enable the warning using -W (or -Wempty-body
> for just that particular warning).
> 
> I suppose you could argue whether or not it's right to have that
> warning on by default, but I've found warnings are generally a matter
> of personal preference. If you don't make spurious semicolon mistakes,
> you probably don't need that warning on. I make tons of such mistakes,
> so I use a variant of the BDECFLAGS. That helps catch most of the
> stupid things I do :)
> 

I yes I switched from GCC, but not for that particular warning. The three
features of LLVM/Clang technology that won me over are the generally much
better error messages, link-time optimization and the static code analyzer.

In any case, though I did not make any claim regarding its handling of this
issue, I stand corrected on GCC.

And yes I do try to keep warnings on as much as possible.

Jean-Denis

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


Re: [sqlite] sqlite3_close ==> " library routine called out of sequence"

2010-02-24 Thread D. Richard Hipp

On Feb 24, 2010, at 1:12 PM, Mike Shal wrote:
>>
>> This compiler is llvm. Check it out at http://llvm.org
>> You can test for this mistake on the demo page at http://llvm.org/ 
>> demo
>>


FWIW, there are currently two places in SQLite where we have had to  
complicate the code in order to work around bugs in LLVM.

D. Richard Hipp
d...@hwaci.com



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


Re: [sqlite] sqlite3_close ==> " library routine called out of sequence"

2010-02-24 Thread Mike Shal
On 2/24/10, Jean-Denis Muys  wrote:
>
>  On 2/24/10 9:36 , "Simon Davies"  wrote:
>
>  > Rogue semicolon on line
>  >
>  >>  if( sqlite3_close( db ) != SQLITE_OK );
>  >
>  > Regards,
>  > Simon
>
>
> I have been bitten by such silly mistakes often enough!
>
>  This is why I have switched to a compiler with sanity checks. On this line
>  of code, it warns:
>
>  "if statement has empty body"
>
>  This compiler is llvm. Check it out at http://llvm.org
>  You can test for this mistake on the demo page at http://llvm.org/demo
>

What compiler were you using before? Gcc warns about this too, though
you have to explicitly enable the warning using -W (or -Wempty-body
for just that particular warning).

I suppose you could argue whether or not it's right to have that
warning on by default, but I've found warnings are generally a matter
of personal preference. If you don't make spurious semicolon mistakes,
you probably don't need that warning on. I make tons of such mistakes,
so I use a variant of the BDECFLAGS. That helps catch most of the
stupid things I do :)

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


Re: [sqlite] sqlite3_close ==> " library routine called out of sequence"

2010-02-24 Thread newlog


I CAN'T BELIEVE I'VE DONE THIS !!!

I must be so stupid that I've spent days wondering why.

Thank you so much Simon for your very advised look on my code.


I deeply apologize for polluting that forum with such a silly mistake.

Regards

Very well done Simon !!


On Feb 24, 9:54 am, Jean-Denis Muys  wrote:
> On 2/24/10 9:36 , "Simon Davies"  wrote:
>
> > On 23 February 2010 17:44, newlog  wrote:
> >> OK,
>
> >> I really don't understand
>
> > Rogue semicolon on line
>
> >>  if( sqlite3_close( db ) != SQLITE_OK );
>
> > Regards,
> > Simon
>
> I have been bitten by such silly mistakes often enough!
>
> This is why I have switched to a compiler with sanity checks. On this line
> of code, it warns:
>
> "if statement has empty body"
>
> This compiler is llvm. Check it out athttp://llvm.org
> You can test for this mistake on the demo page athttp://llvm.org/demo
>
> For example insert a spurious ; in this line in the proposed factorial demo
>
>   if (X == 0); return 1;
>
> Llvm is quite amazing for a number of reasons I won't go into here. Check it
> out.
>
> Jean-Denis
>
> ___
> sqlite-users mailing list
> sqlite-us...@sqlite.orghttp://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] sqlite3_close ==> " library routine called out of sequence"

2010-02-24 Thread Jean-Denis Muys

On 2/24/10 9:36 , "Simon Davies"  wrote:

> On 23 February 2010 17:44, newlog  wrote:
>> OK,
>> 
>> I really don't understand
>> 
> 
> Rogue semicolon on line
> 
>>  if( sqlite3_close( db ) != SQLITE_OK );
> 
> Regards,
> Simon

I have been bitten by such silly mistakes often enough!

This is why I have switched to a compiler with sanity checks. On this line
of code, it warns:

"if statement has empty body"

This compiler is llvm. Check it out at http://llvm.org
You can test for this mistake on the demo page at http://llvm.org/demo

For example insert a spurious ; in this line in the proposed factorial demo

  if (X == 0); return 1;

Llvm is quite amazing for a number of reasons I won't go into here. Check it
out.

Jean-Denis

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


Re: [sqlite] sqlite3_close ==> " library routine called out of sequence"

2010-02-24 Thread Simon Davies
On 23 February 2010 17:44, newlog  wrote:
> OK,
>
> With the following code :
>
> -
>
> sqlite3        *db = NULL;
>
>  if( sqlite3_open( "D:\Test3.db", ) != SQLITE_OK )
>       {
>        // Exit if error while opening.
>        wxMessageBox( wxString( "Error while opening :\n") <<
> sqlite3_errmsg(db)  );
>        sqlite3_close(db);
>        return;
>      }
>
>
>  if( sqlite3_close( db ) != SQLITE_OK );
>        {
>          // Exit if error on closing.
>          wxMessageBox( wxString("Error while closing : \n")   <<
> sqlite3_errmsg( db )    );
>          return;
>        }
>
> A Message windo prompts : " Error while closing : library routine
> called out of sequence "
>
>
> I have to say that the statement sqlite3_open works fine because I
> have no error on opening and I can successfully write/retrieve data in
> the Test3.db database file.
>
>
> I really don't understand
>

Rogue semicolon on line

>  if( sqlite3_close( db ) != SQLITE_OK );

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


Re: [sqlite] sqlite3_close ==> " library routine called out of sequence"

2010-02-23 Thread Simon Slavin

On 23 Feb 2010, at 10:06pm, Simon Slavin wrote:

> Change the two error messages so the first one has a '1' in it and the second 
> one has a '2' in it.  Then run it again and tell us which of the two error 
> messages is being shown.

Ignore that.  I got confused.  Heh heh.

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


Re: [sqlite] sqlite3_close ==> " library routine called out of sequence"

2010-02-23 Thread Simon Slavin

On 23 Feb 2010, at 5:44pm, newlog wrote:

> With the following code :
> 
> -
> 
> sqlite3*db = NULL;
> 
>  if( sqlite3_open( "D:\Test3.db", ) != SQLITE_OK )
>   {
>// Exit if error while opening.
>wxMessageBox( wxString( "Error while opening :\n") <<
> sqlite3_errmsg(db)  );
>sqlite3_close(db);
>return;
>  }
> 
> 
>  if( sqlite3_close( db ) != SQLITE_OK );
>{
>  // Exit if error on closing.
>  wxMessageBox( wxString("Error while closing : \n")   <<
> sqlite3_errmsg( db ));
>  return;
>}
> 
> 
> __
> 
> 
> A Message windo prompts : " Error while closing : library routine
> called out of sequence "

Change the two error messages so the first one has a '1' in it and the second 
one has a '2' in it.  Then run it again and tell us which of the two error 
messages is being shown.

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


Re: [sqlite] sqlite3_close ==> " library routine called out of sequence"

2010-02-23 Thread newlog
OK,

With the following code :

-

sqlite3*db = NULL;

  if( sqlite3_open( "D:\Test3.db", ) != SQLITE_OK )
   {
// Exit if error while opening.
wxMessageBox( wxString( "Error while opening :\n") <<
sqlite3_errmsg(db)  );
sqlite3_close(db);
return;
  }


  if( sqlite3_close( db ) != SQLITE_OK );
{
  // Exit if error on closing.
  wxMessageBox( wxString("Error while closing : \n")   <<
sqlite3_errmsg( db ));
  return;
}


__


A Message windo prompts : " Error while closing : library routine
called out of sequence "


I have to say that the statement sqlite3_open works fine because I
have no error on opening and I can successfully write/retrieve data in
the Test3.db database file.


I really don't understand



On Feb 23, 6:02 pm, Simon Davies 
wrote:
> On 23 February 2010 16:46, newlog  wrote:
>
> > Hi Simon,
>
> > Thanx for your answer,
>
> > IN case of error when trying to open the file, we close db pointer and
> > exit the sub-routine ( return keyword follows closing ).
>
> > So 'sqlite3_close' can't be called twice.
>
> My point was that if the database open has failed, then close will
> provoke MISUSE
>
>
>
> > Sincerely,
>
> > John
>
> Regards,
> Simon
> ___
> sqlite-users mailing list
> sqlite-us...@sqlite.orghttp://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] sqlite3_close ==> " library routine called out of sequence"

2010-02-23 Thread Simon Davies
On 23 February 2010 16:46, newlog  wrote:
> Hi Simon,
>
> Thanx for your answer,
>
>
> IN case of error when trying to open the file, we close db pointer and
> exit the sub-routine ( return keyword follows closing ).
>
> So 'sqlite3_close' can't be called twice.

My point was that if the database open has failed, then close will
provoke MISUSE

>
> Sincerely,
>
> John
>

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


Re: [sqlite] sqlite3_close ==> " library routine called out of sequence"

2010-02-23 Thread newlog
Hi Simon,

Thanx for your answer,


IN case of error when trying to open the file, we close db pointer and
exit the sub-routine ( return keyword follows closing ).

So 'sqlite3_close' can't be called twice.

Sincerely,

John



On Feb 23, 2:40 pm, Simon Davies 
wrote:
> On 23 February 2010 12:51, John  wrote:> Forgot to say 
> that the error occurs at the sqlite3_close   function.
>
> > John
>
> >> The very simple C-code below returns error message " library routine
> >> called out of sequence" .
> >> I really don't understand why  ?
>
> >> I'm using SQLite 3.6.22 under Windows XP
>
> >> Any idea/suggestion would be really appreciated !
>
> .
> .
> .
>
> >> Thanx for your help,
>
> >> John
>
> There are 2 calls to sqlite3_close in your code snippet. If the error
> occurs on the first, then the open has failed, and the error on close
> is probably the expected result.
>
> Regards,
> Simon
> ___
> sqlite-users mailing list
> sqlite-us...@sqlite.orghttp://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] sqlite3_close ==> " library routine called out of sequence"

2010-02-23 Thread Nick Shaw
What's the actual code output from your program?  i.e. which
sqlite3_close() is it failing on?

Can you call sqlite3_errmsg() when sqlite3_open() failed to initialise
the db struct?  I would have thought "db" would be invalid at that
point.  Try setting db to NULL when declaring it, as otherwise you may
be calling sqlite3_errmsg() with a non-null invalid pointer (it'll be
some random memory address if it's not nullified by sqlite3_open() on
open failure), which sqlite3 attempts to use but fails, resulting in
your "library routine called out of sequence" error?

Nick.

-Original Message-
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of John
Sent: 23 February 2010 10:17
To: sqlite-users@sqlite.org
Subject: [sqlite] sqlite3_close ==> " library routine called out of
sequence"



Hi All,

The very simple C-code below returns error message " library routine
called out of sequence" .
I really don't understand why  ?

I'm using SQLite 3.6.22 under Windows XP

Any idea/suggestion would be really appreciated !


-
 sqlite3*db;
 sqlite3_stmt   *statement;
 wxStringTMPstring;


  if( sqlite3_open( "Test3.db", ) )
  { TMPstring << "Failed opening databse file:\n" <<
sqlite3_errmsg(db);
wxMessageBox( TMPstring );
sqlite3_close(db);
return;
  }


if( sqlite3_close( db ) != SQLITE_OK );
{   wxMessageBox( wxString("Database can not be closed
properly !\n\n")   << sqlite3_errmsg( db ));
return( -1 );
}

-


Thanx for your help,


John



___
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] sqlite3_close ==> " library routine called out of sequence"

2010-02-23 Thread Simon Davies
On 23 February 2010 12:51, John  wrote:
> Forgot to say that the error occurs at the sqlite3_close   function.
>
> John
>
>> The very simple C-code below returns error message " library routine
>> called out of sequence" .
>> I really don't understand why  ?
>>
>> I'm using SQLite 3.6.22 under Windows XP
>>
>> Any idea/suggestion would be really appreciated !
>>
.
.
.
>> Thanx for your help,
>>
>> John

There are 2 calls to sqlite3_close in your code snippet. If the error
occurs on the first, then the open has failed, and the error on close
is probably the expected result.

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


Re: [sqlite] sqlite3_close ==> " library routine called out of sequence"

2010-02-23 Thread John
Forgot to say that the error occurs at the sqlite3_close   function.

John

On Feb 23, 11:17 am, John  wrote:
> Hi All,
>
> The very simple C-code below returns error message " library routine
> called out of sequence" .
> I really don't understand why  ?
>
> I'm using SQLite 3.6.22 under Windows XP
>
> Any idea/suggestion would be really appreciated !
>
> -
>  sqlite3        *db;
>  sqlite3_stmt   *statement;
>  wxString        TMPstring;
>
>   if( sqlite3_open( "Test3.db", ) )
>   {     TMPstring << "Failed opening databse file:\n" <<
> sqlite3_errmsg(db);
>         wxMessageBox( TMPstring );
>         sqlite3_close(db);
>         return;
>   }
>
>     if( sqlite3_close( db ) != SQLITE_OK );
>         {   wxMessageBox( wxString("Database can not be closed
> properly !\n\n")   << sqlite3_errmsg( db )    );
>             return( -1 );
>         }
>
> -
>
> Thanx for your help,
>
> John
>
> ___
> sqlite-users mailing list
> sqlite-us...@sqlite.orghttp://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