[libgda] gda_sql_builder_get_sql_statement(): Remove copy_it parameter.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] gda_sql_builder_get_sql_statement(): Remove copy_it parameter.
- Date: Wed, 12 May 2010 09:02:29 +0000 (UTC)
commit 65b8f1bac20891020ab677a5404e6077b2cbbdf7
Author: Murray Cumming <murrayc murrayc com>
Date: Tue May 11 16:21:54 2010 +0200
gda_sql_builder_get_sql_statement(): Remove copy_it parameter.
* libgda/gda-sql-builder.[h|c]: gda_sql_builder_get_sql_statement():
Remove the copy_it parameter, and adapt the documentation, because
this does not belong in API. Callers should call
gda_sql_statement_copy() if necessary, as with any other boxed
type.
* samples/SqlBuilder/example.c
* tests/test-sql-builder.c
* tools/browser/browser-favorites.c: Adapt several uses of this
function. They all just passed FALSE apart from one that passed
TRUE incorrectly, leaking the copy.
libgda/gda-sql-builder.c | 23 ++++++++---------------
libgda/gda-sql-builder.h | 2 +-
samples/SqlBuilder/example.c | 10 +++++-----
tests/test-sql-builder.c | 26 +++++++++++++-------------
tools/browser/browser-favorites.c | 3 ++-
5 files changed, 29 insertions(+), 35 deletions(-)
---
diff --git a/libgda/gda-sql-builder.c b/libgda/gda-sql-builder.c
index d250c25..4175da2 100644
--- a/libgda/gda-sql-builder.c
+++ b/libgda/gda-sql-builder.c
@@ -356,30 +356,23 @@ gda_sql_builder_get_statement (GdaSqlBuilder *builder, GError **error)
*
* Creates a new #GdaSqlStatement structure from @builder's contents.
*
- * If @copy_it is %FALSE, then the returned pointer is considered to be stolen from @builder's internal
- * representation and will make it unusable anymore (resulting in a %GDA_SQL_BUILDER_MISUSE_ERROR error or
- * some warnings if one tries to reuse it).
- * If, on the other
- * hand it is set to %TRUE, then the returned #GdaSqlStatement is a copy of the on @builder uses
- * internally, making it reusable.
+ * The returned pointer belongs to @builder's internal representation.
+ * Use gda_sql_statement_copy() if you need to keep it.
*
* Returns: a #GdaSqlStatement pointer
*
* Since: 4.2
*/
GdaSqlStatement *
-gda_sql_builder_get_sql_statement (GdaSqlBuilder *builder, gboolean copy_it)
+gda_sql_builder_get_sql_statement (GdaSqlBuilder *builder)
{
g_return_val_if_fail (GDA_IS_SQL_BUILDER (builder), NULL);
if (!builder->priv->main_stmt)
return NULL;
- if (copy_it)
- return gda_sql_statement_copy (builder->priv->main_stmt);
- else {
- GdaSqlStatement *stmt = builder->priv->main_stmt;
- builder->priv->main_stmt = NULL;
- return stmt;
- }
+
+ GdaSqlStatement *stmt = builder->priv->main_stmt;
+ builder->priv->main_stmt = NULL;
+ return stmt;
}
/**
@@ -1859,5 +1852,5 @@ gda_sql_builder_import_expression (GdaSqlBuilder *builder, guint id, GdaSqlExpr
g_return_val_if_fail (expr, 0);
g_return_val_if_fail (GDA_SQL_ANY_PART (expr)->type == GDA_SQL_ANY_EXPR, 0);
- return add_part (builder, id, (GdaSqlAnyPart *) gda_sql_expr_copy (expr));
+ return add_part (builder, id, (GdaSqlAnyPart *) gda_sql_expr_copy (expr));
}
diff --git a/libgda/gda-sql-builder.h b/libgda/gda-sql-builder.h
index 3d9dad2..3009d4e 100644
--- a/libgda/gda-sql-builder.h
+++ b/libgda/gda-sql-builder.h
@@ -69,7 +69,7 @@ struct _GdaSqlBuilderClass
GType gda_sql_builder_get_type (void) G_GNUC_CONST;
GdaSqlBuilder *gda_sql_builder_new (GdaSqlStatementType stmt_type);
GdaStatement *gda_sql_builder_get_statement (GdaSqlBuilder *builder, GError **error);
-GdaSqlStatement *gda_sql_builder_get_sql_statement (GdaSqlBuilder *builder, gboolean copy_it);
+GdaSqlStatement *gda_sql_builder_get_sql_statement (GdaSqlBuilder *builder);
/* Expression API */
guint gda_sql_builder_add_id (GdaSqlBuilder *builder, guint id, const gchar *string);
diff --git a/samples/SqlBuilder/example.c b/samples/SqlBuilder/example.c
index ff06873..4bdb3fe 100644
--- a/samples/SqlBuilder/example.c
+++ b/samples/SqlBuilder/example.c
@@ -153,7 +153,7 @@ main (int argc, char *argv[])
gda_sql_builder_select_add_target_id (b, 0,
gda_sql_builder_add_id (b, 0, "subdata"),
NULL);
- sub = gda_sql_builder_get_sql_statement (b, FALSE);
+ sub = gda_sql_builder_get_sql_statement (b);
g_object_unref (b);
b = gda_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
@@ -180,7 +180,7 @@ main (int argc, char *argv[])
gda_sql_builder_add_cond (b, 0, GDA_SQL_OPERATOR_TYPE_EQ,
gda_sql_builder_add_id (b, 0, "t.id"),
gda_sql_builder_add_id (b, 0, "d.topic"), 0));
- sub = gda_sql_builder_get_sql_statement (b, FALSE);
+ sub = gda_sql_builder_get_sql_statement (b);
g_object_unref (b);
b = gda_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
@@ -201,7 +201,7 @@ main (int argc, char *argv[])
gda_sql_builder_select_add_target_id (b, 0,
gda_sql_builder_add_id (b, 0, "subdate"),
NULL);
- sub = gda_sql_builder_get_sql_statement (b, FALSE);
+ sub = gda_sql_builder_get_sql_statement (b);
g_object_unref (b);
b = gda_sql_builder_new (GDA_SQL_STATEMENT_INSERT);
@@ -224,7 +224,7 @@ main (int argc, char *argv[])
gda_sql_builder_select_add_target_id (b, 0,
gda_sql_builder_add_id (b, 0, "subdata1"),
NULL);
- sub1 = gda_sql_builder_get_sql_statement (b, FALSE);
+ sub1 = gda_sql_builder_get_sql_statement (b);
g_object_unref (b);
b = gda_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
@@ -233,7 +233,7 @@ main (int argc, char *argv[])
gda_sql_builder_select_add_target_id (b, 0,
gda_sql_builder_add_id (b, 0, "subdata2"),
NULL);
- sub2 = gda_sql_builder_get_sql_statement (b, FALSE);
+ sub2 = gda_sql_builder_get_sql_statement (b);
g_object_unref (b);
b = gda_sql_builder_new (GDA_SQL_STATEMENT_COMPOUND);
diff --git a/tests/test-sql-builder.c b/tests/test-sql-builder.c
index f90911b..1880b33 100644
--- a/tests/test-sql-builder.c
+++ b/tests/test-sql-builder.c
@@ -138,7 +138,7 @@ build0 (void)
gda_sql_builder_add_id (builder, 0, "*"), 0);
gda_sql_builder_select_add_target_id (builder, 0,
gda_sql_builder_add_id (builder, 0, "mytable"), NULL);
- stmt = gda_sql_builder_get_sql_statement (builder, FALSE);
+ stmt = gda_sql_builder_get_sql_statement (builder);
g_object_unref (builder);
return stmt;
}
@@ -185,7 +185,7 @@ build1 (void)
gda_sql_builder_set_where (builder, gda_sql_builder_add_cond (builder, 0, GDA_SQL_OPERATOR_TYPE_AND, 1, 2, 0));
- stmt = gda_sql_builder_get_sql_statement (builder, FALSE);
+ stmt = gda_sql_builder_get_sql_statement (builder);
g_object_unref (builder);
return stmt;
}
@@ -219,7 +219,7 @@ build2 (void)
gda_sql_builder_add_id (builder, 0, "descr"),
gda_sql_builder_add_param (builder, 0, "descr", G_TYPE_STRING, TRUE));
- stmt = gda_sql_builder_get_sql_statement (builder, FALSE);
+ stmt = gda_sql_builder_get_sql_statement (builder);
g_object_unref (builder);
return stmt;
}
@@ -253,7 +253,7 @@ build3 (void)
gda_sql_builder_add_param (builder, 0, "id", G_TYPE_INT, FALSE),
0));
- stmt = gda_sql_builder_get_sql_statement (builder, FALSE);
+ stmt = gda_sql_builder_get_sql_statement (builder);
g_object_unref (builder);
return stmt;
}
@@ -296,7 +296,7 @@ build4 (void)
gda_sql_builder_select_order_by (b,
gda_sql_builder_add_id (b, 0, "o.rank"), TRUE, NULL);
- stmt = gda_sql_builder_get_sql_statement (b, FALSE);
+ stmt = gda_sql_builder_get_sql_statement (b);
g_object_unref (b);
return stmt;
}
@@ -327,7 +327,7 @@ build5 (void)
gda_sql_builder_add_id (b, 0, "contents"),
gda_sql_builder_add_param (b, 0, "contents", G_TYPE_INT, FALSE), 0), 0));
- stmt = gda_sql_builder_get_sql_statement (b, FALSE);
+ stmt = gda_sql_builder_get_sql_statement (b);
g_object_unref (b);
return stmt;
}
@@ -358,7 +358,7 @@ build6 (void)
gda_sql_builder_set_where (b, gda_sql_builder_add_cond (b, 0, GDA_SQL_OPERATOR_TYPE_AND, 1, 2, 0));
- stmt = gda_sql_builder_get_sql_statement (b, FALSE);
+ stmt = gda_sql_builder_get_sql_statement (b);
g_object_unref (b);
return stmt;
}
@@ -391,7 +391,7 @@ build7 (void)
0);
gda_sql_builder_set_where (b, gda_sql_builder_add_cond (b, 0, GDA_SQL_OPERATOR_TYPE_AND, 1, 2, 3));
- stmt = gda_sql_builder_get_sql_statement (b, FALSE);
+ stmt = gda_sql_builder_get_sql_statement (b);
g_object_unref (b);
return stmt;
}
@@ -412,7 +412,7 @@ build8 (void)
gda_sql_builder_add_id (b, 0, "id"),
gda_sql_builder_add_param (b, 0, "id", G_TYPE_INT, FALSE),
0));
- stmt = gda_sql_builder_get_sql_statement (b, FALSE);
+ stmt = gda_sql_builder_get_sql_statement (b);
g_object_unref (b);
return stmt;
}
@@ -435,7 +435,7 @@ build9 (void)
gda_sql_builder_add_field_value (builder, "name", value);
gda_value_free (value);
- stmt = gda_sql_builder_get_sql_statement (builder, FALSE);
+ stmt = gda_sql_builder_get_sql_statement (builder);
g_object_unref (builder);
return stmt;
@@ -467,7 +467,7 @@ build10 (void)
g_object_unref (st);
}
- stmt = gda_sql_builder_get_sql_statement (b, FALSE);
+ stmt = gda_sql_builder_get_sql_statement (b);
g_object_unref (b);
return stmt;
}
@@ -502,7 +502,7 @@ build11 (void)
}
#endif
- stmt = gda_sql_builder_get_sql_statement (b, FALSE);
+ stmt = gda_sql_builder_get_sql_statement (b);
g_object_unref (b);
return stmt;
}
@@ -542,7 +542,7 @@ build12 (void)
}
#endif
- stmt = gda_sql_builder_get_sql_statement (b, FALSE);
+ stmt = gda_sql_builder_get_sql_statement (b);
g_object_unref (b);
return stmt;
}
diff --git a/tools/browser/browser-favorites.c b/tools/browser/browser-favorites.c
index 81943c2..698bc86 100644
--- a/tools/browser/browser-favorites.c
+++ b/tools/browser/browser-favorites.c
@@ -850,7 +850,8 @@ browser_favorites_list (BrowserFavorites *bfav, guint session_id, BrowserFavorit
#ifdef GDA_DEBUG_NO
{
GdaSqlStatement *sqlst;
- sqlst = gda_sql_builder_get_sql_statement (b, TRUE);
+ sqlst = gda_sql_builder_get_sql_statement (b);
+
g_print ("=>%s\n", gda_sql_statement_serialize (sqlst));
}
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]