gda_server_operation_set_value_at (op, "operation", &error, "/FIELDS_A/@COLUMN_NAME/%d", i);
gda_server_operation_set_value_at (op, "text", &error, "/FIELDS_A/@COLUMN_TYPE/%d", i);
+ /*
+ xmlNodePtr xnode2 = gda_server_operation_save_data_to_xml (op, &error);
+ xmlDocPtr xdoc2 = xmlNewDoc ("1.0");
+ xmlDocSetRootElement (xdoc2, xnode2);
+ xmlSaveFormatFile("-",xdoc2,2);
+ */
+
/* execute the operation */
if (!gda_server_provider_perform_operation (provider, priv->gda_conn, op, &error))
{
return ret;
}
+static gboolean
+dbt_parse_gda_op (Dbt *dbt, xmlNodePtr xnode)
+{
+ DbtPrivate *priv;
+
+ gboolean ret;
+
+ xmlNodePtr cur;
+
+ gchar *str_operation_type;
+ GdaServerOperationType operation_type;
+ GdaServerProvider *provider;
+ GError *error;
+ GdaServerOperation *op;
+
+ ret = TRUE;
+
+ priv = DBT_GET_PRIVATE (dbt);
+
+ cur = xnode->children;
+ while (cur != NULL && ret)
+ {
+ if (xmlNodeIsText (cur))
+ {
+ cur = cur->next;
+ continue;
+ }
+
+ if (xmlStrcmp (cur->name, (const xmlChar *)"serv_op_data") != 0)
+ {
+ g_warning ("Invalid tag \"%s\".\n", cur->name);
+ ret = FALSE;
+ cur = cur->next;
+ continue;
+ }
+
+ str_operation_type = (gchar *)xmlGetProp(cur, (const xmlChar *)"type");
+
+ /* TODO
+ * must find the GdaServerOperationType of the string
+ * i asked on gda mailing list
+ * for now i implement it
+ */
+ operation_type = GDA_SERVER_OPERATION_LAST;
+ if (g_strcmp0 (str_operation_type, "CREATE_DB") == 0) operation_type = GDA_SERVER_OPERATION_CREATE_DB;
+ if (g_strcmp0 (str_operation_type, "DROP_DB") == 0) operation_type = GDA_SERVER_OPERATION_DROP_DB;
+ if (g_strcmp0 (str_operation_type, "CREATE_TABLE") == 0) operation_type = GDA_SERVER_OPERATION_CREATE_TABLE;
+ if (g_strcmp0 (str_operation_type, "DROP_TABLE") == 0) operation_type = GDA_SERVER_OPERATION_DROP_TABLE;
+ if (g_strcmp0 (str_operation_type, "CREATE_INDEX") == 0) operation_type = GDA_SERVER_OPERATION_CREATE_INDEX;
+ if (g_strcmp0 (str_operation_type, "DROP_INDEX") == 0) operation_type = GDA_SERVER_OPERATION_DROP_INDEX;
+ if (g_strcmp0 (str_operation_type, "RENAME_TABLE") == 0) operation_type = GDA_SERVER_OPERATION_RENAME_TABLE;
+ if (g_strcmp0 (str_operation_type, "COMMENT_TABLE") == 0) operation_type = GDA_SERVER_OPERATION_COMMENT_TABLE;
+ if (g_strcmp0 (str_operation_type, "ADD_COLUMN") == 0) operation_type = GDA_SERVER_OPERATION_ADD_COLUMN;
+ if (g_strcmp0 (str_operation_type, "DROP_COLUMN") == 0) operation_type = GDA_SERVER_OPERATION_DROP_COLUMN;
+ if (g_strcmp0 (str_operation_type, "COMMENT_COLUMN") == 0) operation_type = GDA_SERVER_OPERATION_COMMENT_COLUMN;
+ if (g_strcmp0 (str_operation_type, "CREATE_VIEW") == 0) operation_type = GDA_SERVER_OPERATION_CREATE_VIEW;
+ if (g_strcmp0 (str_operation_type, "DROP_VIEW") == 0) operation_type = GDA_SERVER_OPERATION_DROP_VIEW;
+ if (g_strcmp0 (str_operation_type, "CREATE_USER") == 0) operation_type = GDA_SERVER_OPERATION_CREATE_USER;
+ if (g_strcmp0 (str_operation_type, "DROP_USER") == 0) operation_type = GDA_SERVER_OPERATION_DROP_USER;
+ if (g_strcmp0 (str_operation_type, "ALTER_USER") == 0) operation_type = GDA_SERVER_OPERATION_ALTER_USER;
+
+ if (operation_type == GDA_SERVER_OPERATION_LAST)
+ {
+ g_warning ("Operation type \"%s\" not supported.\n%s\n", str_operation_type,
+ error && error->message ? error->message : "No detail");
+ return FALSE;
+ }
+
+ provider = gda_connection_get_provider (priv->gda_conn);
+ if (gda_server_provider_supports_operation (provider, priv->gda_conn, operation_type, NULL))
+ {
+ error = NULL;
+ op = gda_server_provider_create_operation (provider, priv->gda_conn, operation_type, NULL, &error);
+ if (!op)
+ {
+ g_warning ("Unable to create operation type \"%s\".\n%s\n", str_operation_type,
+ error && error->message ? error->message : "No detail");
+ ret = FALSE;
+ }
+ else
+ {
+ error = NULL;
+ if (!gda_server_operation_load_data_from_xml (op, cur, &error))
+ {
+ g_warning ("Unable to load GdaServerOperation from the file.\n%s\n",
+ error && error->message ? error->message : "No detail");
+ ret = FALSE;
+ }
+ else
+ {
+ if (!gda_server_provider_perform_operation (provider, priv->gda_conn, op, &error))
+ {
+ g_warning ("Error on executing GdaServerOperation from the file.\n%s\n",
+ error && error->message ? error->message : "No detail");
+ ret = FALSE;
+ }
+ }
+ g_object_unref (op);
+ }
+ }
+ else
+ {
+ g_warning ("Operation type \"%s\" not supported by the provider.\n", str_operation_type);
+ ret = FALSE;
+ }
+
+ cur = cur->next;
+ }
+
+ return ret;
+}
+
void
dbt_transform (Dbt *dbt)
{
{
tosave = dbt_parse_sql (dbt, xnode);
}
- /*else if (xmlStrcmp (xnode->name, (const xmlChar *)"gda_op") == 0)
+ else if (xmlStrcmp (xnode->name, (const xmlChar *)"gda_op") == 0)
{
tosave = dbt_parse_gda_op (dbt, xnode);
- }*/
+ }
else
{
g_warning ("Invalid tag: %s", xnode->name);
</sql>
</dbtransformation>
+ <dbtransformation id="3">
+ <gda_op>
+ <serv_op_data type="CREATE_TABLE">
+ <op_data path="/TABLE_DEF_P/TABLE_NAME">newtable</op_data>
+ <op_data path="/TABLE_DEF_P/TABLE_TEMP">FALSE</op_data>
+ <op_data path="/TABLE_DEF_P/TABLE_IFNOTEXISTS">FALSE</op_data>
+ <op_data path="/FIELDS_A">
+ <gda_array_data>
+ <gda_array_row>
+ <gda_array_value colid="COLUMN_NAME">id</gda_array_value>
+ <gda_array_value colid="COLUMN_TYPE">integer</gda_array_value>
+ <gda_array_value colid="COLUMN_SIZE" isnull="t"/>
+ <gda_array_value colid="COLUMN_SCALE" isnull="t"/>
+ <gda_array_value colid="COLUMN_NNUL" isnull="t"/>
+ <gda_array_value colid="COLUMN_AUTOINC" isnull="t"/>
+ <gda_array_value colid="COLUMN_UNIQUE" isnull="t"/>
+ <gda_array_value colid="COLUMN_PKEY">TRUE</gda_array_value>
+ <gda_array_value colid="COLUMN_DEFAULT" isnull="t"/>
+ <gda_array_value colid="COLUMN_CHECK" isnull="t"/>
+ <gda_array_value colid="COLUMN_COLLATE" isnull="t"/>
+ <gda_array_value colid="COLUMN_CONFLICT" isnull="t"/>
+ </gda_array_row>
+ </gda_array_data>
+ </op_data>
+ </serv_op_data>
+ </gda_op>
+ </dbtransformation>
+
</dbtransformer>