[sqlite] Retrieving the table info fails

2015-11-16 Thread R Smith
On 2015/11/16 7:59 PM, Igor Korot wrote: > Stephan, > > On Mon, Nov 16, 2015 at 12:42 PM, Stephan Beal > wrote: >> On Mon, Nov 16, 2015 at 6:11 PM, Igor Korot wrote: >> >>> The variables referenced are defined as "std::string" and the code is in >>> C++. >>> >> the std::string(char const *) co

[sqlite] Retrieving the table info fails

2015-11-16 Thread Simon Slavin
On 16 Nov 2015, at 9:09pm, Igor Korot wrote: > 1|name|varchar(100)|0 | |0 Note that this does not tell you anything about the affinity of the column, or the types of the values in it. SQLite doesn't even have a varchar type. > "dflt_value" field may or may

[sqlite] Retrieving the table info fails

2015-11-16 Thread Simon Slavin
On 16 Nov 2015, at 7:40pm, Igor Korot wrote: > But if I issue this PRAGMA command the field name, field type and the PK > are guaranteed to have some values, right? No. Create a field without a declared type and use that as your primary key. > You can't create a field without a name Correct.

[sqlite] Retrieving the table info fails

2015-11-16 Thread Simon Slavin
On 16 Nov 2015, at 5:51pm, Igor Korot wrote: > It looks like I falsely assumed that it will return an empty string instead. > Guess I was wrong. The empty string is a perfectly legitimate default value for a column. And it's not the same as NULL, a different perfectly legitimate default value

[sqlite] Retrieving the table info fails

2015-11-16 Thread Stephan Beal
On Mon, Nov 16, 2015 at 6:42 PM, Stephan Beal wrote: > On Mon, Nov 16, 2015 at 6:11 PM, Igor Korot wrote: > >> The variables referenced are defined as "std::string" and the code is in >> C++. >> > > the std::string(char const *) constructor does not, last time i checked, > accept a NULL value.

[sqlite] Retrieving the table info fails

2015-11-16 Thread Stephan Beal
On Mon, Nov 16, 2015 at 6:11 PM, Igor Korot wrote: > The variables referenced are defined as "std::string" and the code is in > C++. > the std::string(char const *) constructor does not, last time i checked, accept a NULL value. You will need to pass it "" in that case. [stephan at host:~/tmp]

[sqlite] Retrieving the table info fails

2015-11-16 Thread Igor Tandetnik
On 11/16/2015 5:26 PM, Igor Korot wrote: > Do you have any idea what would be the affinity if I do this: > > CREATE TABLE test( field1 PRIMARY KEY, field2); > > for both field1 and field2? From the aforementioned documentation article: If the declared type for a column contains the string "BLOB"

[sqlite] Retrieving the table info fails

2015-11-16 Thread Igor Korot
Igor, On Mon, Nov 16, 2015 at 4:50 PM, Igor Tandetnik wrote: > On 11/16/2015 4:20 PM, Simon Slavin wrote: >> >> >> On 16 Nov 2015, at 9:09pm, Igor Korot wrote: >> >>> 1|name|varchar(100)|0 | |0 >> >> >> Note that this does not tell you anything about the affin

[sqlite] Retrieving the table info fails

2015-11-16 Thread Igor Tandetnik
On 11/16/2015 4:20 PM, Simon Slavin wrote: > > On 16 Nov 2015, at 9:09pm, Igor Korot wrote: > >> 1|name|varchar(100)|0 | |0 > > Note that this does not tell you anything about the affinity of the column Does too. Column affinity is deduced from declared type, f

[sqlite] Retrieving the table info fails

2015-11-16 Thread Igor Korot
Simon, On Mon, Nov 16, 2015 at 4:20 PM, Simon Slavin wrote: > > On 16 Nov 2015, at 9:09pm, Igor Korot wrote: > >> 1|name|varchar(100)|0 | |0 > > Note that this does not tell you anything about the affinity of the column, > or the types of the values in it. SQ

[sqlite] Retrieving the table info fails

2015-11-16 Thread Igor Korot
Simon, On Mon, Nov 16, 2015 at 3:13 PM, Simon Slavin wrote: > > On 16 Nov 2015, at 7:40pm, Igor Korot wrote: > >> But if I issue this PRAGMA command the field name, field type and the PK >> are guaranteed to have some values, right? > > No. Create a field without a declared type and use that as

[sqlite] Retrieving the table info fails

2015-11-16 Thread Igor Korot
Hi, On Mon, Nov 16, 2015 at 2:20 PM, R Smith wrote: > > > On 2015/11/16 7:59 PM, Igor Korot wrote: >> >> Stephan, >> >> On Mon, Nov 16, 2015 at 12:42 PM, Stephan Beal >> wrote: >>> >>> On Mon, Nov 16, 2015 at 6:11 PM, Igor Korot wrote: >>> The variables referenced are defined as "std::stri

[sqlite] Retrieving the table info fails

2015-11-16 Thread Igor Korot
Stephan, On Mon, Nov 16, 2015 at 12:42 PM, Stephan Beal wrote: > On Mon, Nov 16, 2015 at 6:11 PM, Igor Korot wrote: > >> The variables referenced are defined as "std::string" and the code is in >> C++. >> > > the std::string(char const *) constructor does not, last time i checked, > accept a NU

[sqlite] Retrieving the table info fails

2015-11-16 Thread Igor Tandetnik
On 11/16/2015 12:51 PM, Igor Korot wrote: > 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 might be - I think SQLite will automatically convert it to the string "1". -- Igor Tandetnik

[sqlite] Retrieving the table info fails

2015-11-16 Thread Igor Korot
Igor, On Mon, Nov 16, 2015 at 12:42 PM, Igor Tandetnik 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();" I see >> that the default value column is em

[sqlite] Retrieving the table info fails

2015-11-16 Thread Igor Tandetnik
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();" I see > that the default value column is empty (i.e. the column does not have > any value) and the column type is in

[sqlite] Retrieving the table info fails

2015-11-16 Thread Igor Korot
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( sqliteColumnTex

[sqlite] Retrieving the table info fails

2015-11-16 Thread Scott Hess
On Mon, Nov 16, 2015 at 11:20 AM, R Smith wrote: > On 2015/11/16 7:59 PM, Igor Korot wrote: >> >> BTW, are only name, type and pk fields are guaranteed to have a value? >> > > Nothing is guaranteed to have a value unless created with NOT NULL in the > field specification in the CREATE TABLE schem