[libgda] meta-store: fixes on partial and full updates



commit a58741fbffb4069a0719579d77052b8a6854ef59
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date:   Mon Jan 14 16:37:13 2019 -0600

    meta-store: fixes on partial and full updates
    
    Fixes on PostgresSQL provider

 libgda/gda-connection.c                          | 523 +++++++++++++----------
 libgda/gda-meta-store.c                          |  34 +-
 providers/reuseable/postgres/gda-postgres-meta.c |  29 +-
 3 files changed, 352 insertions(+), 234 deletions(-)
---
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index 27f4cc91d..cd4935004 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -4134,29 +4134,30 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                         *  -0- @table_catalog, @table_schema, @table_name, @constraint_name
                         *  -1- @table_catalog, @table_schema, @table_name, @column_name
                         */
-                       const GValue *tabname = NULL;
-                       const GValue *cname = NULL;
-                       i = check_parameters (context, error, 2,
-                                             &catalog, G_TYPE_STRING,
-                                             &schema, G_TYPE_STRING,
-                                             &tabname, G_TYPE_STRING,
-                                             &cname, G_TYPE_STRING, NULL,
-                                             "table_catalog", &catalog, "table_schema", &schema, 
"table_name", &tabname, "constraint_name", &cname, NULL,
-                                             "table_catalog", &catalog, "table_schema", &schema, 
"table_name", &tabname, "column_name", &cname, NULL);
-                       if (i < 0)
-                               return FALSE;
-                       
-                       ASSERT_TABLE_NAME (tname, "check_column_usage");
-                       if (i == 0) {
+                       if (gda_meta_context_get_n_columns (context) == 0) {
+                               ASSERT_TABLE_NAME (tname, "check_column_usage");
+                               retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META__CHECK_COLUMNS, 
error);
+                               WARN_META_UPDATE_FAILURE (retval, "check_columns");
+                       } else {
+                               const GValue *tabname = NULL;
+                               const GValue *cname = NULL;
+                               i = check_parameters (context, error, 2,
+                                                           &catalog, G_TYPE_STRING,
+                                                           &schema, G_TYPE_STRING,
+                                                           &tabname, G_TYPE_STRING,
+                                                           &cname, G_TYPE_STRING, NULL,
+                                                           "table_catalog", &catalog, "table_schema", 
&schema, "table_name", &tabname, "constraint_name", &cname, NULL,
+                                                           "table_catalog", &catalog, "table_schema", 
&schema, "table_name", &tabname, "column_name", &cname, NULL);
+                               if (i < 0)
+                                       return FALSE;
+
+                               ASSERT_TABLE_NAME (tname, "check_column_usage");
                                retval = _gda_server_provider_meta_4arg (provider, cnc, store, context,
                                                                         GDA_SERVER_META_CHECK_COLUMNS, 
catalog, schema, tabname, cname, error);
                                WARN_META_UPDATE_FAILURE (retval, "check_columns");
-                               return retval;
-                       }
-                       else {
-                               /* nothing to do */
-                               return TRUE;
                        }
+                       return retval;
                }
                break;
 
@@ -4189,23 +4190,31 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                         *  -0- @domain_catalog, @domain_schema, @domain_name
                         *  -1- @constraint_catalog, @constraint_schema
                         */
-                       const GValue *domname = NULL;
-                       i = check_parameters (context, error, 2,
-                                             &catalog, G_TYPE_STRING,
-                                             &schema, G_TYPE_STRING,
-                                             &domname, G_TYPE_STRING, NULL,
-                                             "domain_catalog", &catalog, "domain_schema", &schema, 
"domain_name", &domname, NULL,
-                                             "constraint_catalog", &catalog, "constraint_schema", &schema, 
NULL);
+                       if (gda_meta_context_get_n_columns (context) == 0) {
+                               ASSERT_TABLE_NAME (tname, "domain_constraints");
+                               retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META__CONSTRAINTS_DOM, 
error);
+                               WARN_META_UPDATE_FAILURE (retval, "constraints_dom");
+                       } else {
+                               const GValue *domname = NULL;
+                               i = check_parameters (context, error, 2,
+                                                           &catalog, G_TYPE_STRING,
+                                                           &schema, G_TYPE_STRING,
+                                                           &domname, G_TYPE_STRING, NULL,
+                                                           "domain_catalog", &catalog, "domain_schema", 
&schema, "domain_name", &domname, NULL,
+                                                           "constraint_catalog", &catalog, 
"constraint_schema", &schema, NULL);
 
-                       if (i < 0)
-                               return FALSE;
-                       if (i == 1)
-                               return TRUE; /* nothing to do */
+                               if (i < 0)
+                                       return FALSE;
+                               if (i == 1)
+                                       return TRUE; /* nothing to do */
+
+                               ASSERT_TABLE_NAME (tname, "domain_constraints");
+                               retval = _gda_server_provider_meta_3arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META_CONSTRAINTS_DOM, 
catalog, schema, domname, error);
+                               WARN_META_UPDATE_FAILURE (retval, "constraints_dom");
+                       }
 
-                       ASSERT_TABLE_NAME (tname, "domain_constraints");
-                       retval = _gda_server_provider_meta_3arg (provider, cnc, store, context,
-                                                                GDA_SERVER_META_CONSTRAINTS_DOM, catalog, 
schema, domname, error);
-                       WARN_META_UPDATE_FAILURE (retval, "constraints_dom");
                        return retval;
                }
                break;
@@ -4215,18 +4224,26 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                        /* _enums, params: 
                         *  -0- @udt_catalog, @udt_schema, @udt_name
                         */
-                       i = check_parameters (context, error, 1,
+                       if (gda_meta_context_get_n_columns (context) == 0) {
+                               ASSERT_TABLE_NAME (tname, "enums");
+                               retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META__ENUMS, error);
+                               WARN_META_UPDATE_FAILURE (retval, "enums");
+                       } else {
+                               i = check_parameters (context, error, 1,
                                              &catalog, G_TYPE_STRING,
                                              &schema, G_TYPE_STRING,
                                              &name, G_TYPE_STRING, NULL,
                                              "udt_catalog", &catalog, "udt_schema", &schema, "udt_name", 
&name, NULL);
-                       if (i < 0)
-                               return FALSE;
-                       
-                       ASSERT_TABLE_NAME (tname, "enums");
-                       retval = _gda_server_provider_meta_3arg (provider, cnc, store, context,
-                                                                GDA_SERVER_META_ENUMS, catalog, schema, 
name, error);
-                       WARN_META_UPDATE_FAILURE (retval, "enums");
+                               if (i < 0)
+                                       return FALSE;
+
+                               ASSERT_TABLE_NAME (tname, "enums");
+                               retval = _gda_server_provider_meta_3arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META_ENUMS, catalog, 
schema, name, error);
+                               WARN_META_UPDATE_FAILURE (retval, "enums");
+                       }
+
                        return retval;
                }
                else {
@@ -4268,21 +4285,28 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                        /* _index_column_usage, params: 
                         *  -0- @table_catalog, @table_schema, @table_name, @index_name
                         */
-                       const GValue *iname = NULL;
-                       i = check_parameters (context, error, 1,
-                                             &catalog, G_TYPE_STRING,
-                                             &schema, G_TYPE_STRING,
-                                             &name, G_TYPE_STRING,
-                                             &iname, G_TYPE_STRING, NULL,
-                                             "table_catalog", &catalog, "table_schema", &schema, 
"table_name", &name, "index_name", &iname, NULL);
+                       if (gda_meta_context_get_n_columns (context) == 0) {
+                               ASSERT_TABLE_NAME (tname, "index_column_usage");
+                               retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META__INDEX_COLS, error);
+                               WARN_META_UPDATE_FAILURE (retval, "index_cols");
+                       } else {
+                               const GValue *iname = NULL;
+                               i = check_parameters (context, error, 1,
+                                                           &catalog, G_TYPE_STRING,
+                                                           &schema, G_TYPE_STRING,
+                                                           &name, G_TYPE_STRING,
+                                                           &iname, G_TYPE_STRING, NULL,
+                                                           "table_catalog", &catalog, "table_schema", 
&schema, "table_name", &name, "index_name", &iname, NULL);
 
-                       if (i < 0)
-                               return FALSE;
+                               if (i < 0)
+                                       return FALSE;
 
-                       ASSERT_TABLE_NAME (tname, "index_column_usage");
-                       retval = _gda_server_provider_meta_4arg (provider, cnc, store, context,
-                                                                GDA_SERVER_META_INDEX_COLS, catalog, schema, 
name, iname, error);
-                       WARN_META_UPDATE_FAILURE (retval, "index_cols");
+                               ASSERT_TABLE_NAME (tname, "index_column_usage");
+                               retval = _gda_server_provider_meta_4arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META_INDEX_COLS, catalog, 
schema, name, iname, error);
+                               WARN_META_UPDATE_FAILURE (retval, "index_cols");
+                       }
                        return retval;
                }
                break;
@@ -4291,29 +4315,30 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                 *  -0- @table_catalog, @table_schema, @table_name, @constraint_name
                 *  -0- @ref_table_catalog, @ref_table_schema, @ref_table_name, @ref_constraint_name
                 */
-               const GValue *tabname = NULL;
-               const GValue *cname = NULL;
-               i = check_parameters (context, error, 2,
-                                     &catalog, G_TYPE_STRING,
-                                     &schema, G_TYPE_STRING,
-                                     &tabname, G_TYPE_STRING,
-                                     &cname, G_TYPE_STRING, NULL,
-                                     "table_catalog", &catalog, "table_schema", &schema, "table_name", 
&tabname, "constraint_name", &cname, NULL,
-                                     "table_catalog", &catalog, "table_schema", &schema, "table_name", 
&tabname, "column_name", &cname, NULL);
-               if (i < 0)
-                       return FALSE;
-               
-               ASSERT_TABLE_NAME (tname, "key_column_usage");
-               if (i == 0) {
+               if (gda_meta_context_get_n_columns (context) == 0) {
+                       ASSERT_TABLE_NAME (tname, "key_column_usage");
+                       retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
+                                                                GDA_SERVER_META__KEY_COLUMNS, error);
+                       WARN_META_UPDATE_FAILURE (retval, "key_columns");
+               } else {
+                       const GValue *tabname = NULL;
+                       const GValue *cname = NULL;
+                       i = check_parameters (context, error, 2,
+                                                   &catalog, G_TYPE_STRING,
+                                                   &schema, G_TYPE_STRING,
+                                                   &tabname, G_TYPE_STRING,
+                                                   &cname, G_TYPE_STRING, NULL,
+                                                   "table_catalog", &catalog, "table_schema", &schema, 
"table_name", &tabname, "constraint_name", &cname, NULL,
+                                                   "table_catalog", &catalog, "table_schema", &schema, 
"table_name", &tabname, "column_name", &cname, NULL);
+                       if (i < 0)
+                               return FALSE;
+
+                       ASSERT_TABLE_NAME (tname, "key_column_usage");
                        retval = _gda_server_provider_meta_4arg (provider, cnc, store, context,
                                                                 GDA_SERVER_META_KEY_COLUMNS, catalog, 
schema, tabname, cname, error);
                        WARN_META_UPDATE_FAILURE (retval, "key_columns");
-                       return retval;
-               }
-               else {
-                       /* nothing to do */
-                       return TRUE;
                }
