Please find attached a PATH for gda_prepare_create_table. It adds errors checks and honors GDA_EASY_CREATE_TABLE_UNIQUE_FLAG.
-- Trabajar, la mejor arma para tu superación "de grano en grano, se hace la arena" (R) (en trámite, pero para los cuates: LIBRE)
From ddf024de8dd157a25f92ed951bdd4744ddec93e7 Mon Sep 17 00:00:00 2001 From: Daniel Espinosa <[email protected]> Date: Tue, 8 Jun 2010 20:27:32 -0500 Subject: [PATCH] Error checks and honors for GDA_EASY_CREATE_TABLE_UNIQUE_FLAG on gda_prepare_create_table --- doc/C/tmpl/gda-batch.sgml | 3 - doc/C/tmpl/gda-column.sgml | 5 -- doc/C/tmpl/gda-config.sgml | 20 ---------- doc/C/tmpl/gda-connection.sgml | 13 ------ doc/C/tmpl/gda-data-model-bdb.sgml | 12 +----- doc/C/tmpl/gda-data-model-iter.sgml | 5 -- doc/C/tmpl/gda-data-proxy.sgml | 13 ------ libgda/gda-easy.c | 72 +++++++++++++++++++++++++++-------- 8 files changed, 58 insertions(+), 85 deletions(-) diff --git a/doc/C/tmpl/gda-batch.sgml b/doc/C/tmpl/gda-batch.sgml index 526add7..7c12079 100644 --- a/doc/C/tmpl/gda-batch.sgml +++ b/doc/C/tmpl/gda-batch.sgml @@ -35,9 +35,6 @@ a #GdaSqlParser object. </para> -@: -@: - @gdabatch: the object which received the signal. @arg1: diff --git a/doc/C/tmpl/gda-column.sgml b/doc/C/tmpl/gda-column.sgml index 2673d9f..5358ffb 100644 --- a/doc/C/tmpl/gda-column.sgml +++ b/doc/C/tmpl/gda-column.sgml @@ -32,8 +32,6 @@ Management of #GdaDataModel column attributes </para> -@: -@: @: @gdacolumn: the object which received the signal. @@ -45,9 +43,6 @@ Management of #GdaDataModel column attributes </para> -@: -@: - @gdacolumn: the object which received the signal. @arg1: diff --git a/doc/C/tmpl/gda-config.sgml b/doc/C/tmpl/gda-config.sgml index 3fc242e..42b18d0 100644 --- a/doc/C/tmpl/gda-config.sgml +++ b/doc/C/tmpl/gda-config.sgml @@ -59,9 +59,6 @@ g_object_new (GDA_TYPE_CONFIG, "user-file", "my_file", NULL); </para> -@: -@: - @gdaconfig: the object which received the signal. @arg1: @@ -70,9 +67,6 @@ g_object_new (GDA_TYPE_CONFIG, "user-file", "my_file", NULL); </para> -@: -@: - @gdaconfig: the object which received the signal. @arg1: @@ -81,9 +75,6 @@ g_object_new (GDA_TYPE_CONFIG, "user-file", "my_file", NULL); </para> -@: -@: - @gdaconfig: the object which received the signal. @arg1: @@ -92,9 +83,6 @@ g_object_new (GDA_TYPE_CONFIG, "user-file", "my_file", NULL); </para> -@: -@: - @gdaconfig: the object which received the signal. @arg1: @@ -119,10 +107,6 @@ g_object_new (GDA_TYPE_CONFIG, "user-file", "my_file", NULL); @cnc_string: @auth_string: @is_system: -...@_gda_reserved1: -...@_gda_reserved2: -...@_gda_reserved3: -...@_gda_reserved4: <!-- ##### FUNCTION gda_config_get_dsn_info ##### --> <para> @@ -217,10 +201,6 @@ g_object_new (GDA_TYPE_CONFIG, "user-file", "my_file", NULL); @description: @dsn_params: @auth_params: -...@_gda_reserved1: -...@_gda_reserved2: -...@_gda_reserved3: -...@_gda_reserved4: <!-- ##### FUNCTION gda_config_get_provider_info ##### --> <para> diff --git a/doc/C/tmpl/gda-connection.sgml b/doc/C/tmpl/gda-connection.sgml index 6acd755..7722371 100644 --- a/doc/C/tmpl/gda-connection.sgml +++ b/doc/C/tmpl/gda-connection.sgml @@ -67,8 +67,6 @@ A connection to a database </para> -@: - @gdaconnection: the object which received the signal. <!-- ##### SIGNAL GdaConnection::conn-opened ##### --> @@ -76,8 +74,6 @@ A connection to a database </para> -@: - @gdaconnection: the object which received the signal. <!-- ##### SIGNAL GdaConnection::conn-to-close ##### --> @@ -85,8 +81,6 @@ A connection to a database </para> -@: - @gdaconnection: the object which received the signal. <!-- ##### SIGNAL GdaConnection::dsn-changed ##### --> @@ -94,8 +88,6 @@ A connection to a database </para> -@: - @gdaconnection: the object which received the signal. <!-- ##### SIGNAL GdaConnection::error ##### --> @@ -103,9 +95,6 @@ A connection to a database </para> -@: -@: - @gdaconnection: the object which received the signal. @arg1: @@ -114,8 +103,6 @@ A connection to a database </para> -@: - @gdaconnection: the object which received the signal. <!-- ##### ARG GdaConnection:auth-string ##### --> diff --git a/doc/C/tmpl/gda-data-model-bdb.sgml b/doc/C/tmpl/gda-data-model-bdb.sgml index 11710e2..e035941 100644 --- a/doc/C/tmpl/gda-data-model-bdb.sgml +++ b/doc/C/tmpl/gda-data-model-bdb.sgml @@ -32,16 +32,8 @@ virtual methods). </para> - -<!-- ##### ARG GdaDataModelBdb:db-name ##### --> -<para> - -</para> - -<!-- ##### ARG GdaDataModelBdb:filename ##### --> -<para> - -</para> +...@object: +...@priv: <!-- ##### STRUCT GdaDataModelBdbClass ##### --> <para> diff --git a/doc/C/tmpl/gda-data-model-iter.sgml b/doc/C/tmpl/gda-data-model-iter.sgml index 748c66b..db61e18 100644 --- a/doc/C/tmpl/gda-data-model-iter.sgml +++ b/doc/C/tmpl/gda-data-model-iter.sgml @@ -70,8 +70,6 @@ Data model iterator </para> -@: - @gdadatamodeliter: the object which received the signal. <!-- ##### SIGNAL GdaDataModelIter::row-changed ##### --> @@ -79,9 +77,6 @@ Data model iterator </para> -@: -@: - @gdadatamodeliter: the object which received the signal. @arg1: diff --git a/doc/C/tmpl/gda-data-proxy.sgml b/doc/C/tmpl/gda-data-proxy.sgml index a997ca3..e44a0a3 100644 --- a/doc/C/tmpl/gda-data-proxy.sgml +++ b/doc/C/tmpl/gda-data-proxy.sgml @@ -130,8 +130,6 @@ Proxy to hold modifications for any #GdaDataModel, and provides the #GdaDataMode </para> -@: - @gdadataproxy: the object which received the signal. <!-- ##### SIGNAL GdaDataProxy::row-changes-applied ##### --> @@ -139,8 +137,6 @@ Proxy to hold modifications for any #GdaDataModel, and provides the #GdaDataMode </para> -@: -@: @: @gdadataproxy: the object which received the signal. @@ -152,8 +148,6 @@ Proxy to hold modifications for any #GdaDataModel, and provides the #GdaDataMode </para> -@: -@: @: @gdadataproxy: the object which received the signal. @@ -165,8 +159,6 @@ Proxy to hold modifications for any #GdaDataModel, and provides the #GdaDataMode </para> -@: -@: @: @gdadataproxy: the object which received the signal. @@ -178,9 +170,6 @@ Proxy to hold modifications for any #GdaDataModel, and provides the #GdaDataMode </para> -@: -@: - @gdadataproxy: the object which received the signal. @arg1: @@ -189,8 +178,6 @@ Proxy to hold modifications for any #GdaDataModel, and provides the #GdaDataMode </para> -@: -@: @: @Returns: diff --git a/libgda/gda-easy.c b/libgda/gda-easy.c index 0e8aace..6f00f96 100644 --- a/libgda/gda-easy.c +++ b/libgda/gda-easy.c @@ -307,7 +307,12 @@ gda_prepare_create_table (GdaConnection *cnc, const gchar *table_name, GError ** op = gda_server_provider_create_operation (server, cnc, GDA_SERVER_OPERATION_CREATE_TABLE, NULL, error); - gda_server_operation_set_value_at (op, table_name, error, "/TABLE_DEF_P/TABLE_NAME"); + if (!GDA_IS_SERVER_OPERATION(op)) + return NULL; + if(!gda_server_operation_set_value_at (op, table_name, error, "/TABLE_DEF_P/TABLE_NAME")) { + g_object_unref (op); + return NULL; + } va_start (args, error); type = 0; @@ -317,7 +322,10 @@ gda_prepare_create_table (GdaConnection *cnc, const gchar *table_name, GError ** while ((arg = va_arg (args, gchar*))) { /* First argument for Column's name */ - gda_server_operation_set_value_at (op, arg, error, "/FIELDS_A/@COLUMN_NAME/%d", i); + if(!gda_server_operation_set_value_at (op, arg, error, "/FIELDS_A/@COLUMN_NAME/%d", i)){ + g_object_unref (op); + return NULL; + } /* Second to Define column's type */ type = va_arg (args, GType); @@ -329,16 +337,33 @@ gda_prepare_create_table (GdaConnection *cnc, const gchar *table_name, GError ** } dbms_type = (gchar *) gda_server_provider_get_default_dbms_type (server, cnc, type); - gda_server_operation_set_value_at (op, dbms_type, error, "/FIELDS_A/@COLUMN_TYPE/%d", i); + if (!gda_server_operation_set_value_at (op, dbms_type, error, "/FIELDS_A/@COLUMN_TYPE/%d", i)){ + g_object_unref (op); + return NULL; + } /* Third for column's flags */ flag = va_arg (args, GdaEasyCreateTableFlag); if (flag & GDA_EASY_CREATE_TABLE_PKEY_FLAG) - gda_server_operation_set_value_at (op, "TRUE", error, "/FIELDS_A/@COLUMN_PKEY/%d", i); + if(!gda_server_operation_set_value_at (op, "TRUE", error, "/FIELDS_A/@COLUMN_PKEY/%d", i)){ + g_object_unref (op); + return NULL; + } if (flag & GDA_EASY_CREATE_TABLE_NOT_NULL_FLAG) - gda_server_operation_set_value_at (op, "TRUE", error, "/FIELDS_A/@COLUMN_NNUL/%d", i); + if(!gda_server_operation_set_value_at (op, "TRUE", error, "/FIELDS_A/@COLUMN_NNUL/%d", i)){ + g_object_unref (op); + return NULL; + } if (flag & GDA_EASY_CREATE_TABLE_AUTOINC_FLAG) - gda_server_operation_set_value_at (op, "TRUE", error, "/FIELDS_A/@COLUMN_AUTOINC/%d", i); + if (!gda_server_operation_set_value_at (op, "TRUE", error, "/FIELDS_A/@COLUMN_AUTOINC/%d", i)){ + g_object_unref (op); + return NULL; + } + if (flag & GDA_EASY_CREATE_TABLE_UNIQUE_FLAG) + if(!gda_server_operation_set_value_at (op, "TRUE", error, "/FIELDS_A/@COLUMN_UNIQUE/%d", i)){ + g_object_unref (op); + return NULL; + } if (flag & GDA_EASY_CREATE_TABLE_FKEY_FLAG) { gint j; gint fields; @@ -349,8 +374,11 @@ gda_prepare_create_table (GdaConnection *cnc, const gchar *table_name, GError ** refs++; fkey_table = va_arg (args, gchar*); - gda_server_operation_set_value_at (op, fkey_table, error, - "/FKEY_S/%d/FKEY_REF_TABLE", refs); + if (!gda_server_operation_set_value_at (op, fkey_table, error, + "/FKEY_S/%d/FKEY_REF_TABLE", refs)){ + g_object_unref (op); + return NULL; + } fields = va_arg (args, gint); @@ -358,21 +386,33 @@ gda_prepare_create_table (GdaConnection *cnc, const gchar *table_name, GError ** gchar *field, *rfield; field = va_arg (args, gchar*); - gda_server_operation_set_value_at (op, field, error, - "/FKEY_S/%d/FKEY_FIELDS_A/@FK_FIELD/%d", refs, j); + if(!gda_server_operation_set_value_at (op, field, error, + "/FKEY_S/%d/FKEY_FIELDS_A/@FK_FIELD/%d", refs, j)){ + g_object_unref (op); + return NULL; + } rfield = va_arg (args, gchar*); - gda_server_operation_set_value_at (op, rfield, error, - "/FKEY_S/%d/FKEY_FIELDS_A/@FK_REF_PK_FIELD/%d", refs, j); + if(!gda_server_operation_set_value_at (op, rfield, error, + "/FKEY_S/%d/FKEY_FIELDS_A/@FK_REF_PK_FIELD/%d", refs, j)){ + g_object_unref (op); + return NULL; + } } fkey_ondelete = va_arg (args, gchar*); - gda_server_operation_set_value_at (op, fkey_ondelete, error, - "/FKEY_S/%d/FKEY_ONDELETE", refs); + if (!gda_server_operation_set_value_at (op, fkey_ondelete, error, + "/FKEY_S/%d/FKEY_ONDELETE", refs)){ + g_object_unref (op); + return NULL; + } fkey_onupdate = va_arg (args, gchar*); - gda_server_operation_set_value_at (op, fkey_onupdate, error, - "/FKEY_S/%d/FKEY_ONUPDATE", refs); + if(!gda_server_operation_set_value_at (op, fkey_onupdate, error, + "/FKEY_S/%d/FKEY_ONUPDATE", refs)){ + g_object_unref (op); + return NULL; + } } i++; -- 1.7.0.4
_______________________________________________ gnome-db-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gnome-db-list
