[libgda: 3/7] Pstgresql-test: Finalizing test DDL operations



commit 3443db472e5461e5672e55329aea690127b59099
Author: Pavlo Solntsev <p sun fun gmail com>
Date:   Fri Mar 6 15:55:17 2020 -0600

    Pstgresql-test: Finalizing test DDL operations

 tests/test-server-operation-postgresql.c | 549 ++++++++++++++++++++++++-------
 1 file changed, 431 insertions(+), 118 deletions(-)
---
diff --git a/tests/test-server-operation-postgresql.c b/tests/test-server-operation-postgresql.c
index 3134edd08..22d5aa417 100644
--- a/tests/test-server-operation-postgresql.c
+++ b/tests/test-server-operation-postgresql.c
@@ -75,7 +75,7 @@ test_server_operation_start (TestObjectFixture *fixture,
                                                   &error);
 
   if (!fixture->cnc)
-    GDA_PGSQL_ERROR_HANDLE(error);
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_nonnull (fixture->cnc);
 
@@ -105,7 +105,9 @@ test_server_operation_operations (TestObjectFixture *fixture,
                                              fixture->cnc,
                                              GDA_SERVER_OPERATION_CREATE_TABLE,
                                              NULL,
-                                             NULL);
+                                             &error);
+  if (!op)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_nonnull (op);
 
