>> 2010/3/6 Chimerian <chimer...@o2.pl>: >> values.push_back((char*)sqlite3_column_text(statement, col)); >> // HERE IS ERROR !
>From: Simon Davies >What error? >I can not see why THIS line should provoke any error; This line will produce a runtime error when sqlite3_column_text(statement, col); returns NULL pointer (and NULL value is a valid value for any affinity if not restricted by NO NULL clause) > but be aware that you are creating a vector of INVALID pointers. No. values.push_back is not creating vector of invalid pointers. It is creating vector of strings. The problem is no valid string can be created from NULL pointer. This function will fail trying to obtain the length of the string from NULL pointer. >The return from sqlite3_column_text is not valid after subsequent calls to any of >sqlite3_step/sqlite3_reset/sqlite3_finalize. VERY TRUE! It is easy to forget about it! >You need to make a copy of the string and store that, not the pointer >returned from sqlite3_column_text. True. But this is done automatically by values.push_back() The vector, like all other Standard Library containers, stores copies - these copies are made with the copy constructor. Regards, Samuel __________________________________________________________________ Make your browsing faster, safer, and easier with the new Internet Explorer® 8. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/ _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users