]> saetta.ns0.it Git - solipa/libsolipa/commitdiff
Memory leak.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Wed, 29 Jul 2015 07:25:41 +0000 (09:25 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Wed, 29 Jul 2015 07:25:41 +0000 (09:25 +0200)
src/allegato.c

index fc9f40b39d6b001633b48108fcb883388c544424..16a56b3b7f396465565447af40d8c062db043882 100644 (file)
@@ -307,6 +307,15 @@ solipa_allegato_salva_in_db (GdaConnection *gda_con, const gchar *sql,
        g_return_val_if_fail (GDA_IS_CONNECTION (gda_con), FALSE);
 
        parser = gda_connection_create_parser (gda_con);
+       if (parser == NULL)
+               {
+                       parser = gda_sql_parser_new ();
+               }
+       if (parser == NULL)
+               {
+                       g_warning ("Errore nella creazione del parser sql.");
+                       return FALSE;
+               }
 
        error = NULL;
        stmt = gda_sql_parser_parse_string (parser, sql, NULL, &error);
@@ -319,6 +328,8 @@ solipa_allegato_salva_in_db (GdaConnection *gda_con, const gchar *sql,
                }
        gda_statement_get_parameters (stmt, &plist, NULL);
 
+       gda_connection_begin_transaction (gda_con, NULL, 0, NULL);
+
        param = gda_set_get_holder (plist, blob_field_name);
        value = gda_value_new_blob_from_file (percorso);
        error = NULL;
@@ -326,6 +337,8 @@ solipa_allegato_salva_in_db (GdaConnection *gda_con, const gchar *sql,
                {
                        g_object_unref (plist);
 
+                       gda_connection_rollback_transaction (gda_con, NULL, NULL);
+
                        /* TODO error */
                        g_warning ("Errore nell'impostare il blob: %s.",
                                   error != NULL && error->message != NULL ? error->message : "nessun dettaglio");
@@ -341,13 +354,15 @@ solipa_allegato_salva_in_db (GdaConnection *gda_con, const gchar *sql,
 
                        if (error != NULL)
                                {
+                                       gda_connection_rollback_transaction (gda_con, NULL, NULL);
+
                                        /* TODO error */
                                        g_warning ("Errore nell'esecuzione dello statement di aggiornamento del blob: %s.",
                                                   error != NULL && error->message != NULL ? error->message : "nessun dettaglio");
                                        return FALSE;
                                }
+                       gda_connection_commit_transaction (gda_con, NULL, NULL);
                }
-       gda_value_free (value);
 
        return TRUE;
 }