Re: [gnome-db] [GDA] Mysql and LONGTEXT
Vivien Malerba <[email protected]> Thu, 22 Oct 2015 20:05:31 +0200
| Newsgroups | gmane.comp.gnome.db |
|---|---|
| Message-ID | <CAEP1ZN=JvdN9CjfikQ9hKxCB9scs1zWZM9C+GGiuUa7ahfMdRA@mail.gmail.com> |
Hi! I haven't looked into the MySQL provider for some time, but it should work as far as I can tell. Can you send me the Events table schema? Regards, Vivien 2015-10-22 14:35 GMT+02:00 Adrien Schwartzentruber < [email protected]>: > Hello guys, > > I tried to add a longtext value in a mysql database using gda but I have a > SIGPIPE error when I execute the statement. > > THis is the stack : > > (gdb) bt > #0 0x00007ffff6ec12af in send () from /usr/lib/libc.so.6 > #1 0x00007fffee217a4d in ?? () from /usr/lib/libmysqlclient.so.18 > #2 0x00007fffee1f6349 in ?? () from /usr/lib/libmysqlclient.so.18 > #3 0x00007fffee1f6623 in ?? () from /usr/lib/libmysqlclient.so.18 > #4 0x00007fffee1f6d2a in ?? () from /usr/lib/libmysqlclient.so.18 > #5 0x00007fffee1edee4 in mysql_set_character_set () from > /usr/lib/libmysqlclient.so.18 > #6 0x00007fffee1e5266 in mysql_stmt_param_metadata () from > /usr/lib/libmysqlclient.so.18 > #7 0x00007fffee1e753a in mysql_stmt_execute () from > /usr/lib/libmysqlclient.so.18 > #8 0x00007fffee73079a in gda_mysql_provider_statement_execute > (provider=<optimized out>, cnc=0x777220, stmt=<optimized out>, > params=<optimized out>, > model_usage=<optimized out>, col_types=<optimized out>, > last_inserted_row=0x7fffffffead0, task_id=0x0, async_cb=0x0, cb_data=0x0, > error=0x7fffffffeae0) > at gda-mysql-provider.c:2782 > #9 0x00007ffff65c00c1 in gda_connection_statement_execute_v (cnc=cnc@entry=0x777220, > stmt=stmt@entry=0x699680, params=params@entry=0x62b0c0, > model_usage=model_usage@entry=GDA_STATEMENT_MODEL_RANDOM_ACCESS, > last_inserted_row=last_inserted_row@entry=0x7fffffffead0, > error=error@entry=0x7fffffffeae0) > at gda-connection.c:3544 > #10 0x00007ffff65c03b4 in gda_connection_statement_execute (cnc=0x777220, > stmt=0x699680, params=0x62b0c0, > model_usage=GDA_STATEMENT_MODEL_RANDOM_ACCESS, > last_inserted_row=0x7fffffffead0, error=0x7fffffffeae0) at > gda-connection.c:3725 > #11 0x00007ffff78c5a85 in ast_db_event_new_entry_full () from > /usr/lib/libAST_DBLayer.so > #12 0x00007ffff78c5da3 in > ast_db_event_information_new_entry_with_meta_and_hidden () from > /usr/lib/libAST_DBLayer.so > #13 0x0000000000400b0a in main () > > > This is the insertion method : > GValue* > ast_db_event_new_entry_full(GdaConnection* dbConnection, gdouble time, > const gchar* meta, const gchar* type, const gchar* subType, const gchar* > state, gint sourceID, const gchar* username, gboolean hidden) { > GValue* result = NULL; > > GValue* timeValue = gda_value_new(G_TYPE_DOUBLE); > g_value_set_double(timeValue, time); > > GValue* metaValue = NULL; > if (meta != NULL) > metaValue = gda_value_new_from_string(meta, G_TYPE_STRING); > > GValue* subTypeIDValue = > ast_db_event_sub_types_get_or_register(dbConnection, subType, type); > if (subTypeIDValue != NULL) { > GValue* typeIDValue = ast_db_event_types_get_or_register(dbConnection, > type); > if (typeIDValue != NULL) { > GValue* stateID = NULL; > if (state != NULL) { > stateID = ast_db_event_state_get_id(dbConnection, state); > } else { > stateID = gda_value_new_null(); > } > > if (stateID != NULL) { > GValue* sourceIDValue = gda_value_new(G_TYPE_INT); > g_value_set_int(sourceIDValue, sourceID); > > GValue* userIDValue = NULL; > if (username != NULL) { > userIDValue = gda_value_new_from_string(username, G_TYPE_STRING); > } else { > userIDValue = gda_value_new_null(); > } > GValue* isHiddenValue= NULL; > isHiddenValue = gda_value_new(G_TYPE_INT); > g_value_set_int(isHiddenValue, hidden ? 1 : 0); > > GdaStatement *stmt = NULL; > GdaSet * set = NULL; > GdaSet * lastRow = NULL; > GdaHolder *p = NULL; > GError * err = NULL; > GObject * res = NULL; > > stmt = ast_db_common_get_statement(dbConnection, "INSERT INTO Events > (time, meta, fk_EventTypes, fk_EventSubTypes, fk_EventState, fk_Sources, > username, isHidden) VALUES ( ##the_time::gdouble , ##the_meta::string::null > , ##the_type::gint , ##the_subtype::gint, ##the_state::gint::null, > ##the_sourceID::gint, ##the_user::string::null, ##is_hidden::gint::null )"); > if (stmt != NULL) { > gda_statement_get_parameters (stmt, &set, NULL); > > p = gda_set_get_holder (set, "the_time"); > gda_holder_set_value (p, timeValue, NULL); > > if (metaValue) { > p = gda_set_get_holder (set, "the_meta"); > gda_holder_set_value (p, metaValue, NULL); > } > > p = gda_set_get_holder (set, "the_type"); > gda_holder_set_value (p, typeIDValue, NULL); > > p = gda_set_get_holder (set, "the_subtype"); > gda_holder_set_value (p, subTypeIDValue, NULL); > > p = gda_set_get_holder (set, "the_state"); > gda_holder_set_value (p, stateID, NULL); > > p = gda_set_get_holder (set, "the_sourceID"); > gda_holder_set_value (p, sourceIDValue, NULL); > > p = gda_set_get_holder (set, "the_user"); > gda_holder_set_value (p, userIDValue, NULL); > > p = gda_set_get_holder (set, "is_hidden"); > gda_holder_set_value (p, isHiddenValue, NULL); > > res = gda_connection_statement_execute(dbConnection,stmt, > set,GDA_STATEMENT_MODEL_RANDOM_ACCESS, &lastRow, &err); > if ((res != NULL) && (err == NULL)) { > GdaHolder *h = GDA_HOLDER(lastRow->holders->data); > const GValue* holderValue = gda_holder_get_value(h); > > result = gda_value_new(G_TYPE_INT); > g_value_set_int(result, g_value_get_int(holderValue)); > > //Segmentation fault > //g_object_unref(holderValue); > g_object_unref(lastRow); > g_object_unref(res); > } else { > g_error ("Could not INSERT data into the 'Events' table: %s\n", > ast_error_get_error_message(err)); > } > > if (err != NULL) > g_error_free(err); > > > g_object_unref(set); > g_object_unref(stmt); > } > > gda_value_free(sourceIDValue); > gda_value_free(userIDValue); > gda_value_free(stateID); > } else { > g_critical("ast:db:Failed to get the event state. State: %s. SubType: %s. > Type: %s.", type, subType, state); > } > gda_value_free(typeIDValue); > } else { > g_critical("Ast:DB: Failed to get the type ID. Type: %s", type); > } > gda_value_free(subTypeIDValue); > } else { > g_critical("Ast:DB:Failed to get the subType ID. SubType: %s. Type: %s.", > subType, type); > } > > gda_value_free(timeValue); > if (metaValue) > gda_value_free(metaValue); > return result; > } > > This is a test application : > > gint strSize = 10; > while (TRUE) { > GdaConnection* connection = ast_db_get_connection(); > gchar* meta = NULL; > meta = g_new0(gchar, strSize+1); > ast_str_rand_string(meta, strSize); > g_message("Before Insert %d", strSize); > ast_db_event_information_new_entry_with_meta_and_hidden(connection, > "AstInformationEvent","Ast_SystemReport", 1, meta); > g_free(meta); > ast_db_release(connection); > g_message("Insert %d", strSize); > strSize = strSize * 2; > g_usleep(10000); > } > > > *It stop when size if greater than 655360 > > > How can I use longtext using gda ? > > Thx in advance for your help. > > _______________________________________________ > gnome-db-list mailing list > [email protected] > https://mail.gnome.org/mailman/listinfo/gnome-db-list > > _______________________________________________ gnome-db-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/gnome-db-list