List:MySQL++« Previous MessageNext Message »
From:Drew M. Date:December 7 2007 7:47am
Subject:Mismatch between query results and SSQLS column count
View as plain text  
I had a strange issue that I eventually tracked down to a mismatch
between the number of columns included in the results of a select
query and the number of columns my SSQLS structure expected. My query
returned two columns, where my SSQLS expected 3. What made this hard
to track down is the only indication of a problem was a thrown
exception "vector::_M_range_check".

Consider the following pseudo-code:

sql_create_3(my_ssqls_struct, 3, 0,
                   int, id,
                   std::string, name,
                   std::string, status)


mysqlpp::Query query(con);
std::vector<my_ssqls_struct> results;

query << "select id, name from table";
query.storein(results); // exception thrown here


One idea I have to catch this at run-time would be to assert that the
number of columns in a result set matched the size of the ssqls
structure (or at least matched the number of args for a constructor of
the ssqls structure) from within each Query::storein_* function, and
throw a more decipherable exception in that case. I don't think
catching this during compilation would be possible given the way Query
works.

Just thought I'd throw this out there for consideration. Thoughts /
feedback welcome.
Thread
Mismatch between query results and SSQLS column countDrew M.7 Dec
  • Re: Mismatch between query results and SSQLS column countWarren Young8 Dec
    • Re: Mismatch between query results and SSQLS column countDrew M.10 Dec
      • Re: Mismatch between query results and SSQLS column countWarren Young11 Dec