return ret;
}
+static gboolean
+zak_dbt_dbt_parse_add_column (ZakDbtDbt *zak_dbt_dbt, xmlNodePtr xnode)
+{
+ ZakDbtDbtPrivate *priv;
+
+ gboolean ret;
+
+ xmlNodePtr cur;
+
+ gchar *table_name;
+ gchar *column_name;
+ gchar *column_type;
+ gchar *column_size;
+ gchar *column_not_null;
+ gchar *column_auto_increment;
+ gchar *column_unique;
+ gchar *column_default;
+
+ GError *error;
+
+ ret = TRUE;
+
+ priv = ZAK_DBT_DBT_GET_PRIVATE (zak_dbt_dbt);
+
+ table_name = NULL;
+ column_name = NULL;
+ column_type = NULL;
+ column_size = NULL;
+ column_not_null = NULL;
+ column_auto_increment = NULL;
+ column_unique = NULL;
+ column_default = NULL;
+
+ cur = xnode->children;
+ while (cur != NULL && ret)
+ {
+ if (xmlStrcmp (cur->name, (const xmlChar *)"table_name") == 0)
+ {
+ table_name = g_strstrip (g_strdup ((gchar *)xmlNodeGetContent (cur)));
+ }
+ else if (xmlStrcmp (cur->name, (const xmlChar *)"column_name") == 0)
+ {
+ column_name = g_strstrip (g_strdup ((gchar *)xmlNodeGetContent (cur)));
+ }
+ else if (xmlStrcmp (cur->name, (const xmlChar *)"column_type") == 0)
+ {
+ column_type = g_strstrip (g_strdup ((gchar *)xmlNodeGetContent (cur)));
+ }
+ else if (xmlStrcmp (cur->name, (const xmlChar *)"column_size") == 0)
+ {
+ column_size = g_strstrip (g_strdup ((gchar *)xmlNodeGetContent (cur)));
+ }
+ else if (xmlStrcmp (cur->name, (const xmlChar *)"column_not_null") == 0)
+ {
+ column_not_null = g_strstrip (g_strdup ((gchar *)xmlNodeGetContent (cur)));
+ }
+ else if (xmlStrcmp (cur->name, (const xmlChar *)"column_auto_increment") == 0)
+ {
+ column_auto_increment = g_strstrip (g_strdup ((gchar *)xmlNodeGetContent (cur)));
+ }
+ else if (xmlStrcmp (cur->name, (const xmlChar *)"column_unique") == 0)
+ {
+ column_unique = g_strstrip (g_strdup ((gchar *)xmlNodeGetContent (cur)));
+ }
+ else if (xmlStrcmp (cur->name, (const xmlChar *)"column_default") == 0)
+ {
+ column_default = g_strstrip (g_strdup ((gchar *)xmlNodeGetContent (cur)));
+ }
+
+ cur = cur->next;
+ }
+
+ if (table_name != NULL && g_strcmp0 (table_name, "") != 0
+ && column_name != NULL && g_strcmp0 (column_name, "") != 0
+ && column_type != NULL && g_strcmp0 (column_type, "") != 0)
+ {
+ GdaServerOperation *op;
+
+ error = NULL;
+ op = gda_server_provider_create_operation (priv->gda_provider,
+ priv->gda_conn,
+ GDA_SERVER_OPERATION_ADD_COLUMN,
+ NULL,
+ &error);
+
+ error = NULL;
+ gda_server_operation_set_value_at (op, table_name, &error, "/COLUMN_DEF_P/TABLE_NAME");
+
+ error = NULL;
+ gda_server_operation_set_value_at (op, column_name, &error, "/COLUMN_DEF_P/COLUMN_NAME");
+
+ error = NULL;
+ gda_server_operation_set_value_at (op, column_type, &error, "/COLUMN_DEF_P/COLUMN_TYPE");
+
+ if (column_size != NULL && g_strcmp0 (column_size, "") != 0)
+ {
+ error = NULL;
+ gda_server_operation_set_value_at (op, column_size, &error, "/COLUMN_DEF_P/COLUMN_SIZE");
+ }
+
+ if (column_not_null != NULL && g_strcmp0 (column_not_null, "") != 0)
+ {
+ error = NULL;
+ gda_server_operation_set_value_at (op, column_not_null, &error, "/COLUMN_DEF_P/COLUMN_NNULL");
+ }
+
+ if (column_auto_increment != NULL && g_strcmp0 (column_auto_increment, "") != 0)
+ {
+ error = NULL;
+ gda_server_operation_set_value_at (op, column_auto_increment, &error, "/COLUMN_DEF_P/COLUMN_AUTOINC");
+ }
+
+ if (column_unique != NULL && g_strcmp0 (column_unique, "") != 0)
+ {
+ error = NULL;
+ gda_server_operation_set_value_at (op, column_unique, &error, "/COLUMN_DEF_P/COLUMN_UNIQUE");
+ }
+
+ if (column_default != NULL && g_strcmp0 (column_default, "") != 0)
+ {
+ error = NULL;
+ gda_server_operation_set_value_at (op, column_default, &error, "/COLUMN_DEF_P/COLUMN_DEFAULT");
+ }
+
+ error = NULL;
+ if (!gda_server_provider_perform_operation (priv->gda_provider, priv->gda_conn, op, &error))
+ {
+ g_warning ("Error executing the operation: %s.",
+ error != NULL && error->message != NULL ? error->message : "No detail");
+ ret = FALSE;
+ }
+ g_object_unref (op);
+ }
+ else
+ {
+ g_warning ("You must provide at least:\n"
+ " - the name of the table and the column\n"
+ " - the column's type");
+ ret = FALSE;
+ }
+
+ return ret;
+}
+
/**
* zak_dbt_dbt_transform:
* @zak_dbt_dbt:
{
tosave = zak_dbt_dbt_parse_drop_index (zak_dbt_dbt, xnode);
}
+ else if (xmlStrcmp (xnode->name, (const xmlChar *)"add_column") == 0)
+ {
+ tosave = zak_dbt_dbt_parse_add_column (zak_dbt_dbt, xnode);
+ }
else
{
g_warning ("Invalid tag: %s.", xnode->name);