+               return retval;
                break;
        }
 
@@ -4346,29 +4371,38 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                         *  -0- @table_catalog, @table_schema, @table_name, @constraint_name
                         *  -0- @ref_table_catalog, @ref_table_schema, @ref_table_name, @ref_constraint_name
                         */
-                       const GValue *tabname = NULL;
-                       const GValue *cname = NULL;
-                       i = check_parameters (context, error, 2,
-                                             &catalog, G_TYPE_STRING,
-                                             &schema, G_TYPE_STRING,
-                                             &tabname, G_TYPE_STRING,
-                                             &cname, G_TYPE_STRING, NULL,
-                                             "table_catalog", &catalog, "table_schema", &schema, 
"table_name", &tabname, "constraint_name", &cname, NULL,
-                                             "ref_table_catalog", &catalog, "ref_table_schema", &schema, 
"ref_table_name", &tabname, "ref_constraint_name", &cname, NULL);
-                       if (i < 0)
-                               return FALSE;
-                       
-                       ASSERT_TABLE_NAME (tname, "referential_constraints");
-                       if (i == 0) {
-                               retval = _gda_server_provider_meta_4arg (provider, cnc, store, context,
-                                                                        GDA_SERVER_META_CONSTRAINTS_REF, 
catalog, schema, tabname, cname, error);
+                       if (gda_meta_context_get_n_columns (context) == 0) {
+                               ASSERT_TABLE_NAME (tname, "referential_constraints");
+                               retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
+                                                                                
GDA_SERVER_META__CONSTRAINTS_REF, error);
                                WARN_META_UPDATE_FAILURE (retval, "constraints_ref");
                                return retval;
+                       } else {
+                               const GValue *tabname = NULL;
+                               const GValue *cname = NULL;
+                               i = check_parameters (context, error, 2,
+                                                           &catalog, G_TYPE_STRING,
+                                                           &schema, G_TYPE_STRING,
+                                                           &tabname, G_TYPE_STRING,
+                                                           &cname, G_TYPE_STRING, NULL,
+                                                           "table_catalog", &catalog, "table_schema", 
&schema, "table_name", &tabname, "constraint_name", &cname, NULL,
+                                                           "ref_table_catalog", &catalog, 
"ref_table_schema", &schema, "ref_table_name", &tabname, "ref_constraint_name", &cname, NULL);
+                               if (i < 0)
+                                       return FALSE;
+
+                               ASSERT_TABLE_NAME (tname, "referential_constraints");
+                               if (i == 0) {
+                                       retval = _gda_server_provider_meta_4arg (provider, cnc, store, 
context,
+                                                                                
GDA_SERVER_META_CONSTRAINTS_REF, catalog, schema, tabname, cname, error);
+                                       WARN_META_UPDATE_FAILURE (retval, "constraints_ref");
+                                       return retval;
+                               }
+                               else {
+                                       /* nothing to do */
+                                       return TRUE;
+                               }
                        }
-                       else {
-                               /* nothing to do */
-                               return TRUE;
-                       }
+                       return TRUE;
                }
                if ((tname[1] == 'o') && (tname[2] == 'u') && (tname[3] == 't') && (tname[4] == 'i') &&
                    (tname[5] == 'n') && (tname[6] == 'e') && (tname[7] == 's')) {
@@ -4395,23 +4429,26 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                        /* _routine_columns, params: 
                         *  -0- @specific_catalog, @specific_schema, @specific_name
                         */
-                       const GValue *col_name = NULL;
-                       const GValue *ordinal = NULL;
-                       i = check_parameters (context, error, 1,
-                                             &catalog, G_TYPE_STRING,
-                                             &schema, G_TYPE_STRING,
-                                             &name, G_TYPE_STRING,
-                                             &col_name, G_TYPE_STRING,
-                                             &ordinal, G_TYPE_STRING, NULL,
-                                             "specific_catalog", &catalog, "specific_schema", &schema, 
"specific_name", &name, "column_name", &col_name, "ordinal_position", &ordinal, NULL);
-
-                       ASSERT_TABLE_NAME (tname, "routine_columns");
-                       if (i < 0) {
-                               g_clear_error (error);
+                       if (gda_meta_context_get_n_columns (context) == 0) {
+                               ASSERT_TABLE_NAME (tname, "routine_columns");
                                retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
                                                                         GDA_SERVER_META__ROUTINE_COL, error);
                                WARN_META_UPDATE_FAILURE (retval, "routine_col");
                        } else {
+                               const GValue *col_name = NULL;
+                               const GValue *ordinal = NULL;
+                               i = check_parameters (context, error, 1,
+                                                           &catalog, G_TYPE_STRING,
+                                                           &schema, G_TYPE_STRING,
+                                                           &name, G_TYPE_STRING,
+                                                           &col_name, G_TYPE_STRING,
+                                                           &ordinal, G_TYPE_INT, NULL,
+                                                           "specific_catalog", &catalog, "specific_schema", 
&schema, "specific_name", &name, "column_name", &col_name, "ordinal_position", &ordinal, NULL);
+                               if (i < 0) {
+                                       g_message ("Fail _routine_columns");
+                                       return FALSE;
+                               }
+                               ASSERT_TABLE_NAME (tname, "routine_columns");
                                retval = _gda_server_provider_meta_5arg (provider, cnc, store, context,
                                                                         GDA_SERVER_META_ROUTINE_COL, 
catalog, schema, name, col_name, ordinal, error);
                                WARN_META_UPDATE_FAILURE (retval, "routine_col");
@@ -4425,17 +4462,23 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                 *  -0- @catalog_name, @schema_name 
                 *  -1- @catalog_name
                 */
-               i = check_parameters (context, error, 2,
-                                     &schema, G_TYPE_STRING, NULL,
-                                     "catalog_name", &catalog, "schema_name", &schema, NULL,
-                                     "catalog_name", &catalog, NULL);
-               if (i < 0)
-                       return FALSE;
                ASSERT_TABLE_NAME (tname, "schemata");
+               if (gda_meta_context_get_n_columns (context) == 0) {
+                       retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
+                                                        GDA_SERVER_META__SCHEMATA, error);
+                       WARN_META_UPDATE_FAILURE (retval, "schemata");
+               } else {
+                       i = check_parameters (context, error, 2,
+                                                   &schema, G_TYPE_STRING, NULL,
+                                                   "catalog_name", &catalog, "schema_name", &schema, NULL,
+                                                   "catalog_name", &catalog, NULL);
+                       if (i < 0)
+                       return FALSE;
 
-               retval = _gda_server_provider_meta_2arg (provider, cnc, store, context,
-                                                        GDA_SERVER_META_SCHEMATA, catalog, schema, error);
-               WARN_META_UPDATE_FAILURE (retval, "schemata");
+                       retval = _gda_server_provider_meta_2arg (provider, cnc, store, context,
+                                                                GDA_SERVER_META_SCHEMATA, catalog, schema, 
error);
+                       WARN_META_UPDATE_FAILURE (retval, "schemata");
+               }
                return retval;
        }
        case 't': 
@@ -4444,19 +4487,28 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                         *  -0- @table_catalog, @table_schema, @table_name
                         *  -1- @table_catalog, @table_schema
                         */
-                       i = check_parameters (context, error, 2,
-                                             &catalog, G_TYPE_STRING,
-                                             &schema, G_TYPE_STRING,
-                                             &name, G_TYPE_STRING, NULL,
-                                             "table_catalog", &catalog, "table_schema", &schema, 
"table_name", &name, NULL,
-                                             "table_catalog", &catalog, "table_schema", &schema, NULL);
-                       if (i < 0)
-                               return FALSE;
+                       if (gda_meta_context_get_n_columns (context) == 0) {
+                               ASSERT_TABLE_NAME (tname, "tables");
+                               retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META__TABLES_VIEWS, 
error);
+                               WARN_META_UPDATE_FAILURE (retval, "tables_views");
+                       } else {
+                               i = check_parameters (context, error, 3,
+                                                           &catalog, G_TYPE_STRING,
+                                                           &schema, G_TYPE_STRING,
+                                                           &name, G_TYPE_STRING, NULL,
+                                                           "table_catalog", &catalog, "table_schema", 
&schema, "table_name", &name, NULL,
+                                                           "table_catalog", &catalog, "table_schema", 
&schema, NULL,
+                                                           "table_name", &name, NULL);
+                               if (i < 0)
+                                       return FALSE;
+
+                               ASSERT_TABLE_NAME (tname, "tables");
+                               retval = _gda_server_provider_meta_3arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META_TABLES_VIEWS, 
catalog, schema, name, error);
+                               WARN_META_UPDATE_FAILURE (retval, "tables_views");
+                       }
                        
-                       ASSERT_TABLE_NAME (tname, "tables");
-                       retval = _gda_server_provider_meta_3arg (provider, cnc, store, context,
-                                                                GDA_SERVER_META_TABLES_VIEWS, catalog, 
schema, name, error);
-                       WARN_META_UPDATE_FAILURE (retval, "tables_views");
                        return retval;
                }
                else if ((tname[1] == 'a') && (tname[2] == 'b') && (tname[3] == 'l') && (tname[4] == 'e') && 
@@ -4465,23 +4517,30 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                         *  -0- @table_catalog, @table_schema, @table_name, @constraint_name
                         *  -1- @table_catalog, @table_schema, @table_name
                         */
-                       const GValue *cname = NULL;
-                       const GValue *tabname = NULL;
-                       i = check_parameters (context, error, 2,
-                                             &catalog, G_TYPE_STRING,
-                                             &schema, G_TYPE_STRING,
-                                             &cname, G_TYPE_STRING,
-                                             &tabname, G_TYPE_STRING, NULL,
-                                             "table_catalog", &catalog, "table_schema", &schema, 
"table_name", &tabname, "constraint_name", &cname, NULL,
-                                             "table_catalog", &catalog, "table_schema", &schema, 
"table_name", &tabname, NULL);
+                       if (gda_meta_context_get_n_columns (context) == 0) {
+                               retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
+                                                                GDA_SERVER_META__CONSTRAINTS_TAB, error);
+                               WARN_META_UPDATE_FAILURE (retval, "constraints_tab");
+                       } else {
+                               const GValue *cname = NULL;
+                               const GValue *tabname = NULL;
+                               i = check_parameters (context, error, 2,
+                                                           &catalog, G_TYPE_STRING,
+                                                           &schema, G_TYPE_STRING,
+                                                           &cname, G_TYPE_STRING,
+                                                           &tabname, G_TYPE_STRING, NULL,
+                                                           "table_catalog", &catalog, "table_schema", 
&schema, "table_name", &tabname, "constraint_name", &cname, NULL,
+                                                           "table_catalog", &catalog, "table_schema", 
&schema, "table_name", &tabname, NULL);
+
+                               if (i < 0)
+                                       return FALSE;
+
+                               ASSERT_TABLE_NAME (tname, "table_constraints");
+                               retval = _gda_server_provider_meta_4arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META_CONSTRAINTS_TAB, 
catalog, schema, tabname, cname, error);
+                               WARN_META_UPDATE_FAILURE (retval, "constraints_tab");
+                       }
 
