Thank you for the suggestion. But I asked if this by design or it is a bug in sqlite and/or documentation.
What do you think? And is it correct mailing list to ask or I should wrote to sqlite-devel? Valery >________________________________ > From: Roger Binns <rog...@rogerbinns.com> >To: Valery Reznic <valery_rez...@yahoo.com>; General Discussion of SQLite >Database <sqlite-users@sqlite.org> >Sent: Tuesday, January 6, 2015 9:46 PM >Subject: Re: [sqlite] sqlite3_exec and returned error > > >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >On 01/05/2015 11:43 PM, Valery Reznic wrote: >> I was planing to use this function like following: >> >> ------------------------------- >> >> int res; char *errmsg; > >I'd recommend you explicitly set that to NULL here. > >> >> res = sqlite3_exec( db, zSql, NULL, NULL, &errmsg ); >> >> if ( res != SQLITE_OK) { fprintf( stderr, "%s", errmsg) >> sqlite3_free( errmsg ) >> >> } > >In your print block you can do this: > > fprintf(stderr, "%d: %s", res, errmsg ? errmsg : "Error"); > >You can also put this line outside the error block (sqlite3_free on >NULL is harmless): > > > > > > sqlite3_free( errmsg ); > >This way you will always free the message no matter what happened, and >will show error text if available. > >Roger >-----BEGIN PGP SIGNATURE----- >Version: GnuPG v1 > >iEYEARECAAYFAlSsO4QACgkQmOOfHg372QROVACeO7Kh4+bz+JME+bdRdeQbvqtt >RKoAoJlkUoluQwvITqqTDak+xCQiBtKE >=40C3 >-----END PGP SIGNATURE----- > > > > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users