After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 551058 - gda_data_model_iter_get_value_at () does not work with rev #3201
gda_data_model_iter_get_value_at () does not work with rev #3201
Status: RESOLVED FIXED
Product: libgda
Classification: Other
Component: general
unspecified
Other All
: Normal blocker
: ---
Assigned To: malerba
gnome-db Maintainers
Depends on:
Blocks: 358479
 
 
Reported: 2008-09-05 22:39 UTC by Massimo Cora'
Modified: 2008-09-10 18:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
example (7.98 KB, text/plain)
2008-09-05 22:43 UTC, Massimo Cora'
Details
Modified test example (6.50 KB, application/octet-stream)
2008-09-08 09:29 UTC, malerba
Details
test_dataiter (80.89 KB, application/x-compressed-tar)
2008-09-08 14:36 UTC, Massimo Cora'
Details

Description Massimo Cora' 2008-09-05 22:39:13 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:
Comment 1 Massimo Cora' 2008-09-05 22:43:26 UTC
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.
Comment 2 malerba 2008-09-08 09:28:14 UTC
You need to set the iter's position before reading values, use gda_data_model_iter_set_at_row() for example.
Comment 3 malerba 2008-09-08 09:29:24 UTC
Created attachment 118285 [details]
Modified test example

Modified version where ths iter's position is first set and tested.
Comment 4 Massimo Cora' 2008-09-08 13:27:41 UTC
(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.
Comment 5 malerba 2008-09-08 13:39:24 UTC
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.
Comment 6 Massimo Cora' 2008-09-08 14:00:31 UTC
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.

Comment 7 Massimo Cora' 2008-09-08 14:36:21 UTC
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)".
Comment 8 malerba 2008-09-08 15:32:52 UTC
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?
Comment 9 Massimo Cora' 2008-09-08 15:57:19 UTC
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.

Comment 10 malerba 2008-09-09 09:34:29 UTC
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);
Comment 11 Massimo Cora' 2008-09-09 17:23:51 UTC
ok thanks for the suggestion, it works that way.
Comment 12 Massimo Cora' 2008-09-10 18:36:44 UTC
thanks for bugfixing this, with rev #3204 the problem has gone.
Comment 13 malerba 2008-09-10 18:58:35 UTC
Ok, closing the bug then.