-                       if (i < 0)
-                               return FALSE;
-                       
-                       ASSERT_TABLE_NAME (tname, "table_constraints");
-                       retval = _gda_server_provider_meta_4arg (provider, cnc, store, context,
-                                                                GDA_SERVER_META_CONSTRAINTS_TAB, catalog, 
schema, tabname, cname, error);
-                       WARN_META_UPDATE_FAILURE (retval, "constraints_tab");
                        return retval;
                }
                else if ((tname[1] == 'a') && (tname[2] == 'b') && (tname[3] == 'l') && (tname[4] == 'e') && 
@@ -4490,23 +4549,31 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                         *  -0- @table_catalog, @table_schema, @table_name, @index_name
                         *  -1- @table_catalog, @table_schema, @table_name
                         */
-                       const GValue *iname = NULL;
-                       const GValue *tabname = NULL;
-                       i = check_parameters (context, error, 2,
-                                             &catalog, G_TYPE_STRING,
-                                             &schema, G_TYPE_STRING,
-                                             &iname, G_TYPE_STRING,
-                                             &tabname, G_TYPE_STRING, NULL,
-                                             "table_catalog", &catalog, "table_schema", &schema, 
"table_name", &tabname, "index_name", &iname, NULL,
-                                             "table_catalog", &catalog, "table_schema", &schema, 
"table_name", &tabname, NULL);
+                       if (gda_meta_context_get_n_columns (context) == 0) {
+                               ASSERT_TABLE_NAME (tname, "table_indexes");
+                               retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META__INDEXES_TAB, error);
+                               WARN_META_UPDATE_FAILURE (retval, "indexes_tab");
+                       } else {
+                               const GValue *iname = NULL;
+                               const GValue *tabname = NULL;
+                               i = check_parameters (context, error, 2,
+                                                           &catalog, G_TYPE_STRING,
+                                                           &schema, G_TYPE_STRING,
+                                                           &iname, G_TYPE_STRING,
+                                                           &tabname, G_TYPE_STRING, NULL,
+                                                           "table_catalog", &catalog, "table_schema", 
&schema, "table_name", &tabname, "index_name", &iname, NULL,
+                                                           "table_catalog", &catalog, "table_schema", 
&schema, "table_name", &tabname, NULL);
+
+                               if (i < 0)
+                                       return FALSE;
+
+                               ASSERT_TABLE_NAME (tname, "table_indexes");
+                               retval = _gda_server_provider_meta_4arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META_INDEXES_TAB, 
catalog, schema, tabname, iname, error);
+                               WARN_META_UPDATE_FAILURE (retval, "indexes_tab");
+                       }
 
-                       if (i < 0)
-                               return FALSE;
-                       
-                       ASSERT_TABLE_NAME (tname, "table_indexes");
-                       retval = _gda_server_provider_meta_4arg (provider, cnc, store, context,
-                                                                GDA_SERVER_META_INDEXES_TAB, catalog, 
schema, tabname, iname, error);
-                       WARN_META_UPDATE_FAILURE (retval, "indexes_tab");
                        return retval;
                }
                else if ((tname[1] == 'r') && (tname[2] == 'i')) {
@@ -4514,25 +4581,30 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                         *  -0- @trigger_catalog, @trigger_schema
                         *  -1- @event_object_catalog, @event_object_schema, @event_object_table
                         */
-                       i = check_parameters (context, error, 2,
-                                             &catalog, G_TYPE_STRING,
-                                             &schema, G_TYPE_STRING,
-                                             &name, G_TYPE_STRING, NULL,
-                                             "trigger_catalog", &catalog, "trigger_schema", &schema, NULL,
-                                             "event_object_catalog", &catalog, "event_object_schema", 
&schema, "event_object_table", &name, NULL);
-                       if (i < 0)
-                               return FALSE;
-                       
+
                        ASSERT_TABLE_NAME (tname, "triggers");
-                       if (i == 1) {
-                               retval = _gda_server_provider_meta_3arg (provider, cnc, store, context,
-                                                                        GDA_SERVER_META_TRIGGERS, catalog, 
schema, name, error);
-                               WARN_META_UPDATE_FAILURE (retval, "triggers");
-                               return retval;
-                       }
-                       else {
-                               /* nothing to do */
-                               return TRUE;
+                       if (gda_meta_context_get_n_columns (context) == 0) {
+                               retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
+                                                                                GDA_SERVER_META__TRIGGERS, 
error);
+                       } else {
+                               i = check_parameters (context, error, 2,
+                                                           &catalog, G_TYPE_STRING,
+                                                           &schema, G_TYPE_STRING,
+                                                           &name, G_TYPE_STRING, NULL,
+                                                           "trigger_catalog", &catalog, "trigger_schema", 
&schema, NULL,
+                                                           "event_object_catalog", &catalog, 
"event_object_schema", &schema, "event_object_table", &name, NULL);
+                               if (i < 0)
+                                       return FALSE;
+                               if (i == 1) {
+                                       retval = _gda_server_provider_meta_3arg (provider, cnc, store, 
context,
+                                                                                GDA_SERVER_META_TRIGGERS, 
catalog, schema, name, error);
+                                       WARN_META_UPDATE_FAILURE (retval, "triggers");
+                                       return retval;
+                               }
+                               else {
+                                       /* nothing to do */
+                                       return TRUE;
+                               }
                        }
                }
                break;
@@ -4542,17 +4614,24 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                        /* _udt, params: 
                         *  -0- @udt_catalog, @udt_schema
                         */
