Menu

#37 mysql blob SIGPIPE exception

v0.4.0
accepted
Gulliver
1
2014-12-23
2014-11-17
Anonymous
No

mysql> show VARIABLES like '%max_allowed_packet%';
+--------------------------+------------+
| Variable_name | Value |
+--------------------------+------------+
| max_allowed_packet | 16777216 |
| slave_max_allowed_packet | 1073741824 |
+--------------------------+------------+

I use the example database code. And I modified for mysql.

const int sz = 16777216; // what about 20000000 that is more than 16777216;
char* buf = new char[sz];
memset(buf, 0, sz);

    Person jill(db);
    jill.name = "Jill";
    jill.sex = Person::Sex::Female;
    jill.image = Blob(buf, sz);
    jill.age = 33;
    jill.update();

I get "Signal: SIGPIPE (Broken pipe)" at executing "jill.update();". So bad.

What about more than 16777216? Litesql has only one blob type "blob", where is tinyblob, mediumblob and longblob?

I see in the backend.cpp:

string Backend::getSQLType(AT_field_type fieldType, const string& length) const
{
switch(fieldType) {
case A_field_type_integer: return "INTEGER";
case A_field_type_bigint: return "BIGINT";
case A_field_type_string:
{
int flength = atoi(length.c_str());
if (flength > 0 && flength < 65536) return string("VARCHAR("+length+")");
return "TEXT";
}
case A_field_type_float: return "FLOAT";
case A_field_type_double: return "DOUBLE";
case A_field_type_boolean: return "INTEGER";
case A_field_type_date: return "INTEGER";
case A_field_type_time: return "INTEGER";
case A_field_type_datetime: return "INTEGER";
case A_field_type_blob: return "BLOB";
default: return "";
}
}

look, the types are too simple and too few. And 'datetime' is integer? oh no, I think it should be integer64.

Litesql should be greater.

Discussion

  • Anonymous

    Anonymous - 2014-11-17

    I modified the blob data size as following:
    const int sz = 1024 * 1024;

    then update can ececute ok. But the select throw an exception:
    // select all Persons and order them by age
    vector<person> family = select<person>(db).orderBy(Person::Age).all();</person></person>

    what's the problem?

    ps. My email is guang11cheng@qq.com

     
  • Gulliver

    Gulliver - 2014-11-19
    • status: open --> accepted
    • assigned_to: Gulliver
     
  • Gulliver

    Gulliver - 2014-12-23
    • Group: v0.3.17 --> v0.4.0
     

Anonymous
Anonymous

Add attachments
Cancel





Auth0 Logo