@@ -118,139 +120,200 @@ test_server_operation_operations (TestObjectFixture *fixture,
   /* Define table name */
   res = gda_server_operation_set_value_at (op,
                                            "Project",
-                                           NULL,
+                                           &error,
                                            "/TABLE_DEF_P/TABLE_NAME");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   /* Table will not be temporary */
   res = gda_server_operation_set_value_at (op,
                                            "FALSE",
-                                           NULL,
+                                           &error,
                                            "/TABLE_DEF_P/TABLE_TEMP");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   /* Create table if table doesn't exist yet */
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/TABLE_DEF_P/TABLE_IFNOTEXISTS");
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   /* Define column id*/
   gint column_order = 0;
   res = gda_server_operation_set_value_at (op,
                                            "id",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_NAME/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
+/* We need to pass DBMS specific string reprisentation of the column type */
+  const gchar *id_dbms_type = gda_server_provider_get_default_dbms_type (fixture->provider,
+                                                                        fixture->cnc,
+                                                                        G_TYPE_INT);
   res = gda_server_operation_set_value_at (op,
-                                           "gint",
-                                           NULL,
+                                           id_dbms_type,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_TYPE/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_NNUL/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_AUTOINC/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_UNIQUE/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_PKEY/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   /* Define column name */
   column_order++;
   res = gda_server_operation_set_value_at (op,
                                            "name",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_NAME/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
+/* We need to pass DBMS specific string reprisentation of the column type */
+  const gchar *name_dbms_type = gda_server_provider_get_default_dbms_type (fixture->provider,
+                                                                          fixture->cnc,
+                                                                          G_TYPE_STRING);
+
   res = gda_server_operation_set_value_at (op,
-                                           "gchararray",
-                                           NULL,
+                                           name_dbms_type,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_TYPE/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "50",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_SIZE/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
+
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_NNUL/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "FALSE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_AUTOINC/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_UNIQUE/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "FALSE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_PKEY/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "Default_name",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_DEFAULT/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_provider_perform_operation (fixture->provider,
@@ -259,7 +322,7 @@ test_server_operation_operations (TestObjectFixture *fixture,
                                                &error);
 
   if (!res)
-    GDA_PGSQL_ERROR_HANDLE(error);
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
 
@@ -269,246 +332,348 @@ test_server_operation_operations (TestObjectFixture *fixture,
                                              fixture->cnc,
                                              GDA_SERVER_OPERATION_CREATE_TABLE,
                                              NULL,
-                                             NULL);
+                                             &error);
+
+  if (!op)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_nonnull (op);
 
 /* We will create two tables: Employee and Project. One table will contain foreigh key that points
- * to the column from the second one.
+ *iiiiiii to the column from the second one.
  *
  */
   /* Define table name */
   res = gda_server_operation_set_value_at (op,
                                            "Employee",
-                                           NULL,
+                                           &error,
                                            "/TABLE_DEF_P/TABLE_NAME");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   /* Table will not be temporary */
   res = gda_server_operation_set_value_at (op,
                                            "FALSE",
-                                           NULL,
+                                           &error,
                                            "/TABLE_DEF_P/TABLE_TEMP");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   /* Create table if table doesn't exist yet */
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/TABLE_DEF_P/TABLE_IFNOTEXISTS");
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   /* Define column id */
   column_order = 0;
   res = gda_server_operation_set_value_at (op,
                                            "id",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_NAME/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
+/* We need to pass DBMS specific string reprisentation of the column type */
+  const gchar *id2_dbms_type = gda_server_provider_get_default_dbms_type (fixture->provider,
+                                                                         fixture->cnc,
+                                                                         G_TYPE_INT);
   res = gda_server_operation_set_value_at (op,
-                                           "gint",
-                                           NULL,
+                                           id2_dbms_type,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_TYPE/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_NNUL/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_AUTOINC/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_UNIQUE/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_PKEY/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   /* Define column name */
   column_order++;
   res = gda_server_operation_set_value_at (op,
                                            "name",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_NAME/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
+/* We need to pass DBMS specific string reprisentation of the column type */
+  const gchar *name2_dbms_type = gda_server_provider_get_default_dbms_type (fixture->provider,
+                                                                          fixture->cnc,
+                                                                          G_TYPE_STRING);
   res = gda_server_operation_set_value_at (op,
-                                           "gchararray",
-                                           NULL,
+                                           name2_dbms_type,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_TYPE/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "50",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_SIZE/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_NNUL/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "FALSE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_AUTOINC/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_UNIQUE/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "FALSE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_PKEY/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "Default_name",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_DEFAULT/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   /* Define column project_id */
   column_order++;
   res = gda_server_operation_set_value_at (op,
                                            "project_id",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_NAME/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
+/* We need to pass DBMS specific string reprisentation of the column type */
+  const gchar *id3_dbms_type = gda_server_provider_get_default_dbms_type (fixture->provider,
+                                                                         fixture->cnc,
+                                                                         G_TYPE_INT);
   res = gda_server_operation_set_value_at (op,
-                                           "gint",
-                                           NULL,
+                                           id3_dbms_type,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_TYPE/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_NNUL/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "FALSE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_AUTOINC/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "FALSE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_UNIQUE/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "FALSE",
-                                           NULL,
+                                           &error,
                                            "/FIELDS_A/@COLUMN_PKEY/%d",
                                            column_order);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "Project",
-                                           NULL,
+                                           &error,
                                            "/FKEY_S/%d/FKEY_REF_TABLE",
                                            0);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "RESTRICT",
-                                           NULL,
+                                           &error,
                                            "/FKEY_S/%d/FKEY_ONDELETE",
                                            0);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "RESTRICT",
-                                           NULL,
+                                           &error,
                                            "/FKEY_S/%d/FKEY_ONUPDATE",
                                            0);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "project_id",
-                                           NULL,
+                                           &error,
                                            "/FKEY_S/%d/FKEY_FIELDS_A/@FK_FIELD/%d",
                                            0,0);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "id",
-                                           NULL,
+                                           &error,
                                            "/FKEY_S/%d/FKEY_FIELDS_A/@FK_REF_PK_FIELD/%d",
                                            0,0);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_provider_perform_operation (fixture->provider,
                                                fixture->cnc,
                                                op,
-                                               NULL);
+                                               &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
   /* END of CREATE_TABLE operation */
@@ -519,56 +684,84 @@ test_server_operation_operations (TestObjectFixture *fixture,
   op = gda_server_provider_create_operation (fixture->provider, fixture->cnc,
                                              GDA_SERVER_OPERATION_ADD_COLUMN,
                                              NULL,
-                                             NULL);
+                                             &error);
+
+  if (!op)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_nonnull (op);
 
   res = gda_server_operation_set_value_at (op,
                                            "Project",
-                                           NULL,
+                                           &error,
                                            "/COLUMN_DEF_P/TABLE_NAME");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "cost",
-                                           NULL,
+                                           &error,
                                            "/COLUMN_DEF_P/COLUMN_NAME");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
+/* We need to pass DBMS specific string reprisentation of the column type */
+  const gchar *cost_dbms_type = gda_server_provider_get_default_dbms_type (fixture->provider,
+                                                                          fixture->cnc,
+                                                                          GDA_TYPE_NUMERIC);
   res = gda_server_operation_set_value_at (op,
-                                           "gfloat",
-                                           NULL,
+                                           cost_dbms_type,
+                                           &error,
                                            "/COLUMN_DEF_P/COLUMN_TYPE");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "5",
-                                           NULL,
+                                           &error,
                                            "/COLUMN_DEF_P/COLUMN_SIZE");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "2",
-                                           NULL,
+                                           &error,
                                            "/COLUMN_DEF_P/COLUMN_SCALE");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "FALSE",
-                                           NULL,
+                                           &error,
                                            "/COLUMN_DEF_P/COLUMN_NNUL");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_provider_perform_operation (fixture->provider,
                                                fixture->cnc,
                                                op,
-                                               NULL);
+                                               &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE  (error);
 
   g_assert_true (res);
 
@@ -578,28 +771,40 @@ test_server_operation_operations (TestObjectFixture *fixture,
   op = gda_server_provider_create_operation (fixture->provider, fixture->cnc,
                                              GDA_SERVER_OPERATION_RENAME_TABLE,
                                              NULL,
-                                             NULL);
+                                             &error);
+
+  if (!op)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (op);
 
   res = gda_server_operation_set_value_at (op,
                                            "Employee",
-                                           NULL,
+                                           &error,
                                            "/TABLE_DESC_P/TABLE_NAME");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "NewEmployee",
-                                           NULL,
+                                           &error,
                                            "/TABLE_DESC_P/TABLE_NEW_NAME");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_provider_perform_operation (fixture->provider,
                                                fixture->cnc,
                                                op,
-                                               NULL);
+                                               &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
 
