static gboolean zak_dbt_dbt_check_db (ZakDbtDbt *zak_dbt_dbt, gboolean create_tables);
+static gboolean zak_dbt_dbt_parse_create_index (ZakDbtDbt *zak_dbt_dbt, xmlNodePtr xnode);
+static gboolean zak_dbt_dbt_parse_add_column (ZakDbtDbt *zak_dbt_dbt, xmlNodePtr xnode);
+static gboolean zak_dbt_dbt_parse_drop_column (ZakDbtDbt *zak_dbt_dbt, xmlNodePtr xnode);
+
#define ZAK_DBT_DBT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_DBT_TYPE_DBT, ZakDbtDbtPrivate))
typedef struct _ZakDbtDbtPrivate ZakDbtDbtPrivate;
return ret;
}
+static gboolean
+zak_dbt_dbt_parse_create_table (ZakDbtDbt *zak_dbt_dbt, xmlNodePtr xnode)
+{
+ ZakDbtDbtPrivate *priv;
+
+ gboolean ret;
+
+ xmlNodePtr cur;
+ gchar *table_name;
+
+ xmlNode *node;
+
+ GError *error;
+
+ ret = TRUE;
+
+ priv = ZAK_DBT_DBT_GET_PRIVATE (zak_dbt_dbt);
+
+ table_name = 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)));
+ }
+
+ cur = cur->next;
+ }
+
+ if (table_name != NULL && g_strcmp0 (table_name, "") != 0)
+ {
+ GdaServerOperation *op;
+
+ error = NULL;
+ op = gda_server_provider_create_operation (priv->gda_provider,
+ priv->gda_conn,
+ GDA_SERVER_OPERATION_CREATE_TABLE,
+ NULL,
+ &error);
+ if (op == NULL
+ || error != NULL)
+ {
+ g_warning ("Unable to create GdaServerOperation create_table: %s.",
+ error != NULL && error->message != NULL ? error->message : "no detail");
+ ret = FALSE;
+ }
+ else
+ {
+ error = NULL;
+ gda_server_operation_set_value_at (op, table_name, &error, "/TABLE_DEF_P/TABLE_NAME");
+
+ error = NULL;
+ gda_server_operation_set_value_at (op, "zdbt_to_be_delete", &error, "/FIELDS_A/@COLUMN_NAME/0");
+
+ error = NULL;
+ gda_server_operation_set_value_at (op, "integer", &error, "/FIELDS_A/@COLUMN_TYPE/0");
+
+ 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);
+
+ if (ret)
+ {
+ cur = xnode->children;
+ while (cur != NULL && ret)
+ {
+ if (xmlStrcmp (cur->name, (const xmlChar *)"add_column") == 0)
+ {
+ node = xmlNewNode (NULL, (const xmlChar *)"table_name");
+ xmlNodeSetContent (node, (xmlChar *)table_name);
+ xmlAddChild (cur, node);
+
+ zak_dbt_dbt_parse_add_column (zak_dbt_dbt, cur);
+ }
+ else if (xmlStrcmp (cur->name, (const xmlChar *)"create_index") == 0)
+ {
+ node = xmlNewNode (NULL, (const xmlChar *)"table_name");
+ xmlNodeSetContent (node, (xmlChar *)table_name);
+ xmlAddChild (cur, node);
+
+ zak_dbt_dbt_parse_create_index (zak_dbt_dbt, cur);
+ }
+
+ cur = cur->next;
+ }
+
+ /* drop of temp column zdbt_to_be_delete */
+ cur = xmlNewNode (NULL, (const xmlChar *)"drop_colum");
+
+ node = xmlNewNode (NULL, (const xmlChar *)"table_name");
+ xmlNodeSetContent (node, (const xmlChar *)table_name);
+ xmlAddChild (cur, node);
+
+ node = xmlNewNode (NULL, (const xmlChar *)"column_name");
+ xmlNodeSetContent (node, (const xmlChar *)"zdbt_to_be_delete");
+ xmlAddChild (cur, node);
+
+ zak_dbt_dbt_parse_drop_column (zak_dbt_dbt, cur);
+ }
+ }
+ }
+ else
+ {
+ g_warning ("You must provide the name of the table to create.");
+ ret = FALSE;
+ }
+
+ return ret;
+}
+
static gboolean
zak_dbt_dbt_parse_drop_table (ZakDbtDbt *zak_dbt_dbt, xmlNodePtr xnode)
{
|| error != NULL)
{
g_warning ("Unable to create GdaServerOperation add_column: %s.",
- error != NULL && error->message != NULL ? error->message : "no details");
+ error != NULL && error->message != NULL ? error->message : "no detail");
ret = FALSE;
}
else
|| error != NULL)
{
g_warning ("Unable to create GdaServerOperation drop_column: %s.",
- error != NULL && error->message != NULL ? error->message : "no details");
+ error != NULL && error->message != NULL ? error->message : "no detail");
ret = FALSE;
}
else
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 details");
+ error != NULL && error->message != NULL ? error->message : "no detail");
ret = FALSE;
}
g_object_unref (op);
{
tosave = zak_dbt_dbt_parse_gda_op (zak_dbt_dbt, xnode);
}
+ else if (xmlStrcmp (xnode->name, (const xmlChar *)"create_table") == 0)
+ {
+ tosave = zak_dbt_dbt_parse_create_table (zak_dbt_dbt, xnode);
+ }
else if (xmlStrcmp (xnode->name, (const xmlChar *)"drop_table") == 0)
{
tosave = zak_dbt_dbt_parse_drop_table (zak_dbt_dbt, xnode);