GNOME Bugzilla – Bug 551058
gda_data_model_iter_get_value_at () does not work with rev #3201
Last modified: 2008-09-10 18:58:35 UTC
Please describe the problem: I cannot get values from a GdaDataModelIter anymore. See example.c attached file for details Steps to reproduce: 1. 2. 3. Actual results: Expected results: Does this happen every time? Other information:
Created attachment 118129 [details] example gda_data_model_dump works good, but as you can see from line 70 to 78 the datamodeliter does not work retrieving the value at the specified col. I used an old example.c file, I just added some lines. Threads and other things don't matter here.
You need to set the iter's position before reading values, use gda_data_model_iter_set_at_row() for example.
Created attachment 118285 [details] Modified test example Modified version where ths iter's position is first set and tested.
(In reply to comment #2) > You need to set the iter's position before reading values, use > gda_data_model_iter_set_at_row() for example. > well, yes that's right. Anyway that's what I was already doing on my engine, and with the latest update it stopped working. I renamed the functions and added the NULL for the GError parameter. I'm investigating what's wrong but I didn't touch anything on my module.
Note that I've also improved the error reporting and if you get a NULL (not a GDA_TYPE_NULL GValue), then there is an error somewhere.
Well I just discovered that having a GdaDataModel like this ---- snip ---- ** Message: symbol_db_engine_iterator_new () symbol_id | name | file_position | is_file_scope | signature | kind_name | access_name ----------+------------------+---------------+---------------+-----------+-----------+------------ 295 | Build | 34 | 0 | | namespace | NULL 628 | Commander | 44 | 0 | | namespace | NULL 608 | Editor | 25 | 0 | | namespace | NULL 765 | Entwickler | 32 | 0 | | namespace | NULL 445 | PesciosNamespace | 39 | 0 | | namespace | NULL (5 rows) Can't set to row 0: current_row=0 (An error occurred) ---- snip ---- It gives me error when trying to set the gda_data_model_iter_set_at_row. The plain code is: gda_data_model_dump (model, stdout); priv->data_iter = gda_data_model_create_iter (model); gint i = 0; if (! gda_data_model_iter_set_at_row (priv->data_iter , i)) { ... I suppose that there can be some problems with the "access_name" field, which is NULL (correctly anyway). It has always worked before.
Created attachment 118302 [details] test_dataiter Here it the modified example.c to work with a anjuta_sym_db.db taken from an imported project. I reproduced the error I'm getting on Anjuta. As you see from the sql1 I'm doing some joins between tables, and then executing the select. The data dump works good but I cannot set the data_iter at row... "Can't set to row 0: current_row=0 (An error occurred)".
The problem comes from the fact that the "access_name" is NULL when the SQL table definition states that the field is NOT NULL: sqlite> .schema sym_access CREATE TABLE sym_access (access_kind_id integer PRIMARY KEY AUTOINCREMENT, access_name varchar (50) not null unique ); It seems SQLite is happy about letting you set NULL values where you're not supposed to. BTW, they ARE NULL values, because it you use the coalesce() function you see: sqlite> SELECT symbol.symbol_id AS symbol_id, symbol.name AS name, symbol.file_position AS file_position, symbol.is_file_scope AS is_file_scope, symbol.signature AS signature, sym_kind.kind_name AS kind_name, coalesce (sym_access.access_name, 'it''s NULL') AS access_name FROM symbol LEFT JOIN sym_access ON symbol.access_kind_id = sym_access.access_kind_id JOIN sym_kind ON symbol.kind_id = sym_kind.sym_kind_id WHERE symbol.scope_id <= 0 AND symbol.is_file_scope = 0 AND sym_kind.kind_name IN ('namespace') GROUP BY symbol.name; symbol_id|name|file_position|is_file_scope|signature|kind_name|access_name 295|Build|34|0||namespace|it's NULL 628|Commander|44|0||namespace|it's NULL 608|Editor|25|0||namespace|it's NULL 765|Entwickler|32|0||namespace|it's NULL 445|PesciosNamespace|39|0||namespace|it's NULL I don't know how to fix this. Till I find a way, can you make sure your data is OK?
I suppose the problem is on the 'left join', and as such it may permit some joined values to be NULL. These NULL values anyway aren't stored in the table itself. sqlite> select * from sym_access; 1|public 2|private 3|protected Correctly sqlite complains if I try to store NULL into that table: sqlite> insert into sym_access (access_name) values (NULL); SQL error: sym_access.access_name may not be NULL tables.sql refers here, http://svn.gnome.org/viewvc/anjuta/trunk/plugins/symbol-db/tables.sql?view=markup. Sorry I didn't attached in the last test.
Oh, you're right, sorry for my mistake... I'll correct the problem ASAP, in the meanwhile, you can modify the libgda/sqlite/gda-sqlite-recordset.c to change gda_column_set_allow_null (column, !(pkey || notnull)); to gda_column_set_allow_null (column, TRUE);
ok thanks for the suggestion, it works that way.
thanks for bugfixing this, with rev #3204 the problem has gone.
Ok, closing the bug then.