@@ -611,42 +816,60 @@ test_server_operation_operations (TestObjectFixture *fixture,
                                              fixture->cnc,
                                              GDA_SERVER_OPERATION_CREATE_VIEW,
                                              NULL,
-                                             NULL);
+                                             &error);
+
+  if (!op)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_nonnull (op);
 
   res = gda_server_operation_set_value_at (op,
                                            "MyView",
-                                           NULL,
+                                           &error,
                                            "/VIEW_DEF_P/VIEW_NAME");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "FALSE",
-                                           NULL,
+                                           &error,
                                            "/VIEW_DEF_P/VIEW_TEMP");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/VIEW_DEF_P/VIEW_IFNOTEXISTS");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "SELECT name, project_id FROM NewEmployee",
-                                           NULL,
+                                           &error,
                                            "/VIEW_DEF_P/VIEW_DEF");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_provider_perform_operation (fixture->provider,
                                                fixture->cnc,
                                                op,
-                                               NULL);
+                                               &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
   /* END CREATE_VIEEW OPERATION */
@@ -658,28 +881,40 @@ test_server_operation_operations (TestObjectFixture *fixture,
                                              fixture->cnc,
                                              GDA_SERVER_OPERATION_DROP_VIEW,
                                              NULL,
-                                             NULL);
+                                             &error);
+
+  if (!op)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_nonnull (op);
 
   res = gda_server_operation_set_value_at (op,
                                            "MyView",
-                                           NULL,
+                                           &error,
                                            "/VIEW_DESC_P/VIEW_NAME");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/VIEW_DESC_P/VIEW_IFNOTEXISTS");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_provider_perform_operation (fixture->provider,
                                                fixture->cnc,
                                                op,
-                                               NULL);
+                                               &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
   /* END DROP VIEW OPERATION */