-                       i = check_parameters (context, error, 1,
-                                             &catalog, G_TYPE_STRING,
-                                             &schema, G_TYPE_STRING, NULL,
-                                             "udt_catalog", &catalog, "udt_schema", &schema, NULL);
-                       if (i < 0)
-                               return FALSE;
-                       
-                       ASSERT_TABLE_NAME (tname, "udt");
-                       retval = _gda_server_provider_meta_2arg (provider, cnc, store, context,
-                                                                GDA_SERVER_META_UDT, catalog, schema, error);
-                       WARN_META_UPDATE_FAILURE (retval, "udt");
+                       if (gda_meta_context_get_n_columns (context) == 0) {
+                               ASSERT_TABLE_NAME (tname, "udt");
+                               retval = _gda_server_provider_meta_0arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META__UDT, error);
+                               WARN_META_UPDATE_FAILURE (retval, "udt");
+                       } else {
+                               i = check_parameters (context, error, 1,
+                                                           &catalog, G_TYPE_STRING,
+                                                           &schema, G_TYPE_STRING, NULL,
+                                                           "udt_catalog", &catalog, "udt_schema", &schema, 
NULL);
+                               if (i < 0)
+                                       return FALSE;
+
+                               ASSERT_TABLE_NAME (tname, "udt");
+                               retval = _gda_server_provider_meta_2arg (provider, cnc, store, context,
+                                                                        GDA_SERVER_META_UDT, catalog, 
schema, error);
+                               WARN_META_UPDATE_FAILURE (retval, "udt");
+                       }
                        return retval;
                }
                else if ((tname[1] == 'd') && (tname[2] == 't') && (tname[3] == '_')) {
@@ -4584,29 +4663,30 @@ local_meta_update (GdaServerProvider *provider, GdaConnection *cnc, GdaMetaConte
                 *  -0- @view_catalog, @view_schema, @view_name
                 *  -1- @table_catalog, @table_schema, @table_name, @column_name
                 */
-               const GValue *colname = NULL;
-               i = check_parameters (context, error, 2,
-                                     &catalog, G_TYPE_STRING,
-                                     &schema, G_TYPE_STRING,
-                                     &colname, G_TYPE_STRING,
-                                     &name, G_TYPE_STRING, NULL,
-                                     "view_catalog", &catalog, "view_schema", &schema, "view_name", &name, 
NULL,
-                                     "table_catalog", &catalog, "table_schema", &schema, "table_name", 
&name, 
-                                     "column_name", &colname, NULL);
-               if (i < 0)
-                       return FALSE;
-               
-               ASSERT_TABLE_NAME (tname, "view_column_usage");
-               if (i == 0) {
+               if (gda_meta_context_get_n_columns (context) == 0) {
+                       retval = _gda_server_provider_meta_3arg (provider, cnc, store, context,
+                                                                GDA_SERVER_META_VIEW_COLS, catalog, schema, 
name, error);
+                       WARN_META_UPDATE_FAILURE (retval, "view_cols");
+               } else {
+                       const GValue *colname = NULL;
+                       i = check_parameters (context, error, 2,
+                                                   &catalog, G_TYPE_STRING,
+                                                   &schema, G_TYPE_STRING,
+                                                   &colname, G_TYPE_STRING,
+                                                   &name, G_TYPE_STRING, NULL,
+                                                   "view_catalog", &catalog, "view_schema", &schema, 
"view_name", &name, NULL,
+                                                   "table_catalog", &catalog, "table_schema", &schema, 
"table_name", &name,
+                                                   "column_name", &colname, NULL);
+                       if (i < 0)
+                               return FALSE;
+
+                       ASSERT_TABLE_NAME (tname, "view_column_usage");
                        retval = _gda_server_provider_meta_3arg (provider, cnc, store, context,
                                                                 GDA_SERVER_META_VIEW_COLS, catalog, schema, 
name, error);
                        WARN_META_UPDATE_FAILURE (retval, "view_cols");
-                       return retval;
-               }
-               else {
-                       /* nothing to do */
-                       return TRUE;
                }
+
+               return retval;
                break;
        }
        default:
@@ -4861,15 +4941,17 @@ gda_connection_update_meta_store (GdaConnection *cnc, GdaMetaContext *context, G
                cbd.error = NULL;
                cbd.context_templates = g_slist_concat (g_slist_append (up_templates, lcontext), 
dn_templates);
                cbd.context_templates_hash = g_hash_table_new (g_str_hash, g_str_equal);
-               for (list = cbd.context_templates; list; list = list->next) 
-                       g_hash_table_insert (cbd.context_templates_hash, 
((GdaMetaContext*)list->data)->table_name,
-                                            list->data);
-
-               signal_id = g_signal_connect (store, "suggest-update",
-                                             G_CALLBACK (suggest_update_cb_downstream), &cbd);
                retval = local_meta_update (priv->provider_obj, cnc,
-                                           (GdaMetaContext*) (cbd.context_templates->data), error);
-               g_signal_handler_disconnect (store, signal_id);
+                                           lcontext, error);
+               if (retval) {
+                       for (list = cbd.context_templates; list; list = list->next) {
+                               retval = local_meta_update (priv->provider_obj, cnc,
+                                        (GdaMetaContext*) (list->data), error);
+                               if (!retval) {
+                                       break;
+                               }
+                       }
+               }
 
                /* free the memory associated with each template */
                for (list = cbd.context_templates; list; list = list->next) {
@@ -5032,7 +5114,8 @@ gda_connection_get_meta_store_data (GdaConnection *cnc,
                        GdaHolder *h;
                        GValue *v;
                        gchar* fname;
-      
+                       GError *lerror = NULL;
+
                        fname = va_arg (ap, gchar*);
                        if (!fname)
                                break;
@@ -5041,7 +5124,11 @@ gda_connection_get_meta_store_data (GdaConnection *cnc,
                                continue;
                        h = g_object_new (GDA_TYPE_HOLDER, "g-type", G_VALUE_TYPE (v), "id", fname, NULL);
                        filters = g_list_append (filters, h);
-                       if (!gda_holder_set_value (h, v, error)) {
+                       if (!gda_holder_set_value (h, v, &lerror)) {
+                               g_set_error (error, GDA_CONNECTION_ERROR, 
GDA_CONNECTION_META_DATA_CONTEXT_ERROR,
+                                            _("While extracting data from Data Store: %s"),
+                                                                                lerror && lerror->message ? 
lerror->message : "No error message was set");
+                               g_clear_error (&lerror);
                                va_end (ap);
                                goto onerror;
                        }
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index 39a176dac..2673e4ffc 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -3054,12 +3054,17 @@ gda_meta_store_extract (GdaMetaStore *store, const gchar *select_sql, GError **e
                        if (!h)
                                g_warning (_("Parameter '%s' is not present in statement"), pname);
                        else {
-                               if (!gda_holder_set_value (h, value, error)) {
+                               GError *lerror = NULL;
+                               if (!gda_holder_set_value (h, value, &lerror)) {
                                        g_object_unref (stmt);
                                        g_object_unref (params);
                                        va_end (ap);
                                        g_slist_free (params_set);
                                        g_rec_mutex_unlock (& (priv->mutex));
+                                       g_set_error (error, GDA_META_STORE_ERROR, 
GDA_META_STORE_EXTRACT_SQL_ERROR,
+                                            _("While extracting data from Meta Store: %s"),
+                                            lerror && lerror->message ? lerror->message : "No error message 
was set");
+                                       g_clear_error (&lerror);
                                        return NULL;
                                }
                                params_set = g_slist_prepend (params_set, h);
@@ -3174,9 +3179,14 @@ gda_meta_store_extract_v (GdaMetaStore *store, const gchar *select_sql, GHashTab
                        if (!h)
                                g_message (_("Parameter '%s' is not present in statement"), pname);
                        else {
-                               if (!gda_holder_set_value (h, value, error)) {
+                               GError *lerror = NULL;
+                               if (!gda_holder_set_value (h, value, &lerror)) {
                                        g_object_unref (stmt);
                                        g_object_unref (params);
+                                       g_set_error (error, GDA_META_STORE_ERROR, 
GDA_META_STORE_EXTRACT_SQL_ERROR,
+                                            _("While extracting data from store: %s"),
+                                            lerror && lerror->message ? lerror->message : "No error message 
was set");
+                                       g_clear_error (&lerror);
                                        g_rec_mutex_unlock (& (priv->mutex));
                                        return NULL;
                                }
@@ -3484,6 +3494,7 @@ gda_meta_store_modify_v (GdaMetaStore *store, const gchar *table_name,
                                h = gda_set_get_holder (schema_set->params, pid);
                                if (h) {
                                        const GValue *value;
+                                       GError *lerror = NULL;
                                        value = gda_data_model_get_value_at (wrapped_data, j, i, error);
                                        if (!value) {
                                                g_free (pid);
@@ -3503,10 +3514,27 @@ gda_meta_store_modify_v (GdaMetaStore *store, const gchar *table_name,
                                                }
                                        }
 
-                                       if (! gda_holder_set_value (h, value, error)) {
+                                       if (! gda_holder_set_value (h, value, &lerror)) {
                                                g_free (pid);
                                                retval = FALSE;
+                                               g_message ("New Data: Column: '%s' : '%s' - ncol: %d - type: 
%s - Val: %s", gda_data_model_get_column_name (wrapped_data, j),
+                                                                                        
gda_data_model_get_column_title (wrapped_data, j), j, g_type_name (G_VALUE_TYPE (value)),
+                                                                                        gda_value_stringify 
(value));
+                                               g_message ("Holder: '%s' type: %s", gda_holder_get_id (h), 
g_type_name (gda_holder_get_g_type (h)));
+                                               /* if (new_data != wrapped_data) { */
+                                               /*      g_print ("NEW for table %s:\n", table_name); */
+                                               /*      gda_data_model_dump (new_data, stdout); */
+
+                                               /*      g_print ("wrapped as:\n"); */
+                                               /*      gda_data_model_dump (wrapped_data, stdout); */
+                                               /* } else { */
+                                               /*      g_message ("DATA NO WRAPPED"); */
+                                               /* } */
                                                g_object_unref (wrapped_data);
+                                               g_set_error (error, GDA_META_STORE_ERROR, 
GDA_META_STORE_EXTRACT_SQL_ERROR,
+                                            _("Internal error, while updating internal meta store table 
'%s': Parameter value type error: %s"),
+                                            table_name, lerror && lerror->message ? lerror->message : "No 
error message was set");
+                                               g_clear_error (&lerror);
                                                goto out;
                                        }
                                        if (change) {
diff --git a/providers/reuseable/postgres/gda-postgres-meta.c 
b/providers/reuseable/postgres/gda-postgres-meta.c
index 25b10bae4..90ef69aa2 100644
--- a/providers/reuseable/postgres/gda-postgres-meta.c
+++ b/providers/reuseable/postgres/gda-postgres-meta.c
@@ -116,13 +116,13 @@ static gchar *internal_sql[] = {
        "SELECT current_database() AS catalog_name, n.nspname AS schema_name, u.rolname AS schema_owner, CASE 
WHEN n.nspname ~ '^pg_' THEN TRUE WHEN n.nspname = 'information_schema' THEN TRUE ELSE FALSE END, CASE WHEN 
n.nspname = 'public' THEN TRUE ELSE FALSE END AS schema_default FROM pg_namespace n, pg_roles u WHERE 
n.nspowner = u.oid AND current_database() = ##cat::string AND n.nspname = ##name::string",
 
        /* I_STMT_TABLES */
-       "SELECT current_database() AS table_catalog, nc.nspname AS table_schema, c.relname AS table_name, 
CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY' WHEN c.relkind = 'r' THEN 'BASE TABLE' WHEN 
c.relkind = 'v' THEN 'VIEW' ELSE NULL END AS table_type, CASE WHEN c.relkind = 'r' THEN TRUE ELSE FALSE END, 
pg_catalog.obj_description(c.oid), CASE WHEN pg_catalog.pg_table_is_visible(c.oid) IS TRUE AND 
nc.nspname!='pg_catalog' THEN c.relname ELSE coalesce (nc.nspname || '.', '') || c.relname END, coalesce 
(nc.nspname || '.', '') || c.relname, o.rolname FROM pg_namespace nc, pg_class c, pg_roles o WHERE 
current_database() = ##cat::string AND nc.nspname = ##schema::string AND c.relnamespace = nc.oid AND 
(c.relkind = ANY (ARRAY['r', 'v'])) AND NOT pg_is_other_temp_schema(nc.oid) AND (pg_has_role(c.relowner, 
'USAGE') OR has_table_privilege(c.oid, 'SELECT') OR has_table_privilege(c.oid, 'INSERT') OR 
has_table_privilege(c.oid, 'UPDATE') OR has_table_privilege(c.oid, 'DELETE') O
 R has_ta
 ble_privilege(c.oid, 'REFERENCES') OR has_table_privilege(c.oid, 'TRIGGER')) AND o.oid=c.relowner",
+       "SELECT current_database() AS table_catalog, nc.nspname AS table_schema, c.relname AS table_name, 
CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY' WHEN c.relkind = 'r' THEN 'BASE TABLE' WHEN 
c.relkind = 'v' THEN 'VIEW' ELSE NULL END AS table_type, CASE WHEN c.relkind = 'r' THEN TRUE ELSE FALSE END, 
pg_catalog.obj_description(c.oid), CASE WHEN pg_catalog.pg_table_is_visible(c.oid) IS TRUE AND 
nc.nspname!='pg_catalog' THEN c.relname ELSE coalesce (nc.nspname || '.', '') || c.relname END, coalesce 
(nc.nspname || '.', '') || c.relname, o.rolname FROM pg_namespace nc, pg_class c, pg_roles o WHERE CASE WHEN 
##cat::string IS NULL THEN TRUE ELSE current_database() = ##cat::string END AND CASE WHEN ##schema::string IS 
NULL THEN TRUE ELSE nc.nspname = ##schema::string END AND c.relnamespace = nc.oid AND (c.relkind = ANY 
(ARRAY['r', 'v'])) AND NOT pg_is_other_temp_schema(nc.oid) AND (pg_has_role(c.relowner, 'USAGE') OR 
has_table_privilege(c.oid, 'SELECT') OR has_table_pri
 vilege(c
 .oid, 'INSERT') OR has_table_privilege(c.oid, 'UPDATE') OR has_table_privilege(c.oid, 'DELETE') OR 
has_table_privilege(c.oid, 'REFERENCES') OR has_table_privilege(c.oid, 'TRIGGER')) AND o.oid=c.relowner",
 
        /* I_STMT_TABLES_ALL */
        "SELECT current_database() AS table_catalog, nc.nspname AS table_schema, c.relname AS table_name, 
CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY' WHEN c.relkind = 'r' THEN 'BASE TABLE' WHEN 
c.relkind = 'v' THEN 'VIEW' ELSE NULL END AS table_type, CASE WHEN c.relkind = 'r' THEN TRUE ELSE FALSE END, 
pg_catalog.obj_description(c.oid), CASE WHEN pg_catalog.pg_table_is_visible(c.oid) IS TRUE AND 
nc.nspname!='pg_catalog' THEN c.relname ELSE coalesce (nc.nspname || '.', '') || c.relname END, coalesce 
(nc.nspname || '.', '') || c.relname, o.rolname FROM pg_namespace nc, pg_class c, pg_roles o WHERE 
c.relnamespace = nc.oid AND (c.relkind = ANY (ARRAY['r', 'v'])) AND NOT pg_is_other_temp_schema(nc.oid) AND 
(pg_has_role(c.relowner, 'USAGE') OR has_table_privilege(c.oid, 'SELECT') OR has_table_privilege(c.oid, 
'INSERT') OR has_table_privilege(c.oid, 'UPDATE') OR has_table_privilege(c.oid, 'DELETE') OR 
has_table_privilege(c.oid, 'REFERENCES') OR has_table_privilege(c.oid, 
 'TRIGGER
 ')) AND o.oid=c.relowner",
 
        /* I_STMT_TABLE_NAMED */
-       "SELECT current_database() AS table_catalog, nc.nspname AS table_schema, c.relname AS table_name, 
CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY' WHEN c.relkind = 'r' THEN 'BASE TABLE' WHEN 
c.relkind = 'v' THEN 'VIEW' ELSE NULL END AS table_type, CASE WHEN c.relkind = 'r' THEN TRUE ELSE FALSE END, 
pg_catalog.obj_description(c.oid), CASE WHEN pg_catalog.pg_table_is_visible(c.oid) IS TRUE AND 
nc.nspname!='pg_catalog' THEN c.relname ELSE coalesce (nc.nspname || '.', '') || c.relname END, coalesce 
(nc.nspname || '.', '') || c.relname, o.rolname FROM pg_namespace nc, pg_class c, pg_roles o WHERE 
current_database() = ##cat::string AND nc.nspname = ##schema::string AND c.relnamespace = nc.oid AND 
(c.relkind = ANY (ARRAY['r', 'v'])) AND NOT pg_is_other_temp_schema(nc.oid) AND (pg_has_role(c.relowner, 
'USAGE') OR has_table_privilege(c.oid, 'SELECT') OR has_table_privilege(c.oid, 'INSERT') OR 
has_table_privilege(c.oid, 'UPDATE') OR has_table_privilege(c.oid, 'DELETE') O
 R has_ta
 ble_privilege(c.oid, 'REFERENCES') OR has_table_privilege(c.oid, 'TRIGGER')) AND o.oid=c.relowner AND 
c.relname = ##name::string",
+       "SELECT current_database() AS table_catalog, nc.nspname AS table_schema, c.relname AS table_name, 
CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY' WHEN c.relkind = 'r' THEN 'BASE TABLE' WHEN 
c.relkind = 'v' THEN 'VIEW' ELSE NULL END AS table_type, CASE WHEN c.relkind = 'r' THEN TRUE ELSE FALSE END, 
pg_catalog.obj_description(c.oid), CASE WHEN pg_catalog.pg_table_is_visible(c.oid) IS TRUE AND 
nc.nspname!='pg_catalog' THEN c.relname ELSE coalesce (nc.nspname || '.', '') || c.relname END, coalesce 
(nc.nspname || '.', '') || c.relname, o.rolname FROM pg_namespace nc, pg_class c, pg_roles o WHERE CASE WHEN 
##cat::string IS NULL THEN TRUE ELSE current_database() = ##cat::string END AND CASE WHEN ##schema::string IS 
NULL THEN TRUE ELSE nc.nspname = ##schema::string END AND c.relnamespace = nc.oid AND (c.relkind = ANY 
(ARRAY['r', 'v'])) AND NOT pg_is_other_temp_schema(nc.oid) AND (pg_has_role(c.relowner, 'USAGE') OR 
has_table_privilege(c.oid, 'SELECT') OR has_table_pri
 vilege(c
 .oid, 'INSERT') OR has_table_privilege(c.oid, 'UPDATE') OR has_table_privilege(c.oid, 'DELETE') OR 
has_table_privilege(c.oid, 'REFERENCES') OR has_table_privilege(c.oid, 'TRIGGER')) AND o.oid=c.relowner AND 
c.relname = ##name::string",
 
        /* I_STMT_VIEWS */
        "SELECT current_database() AS table_catalog, nc.nspname AS table_schema, c.relname AS table_name, 
pg_catalog.pg_get_viewdef(c.oid, TRUE), NULL, CASE WHEN c.relkind = 'r' THEN TRUE ELSE FALSE END FROM 
pg_namespace nc, pg_class c WHERE current_database() = ##cat::string AND nc.nspname = ##schema::string AND 
c.relnamespace = nc.oid AND c.relkind = 'v' AND NOT pg_is_other_temp_schema(nc.oid) AND 
(pg_has_role(c.relowner, 'USAGE') OR has_table_privilege(c.oid, 'SELECT') OR has_table_privilege(c.oid, 
'INSERT') OR has_table_privilege(c.oid, 'UPDATE') OR has_table_privilege(c.oid, 'DELETE') OR 
has_table_privilege(c.oid, 'REFERENCES') OR has_table_privilege(c.oid, 'TRIGGER'))",
@@ -151,10 +151,10 @@ static gchar *internal_sql[] = {
        "SELECT constraint_catalog, constraint_schema, constraint_name, table_catalog, table_schema, 
table_name, constraint_type, NULL, CASE WHEN is_deferrable = 'YES' THEN TRUE ELSE FALSE END, CASE WHEN 
initially_deferred = 'YES' THEN TRUE ELSE FALSE END FROM information_schema.table_constraints WHERE 
table_catalog = ##cat::string AND table_schema = ##schema::string AND table_name = ##name::string AND 
constraint_name = ##name2::string",
 
        /* I_STMT_REF_CONSTRAINTS */
-       "SELECT current_database(), nt.nspname, t.relname, c.conname, current_database(), nref.nspname, 
ref.relname, pkc.conname, CASE c.confmatchtype WHEN 'f' THEN 'FULL' WHEN 'p' THEN 'PARTIAL' WHEN 'u' THEN 
'NONE' ELSE NULL END AS match_option, CASE c.confupdtype WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' 
WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 'RESTRICT' WHEN 'a' THEN 'NO ACTION' ELSE NULL END AS update_rule, 
CASE c.confdeltype WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 
'RESTRICT' WHEN 'a' THEN 'NO ACTION' ELSE NULL END AS delete_rule FROM pg_constraint c INNER JOIN pg_class t 
ON (c.conrelid=t.oid) INNER JOIN pg_namespace nt ON (nt.oid=t.relnamespace) INNER JOIN pg_class ref ON 
(c.confrelid=ref.oid) INNER JOIN pg_namespace nref ON (nref.oid=ref.relnamespace) INNER JOIN pg_constraint 
pkc ON (c.confrelid = pkc.conrelid AND information_schema._pg_keysequal(c.confkey, pkc.conkey) AND 
pkc.contype='p') WHERE c.contype = 'f' AND 
 current_
 database() = ##cat::string AND nt.nspname = ##schema::string AND t.relname = ##name::string AND c.conname = 
##name2::string",
+       "SELECT current_database() AS table_catalog, nt.nspname AS table_schema, t.relname AS table_name, 
c.conname AS constraint_name, current_database() AS ref_table_catalog, nref.nspname AS ref_table_schema, 
ref.relname AS ref_table_name, pkc.conname AS ref_constraint_name, CASE c.confmatchtype WHEN 'f' THEN 'FULL' 
WHEN 'p' THEN 'PARTIAL' WHEN 'u' THEN 'NONE' ELSE NULL END AS match_option, CASE c.confupdtype WHEN 'c' THEN 
'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 'RESTRICT' WHEN 'a' THEN 'NO 
ACTION' ELSE NULL END AS update_rule, CASE c.confdeltype WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' 
WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 'RESTRICT' WHEN 'a' THEN 'NO ACTION' ELSE NULL END AS delete_rule 
FROM pg_constraint c INNER JOIN pg_class t ON (c.conrelid=t.oid) INNER JOIN pg_namespace nt ON 
(nt.oid=t.relnamespace) INNER JOIN pg_class ref ON (c.confrelid=ref.oid) INNER JOIN pg_namespace nref ON 
(nref.oid=ref.relnamespace) INNER JOIN pg_const
 raint pk
 c ON (c.confrelid = pkc.conrelid AND information_schema._pg_keysequal(c.confkey, pkc.conkey) AND 
pkc.contype='p') WHERE c.contype = 'f' AND current_database() = ##cat::string AND nt.nspname = 
##schema::string AND t.relname = ##name::string AND c.conname = ##name2::string",
 
        /* I_STMT_REF_CONSTRAINTS_ALL */
-       "SELECT current_database(), nt.nspname, t.relname, c.conname, current_database(), nref.nspname, 
ref.relname, pkc.conname, CASE c.confmatchtype WHEN 'f' THEN 'FULL' WHEN 'p' THEN 'PARTIAL' WHEN 'u' THEN 
'NONE' ELSE NULL END AS match_option, CASE c.confupdtype WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' 
WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 'RESTRICT' WHEN 'a' THEN 'NO ACTION' ELSE NULL END AS update_rule, 
CASE c.confdeltype WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 
'RESTRICT' WHEN 'a' THEN 'NO ACTION' ELSE NULL END AS delete_rule FROM pg_constraint c INNER JOIN pg_class t 
ON (c.conrelid=t.oid) INNER JOIN pg_namespace nt ON (nt.oid=t.relnamespace) INNER JOIN pg_class ref ON 
(c.confrelid=ref.oid) INNER JOIN pg_namespace nref ON (nref.oid=ref.relnamespace) INNER JOIN pg_constraint 
pkc ON (c.confrelid = pkc.conrelid AND information_schema._pg_keysequal(c.confkey, pkc.conkey) AND 
pkc.contype='p') WHERE c.contype = 'f'",
+       "SELECT current_database() AS table_catalog, nt.nspname AS table_schema, t.relname AS table_name, 
c.conname AS constraint_name, current_database() AS ref_table_catalog, nref.nspname AS ref_table_schema, 
ref.relname AS ref_table_name, pkc.conname AS ref_constraint_name, CASE c.confmatchtype WHEN 'f' THEN 'FULL' 
WHEN 'p' THEN 'PARTIAL' WHEN 'u' THEN 'NONE' ELSE NULL END AS match_option, CASE c.confupdtype WHEN 'c' THEN 
'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 'RESTRICT' WHEN 'a' THEN 'NO 
ACTION' ELSE NULL END AS update_rule, CASE c.confdeltype WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' 
WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 'RESTRICT' WHEN 'a' THEN 'NO ACTION' ELSE NULL END AS delete_rule 
FROM pg_constraint c INNER JOIN pg_class t ON (c.conrelid=t.oid) INNER JOIN pg_namespace nt ON 
(nt.oid=t.relnamespace) INNER JOIN pg_class ref ON (c.confrelid=ref.oid) INNER JOIN pg_namespace nref ON 
(nref.oid=ref.relnamespace) INNER JOIN pg_const
 raint pk
 c ON (c.confrelid = pkc.conrelid AND information_schema._pg_keysequal(c.confkey, pkc.conkey) AND 
pkc.contype='p') WHERE c.contype = 'f'",
 
        /* I_STMT_KEY_COLUMN_USAGE */
        "SELECT table_catalog, table_schema, table_name, constraint_name, column_name, ordinal_position FROM 
information_schema.key_column_usage WHERE table_catalog = ##cat::string AND table_schema = ##schema::string 
AND table_name = ##name::string AND constraint_name = ##name2::string",
@@ -244,10 +244,10 @@ static gchar *internal_sql[] = {
        "SELECT current_database(), ss.n_nspname, ((ss.proname || '_') || ss.p_oid), (ss.x).n, CASE WHEN 
ss.proargmodes IS NULL THEN 'IN' WHEN ss.proargmodes[(ss.x).n] = 'i' THEN 'IN' WHEN ss.proargmodes[(ss.x).n] 
= 'o' THEN 'OUT' WHEN ss.proargmodes[(ss.x).n] = 'b' THEN 'INOUT' ELSE NULL END, 
NULLIF(ss.proargnames[(ss.x).n], ''), CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'array_spec' ELSE 
coalesce (nt.nspname || '.', '') || t.typname END, CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'ROUP' || 
current_database() || '.' || ss.n_nspname || '.' || ((ss.proname || '_') || ss.p_oid) || '.' || (ss.x).n ELSE 
NULL END FROM pg_type t, pg_namespace nt, ( SELECT n.nspname AS n_nspname, p.proname, p.oid AS p_oid, 
p.proargnames, p.proargmodes, information_schema._pg_expandarray(COALESCE(p.proallargtypes, 
p.proargtypes::oid[])) AS x FROM pg_namespace n, pg_proc p WHERE n.oid = p.pronamespace AND 
(pg_has_role(p.proowner, 'USAGE') OR has_function_privilege(p.oid, 'EXECUTE'))) ss WHERE ((s
 s.proarg
 modes[(ss.x).n] != 't' AND ss.proargmodes[(ss.x).n] != 'v') OR ss.proargmodes[(ss.x).n] IS NULL) AND t.oid = 
(ss.x).x AND t.typnamespace = nt.oid AND current_database() = ##cat::string AND ss.n_nspname = 
##schema::string AND ((ss.proname || '_') || ss.p_oid) = ##name::string",
 
        /* I_STMT_ROUTINE_COL_ALL */
-       "SELECT current_database(), ss.n_nspname, ((ss.proname || '_') || ss.p_oid), 
NULLIF(ss.proargnames[(ss.x).n], ''), (ss.x).n, CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'array_spec' 
ELSE coalesce (nt.nspname || '.', '') || t.typname END, CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 
'ROUC' || current_database() || '.' || ss.n_nspname || '.' || ((ss.proname || '_') || ss.p_oid) || '.' || 
(ss.x).n ELSE NULL END FROM pg_type t, pg_namespace nt, ( SELECT n.nspname AS n_nspname, p.proname, p.oid AS 
p_oid, p.proargnames, p.proargmodes, information_schema._pg_expandarray(COALESCE(p.proallargtypes, 
p.proargtypes::oid[])) AS x FROM pg_namespace n, pg_proc p WHERE n.oid = p.pronamespace AND 
(pg_has_role(p.proowner, 'USAGE') OR has_function_privilege(p.oid, 'EXECUTE'))) ss WHERE t.oid = (ss.x).x AND 
t.typnamespace = nt.oid AND (ss.proargmodes[(ss.x).n] = 'o' OR ss.proargmodes[(ss.x).n] = 'b') ORDER BY 1, 2, 
3, 4, 5",
+       "SELECT current_database() AS specific_catalog, ss.n_nspname AS specific_schema, ((ss.proname || '_') 
|| ss.p_oid) AS specific_name, NULLIF(ss.proargnames[(ss.x).n], '') AS column_name, (ss.x).n AS 
ordinal_position, CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'array_spec' ELSE coalesce (nt.nspname || 
'.', '') || t.typname END AS data_type, CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'ROUC' || 
current_database() || '.' || ss.n_nspname || '.' || ((ss.proname || '_') || ss.p_oid) || '.' || (ss.x).n ELSE 
NULL END AS array_spec FROM pg_type t, pg_namespace nt, ( SELECT n.nspname AS n_nspname, p.proname, p.oid AS 
p_oid, p.proargnames, p.proargmodes, information_schema._pg_expandarray(COALESCE(p.proallargtypes, 
p.proargtypes::oid[])) AS x FROM pg_namespace n, pg_proc p WHERE n.oid = p.pronamespace AND 
(pg_has_role(p.proowner, 'USAGE') OR has_function_privilege(p.oid, 'EXECUTE'))) ss WHERE t.oid = (ss.x).x AND 
t.typnamespace = nt.oid AND (ss.proargmodes[(ss.x).n] = 'o' OR s
 s.proarg
 modes[(ss.x).n] = 'b') ORDER BY 1, 2, 3, 4, 5",
 
        /* I_STMT_ROUTINE_COL */
-       "SELECT current_database(), ss.n_nspname, ((ss.proname || '_') || ss.p_oid), 
NULLIF(ss.proargnames[(ss.x).n], '') AS column_name, (ss.x).n AS ordinal_position, CASE WHEN t.typelem <> 0 
AND t.typlen = -1 THEN 'array_spec' ELSE coalesce (nt.nspname || '.', '') || t.typname END, CASE WHEN 
t.typelem <> 0 AND t.typlen = -1 THEN 'ROUC' || current_database() || '.' || ss.n_nspname || '.' || 
((ss.proname || '_') || ss.p_oid) || '.' || (ss.x).n ELSE NULL END FROM pg_type t, pg_namespace nt, ( SELECT 
n.nspname AS n_nspname, p.proname, p.oid AS p_oid, p.proargnames, p.proargmodes, 
information_schema._pg_expandarray(COALESCE(p.proallargtypes, p.proargtypes::oid[])) AS x FROM pg_namespace 
n, pg_proc p WHERE n.oid = p.pronamespace AND (pg_has_role(p.proowner, 'USAGE') OR 
has_function_privilege(p.oid, 'EXECUTE'))) ss WHERE t.oid = (ss.x).x AND t.typnamespace = nt.oid AND 
(ss.proargmodes[(ss.x).n] = 'o' OR ss.proargmodes[(ss.x).n] = 'b') AND current_database() = ##cat::string AND 
ss.n_nspn
 ame = ##
 schema::string AND ((ss.proname || '_') || ss.p_oid) = ##name::string AND column_name = ##name2::string AND 
ordinal_position = ##name3::string ORDER BY 1, 2, 3, 4, 5",
+       "SELECT current_database() AS specific_catalog, ss.n_nspname AS specific_schema, ((ss.proname || '_') 
|| ss.p_oid) AS specific_name, NULLIF(ss.proargnames[(ss.x).n], '') AS column_name, (ss.x).n AS 
ordinal_position, CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'array_spec' ELSE coalesce (nt.nspname || 
'.', '') || t.typname END AS data_type, CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'ROUC' || 
current_database() || '.' || ss.n_nspname || '.' || ((ss.proname || '_') || ss.p_oid) || '.' || (ss.x).n ELSE 
NULL END FROM pg_type t, pg_namespace nt, ( SELECT n.nspname AS n_nspname, p.proname, p.oid AS p_oid, 
p.proargnames, p.proargmodes, information_schema._pg_expandarray(COALESCE(p.proallargtypes, 
p.proargtypes::oid[])) AS x FROM pg_namespace n, pg_proc p WHERE n.oid = p.pronamespace AND 
(pg_has_role(p.proowner, 'USAGE') OR has_function_privilege(p.oid, 'EXECUTE'))) ss WHERE t.oid = (ss.x).x AND 
t.typnamespace = nt.oid AND (ss.proargmodes[(ss.x).n] = 'o' OR ss.proargmodes[
 (ss.x).n
 ] = 'b') AND current_database() = ##cat::string AND ss.n_nspname = ##schema::string AND ((ss.proname || '_') 
|| ss.p_oid) = ##name::string AND column_name = ##name2::string AND ordinal_position = ##pos::string ORDER BY 
1, 2, 3, 4, 5",
 
        /* I_STMT_INDEXES */
        "SELECT current_database() AS index_catalog, nc2.nspname AS index_schema, c2.relname AS index_name, 
current_database() AS table_catalog, nc.nspname AS table_schema, c.relname AS table_name, i.indisunique, 
pg_get_indexdef (i.indexrelid, 0, false), NULL, NULL, o.rolname, pg_catalog.obj_description (c2.oid), 
i.indexrelid FROM pg_catalog.pg_class c INNER JOIN pg_namespace nc ON (c.relnamespace = nc.oid), 
pg_catalog.pg_class c2 INNER JOIN pg_namespace nc2 ON (c2.relnamespace = nc2.oid) LEFT JOIN pg_roles o ON 
(o.oid=c2.relowner), pg_catalog.pg_index i WHERE c.oid = i.indrelid AND i.indexrelid = c2.oid AND NOT 
i.indisprimary AND pg_catalog.pg_table_is_visible(c.oid) AND nc.nspname = ##schema::string AND c.relname = 
##name::string ORDER BY c.relname",
@@ -286,13 +286,13 @@ static gchar *internal_sql_11[] = {
        "SELECT current_database() AS catalog_name, n.nspname AS schema_name, u.rolname AS schema_owner, CASE 
WHEN n.nspname ~ '^pg_' THEN TRUE WHEN n.nspname = 'information_schema' THEN TRUE ELSE FALSE END, CASE WHEN 
n.nspname = 'public' THEN TRUE ELSE FALSE END AS schema_default FROM pg_namespace n, pg_roles u WHERE 
n.nspowner = u.oid AND current_database() = ##cat::string AND n.nspname = ##name::string",
 
        /* I_STMT_TABLES */
-       "SELECT current_database() AS table_catalog, nc.nspname AS table_schema, c.relname AS table_name, 
CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY' WHEN c.relkind = 'r' THEN 'BASE TABLE' WHEN 
c.relkind = 'v' THEN 'VIEW' ELSE NULL END AS table_type, CASE WHEN c.relkind = 'r' THEN TRUE ELSE FALSE END, 
pg_catalog.obj_description(c.oid), CASE WHEN pg_catalog.pg_table_is_visible(c.oid) IS TRUE AND 
nc.nspname!='pg_catalog' THEN c.relname ELSE coalesce (nc.nspname || '.', '') || c.relname END, coalesce 
(nc.nspname || '.', '') || c.relname, o.rolname FROM pg_namespace nc, pg_class c, pg_roles o WHERE 
current_database() = ##cat::string AND nc.nspname = ##schema::string AND c.relnamespace = nc.oid AND 
(c.relkind = ANY (ARRAY['r', 'v'])) AND NOT pg_is_other_temp_schema(nc.oid) AND (pg_has_role(c.relowner, 
'USAGE') OR has_table_privilege(c.oid, 'SELECT') OR has_table_privilege(c.oid, 'INSERT') OR 
has_table_privilege(c.oid, 'UPDATE') OR has_table_privilege(c.oid, 'DELETE') O
 R has_ta
 ble_privilege(c.oid, 'REFERENCES') OR has_table_privilege(c.oid, 'TRIGGER')) AND o.oid=c.relowner",
+       "SELECT current_database() AS table_catalog, nc.nspname AS table_schema, c.relname AS table_name, 
CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY' WHEN c.relkind = 'r' THEN 'BASE TABLE' WHEN 
c.relkind = 'v' THEN 'VIEW' ELSE NULL END AS table_type, CASE WHEN c.relkind = 'r' THEN TRUE ELSE FALSE END, 
pg_catalog.obj_description(c.oid), CASE WHEN pg_catalog.pg_table_is_visible(c.oid) IS TRUE AND 
nc.nspname!='pg_catalog' THEN c.relname ELSE coalesce (nc.nspname || '.', '') || c.relname END, coalesce 
(nc.nspname || '.', '') || c.relname, o.rolname FROM pg_namespace nc, pg_class c, pg_roles o WHERE CASE WHEN 
##cat::string IS NULL THEN TRUE ELSE current_database() = ##cat::string END AND CASE WHEN ##schema::string IS 
NULL THEN TRUE ELSE nc.nspname = ##schema::string END AND c.relnamespace = nc.oid AND (c.relkind = ANY 
(ARRAY['r', 'v'])) AND NOT pg_is_other_temp_schema(nc.oid) AND (pg_has_role(c.relowner, 'USAGE') OR 
has_table_privilege(c.oid, 'SELECT') OR has_table_pri
 vilege(c
 .oid, 'INSERT') OR has_table_privilege(c.oid, 'UPDATE') OR has_table_privilege(c.oid, 'DELETE') OR 
has_table_privilege(c.oid, 'REFERENCES') OR has_table_privilege(c.oid, 'TRIGGER')) AND o.oid=c.relowner",
 
        /* I_STMT_TABLES_ALL */
        "SELECT current_database() AS table_catalog, nc.nspname AS table_schema, c.relname AS table_name, 
CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY' WHEN c.relkind = 'r' THEN 'BASE TABLE' WHEN 
c.relkind = 'v' THEN 'VIEW' ELSE NULL END AS table_type, CASE WHEN c.relkind = 'r' THEN TRUE ELSE FALSE END, 
pg_catalog.obj_description(c.oid), CASE WHEN pg_catalog.pg_table_is_visible(c.oid) IS TRUE AND 
nc.nspname!='pg_catalog' THEN c.relname ELSE coalesce (nc.nspname || '.', '') || c.relname END, coalesce 
(nc.nspname || '.', '') || c.relname, o.rolname FROM pg_namespace nc, pg_class c, pg_roles o WHERE 
c.relnamespace = nc.oid AND (c.relkind = ANY (ARRAY['r', 'v'])) AND NOT pg_is_other_temp_schema(nc.oid) AND 
(pg_has_role(c.relowner, 'USAGE') OR has_table_privilege(c.oid, 'SELECT') OR has_table_privilege(c.oid, 
'INSERT') OR has_table_privilege(c.oid, 'UPDATE') OR has_table_privilege(c.oid, 'DELETE') OR 
has_table_privilege(c.oid, 'REFERENCES') OR has_table_privilege(c.oid, 
 'TRIGGER
 ')) AND o.oid=c.relowner",
 
        /* I_STMT_TABLE_NAMED */
-       "SELECT current_database() AS table_catalog, nc.nspname AS table_schema, c.relname AS table_name, 
CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY' WHEN c.relkind = 'r' THEN 'BASE TABLE' WHEN 
c.relkind = 'v' THEN 'VIEW' ELSE NULL END AS table_type, CASE WHEN c.relkind = 'r' THEN TRUE ELSE FALSE END, 
pg_catalog.obj_description(c.oid), CASE WHEN pg_catalog.pg_table_is_visible(c.oid) IS TRUE AND 
nc.nspname!='pg_catalog' THEN c.relname ELSE coalesce (nc.nspname || '.', '') || c.relname END, coalesce 
(nc.nspname || '.', '') || c.relname, o.rolname FROM pg_namespace nc, pg_class c, pg_roles o WHERE 
current_database() = ##cat::string AND nc.nspname = ##schema::string AND c.relnamespace = nc.oid AND 
(c.relkind = ANY (ARRAY['r', 'v'])) AND NOT pg_is_other_temp_schema(nc.oid) AND (pg_has_role(c.relowner, 
'USAGE') OR has_table_privilege(c.oid, 'SELECT') OR has_table_privilege(c.oid, 'INSERT') OR 
has_table_privilege(c.oid, 'UPDATE') OR has_table_privilege(c.oid, 'DELETE') O
 R has_ta
 ble_privilege(c.oid, 'REFERENCES') OR has_table_privilege(c.oid, 'TRIGGER')) AND o.oid=c.relowner AND 
c.relname = ##name::string",
+       "SELECT current_database() AS table_catalog, nc.nspname AS table_schema, c.relname AS table_name, 
CASE WHEN nc.oid = pg_my_temp_schema() THEN 'LOCAL TEMPORARY' WHEN c.relkind = 'r' THEN 'BASE TABLE' WHEN 
c.relkind = 'v' THEN 'VIEW' ELSE NULL END AS table_type, CASE WHEN c.relkind = 'r' THEN TRUE ELSE FALSE END, 
pg_catalog.obj_description(c.oid), CASE WHEN pg_catalog.pg_table_is_visible(c.oid) IS TRUE AND 
nc.nspname!='pg_catalog' THEN c.relname ELSE coalesce (nc.nspname || '.', '') || c.relname END, coalesce 
(nc.nspname || '.', '') || c.relname, o.rolname FROM pg_namespace nc, pg_class c, pg_roles o WHERE CASE WHEN 
##cat::string IS NULL THEN TRUE ELSE current_database() = ##cat::string END AND CASE WHEN ##schema::string IS 
NULL THEN TRUE ELSE nc.nspname = ##schema::string END AND c.relnamespace = nc.oid AND (c.relkind = ANY 
(ARRAY['r', 'v'])) AND NOT pg_is_other_temp_schema(nc.oid) AND (pg_has_role(c.relowner, 'USAGE') OR 
has_table_privilege(c.oid, 'SELECT') OR has_table_pri
 vilege(c
 .oid, 'INSERT') OR has_table_privilege(c.oid, 'UPDATE') OR has_table_privilege(c.oid, 'DELETE') OR 
has_table_privilege(c.oid, 'REFERENCES') OR has_table_privilege(c.oid, 'TRIGGER')) AND o.oid=c.relowner AND 
c.relname = ##name::string",
 
        /* I_STMT_VIEWS */
        "SELECT current_database() AS table_catalog, nc.nspname AS table_schema, c.relname AS table_name, 
pg_catalog.pg_get_viewdef(c.oid, TRUE), NULL, CASE WHEN c.relkind = 'r' THEN TRUE ELSE FALSE END FROM 
pg_namespace nc, pg_class c WHERE current_database() = ##cat::string AND nc.nspname = ##schema::string AND 
c.relnamespace = nc.oid AND c.relkind = 'v' AND NOT pg_is_other_temp_schema(nc.oid) AND 
(pg_has_role(c.relowner, 'USAGE') OR has_table_privilege(c.oid, 'SELECT') OR has_table_privilege(c.oid, 
'INSERT') OR has_table_privilege(c.oid, 'UPDATE') OR has_table_privilege(c.oid, 'DELETE') OR 
has_table_privilege(c.oid, 'REFERENCES') OR has_table_privilege(c.oid, 'TRIGGER'))",
@@ -321,10 +321,10 @@ static gchar *internal_sql_11[] = {
        "SELECT constraint_catalog, constraint_schema, constraint_name, table_catalog, table_schema, 
table_name, constraint_type, NULL, CASE WHEN is_deferrable = 'YES' THEN TRUE ELSE FALSE END, CASE WHEN 
initially_deferred = 'YES' THEN TRUE ELSE FALSE END FROM information_schema.table_constraints WHERE 
table_catalog = ##cat::string AND table_schema = ##schema::string AND table_name = ##name::string AND 
constraint_name = ##name2::string",
 
        /* I_STMT_REF_CONSTRAINTS */
-       "SELECT current_database(), nt.nspname, t.relname, c.conname, current_database(), nref.nspname, 
ref.relname, pkc.conname, CASE c.confmatchtype WHEN 'f' THEN 'FULL' WHEN 'p' THEN 'PARTIAL' WHEN 'u' THEN 
'NONE' ELSE NULL END AS match_option, CASE c.confupdtype WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' 
WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 'RESTRICT' WHEN 'a' THEN 'NO ACTION' ELSE NULL END AS update_rule, 
CASE c.confdeltype WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 
'RESTRICT' WHEN 'a' THEN 'NO ACTION' ELSE NULL END AS delete_rule FROM pg_constraint c INNER JOIN pg_class t 
ON (c.conrelid=t.oid) INNER JOIN pg_namespace nt ON (nt.oid=t.relnamespace) INNER JOIN pg_class ref ON 
(c.confrelid=ref.oid) INNER JOIN pg_namespace nref ON (nref.oid=ref.relnamespace) INNER JOIN pg_constraint 
pkc ON (c.confrelid = pkc.conrelid AND information_schema._pg_keysequal(c.confkey, pkc.conkey) AND 
pkc.contype='p') WHERE c.contype = 'f' AND 
 current_
 database() = ##cat::string AND nt.nspname = ##schema::string AND t.relname = ##name::string AND c.conname = 
##name2::string",
+       "SELECT current_database() AS table_catalog, nt.nspname AS table_schema, t.relname AS table_name, 
c.conname AS constraint_name, current_database() AS ref_table_catalog, nref.nspname AS ref_table_schema, 
ref.relname AS ref_table_name, pkc.conname AS ref_constraint_name, CASE c.confmatchtype WHEN 'f' THEN 'FULL' 
WHEN 'p' THEN 'PARTIAL' WHEN 'u' THEN 'NONE' ELSE NULL END AS match_option, CASE c.confupdtype WHEN 'c' THEN 
'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 'RESTRICT' WHEN 'a' THEN 'NO 
ACTION' ELSE NULL END AS update_rule, CASE c.confdeltype WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' 
WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 'RESTRICT' WHEN 'a' THEN 'NO ACTION' ELSE NULL END AS delete_rule 
FROM pg_constraint c INNER JOIN pg_class t ON (c.conrelid=t.oid) INNER JOIN pg_namespace nt ON 
(nt.oid=t.relnamespace) INNER JOIN pg_class ref ON (c.confrelid=ref.oid) INNER JOIN pg_namespace nref ON 
(nref.oid=ref.relnamespace) INNER JOIN pg_const
 raint pk
 c ON (c.confrelid = pkc.conrelid AND information_schema._pg_keysequal(c.confkey, pkc.conkey) AND 
pkc.contype='p') WHERE c.contype = 'f' AND current_database() = ##cat::string AND nt.nspname = 
##schema::string AND t.relname = ##name::string AND c.conname = ##name2::string",
 
        /* I_STMT_REF_CONSTRAINTS_ALL */
-       "SELECT current_database(), nt.nspname, t.relname, c.conname, current_database(), nref.nspname, 
ref.relname, pkc.conname, CASE c.confmatchtype WHEN 'f' THEN 'FULL' WHEN 'p' THEN 'PARTIAL' WHEN 'u' THEN 
'NONE' ELSE NULL END AS match_option, CASE c.confupdtype WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' 
WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 'RESTRICT' WHEN 'a' THEN 'NO ACTION' ELSE NULL END AS update_rule, 
CASE c.confdeltype WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 
'RESTRICT' WHEN 'a' THEN 'NO ACTION' ELSE NULL END AS delete_rule FROM pg_constraint c INNER JOIN pg_class t 
ON (c.conrelid=t.oid) INNER JOIN pg_namespace nt ON (nt.oid=t.relnamespace) INNER JOIN pg_class ref ON 
(c.confrelid=ref.oid) INNER JOIN pg_namespace nref ON (nref.oid=ref.relnamespace) INNER JOIN pg_constraint 
pkc ON (c.confrelid = pkc.conrelid AND information_schema._pg_keysequal(c.confkey, pkc.conkey) AND 
pkc.contype='p') WHERE c.contype = 'f'",
+       "SELECT current_database() AS table_catalog, nt.nspname AS table_schema, t.relname AS table_name, 
c.conname AS constraint_name, current_database() AS ref_table_catalog, nref.nspname AS ref_table_schema, 
ref.relname AS ref_table_name, pkc.conname AS ref_constraint_name, CASE c.confmatchtype WHEN 'f' THEN 'FULL' 
WHEN 'p' THEN 'PARTIAL' WHEN 'u' THEN 'NONE' ELSE NULL END AS match_option, CASE c.confupdtype WHEN 'c' THEN 
'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 'RESTRICT' WHEN 'a' THEN 'NO 
ACTION' ELSE NULL END AS update_rule, CASE c.confdeltype WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' 
WHEN 'd' THEN 'SET DEFAULT' WHEN 'r' THEN 'RESTRICT' WHEN 'a' THEN 'NO ACTION' ELSE NULL END AS delete_rule 
FROM pg_constraint c INNER JOIN pg_class t ON (c.conrelid=t.oid) INNER JOIN pg_namespace nt ON 
(nt.oid=t.relnamespace) INNER JOIN pg_class ref ON (c.confrelid=ref.oid) INNER JOIN pg_namespace nref ON 
(nref.oid=ref.relnamespace) INNER JOIN pg_const
 raint pk
 c ON (c.confrelid = pkc.conrelid AND information_schema._pg_keysequal(c.confkey, pkc.conkey) AND 
pkc.contype='p') WHERE c.contype = 'f'",
 
        /* I_STMT_KEY_COLUMN_USAGE */
        "SELECT table_catalog, table_schema, table_name, constraint_name, column_name, ordinal_position FROM 
information_schema.key_column_usage WHERE table_catalog = ##cat::string AND table_schema = ##schema::string 
AND table_name = ##name::string AND constraint_name = ##name2::string",
@@ -414,10 +414,10 @@ static gchar *internal_sql_11[] = {
        "SELECT current_database(), ss.n_nspname, ((ss.proname || '_') || ss.p_oid), (ss.x).n, CASE WHEN 
ss.proargmodes IS NULL THEN 'IN' WHEN ss.proargmodes[(ss.x).n] = 'i' THEN 'IN' WHEN ss.proargmodes[(ss.x).n] 
= 'o' THEN 'OUT' WHEN ss.proargmodes[(ss.x).n] = 'b' THEN 'INOUT' ELSE NULL END, 
NULLIF(ss.proargnames[(ss.x).n], ''), CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'array_spec' ELSE 
coalesce (nt.nspname || '.', '') || t.typname END, CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'ROUP' || 
current_database() || '.' || ss.n_nspname || '.' || ((ss.proname || '_') || ss.p_oid) || '.' || (ss.x).n ELSE 
NULL END FROM pg_type t, pg_namespace nt, ( SELECT n.nspname AS n_nspname, p.proname, p.oid AS p_oid, 
p.proargnames, p.proargmodes, information_schema._pg_expandarray(COALESCE(p.proallargtypes, 
p.proargtypes::oid[])) AS x FROM pg_namespace n, pg_proc p WHERE n.oid = p.pronamespace AND 
(pg_has_role(p.proowner, 'USAGE') OR has_function_privilege(p.oid, 'EXECUTE'))) ss WHERE ((s
 s.proarg
 modes[(ss.x).n] != 't' AND ss.proargmodes[(ss.x).n] != 'v') OR ss.proargmodes[(ss.x).n] IS NULL) AND t.oid = 
(ss.x).x AND t.typnamespace = nt.oid AND current_database() = ##cat::string AND ss.n_nspname = 
##schema::string AND ((ss.proname || '_') || ss.p_oid) = ##name::string",
 
        /* I_STMT_ROUTINE_COL_ALL */
-       "SELECT current_database(), ss.n_nspname, ((ss.proname || '_') || ss.p_oid), 
NULLIF(ss.proargnames[(ss.x).n], ''), (ss.x).n, CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'array_spec' 
ELSE coalesce (nt.nspname || '.', '') || t.typname END, CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 
'ROUC' || current_database() || '.' || ss.n_nspname || '.' || ((ss.proname || '_') || ss.p_oid) || '.' || 
(ss.x).n ELSE NULL END FROM pg_type t, pg_namespace nt, ( SELECT n.nspname AS n_nspname, p.proname, p.oid AS 
p_oid, p.proargnames, p.proargmodes, information_schema._pg_expandarray(COALESCE(p.proallargtypes, 
p.proargtypes::oid[])) AS x FROM pg_namespace n, pg_proc p WHERE n.oid = p.pronamespace AND 
(pg_has_role(p.proowner, 'USAGE') OR has_function_privilege(p.oid, 'EXECUTE'))) ss WHERE t.oid = (ss.x).x AND 
t.typnamespace = nt.oid AND (ss.proargmodes[(ss.x).n] = 'o' OR ss.proargmodes[(ss.x).n] = 'b') ORDER BY 1, 2, 
3, 4, 5",
+       "SELECT current_database() AS specific_catalog, ss.n_nspname AS specific_schema, ((ss.proname || '_') 
|| ss.p_oid) AS specific_name, NULLIF(ss.proargnames[(ss.x).n], '') AS column_name, (ss.x).n AS 
ordinal_position, CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'array_spec' ELSE coalesce (nt.nspname || 
'.', '') || t.typname END AS data_type, CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'ROUC' || 
current_database() || '.' || ss.n_nspname || '.' || ((ss.proname || '_') || ss.p_oid) || '.' || (ss.x).n ELSE 
NULL END AS array_spec FROM pg_type t, pg_namespace nt, ( SELECT n.nspname AS n_nspname, p.proname, p.oid AS 
p_oid, p.proargnames, p.proargmodes, information_schema._pg_expandarray(COALESCE(p.proallargtypes, 
p.proargtypes::oid[])) AS x FROM pg_namespace n, pg_proc p WHERE n.oid = p.pronamespace AND 
(pg_has_role(p.proowner, 'USAGE') OR has_function_privilege(p.oid, 'EXECUTE'))) ss WHERE t.oid = (ss.x).x AND 
t.typnamespace = nt.oid AND (ss.proargmodes[(ss.x).n] = 'o' OR s
 s.proarg
 modes[(ss.x).n] = 'b') ORDER BY 1, 2, 3, 4, 5",
 
        /* I_STMT_ROUTINE_COL */
-       "SELECT current_database(), ss.n_nspname, ((ss.proname || '_') || ss.p_oid), 
NULLIF(ss.proargnames[(ss.x).n], '') AS column_name, (ss.x).n AS ordinal_position, CASE WHEN t.typelem <> 0 
AND t.typlen = -1 THEN 'array_spec' ELSE coalesce (nt.nspname || '.', '') || t.typname END, CASE WHEN 
t.typelem <> 0 AND t.typlen = -1 THEN 'ROUC' || current_database() || '.' || ss.n_nspname || '.' || 
((ss.proname || '_') || ss.p_oid) || '.' || (ss.x).n ELSE NULL END FROM pg_type t, pg_namespace nt, ( SELECT 
n.nspname AS n_nspname, p.proname, p.oid AS p_oid, p.proargnames, p.proargmodes, 
information_schema._pg_expandarray(COALESCE(p.proallargtypes, p.proargtypes::oid[])) AS x FROM pg_namespace 
n, pg_proc p WHERE n.oid = p.pronamespace AND (pg_has_role(p.proowner, 'USAGE') OR 
has_function_privilege(p.oid, 'EXECUTE'))) ss WHERE t.oid = (ss.x).x AND t.typnamespace = nt.oid AND 
(ss.proargmodes[(ss.x).n] = 'o' OR ss.proargmodes[(ss.x).n] = 'b') AND current_database() = ##cat::string AND 
ss.n_nspn
 ame = ##
 schema::string AND ((ss.proname || '_') || ss.p_oid) = ##name::string AND column_name = ##name2::string AND 
ordinal_position = ##name3::string ORDER BY 1, 2, 3, 4, 5",
+       "SELECT current_database() AS specific_catalog, ss.n_nspname AS specific_schema, ((ss.proname || '_') 
|| ss.p_oid) AS specific_name, NULLIF(ss.proargnames[(ss.x).n], '') AS column_name, (ss.x).n AS 
ordinal_position, CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'array_spec' ELSE coalesce (nt.nspname || 
'.', '') || t.typname END AS data_type, CASE WHEN t.typelem <> 0 AND t.typlen = -1 THEN 'ROUC' || 
current_database() || '.' || ss.n_nspname || '.' || ((ss.proname || '_') || ss.p_oid) || '.' || (ss.x).n ELSE 
NULL END FROM pg_type t, pg_namespace nt, ( SELECT n.nspname AS n_nspname, p.proname, p.oid AS p_oid, 
p.proargnames, p.proargmodes, information_schema._pg_expandarray(COALESCE(p.proallargtypes, 
p.proargtypes::oid[])) AS x FROM pg_namespace n, pg_proc p WHERE n.oid = p.pronamespace AND 
(pg_has_role(p.proowner, 'USAGE') OR has_function_privilege(p.oid, 'EXECUTE'))) ss WHERE t.oid = (ss.x).x AND 
t.typnamespace = nt.oid AND (ss.proargmodes[(ss.x).n] = 'o' OR ss.proargmodes[
 (ss.x).n
 ] = 'b') AND current_database() = ##cat::string AND ss.n_nspname = ##schema::string AND ((ss.proname || '_') 
|| ss.p_oid) = ##name::string AND column_name = ##name2::string AND ordinal_position = ##pos::string ORDER BY 
1, 2, 3, 4, 5",
 
        /* I_STMT_INDEXES */
        "SELECT current_database() AS index_catalog, nc2.nspname AS index_schema, c2.relname AS index_name, 
current_database() AS table_catalog, nc.nspname AS table_schema, c.relname AS table_name, i.indisunique, 
pg_get_indexdef (i.indexrelid, 0, false), NULL, NULL, o.rolname, pg_catalog.obj_description (c2.oid), 
i.indexrelid FROM pg_catalog.pg_class c INNER JOIN pg_namespace nc ON (c.relnamespace = nc.oid), 
pg_catalog.pg_class c2 INNER JOIN pg_namespace nc2 ON (c2.relnamespace = nc2.oid) LEFT JOIN pg_roles o ON 
(o.oid=c2.relowner), pg_catalog.pg_index i WHERE c.oid = i.indrelid AND i.indexrelid = c2.oid AND NOT 
i.indisprimary AND pg_catalog.pg_table_is_visible(c.oid) AND nc.nspname = ##schema::string AND c.relname = 
##name::string ORDER BY c.relname",
@@ -475,7 +475,7 @@ _gda_postgres_provider_meta_init (GdaServerProvider *provider)
                                            "name", G_TYPE_STRING, "",
                                            "schema", G_TYPE_STRING, "",
                                            "name2", G_TYPE_STRING, "",
-                                           "name3", G_TYPE_STRING, "",
+                                           "pos", G_TYPE_INT, "",
                                            "oid", G_TYPE_UINT, 0);
        }
 
@@ -1639,6 +1639,9 @@ _gda_postgres_meta_constraints_ref (G_GNUC_UNUSED GdaServerProvider *prov, GdaCo
 
        /* modify meta store */
        if (retval) {
+    gchar *str = gda_meta_context_stringify (context);
+    g_message ("Updating using: %s", str);
+    g_free (str);
                gda_meta_store_set_reserved_keywords_func (store, 
_gda_postgres_reuseable_get_reserved_keywords_func
                                                   ((GdaProviderReuseable*) rdata));
                retval = gda_meta_store_modify (store, context->table_name, model, 


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