Inconsistency between cass_row_get_column_by_name and cass_value_is_null

68 visualizações
Pular para a primeira mensagem não lida

Kirill Khistyaev

não lida,
24 de jul. de 2015, 11:22:0524/07/2015
para DataStax C++ Driver for Apache Cassandra User Mailing List
The behavior of cass_value_is_null() is confusing and inconsistent with cass_row_get_column_by_name().
cass_row_get_column_by_name() returns NULL pointer if column value doesn't exist but if you check this return value with cass_value_is_null() you will get a SEGFAULT because it directly calls value->is_null() without checking passed pointer for NULL. I believe it should check if pointer is NULL first and return true.
Alternatively cass_row_get_column_by_name() should return non-NULL pointer to CassValue that would return TRUE on is_null() check.

Also I couldn't understand in what case cass_value_is_null() will return true.

Michael Penick

não lida,
24 de jul. de 2015, 11:54:2324/07/2015
para cpp-dri...@lists.datastax.com
Agreed. This is confusing. A column in Cassandra can have the "null" value in a valid column (cass_row_get_column_by_name() returns a valid CassValue i.e. null value) and is distinct from the column just not existing (returning a "NULL" pointer  value from cass_row_get_column_by_name() i.e. no value).  The name null is really overloaded here, but they're two distinct states.

I need to think on this a bit more. I'm not a 100% sold on cass_value_is_null() returning TRUE for "NULL"  pointer, but it is a good thought.

Mike

To unsubscribe from this group and stop receiving emails from it, send an email to cpp-driver-us...@lists.datastax.com.

Kirill Khistyaev

não lida,
24 de jul. de 2015, 15:53:0624/07/2015
para cpp-dri...@lists.datastax.com
Now it makes sense  why it is done that way. I haven't seen anything about NULL column value in C* documentation before. But after googling I found when and why it was introduced: https://issues.apache.org/jira/browse/CASSANDRA-3783
Also the fact that cqlsh shows just null for absent columns adds to the confusion. 

I still believe that it is much safer to return TRUE from cass_value_is_null() if actual NULL pointer is passed rather then crash with SEGFAULT (that what I had in my program. Fortunately far from production.).

Kirill
Responder a todos
Responder ao autor
Encaminhar
0 nova mensagem