Hi, ALL,
I was successfully able to use Mr. Hipp' suggestion:

char *z = sqlite3_mprintf("PRAGMA table_info(\"%w\");", zTableName);
The prepare and step z.
Then:  sqlite3_free(z);

However, for some reason, I'm getting crash. Here is the relevant code:

fieldName = reinterpret_cast<const char *>( sqliteColumnText( stmt2, 1 ) );
fieldType = reinterpret_cast<const char *>( sqliteColumnText( stmt2, 2 ) );
fieldIsNull = sqliteColumnInt( stmt2, 3 );
fieldDefaultValue = reinterpret_cast<const char *>( sqliteColumnText(
stmt2, 4 ) );
fieldPK = sqliteColumnInt( stmt2, 5 );
fields.push_back( Field( fieldName, fieldType, fieldDefaultValue,
fieldIsNull, fieldPK == 1 ? true : false ) );

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?
The variables referenced are defined as "std::string" and the code is in C++.

Thank you.

Reply via email to