@@ -691,63 +926,90 @@ test_server_operation_operations (TestObjectFixture *fixture,
                                              fixture->cnc,
                                              GDA_SERVER_OPERATION_CREATE_INDEX,
                                              NULL,
-                                             NULL);
+                                             &error);
+
+  if (!op)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_nonnull (op);
 
   res = gda_server_operation_set_value_at (op,
                                            "UNIQUE",
-                                           NULL,
+                                           &error,
                                            "/INDEX_DEF_P/INDEX_TYPE");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "MyIndex",
-                                           NULL,
+                                           &error,
                                            "/INDEX_DEF_P/INDEX_NAME");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "NewEmployee",
-                                           NULL,
+                                           &error,
                                            "/INDEX_DEF_P/INDEX_ON_TABLE");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/INDEX_DEF_P/INDEX_IFNOTEXISTS");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "name",
-                                           NULL,
+                                           &error,
                                            "/INDEX_FIELDS_S/%d/INDEX_FIELD",
                                            0);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "BINARY",
-                                           NULL,
+                                           &error,
                                            "/INDEX_FIELD_S/%d/INDEX_COLLATE",
                                            0);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "ASC",
-                                           NULL,
+                                           &error,
                                            "/INDEX_FIELD_S/%d/INDEX_SORT_ORDER",
                                            0);
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
-  res = gda_server_provider_perform_operation (fixture->provider, fixture->cnc, op, NULL);
+  res = gda_server_provider_perform_operation (fixture->provider, fixture->cnc, op, &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
   /* END CREATE_INDEX OPERATION */
@@ -758,28 +1020,40 @@ test_server_operation_operations (TestObjectFixture *fixture,
                                              fixture->cnc,
                                              GDA_SERVER_OPERATION_DROP_INDEX,
                                              NULL,
-                                             NULL);
+                                             &error);
+
+  if (!op)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_nonnull (op);
 
   res = gda_server_operation_set_value_at (op,
                                            "MyIndex",
-                                           NULL,
+                                           &error,
                                            "/INDEX_DESC_P/INDEX_NAME");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/INDEX_DESC_P/INDEX_IFEXISTS");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_provider_perform_operation (fixture->provider,
                                                fixture->cnc,
                                                op,
-                                               NULL);
+                                               &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
   /* END DROP_INDEX OPERATION */
@@ -791,28 +1065,40 @@ test_server_operation_operations (TestObjectFixture *fixture,
                                              fixture->cnc,
                                              GDA_SERVER_OPERATION_DROP_TABLE,
                                              NULL,
-                                             NULL);
+                                             &error);
+
+  if (!op)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_nonnull (op);
 
   res = gda_server_operation_set_value_at (op,
                                            "NewEmployee",
-                                           NULL,
+                                           &error,
                                            "/TABLE_DESC_P/TABLE_NAME");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_operation_set_value_at (op,
                                            "TRUE",
-                                           NULL,
+                                           &error,
                                            "/TABLE_DESC_P/TABLE_IFEXISTS");
 
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
+
   g_assert_true (res);
 
   res = gda_server_provider_perform_operation (fixture->provider,
                                                fixture->cnc,
                                                op,
-                                               NULL);
+                                               &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
   /* END DROP_TABLE OPERATION */
