--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?>
+
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <cconfiguration id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.444330930">
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.444330930" moduleId="org.eclipse.cdt.core.settings" name="Build (GNU)">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration buildProperties="" description="" id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.444330930" name="Build (GNU)" parent="org.eclipse.cdt.build.core.emptycfg">
+ <folderInfo id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.444330930.1685407473" name="/" resourcePath="">
+ <toolChain id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.836272450" name="org.eclipse.linuxtools.cdt.autotools.core.toolChain" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolChain">
+ <targetPlatform id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform.1031969505" isAbstract="false" name="GNU Autotools Target Platform" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform"/>
+ <builder id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder.1197732403" keepEnvironmentInBuildfile="false" managedBuildOn="false" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder"/>
+ <tool id="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure.9367114" name="configure" superClass="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure">
+ <option id="org.eclipse.linuxtools.cdt.autotools.core.option.configure.name.1131657011" name="Name" superClass="org.eclipse.linuxtools.cdt.autotools.core.option.configure.name" value="org.eclipse.linuxtools.cdt.autotools.core.toolChain.444330930" valueType="string"/>
+ </tool>
+ <tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen.155784590" name="autogen.sh" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen"/>
+ <tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc.867105742" name="GCC C Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc">
+ <option id="gnu.c.compiler.option.include.paths.621876005" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+ <listOptionValue builtIn="false" value=""C:\mingw\include""/>
+ <listOptionValue builtIn="false" value=""C:\mingw\include\glib-2.0""/>
+ <listOptionValue builtIn="false" value=""C:\mingw\include\libxml2""/>
+ <listOptionValue builtIn="false" value=""C:\mingw\include\libgda-4.0""/>
+ <listOptionValue builtIn="false" value=""C:\mingw\include\libgda-4.0\libgda""/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.842059199" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp.985338712" name="GCC C++ Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp"/>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="gdadbcopy.null.366714648" name="gdadbcopy"/>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="org.eclipse.linuxtools.cdt.autotools.core.toolChain.444330930;org.eclipse.linuxtools.cdt.autotools.core.toolChain.444330930.1685407473;org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc.867105742;cdt.managedbuild.tool.gnu.c.compiler.input.842059199">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ </scannerConfigBuildInfo>
+ </storageModule>
+</cproject>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>gdadbcopy</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ </natures>
+ <filteredResources>
+ <filter>
+ <id>1356081445076</id>
+ <name></name>
+ <type>30</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-autom4te.cache</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445080</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-Makefile</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445083</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-Makefile.in</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445088</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-config.h</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445091</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-aclocal.m4</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445094</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-config.guess</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445097</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-config.h.in</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445102</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-config.log</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445106</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-config.status</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445109</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-config.sub</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445114</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-configure</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445117</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-depcomp</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445120</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-gdadbcopy.anjuta</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445124</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-install-sh</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445130</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-missing</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445137</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-mkinstalldirs</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445143</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-stamp-h1</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445148</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-*.exe</arguments>
+ </matcher>
+ </filter>
+ <filter>
+ <id>1356081445171</id>
+ <name></name>
+ <type>22</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-*.o</arguments>
+ </matcher>
+ </filter>
+ </filteredResources>
+</projectDescription>
#endif
#include <libgda/libgda.h>
+#include <sql-parser/gda-sql-parser.h>
static gchar *ref_db_cnc = NULL;
static gchar *db_cnc = NULL;
}
}
+static gboolean
+provider_support_operation (GdaConnection *cnc, GdaServerOperationType type)
+{
+
+ return gda_server_provider_supports_operation (gda_connection_get_provider (cnc),
+ cnc,
+ type,
+ NULL);
+}
+
static void
copy_data ()
{
}
}
+static gboolean
+field_server_operation (Table *table,
+ GdaServerOperation *op,
+ GdaMetaTableColumn *column,
+ guint idx_column)
+{
+ GError *error;
+
+ gchar *column_name;
+
+ /* sql builder */
+ column_name = g_strdup_printf ("p_%s", column->column_name);
+ gda_sql_builder_add_field_value_id (table->sqlbuilder,
+ gda_sql_builder_add_id (table->sqlbuilder, column->column_name),
+ gda_sql_builder_add_param (table->sqlbuilder,
+ column_name,
+ column->gtype,
+ column->nullok));
+ g_free (column_name);
+
+ /* server operation */
+ error = NULL;
+ if (!gda_server_operation_set_value_at (op,
+ column->column_name,
+ &error,
+ "/FIELDS_A/@COLUMN_NAME/%d", idx_column))
+ {
+ g_warning ("Error on setting GdaServerOperation's value: %s.",
+ error != NULL && error->message != NULL ? error->message : "no details");
+ return FALSE;
+ }
+
+ error = NULL;
+ if (!gda_server_operation_set_value_at (op,
+ column->column_type,
+ &error,
+ "/FIELDS_A/@COLUMN_TYPE/%d", idx_column))
+ {
+ g_warning ("Error on setting GdaServerOperation's value: %s.",
+ error != NULL && error->message != NULL ? error->message : "no details");
+ return FALSE;
+ }
+
+ if (column->pkey)
+ {
+ error = NULL;
+ if (!gda_server_operation_set_value_at (op,
+ "TRUE",
+ &error,
+ "/FIELDS_A/@COLUMN_PKEY/%d", idx_column))
+ {
+ g_warning ("Error on setting GdaServerOperation's value: %s.",
+ error != NULL && error->message != NULL ? error->message : "no details");
+ return FALSE;
+ }
+ }
+
+ if (!column->nullok)
+ {
+ error = NULL;
+ if (!gda_server_operation_set_value_at (op,
+ "TRUE",
+ &error,
+ "/FIELDS_A/@COLUMN_NNUL/%d", idx_column))
+ {
+ g_warning ("Error on setting GdaServerOperation's value: %s.",
+ error != NULL && error->message != NULL ? error->message : "no details");
+ return FALSE;
+ }
+ }
+
+ if (column->default_value != NULL)
+ {
+ error = NULL;
+ if (!gda_server_operation_set_value_at (op,
+ column->default_value,
+ &error,
+ "/FIELDS_A/@COLUMN_DEFAULT/%d", idx_column))
+ {
+ g_warning ("Error on setting GdaServerOperation's value: %s.",
+ error != NULL && error->message != NULL ? error->message : "no details");
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
static void
read_fields (Table *table, GdaServerOperation *op)
{
GdaMetaTableColumn *column;
guint i;
- gchar *column_name;
mcontext.column_names = g_new (gchar *, 1);
mcontext.column_names[0] = "table_name";
column->default_value);
}
- /* sql builder */
- column_name = g_strdup_printf ("p_%s", column->column_name);
- gda_sql_builder_add_field_value_id (table->sqlbuilder,
- gda_sql_builder_add_id (table->sqlbuilder, column->column_name),
- gda_sql_builder_add_param (table->sqlbuilder,
- column_name,
- column->gtype,
- column->nullok));
- g_free (column_name);
-
- /* server operation */
- error = NULL;
- if (!gda_server_operation_set_value_at (op,
- column->column_name,
- &error,
- "/FIELDS_A/@COLUMN_NAME/%d", i))
- {
- g_warning ("Error on setting GdaServerOperation's value: %s.",
- error != NULL && error->message != NULL ? error->message : "no details");
- continue;
- }
+ field_server_operation (table, op, column, i);
+ }
+ }
+ g_object_unref (mstruct);
+}
+
+static void
+drop_table (Table *table)
+{
+ GError *error;
+
+ GdaServerOperation *op;
+
+ if (!provider_support_operation (gda_conn_db, GDA_SERVER_OPERATION_DROP_TABLE))
+ {
+ g_warning ("Provider doesn't support GDA_SERVER_OPERATION_DROP_TABLE.");
+ return;
+ }
+ error = NULL;
+ op = gda_connection_create_operation (gda_conn_db, GDA_SERVER_OPERATION_DROP_TABLE, NULL, &error);
+ if (op == NULL
+ || error != NULL)
+ {
+ g_warning ("Error on creating GdaServerOperation: %s.",
+ error != NULL && error->message != NULL ? error->message : "no details");
+ }
+ else
+ {
+ error = NULL;
+ if (!gda_server_operation_set_value_at (op, table->name, &error,
+ "/TABLE_DESC_P/TABLE_NAME"))
+ {
+ g_warning ("Error on setting GdaServerOperation's value: %s.",
+ error != NULL && error->message != NULL ? error->message : "no details");
+ }
+ else
+ {
error = NULL;
- if (!gda_server_operation_set_value_at (op,
- column->column_type,
- &error,
- "/FIELDS_A/@COLUMN_TYPE/%d", i))
+ if (!gda_connection_perform_operation (gda_conn_db, op, &error))
{
- g_warning ("Error on setting GdaServerOperation's value: %s.",
+ g_warning ("Error on performing GdaServerOperation: %s.",
error != NULL && error->message != NULL ? error->message : "no details");
- continue;
- }
+ }
+ }
+ }
+
+ if (op != NULL)
+ {
+ g_object_unref (op);
+ }
+}
+
+static GdaServerOperation
+*table_start_server_operation (Table *table)
+{
+ GError *error;
+
+ GdaServerOperation *op;
+
+ /* sql builder for insert into */
+ table->sqlbuilder = gda_sql_builder_new (GDA_SQL_STATEMENT_INSERT);
+ gda_sql_builder_set_table (table->sqlbuilder, table->name);
+
+ if (!provider_support_operation (gda_conn_db, GDA_SERVER_OPERATION_CREATE_TABLE))
+ {
+ g_warning ("Provider doesn't support GDA_SERVER_OPERATION_CREATE_TABLE.");
+ return NULL;
+ }
+
+ /* starting server operation */
+ error = NULL;
+ op = gda_connection_create_operation (gda_conn_db, GDA_SERVER_OPERATION_CREATE_TABLE, NULL, &error);
+ if (op == NULL
+ || error != NULL)
+ {
+ g_warning ("Error on creating GdaServerOperation: %s.",
+ error != NULL && error->message != NULL ? error->message : "no details");
+ return NULL;
+ }
+
+ error = NULL;
+ if (!gda_server_operation_set_value_at (op, table->name, &error,
+ "/TABLE_DEF_P/TABLE_NAME"))
+ {
+ g_warning ("Error on setting GdaServerOperation's value: %s.",
+ error != NULL && error->message != NULL ? error->message : "no details");
+ return NULL;
+ }
+
+ return op;
+}
+
+static void
+table_exec_server_operation (GdaServerOperation *op)
+{
+ GError *error;
+
+ g_return_if_fail (GDA_IS_SERVER_OPERATION (op));
+
+ error = NULL;
+ if (!gda_connection_perform_operation (gda_conn_db, op, &error))
+ {
+ g_warning ("Error on performing GdaServerOperation: %s.",
+ error != NULL && error->message != NULL ? error->message : "no details");
+ }
+}
+
+static void
+output_server_operation (GdaServerOperation *op)
+{
+ GError *error;
+
+ g_return_if_fail (GDA_IS_SERVER_OPERATION (op));
+
+ error = NULL;
+ xmlAddChild (xroot,
+ gda_server_operation_save_data_to_xml (op,
+ &error));
+ if (error != NULL)
+ {
+ g_warning ("Error on saving GdaServerOperation to xml: %s.",
+ error->message != NULL ? error->message : "no details");
+ }
+}
+
+static void
+read_tables_explicit ()
+{
+ /* if there's some tables speicified on command line */
+ if (ht_tables_to_copy != NULL)
+ {
+ /* try to read the schema with an sql */
+ GdaSqlParser *parser;
+
+ GHashTableIter iter;
+ gpointer key;
+ gpointer value;
+
+ gchar *sql;
+ GdaStatement *stmt;
+ GError *error;
+ GdaDataModel *dm;
+
+ guint cols;
+ guint col;
+
+ Table *table;
+ GdaServerOperation *op;
+ GdaColumn *gda_column;
+ GdaMetaTableColumn *mt_column;
+
+ g_printf ("* Reading tables on reference database declared on command line.\n");
+
+ parser = gda_connection_create_parser (gda_conn_ref_db);
+ if (!parser)
+ {
+ /* @cnc doe snot provide its own parser => use default one */
+ parser = gda_sql_parser_new ();
+ }
- if (column->pkey)
+ g_hash_table_iter_init (&iter, ht_tables_to_copy);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ sql = g_strdup_printf ("SELECT * FROM %s", (gchar *)key);
+ stmt = gda_sql_parser_parse_string (parser, sql, NULL, NULL);
+ g_free (sql);
+ dm = gda_connection_statement_execute_select (gda_conn_ref_db, stmt, NULL, &error);
+ g_object_unref (stmt);
+ if (dm != NULL)
{
- error = NULL;
- if (!gda_server_operation_set_value_at (op,
- "TRUE",
- &error,
- "/FIELDS_A/@COLUMN_PKEY/%d", i))
+ cols = gda_data_model_get_n_columns (dm);
+ if (cols > 0)
{
- g_warning ("Error on setting GdaServerOperation's value: %s.",
- error != NULL && error->message != NULL ? error->message : "no details");
- continue;
+ table = g_new0 (Table, 1);
+ table->name = g_strdup ((gchar *)key);
+ table->sqlbuilder = NULL;
+ table->fields = NULL;
+
+ g_printf ("\tTable: %s\n",
+ table->name);
+
+ if (drop_tables)
+ {
+ drop_table (table);
+ }
+
+ op = table_start_server_operation (table);
+ if (op == NULL)
+ {
+ continue;
+ }
}
- }
- if (!column->nullok)
- {
- error = NULL;
- if (!gda_server_operation_set_value_at (op,
- "TRUE",
- &error,
- "/FIELDS_A/@COLUMN_NNUL/%d", i))
+ for (col = 0; col < cols; col++)
{
- g_warning ("Error on setting GdaServerOperation's value: %s.",
- error != NULL && error->message != NULL ? error->message : "no details");
- continue;
+ gda_column = gda_data_model_describe_column (dm, col);
+
+ mt_column = g_new0 (GdaMetaTableColumn, 1);
+ mt_column->column_name = g_strdup (gda_column_get_name (gda_column));
+ mt_column->column_type = g_strdup (gda_column_get_dbms_type (gda_column));
+ mt_column->gtype = gda_column_get_g_type (gda_column);
+ /*mt_column->pkey = gda_column_get_*/
+ mt_column->nullok = gda_column_get_allow_null (gda_column);
+ mt_column->default_value = gda_value_stringify (gda_column_get_default_value (gda_column));
+ table->fields = g_slist_append (table->fields, mt_column);
+
+ if (verbose)
+ {
+ g_printf ("\t\tField: %s - %s - %d - %d - %d - %s\n",
+ mt_column->column_name,
+ mt_column->column_type,
+ mt_column->gtype,
+ mt_column->pkey,
+ mt_column->nullok,
+ mt_column->default_value);
+ }
+
+ field_server_operation (table, op, mt_column, col);
}
- }
- if (column->default_value != NULL)
- {
- error = NULL;
- if (!gda_server_operation_set_value_at (op,
- column->default_value,
- &error,
- "/FIELDS_A/@COLUMN_DEFAULT/%d", i))
+ if (cols > 0)
{
- g_warning ("Error on setting GdaServerOperation's value: %s.",
- error != NULL && error->message != NULL ? error->message : "no details");
- continue;
+ if (output_file != NULL)
+ {
+ output_server_operation (op);
+ }
+
+ table_exec_server_operation (op);
+
+ if (verbose)
+ {
+ error = NULL;
+ stmt = gda_sql_builder_get_statement (table->sqlbuilder, &error);
+ error = NULL;
+ g_printf ("\t\tSql: %s\n",
+ gda_statement_to_sql (stmt, NULL, &error));
+ g_object_unref (stmt);
+ }
+
+ g_object_unref (op);
}
}
}
}
- g_object_unref (mstruct);
}
static void
if (dm_tables != NULL && error == NULL)
{
rows = gda_data_model_get_n_rows (dm_tables);
+ if (rows == 0)
+ {
+ g_printf ("* No table on reference datababe.\n");
+ read_tables_explicit ();
+ }
+
for (row = 0; row < rows; row++)
{
table = g_new0 (Table, 1);
if (drop_tables)
{
- error = NULL;
- op = gda_connection_create_operation (gda_conn_db, GDA_SERVER_OPERATION_DROP_TABLE, NULL, &error);
- if (op == NULL
- || error != NULL)
- {
- g_warning ("Error on creating GdaServerOperation: %s.",
- error != NULL && error->message != NULL ? error->message : "no details");
- }
- else
- {
- error = NULL;
- if (!gda_server_operation_set_value_at (op, table->name, &error,
- "/TABLE_DESC_P/TABLE_NAME"))
- {
- g_warning ("Error on setting GdaServerOperation's value: %s.",
- error != NULL && error->message != NULL ? error->message : "no details");
- }
- else
- {
- error = NULL;
- if (!gda_connection_perform_operation (gda_conn_db, op, &error))
- {
- g_warning ("Error on performing GdaServerOperation: %s.",
- error != NULL && error->message != NULL ? error->message : "no details");
- }
- }
- }
-
- if (op != NULL)
- {
- g_object_unref (op);
- }
- }
-
- /* sql builder for insert into */
- table->sqlbuilder = gda_sql_builder_new (GDA_SQL_STATEMENT_INSERT);
- gda_sql_builder_set_table (table->sqlbuilder, table->name);
-
- /* starting server operation */
- error = NULL;
- op = gda_connection_create_operation (gda_conn_db, GDA_SERVER_OPERATION_CREATE_TABLE, NULL, &error);
- if (op == NULL
- || error != NULL)
- {
- g_warning ("Error on creating GdaServerOperation: %s.",
- error != NULL && error->message != NULL ? error->message : "no details");
- continue;
+ drop_table (table);
}
- error = NULL;
- if (!gda_server_operation_set_value_at (op, table->name, &error,
- "/TABLE_DEF_P/TABLE_NAME"))
+ op = table_start_server_operation (table);
+ if (op == NULL)
{
- g_warning ("Error on setting GdaServerOperation's value: %s.",
- error != NULL && error->message != NULL ? error->message : "no details");
continue;
}
if (output_file != NULL)
{
- error = NULL;
- xmlAddChild (xroot,
- gda_server_operation_save_data_to_xml (op,
- &error));
- if (error != NULL)
- {
- g_warning ("Error on saving GdaServerOperation to xml: %s.",
- error->message != NULL ? error->message : "no details");
- continue;
- }
+ output_server_operation (op);
}
- error = NULL;
- if (!gda_connection_perform_operation (gda_conn_db, op, &error))
- {
- g_warning ("Error on performing GdaServerOperation: %s.",
- error != NULL && error->message != NULL ? error->message : "no details");
- continue;
- }
+ table_exec_server_operation (op);
if (verbose)
{
{
g_warning ("Could not open connection to reference database: %s.\n",
error != NULL && error->message != NULL ? error->message : "no detail");
- return;
+ return 0;
}
error = NULL;
{
g_warning ("Could not open connection to database: %s.\n",
error != NULL && error->message != NULL ? error->message : "no detail");
- return;
+ return 0;
}
if (tables_to_copy != NULL)