tupshin / cassandra-rs

Apache License 2.0
50 stars 16 forks source link

calling get_col_by_name causes panic and program exit #23

Closed rustyrazorblade closed 8 years ago

rustyrazorblade commented 8 years ago

This snippet:

let query = format!("select column_name, type from system_schema.columns where keyspace_name = '{}' and table_name = '{}'", keyspace, table);
            let schema_query = Statement::new(&query, 0);

            let result = self.session.execute(&schema_query).wait().unwrap();
            for row in result {
                let name : String = row.get_col_by_name("column_name").unwrap();
                let ftype : String = row.get_col_by_name("type").unwrap();

                println!("{} {}", name, ftype);
            }

Causes this error:

thread 'main' panicked at 'Unsupported type: CASS_VALUE_TYPE_BLOB', /Users/jhaddad/.multirust/toolchains/nightly/cargo/registry/src/github.com-1ecc6299db9ec823/cassandra-0.6.10/src/cassandra/column.rs:279

The odd thing is that re-running the same pgoram gives me another error; except sometimes it errors with 'Unsupported type: CASS_VALUE_TYPE_BLOB'.

rustyrazorblade commented 8 years ago

I have a minimal main() you can use to verify.

extern crate cassandra;
use cassandra::*;
use std::str::FromStr;

fn main() {
    let mut cluster = Cluster::new();
    let contact_points = ContactPoints::from_str("127.0.0.1").unwrap();

    cluster.set_contact_points(contact_points).unwrap();
    cluster.set_load_balance_round_robin();

    let mut session = cluster.connect().unwrap();

    let query = String::from("select column_name, type from system_schema.columns where keyspace_name = 'cdmtest' and table_name = 'users'");

    println!("Keyspace query: {}", query);

    let schema_query = Statement::new(&query, 0);

    let result = session.execute(&schema_query).wait().unwrap();

    for row in result {
        let name : String = row.get_col_by_name("column_name").unwrap();
        let ftype : String = row.get_col_by_name("type").unwrap();

        println!("{} {}", name, ftype);
    }
    println!("Hello, world!");
}
rustyrazorblade commented 8 years ago

I've added some debug into to my main() and it looks like the call to cass_value_type gets back the wrong information. I've run the program several times and I've gotten back all of the following:

CASS_VALUE_TYPE_DECIMAL
CASS_VALUE_TYPE_BIGINT
CASS_VALUE_TYPE_BLOB
CASS_VALUE_TYPE_BOOLEAN
rustyrazorblade commented 8 years ago

I wonder if this is due to a change on the C driver in recent builds. I'm going to regen cassandra-sys and see if the problem goes away

jshook commented 8 years ago

Did you have any different behavior after your last regen?

rustyrazorblade commented 8 years ago

No, still an issue

rustyrazorblade commented 8 years ago

We should verify the equiv code actually works with the C driver

tupshin commented 8 years ago

Fixed in 0.7.3.