@@ -824,7 +1110,7 @@ static void
 test_server_operation_operations_db (TestObjectFixture *fixture,
                                      G_GNUC_UNUSED gconstpointer user_data)
 {
-
+  GError *error = NULL;
 /* Define table Project */
   GdaDbTable *tproject = gda_db_table_new ();
   gda_db_base_set_name (GDA_DB_BASE (tproject), "Project");
@@ -859,7 +1145,10 @@ test_server_operation_operations_db (TestObjectFixture *fixture,
   g_object_unref (pname);
 
 /* Create table */
-  gboolean res = gda_db_table_create (tproject, fixture->cnc, TRUE, NULL);
+  gboolean res = gda_db_table_create (tproject, fixture->cnc, TRUE, &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
 
@@ -918,19 +1207,25 @@ test_server_operation_operations_db (TestObjectFixture *fixture,
 
   g_object_unref (fkey);
 
-  res = gda_db_table_create (temployee, fixture->cnc, TRUE, NULL);
+  res = gda_db_table_create (temployee, fixture->cnc, TRUE, &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
 
   /* Start of ADD_COLUMN operation */
   GdaDbColumn *cost = gda_db_column_new ();
-  gda_db_column_set_name (cost, "cost");
-  gda_db_column_set_type (cost, G_TYPE_FLOAT);
+  gda_db_column_set_name (cost, "costa");
+  gda_db_column_set_type (cost, GDA_TYPE_NUMERIC);
   gda_db_column_set_size (cost, 5);
   gda_db_column_set_scale (cost, 2);
   gda_db_column_set_nnul (cost, FALSE);
 
-  res = gda_db_table_add_column (tproject, cost, fixture->cnc, NULL);
+  res = gda_db_table_add_column (tproject, cost, fixture->cnc, &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
 
@@ -941,7 +1236,10 @@ test_server_operation_operations_db (TestObjectFixture *fixture,
   GdaDbTable *new_table = gda_db_table_new ();
   gda_db_base_set_name (GDA_DB_BASE (new_table), "NewEmployee");
 
-  res = gda_db_table_rename (temployee, new_table, fixture->cnc, NULL);
+  res = gda_db_table_rename (temployee, new_table, fixture->cnc, &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
 
@@ -950,10 +1248,16 @@ test_server_operation_operations_db (TestObjectFixture *fixture,
   gda_db_view_set_istemp (myview, FALSE);
   gda_db_view_set_defstring (myview, "SELECT name, project_id FROM NewEmployee");
 
-  res = gda_db_view_create (myview, fixture->cnc, TRUE, NULL);
+  res = gda_db_view_create (myview, fixture->cnc, TRUE, &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   /* DROP_VIEW operation. We will reuse the  view */
-  res = gda_db_view_drop (myview, fixture->cnc, TRUE, GDA_DB_VIEW_RESTRICT, NULL);
+  res = gda_db_view_drop (myview, fixture->cnc, TRUE, GDA_DB_VIEW_RESTRICT, &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
 
@@ -975,15 +1279,24 @@ test_server_operation_operations_db (TestObjectFixture *fixture,
   g_object_unref (fcol);
   g_object_unref (field);
 
-  res = gda_db_table_add_index (new_table, index, fixture->cnc, TRUE, NULL);
+  res = gda_db_table_add_index (new_table, index, fixture->cnc, TRUE, &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
 
-  res = gda_db_index_drop (index, fixture->cnc, TRUE, NULL);
+  res = gda_db_index_drop (index, fixture->cnc, TRUE, &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
 
-  res = gda_db_table_drop (new_table, fixture->cnc, TRUE, NULL);
+  res = gda_db_table_drop (new_table, fixture->cnc, TRUE, &error);
+
+  if (!res)
+    GDA_PGSQL_ERROR_HANDLE (error);
 
   g_assert_true (res);
 }
@@ -996,18 +1309,18 @@ main(gint argc, gchar *argv[])
   g_test_init (&argc,&argv,NULL);
 
   g_test_add ("/test-server-operation-sqlite/old-so-module",
-              TestObjectFixture,
-              NULL,
-              test_server_operation_start,
-              test_server_operation_operations,
-              test_server_operation_finish);
+             TestObjectFixture,
+             NULL,
+             test_server_operation_start,
+             test_server_operation_operations,
+             test_server_operation_finish);
 
   g_test_add ("/test-server-operation-sqlite/gda-db-module",
-              TestObjectFixture,
-              NULL,
-              test_server_operation_start,
-              test_server_operation_operations_db,
-              test_server_operation_finish);
+             TestObjectFixture,
+             NULL,
+             test_server_operation_start,
+             test_server_operation_operations_db,
+             test_server_operation_finish);
 
   return g_test_run();
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]