Igor, On Mon, Nov 16, 2015 at 12:42 PM, Igor Tandetnik <igor at tandetnik.org> wrote: > On 11/16/2015 12:11 PM, Igor Korot wrote: >> >> The crash occurs when the program tries to retrieve the value for >> "fieldDefaultValue". >> Looking at the output of "PRAGMA table_info(<my_table_name>);" I see >> that the default value column is empty (i.e. the column does not have >> any value) and the column type is integer and field is a PK. >> I think it also may be set as "Auto-Increment". >> >> The crash happens because the program hit a NULL pointer. >> >> Any idea on what to look for? > > > I'm not sure I understand the nature of the problem. Yes, it is entirely > possible - common even - for a column to have no declared default value; in > that case, PRAGMA table_info would report NULL in the corresponding column. > Further, where there is a default value, it doesn't have to be of TEXT type.
It looks like I falsely assumed that it will return an empty string instead. Guess I was wrong. Also, are you saying that if I have a integer field with the default value of 1, I will not be able to retrieve it with sqliteColumnText()? > > You seem to assume the default value always exists and is always a string, > and so it's OK to use sqliteColumnText unconditionally - either assumption > may not hold, and so it's not OK. See above. I know the default value is optional, but thought it will be "". Thank you. > -- > Igor Tandetnik > > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users