[libgda: 1/2] DDL module was replaced to DB module
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda: 1/2] DDL module was replaced to DB module
- Date: Sun, 30 Dec 2018 20:30:28 +0000 (UTC)
commit f839d184362229fea4a1fcb967406dba502ad10d
Author: Pavlo Solntsev <p sun fun gmail com>
Date: Fri Dec 21 14:36:02 2018 -0600
DDL module was replaced to DB module
GdaDdl* was renamed to GdaDb*
GdaDdlCreator was renamed to GdaDbCatalog
catalog-postgresql test was added to the autotools
doc/C/libgda/libgda-6.0-docs.xml | 18 +-
doc/C/libgda/libgda-6.0-sections.txt | 290 ++++++-------
libgda/Gda-6.0.metadata | 4 +-
libgda/Makefile.am | 30 +-
libgda/gda-connection.c | 16 +-
libgda/gda-connection.h | 4 +-
libgda/{gda-ddl-base.c => gda-db-base.c} | 134 +++---
libgda/gda-db-base.h | 64 +++
libgda/{gda-ddl-buildable.c => gda-db-buildable.c} | 52 +--
libgda/{gda-ddl-buildable.h => gda-db-buildable.h} | 22 +-
libgda/{gda-ddl-creator.c => gda-db-catalog.c} | 403 +++++++++---------
libgda/gda-db-catalog.h | 111 +++++
libgda/{gda-ddl-column.c => gda-db-column.c} | 466 ++++++++++-----------
libgda/gda-db-column.h | 111 +++++
libgda/{gda-ddl-fkey.c => gda-db-fkey.c} | 284 ++++++-------
libgda/gda-db-fkey.h | 99 +++++
libgda/{gda-ddl-table.c => gda-db-table.c} | 312 +++++++-------
libgda/{gda-ddl-table.h => gda-db-table.h} | 60 +--
libgda/{gda-ddl-view.c => gda-db-view.c} | 234 +++++------
libgda/gda-db-view.h | 90 ++++
libgda/gda-ddl-base.h | 64 ---
libgda/gda-ddl-column.h | 111 -----
libgda/gda-ddl-creator.h | 111 -----
libgda/gda-ddl-fkey.h | 99 -----
libgda/gda-ddl-view.h | 87 ----
libgda/gda-init.c | 20 +-
...ibgda-ddl-creator.dtd => libgda-db-catalog.dtd} | 0
libgda/libgda.h.in | 2 +-
libgda/meson.build | 30 +-
po/POTFILES.in | 10 +-
tests/ddl/Makefile.am | 42 +-
tests/ddl/{check-ddl-base.c => check-db-base.c} | 116 ++---
tests/ddl/check-db-catalog-postgresql.c | 334 +++++++++++++++
.../{check-ddl-creator.c => check-db-catalog.c} | 208 ++++-----
tests/ddl/check-db-column.c | 337 +++++++++++++++
...{check-ddl-db-create.c => check-db-db-create.c} | 40 +-
tests/ddl/{check-ddl-fkey.c => check-db-fkey.c} | 54 +--
tests/ddl/{check-ddl-view.c => check-db-view.c} | 94 ++---
tests/ddl/check-ddl-column.c | 337 ---------------
tests/ddl/check-ddl-creator-postgresql.c | 341 ---------------
tests/ddl/meson.build | 52 +--
41 files changed, 2648 insertions(+), 2645 deletions(-)
---
diff --git a/doc/C/libgda/libgda-6.0-docs.xml b/doc/C/libgda/libgda-6.0-docs.xml
index d53c2f437..aa0184641 100644
--- a/doc/C/libgda/libgda-6.0-docs.xml
+++ b/doc/C/libgda/libgda-6.0-docs.xml
@@ -88,15 +88,15 @@
<xi:include href="xml/gda-attributes-manager.xml"/>
</chapter>
- <chapter id="DDL">
- <title>DDL</title>
- <xi:include href="xml/gda-ddl-base.xml"/>
- <xi:include href="xml/gda-ddl-buildable.xml"/>
- <xi:include href="xml/gda-ddl-column.xml"/>
- <xi:include href="xml/gda-ddl-creator.xml"/>
- <xi:include href="xml/gda-ddl-fkey.xml"/>
- <xi:include href="xml/gda-ddl-table.xml"/>
- <xi:include href="xml/gda-ddl-view.xml"/>
+ <chapter id="DB Catalog">
+ <title>DB Catalog</title>
+ <xi:include href="xml/gda-db-base.xml"/>
+ <xi:include href="xml/gda-db-buildable.xml"/>
+ <xi:include href="xml/gda-db-column.xml"/>
+ <xi:include href="xml/gda-db-catalog.xml"/>
+ <xi:include href="xml/gda-db-fkey.xml"/>
+ <xi:include href="xml/gda-db-table.xml"/>
+ <xi:include href="xml/gda-db-view.xml"/>
</chapter>
<chapter id="Statement">
diff --git a/doc/C/libgda/libgda-6.0-sections.txt b/doc/C/libgda/libgda-6.0-sections.txt
index 5cb10cd41..ccc8d63bd 100644
--- a/doc/C/libgda/libgda-6.0-sections.txt
+++ b/doc/C/libgda/libgda-6.0-sections.txt
@@ -1,149 +1,149 @@
<SECTION>
-<FILE>gda-ddl-fkey</FILE>
-<TITLE>GdaDdlFkey</TITLE>
-GdaDdlFkey
-GDA_TYPE_DDL_FKEY
-GdaDdlFkeyReferenceAction
-gda_ddl_fkey_new
-gda_ddl_fkey_new_from_meta
-gda_ddl_fkey_free
-gda_ddl_fkey_get_field_name
-gda_ddl_fkey_get_ref_field
-gda_ddl_fkey_set_field
-gda_ddl_fkey_get_ref_table
-gda_ddl_fkey_set_ref_table
-gda_ddl_fkey_get_ondelete
-gda_ddl_fkey_get_ondelete_id
-gda_ddl_fkey_set_ondelete
-gda_ddl_fkey_get_onupdate
-gda_ddl_fkey_get_onupdate_id
-gda_ddl_fkey_set_onupdate
-gda_ddl_fkey_prepare_create
-</SECTION>
-
-<SECTION>
-<FILE>gda-ddl-column</FILE>
-<TITLE>GdaDdlColumn</TITLE>
-GdaDdlColumn
-GdaDdlColumnError
-GDA_TYPE_DDL_COLUMN
-gda_ddl_column_new
-gda_ddl_column_new_from_meta
-gda_ddl_column_free
-gda_ddl_column_get_autoinc
-gda_ddl_column_set_autoinc
-gda_ddl_column_get_check
-gda_ddl_column_set_check
-gda_ddl_column_get_comment
-gda_ddl_column_set_comment
-gda_ddl_column_get_gtype
-gda_ddl_column_get_ctype
-gda_ddl_column_set_type
-gda_ddl_column_get_default
-gda_ddl_column_set_default
-gda_ddl_column_get_name
-gda_ddl_column_set_name
-gda_ddl_column_get_nnul
-gda_ddl_column_set_nnul
-gda_ddl_column_get_pkey
-gda_ddl_column_set_pkey
-gda_ddl_column_get_scale
-gda_ddl_column_set_scale
-gda_ddl_column_get_size
-gda_ddl_column_set_size
-gda_ddl_column_get_unique
-gda_ddl_column_set_unique
-gda_ddl_column_prepare_add
-gda_ddl_column_prepare_create
-</SECTION>
-
-<SECTION>
-<FILE>gda-ddl-base</FILE>
-<TITLE>GdaDdlBase</TITLE>
-GdaDdlBase
-GDA_TYPE_DDL_BASE
-gda_ddl_base_compare
-gda_ddl_base_free
-gda_ddl_base_get_catalog
-gda_ddl_base_get_full_name
-gda_ddl_base_get_name
-gda_ddl_base_get_schema
-gda_ddl_base_new
-gda_ddl_base_set_catalog
-gda_ddl_base_set_name
-gda_ddl_base_set_names
-gda_ddl_base_set_schema
-</SECTION>
-
-<SECTION>
-<FILE>gda-ddl-buildable</FILE>
-<TITLE>GdaDdlBuildable</TITLE>
-GdaDdlBuildable
-GDA_TYPE_DDL_BUILDABLE
-gda_ddl_buildable_parse_node
-gda_ddl_buildable_write_node
-</SECTION>
-
-<SECTION>
-<FILE>gda-ddl-creator</FILE>
-<TITLE>GdaDdlCreator</TITLE>
-GdaDdlCreator
-GdaDdlCreatorError
-GDA_TYPE_DDL_CREATOR
-gda_ddl_creator_get_type
-gda_ddl_creator_new
-gda_ddl_creator_free
-gda_ddl_creator_get_tables
-gda_ddl_creator_get_views
-gda_ddl_creator_append_table
-gda_ddl_creator_append_view
-gda_ddl_creator_parse_cnc
-gda_ddl_creator_parse_file
-gda_ddl_creator_parse_file_from_path
-gda_ddl_creator_perform_operation
-gda_ddl_creator_write_to_file
-gda_ddl_creator_write_to_path
-</SECTION>
-
-<SECTION>
-<FILE>gda-ddl-table</FILE>
-<TITLE>GdaDdlTable</TITLE>
-GdaDdlTable
-GdaDdlTableError
-GDA_TYPE_DDL_TABLE
-gda_ddl_table_new
-gda_ddl_table_new_from_meta
-gda_ddl_table_free
-gda_ddl_table_is_valid
-gda_ddl_table_append_column
-gda_ddl_table_get_columns
-gda_ddl_table_append_fkey
-gda_ddl_table_get_fkeys
-gda_ddl_table_create
-gda_ddl_table_is_temp
-gda_ddl_table_set_temp
-gda_ddl_table_prepare_create
-gda_ddl_table_update
-</SECTION>
-
-<SECTION>
-<FILE>gda-ddl-view</FILE>
-<TITLE>GdaDdlView</TITLE>
-GdaDdlView
-GDA_TYPE_DDL_VIEW
-gda_ddl_view_new
-gda_ddl_view_new_from_meta
-gda_ddl_view_free
-gda_ddl_view_get_defstring
-gda_ddl_view_set_defstring
-gda_ddl_view_get_ifnoexist
-gda_ddl_view_set_ifnoexist
-gda_ddl_view_get_istemp
-gda_ddl_view_set_istemp
-gda_ddl_view_get_replace
-gda_ddl_view_set_replace
-gda_ddl_view_prepare_create
-gda_ddl_view_create
+<FILE>gda-db-fkey</FILE>
+<TITLE>GdaDbFkey</TITLE>
+GdaDbFkey
+GDA_TYPE_DB_FKEY
+GdaDbFkeyReferenceAction
+gda_db_fkey_new
+gda_db_fkey_new_from_meta
+gda_db_fkey_free
+gda_db_fkey_get_field_name
+gda_db_fkey_get_ref_field
+gda_db_fkey_set_field
+gda_db_fkey_get_ref_table
+gda_db_fkey_set_ref_table
+gda_db_fkey_get_ondelete
+gda_db_fkey_get_ondelete_id
+gda_db_fkey_set_ondelete
+gda_db_fkey_get_onupdate
+gda_db_fkey_get_onupdate_id
+gda_db_fkey_set_onupdate
+gda_db_fkey_prepare_create
+</SECTION>
+
+<SECTION>
+<FILE>gda-db-column</FILE>
+<TITLE>GdaDbColumn</TITLE>
+GdaDbColumn
+GdaDbColumnError
+GDA_TYPE_DB_COLUMN
+gda_db_column_new
+gda_db_column_new_from_meta
+gda_db_column_free
+gda_db_column_get_autoinc
+gda_db_column_set_autoinc
+gda_db_column_get_check
+gda_db_column_set_check
+gda_db_column_get_comment
+gda_db_column_set_comment
+gda_db_column_get_gtype
+gda_db_column_get_ctype
+gda_db_column_set_type
+gda_db_column_get_default
+gda_db_column_set_default
+gda_db_column_get_name
+gda_db_column_set_name
+gda_db_column_get_nnul
+gda_db_column_set_nnul
+gda_db_column_get_pkey
+gda_db_column_set_pkey
+gda_db_column_get_scale
+gda_db_column_set_scale
+gda_db_column_get_size
+gda_db_column_set_size
+gda_db_column_get_unique
+gda_db_column_set_unique
+gda_db_column_prepare_add
+gda_db_column_prepare_create
+</SECTION>
+
+<SECTION>
+<FILE>gda-db-base</FILE>
+<TITLE>GdaDbBase</TITLE>
+GdaDbBase
+GDA_TYPE_DB_BASE
+gda_db_base_compare
+gda_db_base_free
+gda_db_base_get_catalog
+gda_db_base_get_full_name
+gda_db_base_get_name
+gda_db_base_get_schema
+gda_db_base_new
+gda_db_base_set_catalog
+gda_db_base_set_name
+gda_db_base_set_names
+gda_db_base_set_schema
+</SECTION>
+
+<SECTION>
+<FILE>gda-db-buildable</FILE>
+<TITLE>GdaDbBuildable</TITLE>
+GdaDbBuildable
+GDA_TYPE_DB_BUILDABLE
+gda_db_buildable_parse_node
+gda_db_buildable_write_node
+</SECTION>
+
+<SECTION>
+<FILE>gda-db-catalog</FILE>
+<TITLE>GdaDbCatalog</TITLE>
+GdaDbCatalog
+GdaDbCatalogError
+GDA_TYPE_DB_CREATOR
+gda_db_catalog_get_type
+gda_db_catalog_new
+gda_db_catalog_free
+gda_db_catalog_get_tables
+gda_db_catalog_get_views
+gda_db_catalog_append_table
+gda_db_catalog_append_view
+gda_db_catalog_parse_cnc
+gda_db_catalog_parse_file
+gda_db_catalog_parse_file_from_path
+gda_db_catalog_perform_operation
+gda_db_catalog_write_to_file
+gda_db_catalog_write_to_path
+</SECTION>
+
+<SECTION>
+<FILE>gda-db-table</FILE>
+<TITLE>GdaDbTable</TITLE>
+GdaDbTable
+GdaDbTableError
+GDA_TYPE_DB_TABLE
+gda_db_table_new
+gda_db_table_new_from_meta
+gda_db_table_free
+gda_db_table_is_valid
+gda_db_table_append_column
+gda_db_table_get_columns
+gda_db_table_append_fkey
+gda_db_table_get_fkeys
+gda_db_table_create
+gda_db_table_is_temp
+gda_db_table_set_temp
+gda_db_table_prepare_create
+gda_db_table_update
+</SECTION>
+
+<SECTION>
+<FILE>gda-db-view</FILE>
+<TITLE>GdaDbView</TITLE>
+GdaDbView
+GDA_TYPE_DB_VIEW
+gda_db_view_new
+gda_db_view_new_from_meta
+gda_db_view_free
+gda_db_view_get_defstring
+gda_db_view_set_defstring
+gda_db_view_get_ifnoexist
+gda_db_view_set_ifnoexist
+gda_db_view_get_istemp
+gda_db_view_set_istemp
+gda_db_view_get_replace
+gda_db_view_set_replace
+gda_db_view_prepare_create
+gda_db_view_create
</SECTION>
<SECTION>
diff --git a/libgda/Gda-6.0.metadata b/libgda/Gda-6.0.metadata
index 20ef63cf2..595de429e 100644
--- a/libgda/Gda-6.0.metadata
+++ b/libgda/Gda-6.0.metadata
@@ -9,8 +9,8 @@ utility_holder_load_attributes.node type="Xml.Node*"
DataModelImport.new_xml_node.node type="Xml.Node*"
value_new_from_xml.node type="Xml.Node"
ServerOperation.load_data_from_xml.node type="Xml.Node*"
-DdlBuildable.parse_node.node type="Xml.Node*"
-DdlBuildable.write_node.node type="Xml.Node*"
+DbBuildable.parse_node.node type="Xml.Node*"
+DbBuildable.write_node.node type="Xml.Node*"
// Rename methods
Numeric.get_string nullable=true
diff --git a/libgda/Makefile.am b/libgda/Makefile.am
index 1d059b7d0..ed4f56841 100644
--- a/libgda/Makefile.am
+++ b/libgda/Makefile.am
@@ -111,13 +111,13 @@ gda_headers = \
gda-xa-transaction.h \
libgda-global-variables.h \
gda-data-pivot.h \
- gda-ddl-base.h \
- gda-ddl-fkey.h \
- gda-ddl-column.h \
- gda-ddl-table.h \
- gda-ddl-buildable.h \
- gda-ddl-view.h \
- gda-ddl-creator.h
+ gda-db-base.h \
+ gda-db-fkey.h \
+ gda-db-column.h \
+ gda-db-table.h \
+ gda-db-buildable.h \
+ gda-db-view.h \
+ gda-db-catalog.h
gda_built_sources= \
$(builddir)/libgda.h
@@ -173,13 +173,13 @@ gda_sources= \
gda-value.c \
gda-xa-transaction.c \
gda-data-pivot.c \
- gda-ddl-base.c \
- gda-ddl-fkey.c \
- gda-ddl-column.c \
- gda-ddl-table.c \
- gda-ddl-buildable.c \
- gda-ddl-view.c \
- gda-ddl-creator.c
+ gda-db-base.c \
+ gda-db-fkey.c \
+ gda-db-column.c \
+ gda-db-table.c \
+ gda-db-buildable.c \
+ gda-db-view.c \
+ gda-db-catalog.c
libgda_sources = \
csv.h \
@@ -307,7 +307,7 @@ xml_DATA = $(srcdir)/information_schema.xml
DTD_FILES = libgda-array.dtd \
libgda-paramlist.dtd \
libgda-server-operation.dtd \
- libgda-ddl-creator.dtd
+ libgda-db-catalog.dtd
dtddir=$(LIBGDA_DTDDIR)
dtd_DATA=$(DTD_FILES)
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index c7985ac9c..97aebeb4d 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -7127,25 +7127,25 @@ gda_connection_operation_get_sql_identifier_at_path (GdaConnection *cnc, GdaServ
}
/**
- * gda_connection_create_ddl_creator:
+ * gda_connection_create_db_catalog:
* @cnc: A #GdaConnection object to use
*
- * A convenient method to create a new #GdaDdlCreator instance and set the current @cnc as a
+ * A convenient method to create a new #GdaDbCreator instance and set the current @cnc as a
* property. If for some reason, this approach doesn't fit well, the same task can be achieved
* by the following code:
*
- * GdaDdlCreator *creator = gda_ddl_creator_new ();
- * g_object_set (creator, "connection", cnc, NULL);
+ * GdaDbCatalog *catalog = gda_db_catalog_new ();
+ * g_object_set (catalog, "connection", cnc, NULL);
*
- * Returns: (transfer full): A new instance of #GdaDdlCreator. The new object should be deallocated
+ * Returns: (transfer full): A new instance of #GdaDbCatalog. The new object should be deallocated
* using g_object_unref().
*
* Since: 6.0
*/
-GdaDdlCreator*
-gda_connection_create_ddl_creator (GdaConnection *cnc)
+GdaDbCatalog*
+gda_connection_create_db_catalog (GdaConnection *cnc)
{
g_return_val_if_fail (GDA_IS_CONNECTION (cnc),NULL);
- return g_object_new (GDA_TYPE_DDL_CREATOR,"connection",cnc,NULL);
+ return g_object_new (GDA_TYPE_DB_CATALOG,"connection",cnc,NULL);
}
diff --git a/libgda/gda-connection.h b/libgda/gda-connection.h
index 86e3b3b31..fe0d0a7e1 100644
--- a/libgda/gda-connection.h
+++ b/libgda/gda-connection.h
@@ -41,7 +41,7 @@
#include <libgda/gda-meta-store.h>
#include <libgda/gda-server-operation.h>
#include <libgda/gda-batch.h>
-#include <libgda/gda-ddl-creator.h>
+#include <libgda/gda-db-catalog.h>
G_BEGIN_DECLS
@@ -394,7 +394,7 @@ GdaDataModel *gda_connection_get_meta_store_data (GdaConnection *cnc, Gd
GError **error, gint nb_filters, ...);
GdaDataModel *gda_connection_get_meta_store_data_v(GdaConnection *cnc, GdaConnectionMetaType
meta_type,
GList* filters, GError **error);
-GdaDdlCreator *gda_connection_create_ddl_creator (GdaConnection *cnc);
+GdaDbCatalog *gda_connection_create_db_catalog (GdaConnection *cnc);
G_END_DECLS
#endif
diff --git a/libgda/gda-ddl-base.c b/libgda/gda-db-base.c
similarity index 64%
rename from libgda/gda-ddl-base.c
rename to libgda/gda-db-base.c
index b587a6f92..db55ef303 100644
--- a/libgda/gda-ddl-base.c
+++ b/libgda/gda-db-base.c
@@ -1,4 +1,4 @@
-/* gda-ddl-base.c
+/* gda-db-base.c
*
* Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
*
@@ -17,7 +17,7 @@
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-#include "gda-ddl-base.h"
+#include "gda-db-base.h"
#include <glib/gi18n.h>
typedef struct
@@ -26,60 +26,60 @@ typedef struct
gchar *m_schema;
gchar *m_name;
gchar *m_fullname;
-} GdaDdlBasePrivate;
+} GdaDbBasePrivate;
/**
- * SECTION:gda-ddl-base
+ * SECTION:gda-db-base
* @short_description: The basic class for all database objects
- * @see_also: #GdaDdlTable, #GdaDdlView
+ * @see_also: #GdaDbTable, #GdaDbView
* @stability: Stable
* @include: libgda/libgda.h
*
- * This is a basic class for database objects, e.g. #GdaDdlTable and #GdaDdlView. It is not common to
+ * This is a basic class for database objects, e.g. #GdaDbTable and #GdaDbView. It is not common to
* use it directly.
*/
-G_DEFINE_TYPE_WITH_PRIVATE (GdaDdlBase, gda_ddl_base, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (GdaDbBase, gda_db_base, G_TYPE_OBJECT)
/**
- * gda_ddl_base_new:
+ * gda_db_base_new:
*
- * Create a new #GdaDdlBase instance
+ * Create a new #GdaDbBase instance
*
- * Returns: a new #GdaDdlBase instance
+ * Returns: a new #GdaDbBase instance
*/
-GdaDdlBase*
-gda_ddl_base_new (void)
+GdaDbBase*
+gda_db_base_new (void)
{
- return g_object_new (GDA_TYPE_DDL_BASE, NULL);
+ return g_object_new (GDA_TYPE_DB_BASE, NULL);
}
static void
-gda_ddl_base_finalize (GObject *object)
+gda_db_base_finalize (GObject *object)
{
- GdaDdlBase *self = (GdaDdlBase *)object;
- GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
+ GdaDbBase *self = (GdaDbBase *)object;
+ GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
g_free (priv->m_catalog);
g_free (priv->m_schema);
g_free (priv->m_name);
g_free (priv->m_fullname);
- G_OBJECT_CLASS (gda_ddl_base_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gda_db_base_parent_class)->finalize (object);
}
static void
-gda_ddl_base_class_init (GdaDdlBaseClass *klass)
+gda_db_base_class_init (GdaDbBaseClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gda_ddl_base_finalize;
+ object_class->finalize = gda_db_base_finalize;
}
static void
-gda_ddl_base_init (GdaDdlBase *self)
+gda_db_base_init (GdaDbBase *self)
{
- GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
+ GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
priv->m_catalog = NULL;
priv->m_schema = NULL;
@@ -88,8 +88,8 @@ gda_ddl_base_init (GdaDdlBase *self)
}
/**
- * gda_ddl_base_set_names:
- * @self: a #GdaDdlBase object
+ * gda_db_base_set_names:
+ * @self: a #GdaDbBase object
* @catalog: (nullable): a catalog name associated with the table
* @schema: (nullable): a schema name associated with the table
* @name: a table name associated with the table
@@ -102,15 +102,15 @@ gda_ddl_base_init (GdaDdlBase *self)
* Since: 6.0
*/
void
-gda_ddl_base_set_names (GdaDdlBase *self,
- const gchar* catalog,
- const gchar* schema,
- const gchar* name)
+gda_db_base_set_names (GdaDbBase *self,
+ const gchar* catalog,
+ const gchar* schema,
+ const gchar* name)
{
g_return_if_fail (self);
g_return_if_fail (name);
- GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
+ GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
g_free (priv->m_name);
g_free (priv->m_schema);
@@ -144,8 +144,8 @@ gda_ddl_base_set_names (GdaDdlBase *self,
}
/**
- * gda_ddl_base_get_full_name:
- * @self: an instance of #GdaDdlBase
+ * gda_db_base_get_full_name:
+ * @self: an instance of #GdaDbBase
*
* This method returns a full name in the format catalog.schema.name.
* If schema is %NULL but catalog and name are not, then only name is
@@ -157,11 +157,11 @@ gda_ddl_base_set_names (GdaDdlBase *self,
* Since: 6.0
*/
const gchar*
-gda_ddl_base_get_full_name (GdaDdlBase *self)
+gda_db_base_get_full_name (GdaDbBase *self)
{
g_return_val_if_fail (self,NULL);
- GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
+ GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
GString *fullnamestr = NULL;
@@ -184,8 +184,8 @@ gda_ddl_base_get_full_name (GdaDdlBase *self)
}
/**
- * gda_ddl_base_get_catalog:
- * @self: a #GdaDdlBase object
+ * gda_db_base_get_catalog:
+ * @self: a #GdaDbBase object
*
* Returns current catalog name. The returned string should not be freed.
*
@@ -194,18 +194,18 @@ gda_ddl_base_get_full_name (GdaDdlBase *self)
* Since: 6.0
*/
const gchar*
-gda_ddl_base_get_catalog (GdaDdlBase *self)
+gda_db_base_get_catalog (GdaDbBase *self)
{
g_return_val_if_fail (self,NULL);
- GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
+ GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
return priv->m_catalog;
}
/**
- * gda_ddl_base_get_schema:
- * @self: GdaDdlBase object
+ * gda_db_base_get_schema:
+ * @self: GdaDbBase object
*
* Returns current schema name. The returned string should not be freed.
*
@@ -214,18 +214,18 @@ gda_ddl_base_get_catalog (GdaDdlBase *self)
* Since: 6.0
*/
const gchar*
-gda_ddl_base_get_schema (GdaDdlBase *self)
+gda_db_base_get_schema (GdaDbBase *self)
{
g_return_val_if_fail (self,NULL);
- GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
+ GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
return priv->m_schema;
}
/**
- * gda_ddl_base_get_name:
- * @self: GdaDdlBase object
+ * gda_db_base_get_name:
+ * @self: GdaDbBase object
*
* Returns current object name. The returned string should not be freed.
*
@@ -234,18 +234,18 @@ gda_ddl_base_get_schema (GdaDdlBase *self)
* Since: 6.0
*/
const gchar*
-gda_ddl_base_get_name (GdaDdlBase *self)
+gda_db_base_get_name (GdaDbBase *self)
{
g_return_val_if_fail (self,NULL);
- GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
+ GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
return priv->m_name;
}
/**
- * gda_ddl_base_set_catalog:
- * @self: a #GdaDdlBase instance
+ * gda_db_base_set_catalog:
+ * @self: a #GdaDbBase instance
* @catalog: Catalog name as a string
*
* Set catalog name
@@ -253,20 +253,20 @@ gda_ddl_base_get_name (GdaDdlBase *self)
* Since: 6.0
*/
void
-gda_ddl_base_set_catalog (GdaDdlBase *self,
- const gchar *catalog)
+gda_db_base_set_catalog (GdaDbBase *self,
+ const gchar *catalog)
{
g_return_if_fail (self);
- GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
+ GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
g_free (priv->m_catalog);
priv->m_catalog = g_strdup (catalog);
}
/**
- * gda_ddl_base_set_schema:
- * @self: a #GdaDdlBase instance
+ * gda_db_base_set_schema:
+ * @self: a #GdaDbBase instance
* @schema: Schema name as a string
*
* Set object schema.
@@ -274,20 +274,20 @@ gda_ddl_base_set_catalog (GdaDdlBase *self,
* Since: 6.0
*/
void
-gda_ddl_base_set_schema (GdaDdlBase *self,
- const gchar *schema)
+gda_db_base_set_schema (GdaDbBase *self,
+ const gchar *schema)
{
g_return_if_fail (self);
- GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
+ GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
g_free (priv->m_schema);
priv->m_schema = g_strdup (schema);
}
/**
- * gda_ddl_base_set_name:
- * @self: a #GdaDdlBase instance
+ * gda_db_base_set_name:
+ * @self: a #GdaDbBase instance
* @name: Object name as a string
*
* Set object name
@@ -295,21 +295,21 @@ gda_ddl_base_set_schema (GdaDdlBase *self,
* Since: 6.0
*/
void
-gda_ddl_base_set_name (GdaDdlBase *self,
- const gchar *name)
+gda_db_base_set_name (GdaDbBase *self,
+ const gchar *name)
{
g_return_if_fail (self);
- GdaDdlBasePrivate *priv = gda_ddl_base_get_instance_private (self);
+ GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
g_free (priv->m_name);
priv->m_name = g_strdup (name);
}
/**
- * gda_ddl_base_compare:
- * @a: first #GdaDdlBase object
- * @b: second #GdaDdlBase object
+ * gda_db_base_compare:
+ * @a: first #GdaDbBase object
+ * @b: second #GdaDbBase object
*
* Compares two objects similar to g_strcmp().
*
@@ -318,7 +318,8 @@ gda_ddl_base_set_name (GdaDdlBase *self,
* Since: 6.0
*/
gint
-gda_ddl_base_compare (GdaDdlBase *a, GdaDdlBase *b)
+gda_db_base_compare (GdaDbBase *a,
+ GdaDbBase *b)
{
if (!a && !b)
return 0;
@@ -327,18 +328,17 @@ gda_ddl_base_compare (GdaDdlBase *a, GdaDdlBase *b)
else if (a && !b)
return 1;
- gint res = g_strcmp0 (gda_ddl_base_get_name(a),gda_ddl_base_get_name(b));
+ gint res = g_strcmp0 (gda_db_base_get_name(a),gda_db_base_get_name(b));
if (!res)
{
- res = g_strcmp0 (gda_ddl_base_get_catalog(a),gda_ddl_base_get_catalog(b));
+ res = g_strcmp0 (gda_db_base_get_catalog(a),gda_db_base_get_catalog(b));
if (!res)
- return g_strcmp0(gda_ddl_base_get_schema(a),gda_ddl_base_get_schema(b));
+ return g_strcmp0(gda_db_base_get_schema(a),gda_db_base_get_schema(b));
else
return res;
}
else
return res;
-
}
diff --git a/libgda/gda-db-base.h b/libgda/gda-db-base.h
new file mode 100644
index 000000000..998d2fc86
--- /dev/null
+++ b/libgda/gda-db-base.h
@@ -0,0 +1,64 @@
+/* gda-db-base.h
+ *
+ * Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef GDA_DB_BASE_H
+#define GDA_DB_BASE_H
+
+#include <glib-object.h>
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define GDA_TYPE_DB_BASE (gda_db_base_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (GdaDbBase, gda_db_base, GDA, DB_BASE, GObject)
+
+struct _GdaDbBaseClass
+{
+ GObjectClass parent;
+};
+
+GdaDbBase* gda_db_base_new (void);
+
+void gda_db_base_set_names (GdaDbBase *self,
+ const gchar *catalog,
+ const gchar *schema,
+ const gchar *name);
+
+const gchar* gda_db_base_get_full_name (GdaDbBase *self);
+const gchar* gda_db_base_get_name (GdaDbBase *self);
+void gda_db_base_set_name (GdaDbBase *self,
+ const gchar *name);
+
+const gchar* gda_db_base_get_catalog (GdaDbBase *self);
+void gda_db_base_set_catalog (GdaDbBase *self,
+ const gchar *catalog);
+
+const gchar* gda_db_base_get_schema (GdaDbBase *self);
+void gda_db_base_set_schema (GdaDbBase *self,
+ const gchar *schema);
+
+gint gda_db_base_compare (GdaDbBase *a, GdaDbBase *b);
+
+#define GDA_BOOL_TO_STR(x) (x ? "TRUE" : "FALSE")
+G_END_DECLS
+
+#endif /* GDA_DB_BASE_H */
+
diff --git a/libgda/gda-ddl-buildable.c b/libgda/gda-db-buildable.c
similarity index 58%
rename from libgda/gda-ddl-buildable.c
rename to libgda/gda-db-buildable.c
index 3b5dc7321..f84132298 100644
--- a/libgda/gda-ddl-buildable.c
+++ b/libgda/gda-db-buildable.c
@@ -1,5 +1,5 @@
/*
- * gda-ddl-buildable.c
+ * gda-db-buildable.c
*
* Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
*
@@ -19,31 +19,31 @@
* Boston, MA 02110-1301, USA.
*/
-#include "gda-ddl-buildable.h"
+#include "gda-db-buildable.h"
-G_DEFINE_INTERFACE (GdaDdlBuildable, gda_ddl_buildable, G_TYPE_OBJECT)
+G_DEFINE_INTERFACE (GdaDbBuildable, gda_db_buildable, G_TYPE_OBJECT)
/**
- * SECTION:gda-ddl-buildable
- * @title: GdaDdlBuildable
+ * SECTION:gda-db-buildable
+ * @title: GdaDbBuildable
* @short: Represents interface for parsing and writing xml nodes
- * @see_also: #GdaDdlTable, #GdaDdlView
+ * @see_also: #GdaDbTable, #GdaDbView
* @stability: Stable
- * @include: libgda/gda-ddl-buildable.h
+ * @include: libgda/gda-db-buildable.h
*
- * #GdaDdlBuildable represents an interface for writing and reading xml nodes. #GdaDdlTable and
- * #GdaDdlView implement this interface.
+ * #GdaDbBuildable represents an interface for writing and reading xml nodes. #GdaDbTable and
+ * #GdaDbView implement this interface.
*/
static void
-gda_ddl_buildable_default_init (GdaDdlBuildableInterface *iface)
+gda_db_buildable_default_init (GdaDbBuildableInterface *iface)
{
/* add properties and signals to the interface here */
}
/**
- * gda_ddl_buildable_parse_node:
- * @self: an instance of #GdaDdlBuildable where parsed data should be storred
+ * gda_db_buildable_parse_node:
+ * @self: an instance of #GdaDbBuildable where parsed data should be storred
* @node: a node to parse
* @error: (nullable): an object to store error
*
@@ -54,23 +54,23 @@ gda_ddl_buildable_default_init (GdaDdlBuildableInterface *iface)
* Stability: stable
*/
gboolean
-gda_ddl_buildable_parse_node (GdaDdlBuildable *self,
- xmlNodePtr node,
- GError **error)
+gda_db_buildable_parse_node (GdaDbBuildable *self,
+ xmlNodePtr node,
+ GError **error)
{
- GdaDdlBuildableInterface *iface;
+ GdaDbBuildableInterface *iface;
- g_return_val_if_fail (GDA_IS_DDL_BUILDABLE (self),FALSE);
+ g_return_val_if_fail (GDA_IS_DB_BUILDABLE (self),FALSE);
g_return_val_if_fail (error == NULL || *error == NULL,FALSE);
- iface = GDA_DDL_BUILDABLE_GET_IFACE (self);
+ iface = GDA_DB_BUILDABLE_GET_IFACE (self);
g_return_val_if_fail (iface->parse_node != NULL,FALSE);
return iface->parse_node (self, node, error);
}
/**
- * gda_ddl_buildable_write_node:
- * @self: an instance of #GdaDdlBuildable where data should be taken
+ * gda_db_buildable_write_node:
+ * @self: an instance of #GdaDbBuildable where data should be taken
* @node: a node to write data in
* @error: (nullable): an object to store error
*
@@ -81,16 +81,16 @@ gda_ddl_buildable_parse_node (GdaDdlBuildable *self,
* Stability: stable
*/
gboolean
-gda_ddl_buildable_write_node (GdaDdlBuildable *self,
- xmlNodePtr node,
- GError **error)
+gda_db_buildable_write_node (GdaDbBuildable *self,
+ xmlNodePtr node,
+ GError **error)
{
- GdaDdlBuildableInterface *iface;
+ GdaDbBuildableInterface *iface;
- g_return_val_if_fail (GDA_IS_DDL_BUILDABLE (self),FALSE);
+ g_return_val_if_fail (GDA_IS_DB_BUILDABLE (self),FALSE);
g_return_val_if_fail (error == NULL || *error == NULL,FALSE);
- iface = GDA_DDL_BUILDABLE_GET_IFACE (self);
+ iface = GDA_DB_BUILDABLE_GET_IFACE (self);
g_return_val_if_fail (iface->write_node != NULL,FALSE);
return iface->write_node (self, node, error);
}
diff --git a/libgda/gda-ddl-buildable.h b/libgda/gda-db-buildable.h
similarity index 72%
rename from libgda/gda-ddl-buildable.h
rename to libgda/gda-db-buildable.h
index da48fc3bb..d2ee275c6 100644
--- a/libgda/gda-ddl-buildable.h
+++ b/libgda/gda-db-buildable.h
@@ -1,5 +1,5 @@
/*
- * gda-ddl-buildable.h
+ * gda-db-buildable.h
*
* Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
*
@@ -18,8 +18,8 @@
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-#ifndef GDA_DDL_BUILDABLE_H
-#define GDA_DDL_BUILDABLE_H
+#ifndef GDA_DB_BUILDABLE_H
+#define GDA_DB_BUILDABLE_H
#include <glib-object.h>
#include <glib.h>
@@ -28,32 +28,32 @@
G_BEGIN_DECLS
-#define GDA_TYPE_DDL_BUILDABLE gda_ddl_buildable_get_type ()
-G_DECLARE_INTERFACE(GdaDdlBuildable, gda_ddl_buildable,GDA, DDL_BUILDABLE,GObject)
+#define GDA_TYPE_DB_BUILDABLE gda_db_buildable_get_type ()
+G_DECLARE_INTERFACE(GdaDbBuildable, gda_db_buildable,GDA, DB_BUILDABLE,GObject)
-struct _GdaDdlBuildableInterface
+struct _GdaDbBuildableInterface
{
GTypeInterface parent_iface;
- gboolean (*parse_node)(GdaDdlBuildable *self,
+ gboolean (*parse_node)(GdaDbBuildable *self,
xmlNodePtr node,
GError **error);
- gboolean (*write_node)(GdaDdlBuildable *self,
+ gboolean (*write_node)(GdaDbBuildable *self,
xmlNodePtr node,
GError **error);
};
-gboolean gda_ddl_buildable_parse_node (GdaDdlBuildable *self,
+gboolean gda_db_buildable_parse_node (GdaDbBuildable *self,
xmlNodePtr node,
GError **error);
-gboolean gda_ddl_buildable_write_node (GdaDdlBuildable *self,
+gboolean gda_db_buildable_write_node (GdaDbBuildable *self,
xmlNodePtr node,
GError **error);
G_END_DECLS
-#endif /* end of include guard: GDA-DDL-BUILDABLE_H */
+#endif /* end of include guard: GDA-DB-BUILDABLE_H */
diff --git a/libgda/gda-ddl-creator.c b/libgda/gda-db-catalog.c
similarity index 64%
rename from libgda/gda-ddl-creator.c
rename to libgda/gda-db-catalog.c
index 1d0d8f345..c7543af6b 100644
--- a/libgda/gda-ddl-creator.c
+++ b/libgda/gda-db-catalog.c
@@ -1,4 +1,4 @@
-/* gda-ddl-creator.c
+/* gda-db-catalog.c
*
* Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
*
@@ -18,10 +18,10 @@
* Boston, MA 02110-1301, USA.
*/
-#include "gda-ddl-creator.h"
-#include "gda-ddl-table.h"
-#include "gda-ddl-view.h"
-#include "gda-ddl-fkey.h"
+#include "gda-db-catalog.h"
+#include "gda-db-table.h"
+#include "gda-db-view.h"
+#include "gda-db-fkey.h"
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <glib.h>
@@ -32,33 +32,33 @@
#include <libgda/gda-lockable.h>
#include "gda-meta-struct.h"
-G_DEFINE_QUARK (gda_ddl_creator_error, gda_ddl_creator_error)
+G_DEFINE_QUARK (gda_db_catalog_error, gda_db_catalog_error)
typedef struct
{
- GList *mp_tables; /* List of all tables that should be create, GdaDdlTable */
- GList *mp_views; /* List of all views that should be created, GdaDdlView */
+ GList *mp_tables; /* List of all tables that should be create, GdaDbTable */
+ GList *mp_views; /* List of all views that should be created, GdaDbView */
gchar *mp_schemaname;
GdaConnection *cnc;
-} GdaDdlCreatorPrivate;
+} GdaDbCatalogPrivate;
/**
- * SECTION:gda-ddl-creator
- * @title: GdaDdlCreator
+ * SECTION:gda-db-catalog
+ * @title: GdaDbCatalog
* @short_description: Object to constract database representation from an xml file or by reading the
existing datatabase
- * @see_also: #GdaDdlTable, #GdaDdlView
+ * @see_also: #GdaDbTable, #GdaDbView
* @stability: Stable
* @include: libgda/libgda.h
*
* This is a main object that represents overall database. In can be constracted from an xml
- * file using gda_ddl_creator_parse_file() or gda_ddl_creator_parse_file_from_path(). It can also
- * be constracted from an open connection using gda_ddl_creator_parse_cnc(). The database can be
- * updated using gda_ddl_creator_perform_operation() and dumped to a file using
- * gda_ddl_creator_write_to_path() and gda_ddl_creator_write_to_file().
+ * file using gda_db_catalog_parse_file() or gda_db_creator_parse_file_from_path(). It can also
+ * be constracted from an open connection using gda_db_catalog_parse_cnc(). The database can be
+ * updated using gda_db_catalog_perform_operation() and dumped to a file using
+ * gda_db_catalog_write_to_path() and gda_db_creator_write_to_file().
*
*/
-G_DEFINE_TYPE_WITH_PRIVATE (GdaDdlCreator, gda_ddl_creator, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (GdaDbCatalog, gda_db_catalog, G_TYPE_OBJECT)
enum {
PROP_0,
@@ -71,39 +71,39 @@ enum {
static GParamSpec *properties [N_PROPS] = {NULL};
/* Originally defined in gda-init.c */
-extern xmlDtdPtr _gda_ddl_creator_dtd;
+extern xmlDtdPtr _gda_db_catalog_dtd;
/**
- * gda_ddl_creator_new:
+ * gda_db_catalog_new:
*
- * Create new instance of #GdaDdlCreator.
+ * Create new instance of #GdaDbCatalog.
*
- * Returns: a new instance of #GdaDdlCreator
+ * Returns: a new instance of #GdaDbCatalog
*
* Since: 6.0
*/
-GdaDdlCreator*
-gda_ddl_creator_new (void)
+GdaDbCatalog*
+gda_db_catalog_new (void)
{
- return g_object_new (GDA_TYPE_DDL_CREATOR, NULL);
+ return g_object_new (GDA_TYPE_DB_CATALOG, NULL);
}
static void
-gda_ddl_creator_finalize (GObject *object)
+gda_db_catalog_finalize (GObject *object)
{
- GdaDdlCreator *self = GDA_DDL_CREATOR(object);
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalog *self = GDA_DB_CATALOG(object);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
g_free (priv->mp_schemaname);
- G_OBJECT_CLASS (gda_ddl_creator_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gda_db_catalog_parent_class)->finalize (object);
}
static void
-gda_ddl_creator_dispose (GObject *object)
+gda_db_catalog_dispose (GObject *object)
{
- GdaDdlCreator *self = GDA_DDL_CREATOR(object);
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalog *self = GDA_DB_CATALOG(object);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
if (priv->mp_tables)
g_list_free_full (priv->mp_tables, (GDestroyNotify) g_object_unref);
@@ -114,16 +114,17 @@ gda_ddl_creator_dispose (GObject *object)
if (priv->cnc)
g_object_unref (priv->cnc);
- G_OBJECT_CLASS (gda_ddl_creator_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gda_db_catalog_parent_class)->finalize (object);
}
+
static void
-gda_ddl_creator_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gda_db_catalog_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdaDdlCreator *self = GDA_DDL_CREATOR (object);
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalog *self = GDA_DB_CATALOG (object);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
switch (prop_id)
{
@@ -139,13 +140,13 @@ gda_ddl_creator_get_property (GObject *object,
}
static void
-gda_ddl_creator_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gda_db_catalog_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdaDdlCreator *self = GDA_DDL_CREATOR (object);
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalog *self = GDA_DB_CATALOG (object);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
switch (prop_id)
{
@@ -165,14 +166,14 @@ gda_ddl_creator_set_property (GObject *object,
}
static void
-gda_ddl_creator_class_init (GdaDdlCreatorClass *klass)
+gda_db_catalog_class_init (GdaDbCatalogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gda_ddl_creator_finalize;
- object_class->dispose = gda_ddl_creator_dispose;
- object_class->get_property = gda_ddl_creator_get_property;
- object_class->set_property = gda_ddl_creator_set_property;
+ object_class->finalize = gda_db_catalog_finalize;
+ object_class->dispose = gda_db_catalog_dispose;
+ object_class->get_property = gda_db_catalog_get_property;
+ object_class->set_property = gda_db_catalog_set_property;
properties[PROP_SCHEMA_NAME] =
g_param_spec_string ("schema_name",
@@ -192,9 +193,9 @@ gda_ddl_creator_class_init (GdaDdlCreatorClass *klass)
}
static void
-gda_ddl_creator_init (GdaDdlCreator *self)
+gda_db_catalog_init (GdaDbCatalog *self)
{
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
priv->mp_tables = NULL;
priv->mp_views = NULL;
@@ -203,8 +204,8 @@ gda_ddl_creator_init (GdaDdlCreator *self)
}
static gboolean
-_gda_ddl_creator_validate_doc (xmlDocPtr doc,
- GError **error)
+_gda_db_catalog_validate_doc (xmlDocPtr doc,
+ GError **error)
{
g_return_val_if_fail (doc,FALSE);
@@ -215,19 +216,19 @@ _gda_ddl_creator_validate_doc (xmlDocPtr doc,
if (!ctx)
{
g_set_error (error,
- GDA_DDL_CREATOR_ERROR,
- GDA_DDL_CREATOR_CONTEXT_NULL,
+ GDA_DB_CATALOG_ERROR,
+ GDA_DB_CATALOG_CONTEXT_NULL,
_("Context to validate xml file can't be created."));
goto on_error;
}
- int valid = xmlValidateDtd (ctx,doc,_gda_ddl_creator_dtd);
+ int valid = xmlValidateDtd (ctx,doc,_gda_db_catalog_dtd);
if (!valid)
{
g_set_error (error,
- GDA_DDL_CREATOR_ERROR,
- GDA_DDL_CREATOR_INVALID_XML,
+ GDA_DB_CATALOG_ERROR,
+ GDA_DB_CATALOG_INVALID_XML,
_("xml file is invalid"));
goto on_error;
}
@@ -241,20 +242,20 @@ on_error:
}
/**
- * _gda_ddl_creator_parse_doc:
- * @self: a #GdaDdlCreator instance
+ * _gda_db_catalog_parse_doc:
+ * @self: a #GdaDbCatalog instance
* @doc: a #xmlDocPtr instance to parse
* @error: error container
*
- * Internal method to populate #GdaDdlCreator from @doc instance.
+ * Internal method to populate #GdaDbCatalog from @doc instance.
*
* Returns: %TRUE if no errors, %FALSE otherwise.
*
*/
static gboolean
-_gda_ddl_creator_parse_doc (GdaDdlCreator *self,
- xmlDocPtr doc,
- GError **error)
+_gda_db_catalog_parse_doc (GdaDbCatalog *self,
+ xmlDocPtr doc,
+ GError **error)
{
g_return_val_if_fail (self,FALSE);
g_return_val_if_fail (doc,FALSE);
@@ -267,13 +268,13 @@ _gda_ddl_creator_parse_doc (GdaDdlCreator *self,
if (!node || g_strcmp0 ((gchar *)node->name, "schema") != 0)
{
g_set_error (error,
- GDA_DDL_CREATOR_ERROR,
- GDA_DDL_CREATOR_INVALID_SCHEMA,
+ GDA_DB_CATALOG_ERROR,
+ GDA_DB_CATALOG_INVALID_SCHEMA,
_("Root node should be <schema>."));
goto on_error;
}
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
schema_name = xmlGetProp(node,(xmlChar *)"name");
// g_assert (schema_name); /* If schema_name == NULL we have problem with validation */
@@ -288,11 +289,11 @@ _gda_ddl_creator_parse_doc (GdaDdlCreator *self,
/* <table> tag for table creation */
if (!g_strcmp0 ((gchar *) node->name, "table"))
{
- GdaDdlTable *table;
- table = gda_ddl_table_new ();
- gda_ddl_base_set_schema (GDA_DDL_BASE(table), priv->mp_schemaname);
+ GdaDbTable *table;
+ table = gda_db_table_new ();
+ gda_db_base_set_schema (GDA_DB_BASE(table), priv->mp_schemaname);
- if (!gda_ddl_buildable_parse_node (GDA_DDL_BUILDABLE(table), node, error))
+ if (!gda_db_buildable_parse_node (GDA_DB_BUILDABLE(table), node, error))
{
g_object_unref (table);
goto on_error;
@@ -302,11 +303,11 @@ _gda_ddl_creator_parse_doc (GdaDdlCreator *self,
}
else if (!g_strcmp0 ((gchar *) node->name, "view"))
{
- GdaDdlView *view;
- view = gda_ddl_view_new ();
- gda_ddl_base_set_schema (GDA_DDL_BASE(view), priv->mp_schemaname);
+ GdaDbView *view;
+ view = gda_db_view_new ();
+ gda_db_base_set_schema (GDA_DB_BASE(view), priv->mp_schemaname);
- if (!gda_ddl_buildable_parse_node (GDA_DDL_BUILDABLE(view), node, error))
+ if (!gda_db_buildable_parse_node (GDA_DB_BUILDABLE(view), node, error))
{
g_object_unref (view);
goto on_error;
@@ -325,8 +326,8 @@ on_error:
}
/**
- * gda_ddl_creator_parse_file_from_path:
- * @self: an instance of #GdaDdlCreator
+ * gda_db_catalog_parse_file_from_path:
+ * @self: an instance of #GdaDbCatalog
* @xmlfile: xml file to parse
* @error: Error container
*
@@ -376,21 +377,21 @@ on_error:
* ]|
*
* Up to day description of the xml file schema can be found in DTD file
- * [libgda-ddl-creator.dtd]
- * (https://gitlab.gnome.org/GNOME/libgda/blob/master/libgda/libgda-ddl-creator.dtd)
+ * [libgda-db-catalog.dtd]
+ * (https://gitlab.gnome.org/GNOME/libgda/blob/master/libgda/libgda-db-catalog.dtd)
*
* The given @xmlfile will be checked before parsing and %FALSE will be
* returned if fails. The @xmlfile will be validated internally.
* The same method can be used to validate xmlfile before parsing it.
*/
gboolean
-gda_ddl_creator_parse_file_from_path (GdaDdlCreator *self,
- const gchar *xmlfile,
- GError **error)
+gda_db_catalog_parse_file_from_path (GdaDbCatalog *self,
+ const gchar *xmlfile,
+ GError **error)
{
g_return_val_if_fail (self,FALSE);
g_return_val_if_fail (xmlfile,FALSE);
- g_return_val_if_fail (_gda_ddl_creator_dtd,FALSE);
+ g_return_val_if_fail (_gda_db_catalog_dtd,FALSE);
xmlDocPtr doc = NULL;
@@ -399,22 +400,22 @@ gda_ddl_creator_parse_file_from_path (GdaDdlCreator *self,
if (!doc)
{
g_set_error (error,
- GDA_DDL_CREATOR_ERROR,
- GDA_DDL_CREATOR_DOC_NULL,
+ GDA_DB_CATALOG_ERROR,
+ GDA_DB_CATALOG_DOC_NULL,
_("xmlDoc object can't be created from xmfile name '%s'"), xmlfile);
goto on_error;
}
- if (!_gda_ddl_creator_validate_doc (doc,error))
+ if (!_gda_db_catalog_validate_doc (doc,error))
{
g_set_error (error,
- GDA_DDL_CREATOR_ERROR,
- GDA_DDL_CREATOR_INVALID_XML,
+ GDA_DB_CATALOG_ERROR,
+ GDA_DB_CATALOG_INVALID_XML,
_("xml file '%s' is not valid\n"), xmlfile);
goto on_error;
}
- if (!_gda_ddl_creator_parse_doc (self,doc,error))
+ if (!_gda_db_catalog_parse_doc (self,doc,error))
goto on_error;
xmlFreeDoc (doc);
@@ -427,7 +428,7 @@ on_error:
}
/**
- * gda_ddl_creator_validate_file_from_path:
+ * gda_db_catalog_validate_file_from_path:
* @xmlfile: xml file to validate
* @error: error container
*
@@ -438,11 +439,11 @@ on_error:
* Since: 6.0
*/
gboolean
-gda_ddl_creator_validate_file_from_path (const gchar *xmlfile,
- GError **error)
+gda_db_catalog_validate_file_from_path (const gchar *xmlfile,
+ GError **error)
{
g_return_val_if_fail (xmlfile,FALSE);
- g_return_val_if_fail (_gda_ddl_creator_dtd,FALSE);
+ g_return_val_if_fail (_gda_db_catalog_dtd,FALSE);
xmlDocPtr doc = NULL;
@@ -451,13 +452,13 @@ gda_ddl_creator_validate_file_from_path (const gchar *xmlfile,
if (!doc)
{
g_set_error (error,
- GDA_DDL_CREATOR_ERROR,
- GDA_DDL_CREATOR_DOC_NULL,
+ GDA_DB_CATALOG_ERROR,
+ GDA_DB_CATALOG_DOC_NULL,
_("xmlDoc object can't be created from xmfile name '%s'"), xmlfile);
goto on_error;
}
- if (!_gda_ddl_creator_validate_doc (doc,error))
+ if (!_gda_db_catalog_validate_doc (doc,error))
goto on_error;
xmlFreeDoc (doc);
@@ -470,66 +471,66 @@ on_error:
}
/**
- * gda_ddl_creator_get_tables:
- * @self: a #GdaDdlCreator object
+ * gda_db_catalog_get_tables:
+ * @self: a #GdaDbCatalog object
*
- * Returns: (element-type Gda.DdlTable) (transfer none): a list of tables
+ * Returns: (element-type Gda.DbTable) (transfer none): a list of tables
*
* Since: 6.0
*/
GList*
-gda_ddl_creator_get_tables (GdaDdlCreator *self)
+gda_db_catalog_get_tables (GdaDbCatalog *self)
{
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
return priv->mp_tables;
}
/**
- * gda_ddl_creator_get_views:
- * @self: a #GdaDdlCreator object
+ * gda_db_catalog_get_views:
+ * @self: a #GdaDbCatalog object
*
- * Returns: (element-type Gda.DdlView) (transfer none): a list of views
+ * Returns: (element-type Gda.DbView) (transfer none): a list of views
*
* Since: 6.0
*/
GList*
-gda_ddl_creator_get_views (GdaDdlCreator *self)
+gda_db_catalog_get_views (GdaDbCatalog *self)
{
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
return priv->mp_views;
}
/**
- * gda_ddl_creator_get_table:
- * @self: a #GdaDdlCreator object
+ * gda_db_catalog_get_table:
+ * @self: a #GdaDbCatalog object
* @name: table name
*
* Convenient function to return a table based on name
*
- * Returns: table as #GdaDdlTable or %NULL
+ * Returns: table as #GdaDbTable or %NULL
*
*/
-const GdaDdlTable*
-gda_ddl_creator_get_table (GdaDdlCreator *self,
- const gchar *catalog,
- const gchar *schema,
- const gchar *name)
+const GdaDbTable*
+gda_db_catalog_get_table (GdaDbCatalog *self,
+ const gchar *catalog,
+ const gchar *schema,
+ const gchar *name)
{
g_return_val_if_fail (self,NULL);
g_return_val_if_fail (name,NULL);
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
- GdaDdlBase *iobj = gda_ddl_base_new ();
- gda_ddl_base_set_names (iobj,catalog,schema,name);
+ GdaDbBase *iobj = gda_db_base_new ();
+ gda_db_base_set_names (iobj,catalog,schema,name);
GList *it = NULL;
for (it = priv->mp_tables; it; it = it->next)
- if (!gda_ddl_base_compare (iobj,GDA_DDL_BASE(it->data)))
+ if (!gda_db_base_compare (iobj,GDA_DB_BASE(it->data)))
{
g_object_unref (iobj);
- return GDA_DDL_TABLE(it->data);
+ return GDA_DB_TABLE(it->data);
}
g_object_unref (iobj);
@@ -537,33 +538,33 @@ gda_ddl_creator_get_table (GdaDdlCreator *self,
}
/**
- * gda_ddl_creator_get_view:
- * @self: a #GdaDdlCreator object
+ * gda_db_catalog_get_view:
+ * @self: a #GdaDbCatalog object
* @name: view name
*
* Convenient function to return a view based on name
*
- * Returns: table as #GdaDdlView or %NULL
+ * Returns: table as #GdaDbView or %NULL
*
*/
-const GdaDdlView*
-gda_ddl_creator_get_view (GdaDdlCreator *self,
- const gchar *catalog,
- const gchar *schema,
- const gchar *name)
+const GdaDbView*
+gda_db_catalog_get_view (GdaDbCatalog *self,
+ const gchar *catalog,
+ const gchar *schema,
+ const gchar *name)
{
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
GList *it = NULL;
- GdaDdlBase *iobj = gda_ddl_base_new ();
- gda_ddl_base_set_names (iobj,catalog,schema,name);
+ GdaDbBase *iobj = gda_db_base_new ();
+ gda_db_base_set_names (iobj,catalog,schema,name);
for (it = priv->mp_views; it; it = it->next)
- if (!gda_ddl_base_compare (iobj,GDA_DDL_BASE(it)))
+ if (!gda_db_base_compare (iobj,GDA_DB_BASE(it)))
{
g_object_unref (iobj);
- return GDA_DDL_VIEW(it);
+ return GDA_DB_VIEW(it);
}
g_object_unref (iobj);
@@ -571,8 +572,8 @@ gda_ddl_creator_get_view (GdaDdlCreator *self,
}
/**
- * gda_ddl_creator_parse_cnc:
- * @self: a #GdaDdlCreator instance
+ * gda_db_catalog_parse_cnc:
+ * @self: a #GdaDbCatalog instance
* @error: error storage object
*
* Parse cnc to populate @self object. This method should be called every time after database was
@@ -581,12 +582,12 @@ gda_ddl_creator_get_view (GdaDdlCreator *self,
* Returns: Returns %TRUE if succeeded, %FALSE otherwise.
*/
gboolean
-gda_ddl_creator_parse_cnc (GdaDdlCreator *self,
- GError **error)
+gda_db_catalog_parse_cnc (GdaDbCatalog *self,
+ GError **error)
{
g_return_val_if_fail (self,FALSE);
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
if (!gda_connection_is_opened (priv->cnc))
return FALSE;
@@ -617,7 +618,7 @@ gda_ddl_creator_parse_cnc (GdaDdlCreator *self,
{
if(GDA_META_DB_OBJECT(it->data)->obj_type == GDA_META_DB_TABLE)
{
- GdaDdlTable *table = gda_ddl_table_new_from_meta(it->data);
+ GdaDbTable *table = gda_db_table_new_from_meta(it->data);
if (!table)
continue;
@@ -627,7 +628,7 @@ gda_ddl_creator_parse_cnc (GdaDdlCreator *self,
if(GDA_META_DB_OBJECT(it->data)->obj_type == GDA_META_DB_VIEW)
{
- GdaDdlView *view = gda_ddl_view_new_from_meta(it->data);
+ GdaDbView *view = gda_db_view_new_from_meta(it->data);
priv->mp_views = g_list_append (priv->mp_views,view);
continue;
}
@@ -645,8 +646,8 @@ on_error:
}
/**
- * gda_ddl_creator_append_table:
- * @self: a #GdaDdlCreator instance
+ * gda_db_catalog_append_table:
+ * @self: a #GdaDbCatalog instance
* @table: table to append
*
* This method append @table to the total list of all tables stored in @self.
@@ -654,19 +655,19 @@ on_error:
* Since: 6.0
*/
void
-gda_ddl_creator_append_table (GdaDdlCreator *self,
- GdaDdlTable *table)
+gda_db_catalog_append_table (GdaDbCatalog *self,
+ GdaDbTable *table)
{
g_return_if_fail (self);
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
priv->mp_tables = g_list_append (priv->mp_tables,g_object_ref (table));
}
/**
- * gda_ddl_creator_append_view:
- * @self: a #GdaDdlCreator instance
+ * gda_db_catalog_append_view:
+ * @self: a #GdaDbCatalog instance
* @view: view to append
*
* This method append @view to the total list of all views stored in @self.
@@ -674,32 +675,32 @@ gda_ddl_creator_append_table (GdaDdlCreator *self,
* Since: 6.0
*/
void
-gda_ddl_creator_append_view (GdaDdlCreator *self,
- GdaDdlView *view)
+gda_db_catalog_append_view (GdaDbCatalog *self,
+ GdaDbView *view)
{
g_return_if_fail (self);
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
priv->mp_views = g_list_append (priv->mp_views,g_object_ref (view));
}
/**
- * gda_ddl_creator_perform_operation:
- * @self: a #GdaDdlCreator object
+ * gda_db_catalog_perform_operation:
+ * @self: a #GdaDbCatalog object
* @error: object to store error
*
* After population @self with all data this method may be
* called to trigger code and modify user database. This is the main
* method to work with database. For retrieving information from database to an
- * xml file use gda_ddl_creator_parse_cnc() and gda_ddl_buildable_write_xml().
+ * xml file use gda_db_catalog_parse_cnc() and gda_db_buildable_write_xml().
*
* Connection should be opened to use this method. See gda_connection_open()
* method for reference.
*
* Only table can be created. Views are ignored
*
- * Each table from database compared with each table in the #GdaDdlCreator
+ * Each table from database compared with each table in the #GdaDbCatalog
* instance. If the table doesn't exist in database, it will be created (CREATE_TABLE).
* If table exists in the database and xml file, all columns will be checked. If columns
* are present in xml file but not in the database it will be created (ADD_COLUMN). If
@@ -710,19 +711,19 @@ gda_ddl_creator_append_view (GdaDdlCreator *self,
* issue was open on gitlab page.
*/
gboolean
-gda_ddl_creator_perform_operation (GdaDdlCreator *self,
- GError **error)
+gda_db_catalog_perform_operation (GdaDbCatalog *self,
+ GError **error)
{
g_return_val_if_fail (self, FALSE);
gboolean st = TRUE;
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
if (!gda_connection_is_opened (priv->cnc))
{
g_set_error (error,
- GDA_DDL_CREATOR_ERROR,
- GDA_DDL_CREATOR_CONNECTION_CLOSED,
+ GDA_DB_CATALOG_ERROR,
+ GDA_DB_CATALOG_CONNECTION_CLOSED,
_("Connection is not opened"));
return FALSE;
}
@@ -754,20 +755,20 @@ gda_ddl_creator_perform_operation (GdaDdlCreator *self,
* Other databases may also ignore schema and reference objects only by database and
* name, e.g. db_name.table_name
* */
- g_value_set_string (catalog, gda_ddl_base_get_catalog(it->data));
- g_value_set_string (schema , gda_ddl_base_get_schema (it->data));
- g_value_set_string (name , gda_ddl_base_get_name (it->data));
+ g_value_set_string (catalog, gda_db_base_get_catalog(it->data));
+ g_value_set_string (schema , gda_db_base_get_schema (it->data));
+ g_value_set_string (name , gda_db_base_get_name (it->data));
mobj = gda_meta_struct_complement (mstruct, GDA_META_DB_TABLE, catalog, schema,name, NULL);
if (mobj) {
- st = gda_ddl_table_update (it->data,GDA_META_TABLE(mobj), priv->cnc, error);
+ st = gda_db_table_update (it->data,GDA_META_TABLE(mobj), priv->cnc, error);
if (!st) {
break;
}
}
else {
- if(st = gda_ddl_table_create (it->data,priv->cnc, TRUE, error))
+ if(st = gda_db_table_create (it->data,priv->cnc, TRUE, error))
if (!st) {
break;
}
@@ -781,7 +782,7 @@ gda_ddl_creator_perform_operation (GdaDdlCreator *self,
if (st) {
/*TODO: add update option for views */
for (it = priv->mp_views; it; it = it->next) {
- st = gda_ddl_view_create (it->data, priv->cnc, error);
+ st = gda_db_view_create (it->data, priv->cnc, error);
if (!st) {
break;
}
@@ -795,36 +796,36 @@ gda_ddl_creator_perform_operation (GdaDdlCreator *self,
}
/**
- * gda_ddl_creator_write_to_file:
- * @self: a #GdaDdlCreator instance
+ * gda_db_catalog_write_to_file:
+ * @self: a #GdaDbCatalog instance
* @file: a #GFile to write database description
* @error: container to hold error
*
* This method writes database description as xml file.
- * Similar to gda_ddl_creator_write_to_path()
+ * Similar to gda_db_catalog_write_to_path()
*
* Returns: %TRUE if no error occurred, %FALSE otherwise.
*
* Since: 6.0
*/
gboolean
-gda_ddl_creator_write_to_file (GdaDdlCreator *self,
- GFile *file,
- GError **error)
+gda_db_catalog_write_to_file (GdaDbCatalog *self,
+ GFile *file,
+ GError **error)
{
g_return_val_if_fail (self,FALSE);
g_return_val_if_fail (file,FALSE);
gchar *filepath = g_file_get_path (file);
- gboolean res = gda_ddl_creator_write_to_path (self,filepath,error);
+ gboolean res = gda_db_catalog_write_to_path (self,filepath,error);
g_free (filepath);
return res;
}
/**
- * gda_ddl_creator_write_to_path:
- * @self: a #GdaDdlCreator instance
- * @path: path to xml file to save #GdaDdlCreator
+ * gda_db_catalog_write_to_path:
+ * @self: a #GdaDbCatalog instance
+ * @path: path to xml file to save #GdaDbCatalog
* @error: container to hold an error
*
* Save content of @self to a user friendly xml file.
@@ -834,14 +835,14 @@ gda_ddl_creator_write_to_file (GdaDdlCreator *self,
* Since: 6.0
*/
gboolean
-gda_ddl_creator_write_to_path (GdaDdlCreator *self,
- const gchar *path,
- GError **error)
+gda_db_catalog_write_to_path (GdaDbCatalog *self,
+ const gchar *path,
+ GError **error)
{
g_return_val_if_fail (self,FALSE);
g_return_val_if_fail (path,FALSE);
- GdaDdlCreatorPrivate *priv = gda_ddl_creator_get_instance_private (self);
+ GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
xmlDocPtr doc = NULL;
xmlNodePtr node_root = NULL;
@@ -857,12 +858,12 @@ gda_ddl_creator_write_to_path (GdaDdlCreator *self,
GList *it = NULL;
for (it = priv->mp_tables; it; it=it->next)
- if (!gda_ddl_buildable_write_node (GDA_DDL_BUILDABLE(GDA_DDL_TABLE(it->data)),
+ if (!gda_db_buildable_write_node (GDA_DB_BUILDABLE(GDA_DB_TABLE(it->data)),
node_root,error))
goto on_error;
for (it = priv->mp_views; it; it=it->next)
- if (!gda_ddl_buildable_write_node (GDA_DDL_BUILDABLE(GDA_DDL_VIEW(it->data)),
+ if (!gda_db_buildable_write_node (GDA_DB_BUILDABLE(GDA_DB_VIEW(it->data)),
node_root,error))
goto on_error;
@@ -879,23 +880,23 @@ on_error:
}
/**
- * gda_ddl_creator_parse_file:
- * @self: an instance of #GdaDdlCreator
+ * gda_db_catalog_parse_file:
+ * @self: an instance of #GdaDbCatalog
* @xmlfile: xml file as #GFile instance
* @error: Error container
*
- * For detailed description see gda_ddl_creator_parse_file_from_path()
+ * For detailed description see gda_db_catalog_parse_file_from_path()
*
* Since: 6.0
*/
gboolean
-gda_ddl_creator_parse_file (GdaDdlCreator *self,
- GFile *xmlfile,
- GError **error)
+gda_db_catalog_parse_file (GdaDbCatalog *self,
+ GFile *xmlfile,
+ GError **error)
{
g_return_val_if_fail (self,FALSE);
g_return_val_if_fail (xmlfile,FALSE);
- g_return_val_if_fail (_gda_ddl_creator_dtd,FALSE);
+ g_return_val_if_fail (_gda_db_catalog_dtd,FALSE);
GFileInputStream *istream = NULL;
xmlDocPtr doc = NULL;
@@ -905,8 +906,8 @@ gda_ddl_creator_parse_file (GdaDdlCreator *self,
if(!istream)
{
g_set_error (error,
- GDA_DDL_CREATOR_ERROR,
- GDA_DDL_CREATOR_FILE_READ,
+ GDA_DB_CATALOG_ERROR,
+ GDA_DB_CATALOG_FILE_READ,
_("Can't open stream for reading file '%s'"), g_file_get_basename(xmlfile));
return FALSE;
}
@@ -918,8 +919,8 @@ gda_ddl_creator_parse_file (GdaDdlCreator *self,
if (!ctxt)
{
g_set_error (error,
- GDA_DDL_CREATOR_ERROR,
- GDA_DDL_CREATOR_FILE_READ,
+ GDA_DB_CATALOG_ERROR,
+ GDA_DB_CATALOG_FILE_READ,
_("Can't create parse context for '%s'"), g_file_get_basename(xmlfile));
goto on_error;
}
@@ -932,8 +933,8 @@ gda_ddl_creator_parse_file (GdaDdlCreator *self,
if (rescheck != 0)
{
g_set_error (error,
- GDA_DDL_CREATOR_ERROR,
- GDA_DDL_CREATOR_PARSE_CHUNK,
+ GDA_DB_CATALOG_ERROR,
+ GDA_DB_CATALOG_PARSE_CHUNK,
_("Error during xmlParseChunk with error '%d'"), rescheck);
goto on_error;
@@ -948,8 +949,8 @@ gda_ddl_creator_parse_file (GdaDdlCreator *self,
if (!ctxt_res)
{
g_set_error (error,
- GDA_DDL_CREATOR_ERROR,
- GDA_DDL_CREATOR_PARSE,
+ GDA_DB_CATALOG_ERROR,
+ GDA_DB_CATALOG_PARSE,
_("Failed to parse file '%s'"), g_file_get_basename (xmlfile));
goto on_error;
}
@@ -957,22 +958,22 @@ gda_ddl_creator_parse_file (GdaDdlCreator *self,
if (!doc)
{
g_set_error (error,
- GDA_DDL_CREATOR_ERROR,
- GDA_DDL_CREATOR_DOC_NULL,
+ GDA_DB_CATALOG_ERROR,
+ GDA_DB_CATALOG_DOC_NULL,
_("xmlDoc object can't be created from xmfile name"));
goto on_error;
}
- if (!_gda_ddl_creator_validate_doc(doc, error))
+ if (!_gda_db_catalog_validate_doc(doc, error))
{
g_set_error (error,
- GDA_DDL_CREATOR_ERROR,
- GDA_DDL_CREATOR_INVALID_XML,
+ GDA_DB_CATALOG_ERROR,
+ GDA_DB_CATALOG_INVALID_XML,
_("xml file is not valid\n"));
goto on_error;
}
- if (!_gda_ddl_creator_parse_doc (self, doc, error))
+ if (!_gda_db_catalog_parse_doc (self, doc, error))
goto on_error;
g_input_stream_close (G_INPUT_STREAM(istream), NULL, error);
diff --git a/libgda/gda-db-catalog.h b/libgda/gda-db-catalog.h
new file mode 100644
index 000000000..8aedfb724
--- /dev/null
+++ b/libgda/gda-db-catalog.h
@@ -0,0 +1,111 @@
+/* gda-db-catalog.h
+ *
+ * Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef GDA_DB_CATALOG_H
+#define GDA_DB_CATALOG_H
+
+#include <glib-object.h>
+#include <gmodule.h>
+#include "gda-db-table.h"
+#include "gda-db-view.h"
+#include "gda-server-operation.h"
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define GDA_TYPE_DB_CATALOG (gda_db_catalog_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (GdaDbCatalog, gda_db_catalog, GDA, DB_CATALOG, GObject)
+
+struct _GdaDbCatalogClass {
+ GObjectClass parent;
+};
+
+/**
+ * GdaDbCatalogError:
+ * @GDA_DB_CATALOG_CONTEXT_NULL: Context is %NULL. Should not be %NULL for normal operation.
+ * @GDA_DB_CATALOG_DOC_NULL: #xmlDocPtr is %NULL.
+ * @GDA_DB_CATALOG_INVALID_XML: Sets if xml check fails. Xml file structure doesn't match with DTD
+ * file
+ * @GDA_DB_CATALOG_INVALID_SCHEMA: Sets if the used schema is invalid.
+ * @GDA_DB_CATALOG_SERVER_OPERATION: Sets if server operation is %NULL.
+ * @GDA_DB_CATALOG_FILE_READ: Sets if xml file is not readable
+ * @GDA_DB_CATALOG_PARSE_CONTEXT: Sets if an error with context during parsing an xml file
+ * @GDA_DB_CATALOG_PARSE: Sets if parsing reports an error
+ * @GDA_DB_CATALOG_PARSE_CHUNK: If set, error with parse chunk algorithm.
+ * @GDA_DB_CATALOG_CONNECTION_CLOSED: Connection is not open.
+ *
+ * These error are primary for developers to troubleshoot the problem rather than for user.
+ */
+typedef enum {
+ GDA_DB_CATALOG_CONTEXT_NULL,
+ GDA_DB_CATALOG_DOC_NULL,
+ GDA_DB_CATALOG_INVALID_XML,
+ GDA_DB_CATALOG_INVALID_SCHEMA,
+ GDA_DB_CATALOG_SERVER_OPERATION,
+ GDA_DB_CATALOG_FILE_READ,
+ GDA_DB_CATALOG_PARSE_CONTEXT,
+ GDA_DB_CATALOG_PARSE,
+ GDA_DB_CATALOG_PARSE_CHUNK,
+ GDA_DB_CATALOG_CONNECTION_CLOSED
+} GdaDbCatalogError;
+
+#define GDA_DB_CATALOG_ERROR gda_db_catalog_error_quark()
+GQuark gda_db_catalog_error_quark (void);
+
+GdaDbCatalog *gda_db_catalog_new (void);
+
+gboolean gda_db_catalog_parse_file_from_path (GdaDbCatalog *self,
+ const gchar *xmlfile,
+ GError **error);
+
+gboolean gda_db_catalog_parse_file (GdaDbCatalog *self,
+ GFile *xmlfile,
+ GError **error);
+
+GList *gda_db_catalog_get_tables (GdaDbCatalog *self);
+GList *gda_db_catalog_get_views (GdaDbCatalog *self);
+
+gboolean gda_db_catalog_parse_cnc (GdaDbCatalog *self,
+ GError **error);
+
+void gda_db_catalog_append_table (GdaDbCatalog *self,
+ GdaDbTable *table);
+
+void gda_db_catalog_append_view (GdaDbCatalog *self,
+ GdaDbView *view);
+
+gboolean gda_db_catalog_perform_operation (GdaDbCatalog *self,
+ GError **error);
+
+gboolean gda_db_catalog_write_to_file (GdaDbCatalog *self,
+ GFile *file,
+ GError **error);
+
+gboolean gda_db_catalog_write_to_path (GdaDbCatalog *self,
+ const gchar *path,
+ GError **error);
+
+gboolean gda_db_catalog_validate_file_from_path (const gchar *xmlfile,
+ GError **error);
+G_END_DECLS
+
+#endif /* GDA_DB_CATALOG_H */
+
diff --git a/libgda/gda-ddl-column.c b/libgda/gda-db-column.c
similarity index 64%
rename from libgda/gda-ddl-column.c
rename to libgda/gda-db-column.c
index dafbd27f4..ca431c833 100644
--- a/libgda/gda-ddl-column.c
+++ b/libgda/gda-db-column.c
@@ -1,4 +1,4 @@
-/* gda-ddl-column.c
+/* gda-db-column.c
*
* Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
*
@@ -18,14 +18,14 @@
* Boston, MA 02110-1301, USA.
*/
#include <stdlib.h>
-#include "gda-ddl-column.h"
+#include "gda-db-column.h"
#include <glib/gi18n-lib.h>
#include "gda-util.h"
-#include "gda-ddl-buildable.h"
-#include "gda-ddl-base.h"
+#include "gda-db-buildable.h"
+#include "gda-db-base.h"
#include "gda-server-provider.h"
-G_DEFINE_QUARK (gda-ddl-column-error, gda_ddl_column_error)
+G_DEFINE_QUARK (gda-db-column-error, gda_db_column_error)
typedef struct
{
@@ -44,38 +44,38 @@ typedef struct
gboolean m_autoinc; /* property */
gboolean m_unique; /* property */
gboolean m_pkey; /* property */
-}GdaDdlColumnPrivate;
+}GdaDbColumnPrivate;
/**
- * SECTION:gda-ddl-column
+ * SECTION:gda-db-column
* @short_description: Object to represent table column
- * @see_also: #GdaDdlTable, #GdaDdlView, #GdaDdlBuildable
+ * @see_also: #GdaDbTable, #GdaDbView, #GdaDbBuildable
* @stability: Stable
* @include: libgda/libgda.h
*
* This object represents a column of a table or a view. The column can be constracted manually
- * using API or generated from xml file together with other databse objects. See #GdaDdlCreator.
- * #GdaDdlColumn implements #GdaDdlBuildable interface for parsing xml file.
+ * using API or generated from xml file together with other databse objects. See #GdaDbCreator.
+ * #GdaDbColumn implements #GdaDbBuildable interface for parsing xml file.
*/
/* All nodes in xml should be accessed using enum below */
enum {
- GDA_DDL_COLUMN_NODE,
- GDA_DDL_COLUMN_NAME,
- GDA_DDL_COLUMN_ATYPE,
- GDA_DDL_COLUMN_PKEY,
- GDA_DDL_COLUMN_UNIQUE,
- GDA_DDL_COLUMN_AUTOINC,
- GDA_DDL_COLUMN_NNUL,
- GDA_DDL_COLUMN_COMMENT,
- GDA_DDL_COLUMN_SIZE,
- GDA_DDL_COLUMN_CHECK,
- GDA_DDL_COLUMN_VALUE,
- GDA_DDL_COLUMN_SCALE,
- GDA_DDL_COLUMN_N_NODES
+ GDA_DB_COLUMN_NODE,
+ GDA_DB_COLUMN_NAME,
+ GDA_DB_COLUMN_ATYPE,
+ GDA_DB_COLUMN_PKEY,
+ GDA_DB_COLUMN_UNIQUE,
+ GDA_DB_COLUMN_AUTOINC,
+ GDA_DB_COLUMN_NNUL,
+ GDA_DB_COLUMN_COMMENT,
+ GDA_DB_COLUMN_SIZE,
+ GDA_DB_COLUMN_CHECK,
+ GDA_DB_COLUMN_VALUE,
+ GDA_DB_COLUMN_SCALE,
+ GDA_DB_COLUMN_N_NODES
};
-const gchar *gdaddlcolumnnode[GDA_DDL_COLUMN_N_NODES] = {
+const gchar *gdadbcolumnnode[GDA_DB_COLUMN_N_NODES] = {
"column",
"name",
"type",
@@ -91,12 +91,12 @@ const gchar *gdaddlcolumnnode[GDA_DDL_COLUMN_N_NODES] = {
};
static void
-gda_ddl_column_buildable_interface_init (GdaDdlBuildableInterface *iface);
+gda_db_column_buildable_interface_init (GdaDbBuildableInterface *iface);
-G_DEFINE_TYPE_WITH_CODE (GdaDdlColumn, gda_ddl_column, G_TYPE_OBJECT,
- G_ADD_PRIVATE (GdaDdlColumn)
- G_IMPLEMENT_INTERFACE (GDA_TYPE_DDL_BUILDABLE,
- gda_ddl_column_buildable_interface_init))
+G_DEFINE_TYPE_WITH_CODE (GdaDbColumn, gda_db_column, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (GdaDbColumn)
+ G_IMPLEMENT_INTERFACE (GDA_TYPE_DB_BUILDABLE,
+ gda_db_column_buildable_interface_init))
enum {
PROP_0,
PROP_COLUMN_NAME,
@@ -114,48 +114,48 @@ enum {
};
static void
-_gda_ddl_column_set_type (GdaDdlColumn *self,
- const gchar *type,
- GError **error);
+_gda_db_column_set_type (GdaDbColumn *self,
+ const gchar *type,
+ GError **error);
static GParamSpec *properties [N_PROPS] = {NULL};
/**
- * gda_ddl_column_new:
+ * gda_db_column_new:
*
- * Returns: New instance of #GdaDdlColumn
+ * Returns: New instance of #GdaDbColumn
*
* Since: 6.0
*
*/
-GdaDdlColumn *
-gda_ddl_column_new (void)
+GdaDbColumn *
+gda_db_column_new (void)
{
- return g_object_new (GDA_TYPE_DDL_COLUMN, NULL);
+ return g_object_new (GDA_TYPE_DB_COLUMN, NULL);
}
static void
-gda_ddl_column_finalize (GObject *object)
+gda_db_column_finalize (GObject *object)
{
- GdaDdlColumn *self = GDA_DDL_COLUMN (object);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumn *self = GDA_DB_COLUMN (object);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
g_free (priv->mp_name);
g_free (priv->mp_type);
g_free (priv->mp_default);
g_free (priv->mp_check);
- G_OBJECT_CLASS (gda_ddl_column_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gda_db_column_parent_class)->finalize (object);
}
static void
-gda_ddl_column_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+gda_db_column_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GdaDdlColumn *self = GDA_DDL_COLUMN (object);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumn *self = GDA_DB_COLUMN (object);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
switch (prop_id) {
case PROP_COLUMN_NAME:
@@ -195,13 +195,13 @@ gda_ddl_column_get_property (GObject *object,
}
static void
-gda_ddl_column_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+gda_db_column_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- GdaDdlColumn *self = GDA_DDL_COLUMN (object);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumn *self = GDA_DB_COLUMN (object);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
switch (prop_id){
case PROP_COLUMN_NAME:
@@ -245,13 +245,13 @@ gda_ddl_column_set_property (GObject *object,
}
static void
-gda_ddl_column_class_init (GdaDdlColumnClass *klass)
+gda_db_column_class_init (GdaDbColumnClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gda_ddl_column_finalize;
- object_class->get_property = gda_ddl_column_get_property;
- object_class->set_property = gda_ddl_column_set_property;
+ object_class->finalize = gda_db_column_finalize;
+ object_class->get_property = gda_db_column_get_property;
+ object_class->set_property = gda_db_column_set_property;
properties[PROP_COLUMN_NAME] =
g_param_spec_string ("name","Name","Column name",NULL,G_PARAM_READWRITE);
@@ -288,9 +288,9 @@ gda_ddl_column_class_init (GdaDdlColumnClass *klass)
}
static void
-gda_ddl_column_init (GdaDdlColumn *self)
+gda_db_column_init (GdaDbColumn *self)
{
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
priv->mp_type = NULL;
priv->m_scale = 0;
@@ -306,8 +306,8 @@ gda_ddl_column_init (GdaDdlColumn *self)
}
/**
- * gda_ddl_column_parse_node: (skip)
- * @self: #GdaDdlColumn object to store parsed data
+ * gda_db_column_parse_node: (skip)
+ * @self: #GdaDbColumn object to store parsed data
* @node: instance of #xmlNodePtr to parse
* @error: error container
*
@@ -318,9 +318,9 @@ gda_ddl_column_init (GdaDdlColumn *self)
* Since: 6.0
*/
static gboolean
-gda_ddl_column_parse_node (GdaDdlBuildable *buildable,
- xmlNodePtr node,
- GError **error)
+gda_db_column_parse_node (GdaDbBuildable *buildable,
+ xmlNodePtr node,
+ GError **error)
{
g_return_val_if_fail (buildable,FALSE);
g_return_val_if_fail (node,FALSE);
@@ -328,24 +328,24 @@ gda_ddl_column_parse_node (GdaDdlBuildable *buildable,
/*TODO: Appropriate error should be set an returned.
* It should be added to the header file first
*/
- if (g_strcmp0 ((gchar *)node->name,gdaddlcolumnnode[GDA_DDL_COLUMN_NODE]))
+ if (g_strcmp0 ((gchar *)node->name,gdadbcolumnnode[GDA_DB_COLUMN_NODE]))
return FALSE;
- GdaDdlColumn *self = GDA_DDL_COLUMN (buildable);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumn *self = GDA_DB_COLUMN (buildable);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
- xmlChar *name = xmlGetProp (node,(xmlChar *)gdaddlcolumnnode[GDA_DDL_COLUMN_NAME]);
+ xmlChar *name = xmlGetProp (node,(xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_NAME]);
g_assert (name); /* If here bug with xml validation */
g_object_set (G_OBJECT(self),"name",(gchar*)name,NULL);
xmlFree (name);
- xmlChar *type = xmlGetProp (node,(xmlChar *)gdaddlcolumnnode[GDA_DDL_COLUMN_ATYPE]);
+ xmlChar *type = xmlGetProp (node,(xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_ATYPE]);
g_assert (type); /* If here buf with validation */
- _gda_ddl_column_set_type (self,(const gchar *)type,error);
+ _gda_db_column_set_type (self,(const gchar *)type,error);
xmlFree (type);
xmlChar *cprop = NULL;
- cprop = xmlGetProp (node,(xmlChar *)gdaddlcolumnnode[GDA_DDL_COLUMN_PKEY]);
+ cprop = xmlGetProp (node,(xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_PKEY]);
if (cprop)
{
g_object_set (G_OBJECT(self),"pkey",*cprop == 't' || *cprop == 'T' ? TRUE : FALSE, NULL);
@@ -353,7 +353,7 @@ gda_ddl_column_parse_node (GdaDdlBuildable *buildable,
}
/* We need scale only for NUMBERIC data type, e.g. float, double */
- cprop = xmlGetProp (node,(xmlChar *)gdaddlcolumnnode[GDA_DDL_COLUMN_UNIQUE]);
+ cprop = xmlGetProp (node,(xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_UNIQUE]);
if (cprop)
{
@@ -361,7 +361,7 @@ gda_ddl_column_parse_node (GdaDdlBuildable *buildable,
xmlFree (cprop);
}
- cprop = xmlGetProp (node,(xmlChar *)gdaddlcolumnnode[GDA_DDL_COLUMN_AUTOINC]);
+ cprop = xmlGetProp (node,(xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_AUTOINC]);
if (cprop)
{
@@ -369,7 +369,7 @@ gda_ddl_column_parse_node (GdaDdlBuildable *buildable,
xmlFree (cprop);
}
- cprop = xmlGetProp (node,(xmlChar *)gdaddlcolumnnode[GDA_DDL_COLUMN_NNUL]);
+ cprop = xmlGetProp (node,(xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_NNUL]);
if (cprop)
{
@@ -379,7 +379,7 @@ gda_ddl_column_parse_node (GdaDdlBuildable *buildable,
for (xmlNodePtr it = node->children; it; it = it->next)
{
- if (!g_strcmp0 ((char *)it->name,gdaddlcolumnnode[GDA_DDL_COLUMN_VALUE]))
+ if (!g_strcmp0 ((char *)it->name,gdadbcolumnnode[GDA_DB_COLUMN_VALUE]))
{
xmlChar *value = xmlNodeGetContent (it);
@@ -389,7 +389,7 @@ gda_ddl_column_parse_node (GdaDdlBuildable *buildable,
xmlFree (value);
}
- xmlChar *nprop = xmlGetProp (it,BAD_CAST gdaddlcolumnnode[GDA_DDL_COLUMN_SIZE]);
+ xmlChar *nprop = xmlGetProp (it,BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_SIZE]);
guint64 tint = 0;
if (nprop)
{
@@ -402,7 +402,7 @@ gda_ddl_column_parse_node (GdaDdlBuildable *buildable,
priv->m_gtype == G_TYPE_DOUBLE ||
priv->m_gtype == GDA_TYPE_NUMERIC)
{
- nprop = xmlGetProp (it,(xmlChar *)gdaddlcolumnnode[GDA_DDL_COLUMN_SCALE]);
+ nprop = xmlGetProp (it,(xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_SCALE]);
if (nprop)
{
guint64 tint = g_ascii_strtoull ((gchar*)nprop,NULL,10);
@@ -412,14 +412,14 @@ gda_ddl_column_parse_node (GdaDdlBuildable *buildable,
}
}
- if (!g_strcmp0 ((char *)it->name,gdaddlcolumnnode[GDA_DDL_COLUMN_CHECK]))
+ if (!g_strcmp0 ((char *)it->name,gdadbcolumnnode[GDA_DB_COLUMN_CHECK]))
{
xmlChar *check = xmlNodeGetContent (it);
g_object_set (G_OBJECT (self),"check",check,NULL);
xmlFree (check);
}
- if (!g_strcmp0 ((char *)it->name,gdaddlcolumnnode[GDA_DDL_COLUMN_COMMENT]))
+ if (!g_strcmp0 ((char *)it->name,gdadbcolumnnode[GDA_DB_COLUMN_COMMENT]))
{
xmlChar *comment = xmlNodeGetContent (it);
g_object_set (G_OBJECT (self),"comment",comment,NULL);
@@ -427,53 +427,53 @@ gda_ddl_column_parse_node (GdaDdlBuildable *buildable,
}
} /* End of for loop */
return TRUE;
-} /* End of gda_ddl_column_parse_node */
+} /* End of gda_db_column_parse_node */
static gboolean
-gda_ddl_column_write_node (GdaDdlBuildable *buildable,
- xmlNodePtr rootnode,
- GError **error)
+gda_db_column_write_node (GdaDbBuildable *buildable,
+ xmlNodePtr rootnode,
+ GError **error)
{
g_return_val_if_fail (buildable,FALSE);
g_return_val_if_fail (rootnode,FALSE);
- GdaDdlColumn *self = GDA_DDL_COLUMN (buildable);
+ GdaDbColumn *self = GDA_DB_COLUMN (buildable);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
xmlNodePtr node = NULL;
node = xmlNewChild (rootnode,
NULL,
- BAD_CAST gdaddlcolumnnode[GDA_DDL_COLUMN_NODE],
+ BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_NODE],
NULL);
xmlNewProp (node,
- BAD_CAST gdaddlcolumnnode[GDA_DDL_COLUMN_NAME],
- BAD_CAST gda_ddl_column_get_name (self));
+ BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_NAME],
+ BAD_CAST gda_db_column_get_name (self));
xmlNewProp (node,
- BAD_CAST gdaddlcolumnnode[GDA_DDL_COLUMN_ATYPE],
+ BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_ATYPE],
BAD_CAST priv->mp_type);
xmlNewProp (node,
- BAD_CAST gdaddlcolumnnode[GDA_DDL_COLUMN_PKEY],
+ BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_PKEY],
BAD_CAST GDA_BOOL_TO_STR(priv->m_pkey));
xmlNewProp (node,
- BAD_CAST gdaddlcolumnnode[GDA_DDL_COLUMN_UNIQUE],
+ BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_UNIQUE],
BAD_CAST GDA_BOOL_TO_STR(priv->m_unique));
xmlNewProp (node,
- BAD_CAST gdaddlcolumnnode[GDA_DDL_COLUMN_AUTOINC],
+ BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_AUTOINC],
BAD_CAST GDA_BOOL_TO_STR(priv->m_autoinc));
xmlNewProp (node,
- BAD_CAST gdaddlcolumnnode[GDA_DDL_COLUMN_NNUL],
+ BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_NNUL],
BAD_CAST GDA_BOOL_TO_STR(priv->m_nnul));
if (priv->mp_comment)
xmlNewChild (node,NULL,
- BAD_CAST gdaddlcolumnnode[GDA_DDL_COLUMN_COMMENT],
+ BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_COMMENT],
BAD_CAST priv->mp_comment);
xmlNodePtr nodevalue = NULL;
@@ -482,7 +482,7 @@ gda_ddl_column_write_node (GdaDdlBuildable *buildable,
{
nodevalue = xmlNewChild (node,
NULL,
- BAD_CAST gdaddlcolumnnode[GDA_DDL_COLUMN_VALUE],
+ BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_VALUE],
BAD_CAST priv->mp_default);
if (priv->m_size > 0)
@@ -492,7 +492,7 @@ gda_ddl_column_write_node (GdaDdlBuildable *buildable,
g_string_printf (sizestr,"%d",priv->m_size);
xmlNewProp (nodevalue,
- BAD_CAST gdaddlcolumnnode[GDA_DDL_COLUMN_SIZE],
+ BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_SIZE],
BAD_CAST sizestr->str);
g_string_free (sizestr,TRUE);
@@ -506,7 +506,7 @@ gda_ddl_column_write_node (GdaDdlBuildable *buildable,
g_string_printf (scale_str,"%d",priv->m_scale);
xmlNewProp (nodevalue,
- BAD_CAST gdaddlcolumnnode[GDA_DDL_COLUMN_SCALE],
+ BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_SCALE],
BAD_CAST scale_str->str);
g_string_free (scale_str,TRUE);
@@ -516,28 +516,28 @@ gda_ddl_column_write_node (GdaDdlBuildable *buildable,
if (priv->mp_check)
xmlNewChild (node,NULL,
- BAD_CAST gdaddlcolumnnode[GDA_DDL_COLUMN_CHECK],
+ BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_CHECK],
BAD_CAST priv->mp_check);
return TRUE;
}
static void
-gda_ddl_column_buildable_interface_init (GdaDdlBuildableInterface *iface)
+gda_db_column_buildable_interface_init (GdaDbBuildableInterface *iface)
{
- iface->parse_node = gda_ddl_column_parse_node;
- iface->write_node = gda_ddl_column_write_node;
+ iface->parse_node = gda_db_column_parse_node;
+ iface->write_node = gda_db_column_write_node;
}
static void
-_gda_ddl_column_set_type (GdaDdlColumn *self,
- const char *type,
- GError **error)
+_gda_db_column_set_type (GdaDbColumn *self,
+ const char *type,
+ GError **error)
{
g_return_if_fail (self);
g_return_if_fail (type);
// g_return_if_fail (!*error);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
GType ttype = gda_g_type_from_string (type);
if (ttype != G_TYPE_INVALID){
priv->mp_type = g_strdup (type);
@@ -545,16 +545,16 @@ _gda_ddl_column_set_type (GdaDdlColumn *self,
}
else {
g_set_error (error,
- GDA_DDL_COLUMN_ERROR,
- GDA_DDL_COLUMN_ERROR_TYPE,
+ GDA_DB_COLUMN_ERROR,
+ GDA_DB_COLUMN_ERROR_TYPE,
_("Invalid column type %s. See API for gda_g_type_from_string ().\n"),
type);
}
}
/**
- * gda_ddl_column_get_name:
- * @self: a #GdaDdlColumn instance
+ * gda_db_column_get_name:
+ * @self: a #GdaDbColumn instance
*
* Returns name of the column
*
@@ -563,17 +563,17 @@ _gda_ddl_column_set_type (GdaDdlColumn *self,
* Since: 6.0
*/
const gchar*
-gda_ddl_column_get_name (GdaDdlColumn *self)
+gda_db_column_get_name (GdaDbColumn *self)
{
g_return_val_if_fail (self,NULL);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->mp_name;
}
/**
- * gda_ddl_column_set_name:
- * @self: a #GdaDdlColumn object
+ * gda_db_column_set_name:
+ * @self: a #GdaDbColumn object
* @name: name as a string
*
* Set column name.
@@ -581,35 +581,35 @@ gda_ddl_column_get_name (GdaDdlColumn *self)
* Since: 6.0
*/
void
-gda_ddl_column_set_name (GdaDdlColumn *self,
- const gchar *name)
+gda_db_column_set_name (GdaDbColumn *self,
+ const gchar *name)
{
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
g_free (priv->mp_name);
priv->mp_name = g_strdup (name);
}
/**
- * gda_ddl_column_get_gtype:
- * @self: a #GdaDdlColumn object
+ * gda_db_column_get_gtype:
+ * @self: a #GdaDbColumn object
*
* Return of column type as #GType
*
* Since: 6.0
*/
GType
-gda_ddl_column_get_gtype (GdaDdlColumn *self)
+gda_db_column_get_gtype (GdaDbColumn *self)
{
g_return_val_if_fail (self,GDA_TYPE_NULL);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->m_gtype;
}
/**
- * gda_ddl_column_get_ctype:
- * @self: a #GdaDdlColumn object
+ * gda_db_column_get_ctype:
+ * @self: a #GdaDbColumn object
*
* Returns column type as a string derivied from #GType
*
@@ -618,16 +618,16 @@ gda_ddl_column_get_gtype (GdaDdlColumn *self)
* Since: 6.0
*/
const gchar*
-gda_ddl_column_get_ctype (GdaDdlColumn *self)
+gda_db_column_get_ctype (GdaDbColumn *self)
{
g_return_val_if_fail (self,NULL);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->mp_type;
}
/**
- * gda_ddl_column_set_type:
- * @self: a #GdaDdlColumn instance
+ * gda_db_column_set_type:
+ * @self: a #GdaDbColumn instance
* @type: #GType for column
*
* Set type of the column as a #GType
@@ -635,19 +635,19 @@ gda_ddl_column_get_ctype (GdaDdlColumn *self)
* Since: 6.0
*/
void
-gda_ddl_column_set_type (GdaDdlColumn *self,
- GType type)
+gda_db_column_set_type (GdaDbColumn *self,
+ GType type)
{
g_return_if_fail (self);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
priv->m_gtype = type;
g_free (priv->mp_type);
priv->mp_type = g_strdup (gda_g_type_to_string (type));
}
/**
- * gda_ddl_column_get_scale:
- * @self: a #GdaDdlColumn object
+ * gda_db_column_get_scale:
+ * @self: a #GdaDbColumn object
*
* Scale is used for float number representation to specify a number of decimal digits.
* This value is ignore for column types except float or double.
@@ -656,16 +656,16 @@ gda_ddl_column_set_type (GdaDdlColumn *self,
* Since: 6.0
*/
guint
-gda_ddl_column_get_scale (GdaDdlColumn *self)
+gda_db_column_get_scale (GdaDbColumn *self)
{
g_return_val_if_fail (self,0);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->m_scale;
}
/**
- * gda_ddl_column_set_scale:
- * @self: a #GdaDdlColumn
+ * gda_db_column_set_scale:
+ * @self: a #GdaDbColumn
* @scale: scale value to set
*
* Scale is used for float number representation to specify a number of decimal digits.
@@ -674,17 +674,17 @@ gda_ddl_column_get_scale (GdaDdlColumn *self)
* Since: 6.0
*/
void
-gda_ddl_column_set_scale (GdaDdlColumn *self,
- guint scale)
+gda_db_column_set_scale (GdaDbColumn *self,
+ guint scale)
{
g_return_if_fail (self);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
priv->m_scale = scale;
}
/**
- * gda_ddl_column_get_pkey:
- * @self: a #GdaDdlColumn object
+ * gda_db_column_get_pkey:
+ * @self: a #GdaDbColumn object
*
* Returns a primary key flag
*
@@ -693,32 +693,32 @@ gda_ddl_column_set_scale (GdaDdlColumn *self,
* Since: 6.0
*/
gboolean
-gda_ddl_column_get_pkey (GdaDdlColumn *self)
+gda_db_column_get_pkey (GdaDbColumn *self)
{
g_return_val_if_fail (self,FALSE);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->m_pkey;
}
/**
- * gda_ddl_column_set_pkey:
- * @self: a #GdaDdlColumn object
+ * gda_db_column_set_pkey:
+ * @self: a #GdaDbColumn object
* @pkey: value to set
*
* Since: 6.0
*/
void
-gda_ddl_column_set_pkey (GdaDdlColumn *self,
- gboolean pkey)
+gda_db_column_set_pkey (GdaDbColumn *self,
+ gboolean pkey)
{
g_return_if_fail (self);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
priv->m_pkey = pkey;
}
/**
- * gda_ddl_column_get_nnul:
- * @self: a @GdaDdlColumn object
+ * gda_db_column_get_nnul:
+ * @self: a @GdaDbColumn object
*
* Specify if the column's value can be NULL.
*
@@ -727,32 +727,32 @@ gda_ddl_column_set_pkey (GdaDdlColumn *self,
* Since: 6.0
*/
gboolean
-gda_ddl_column_get_nnul (GdaDdlColumn *self)
+gda_db_column_get_nnul (GdaDbColumn *self)
{
g_return_val_if_fail (self,FALSE);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->m_nnul;
}
/**
- * gda_ddl_column_set_nnul:
- * @self: a GdaDdlColumn object
+ * gda_db_column_set_nnul:
+ * @self: a GdaDbColumn object
* @nnul: value to set for nnul
*
* Since: 6.0
*/
void
-gda_ddl_column_set_nnul (GdaDdlColumn *self,
- gboolean nnul)
+gda_db_column_set_nnul (GdaDbColumn *self,
+ gboolean nnul)
{
g_return_if_fail (self);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
priv->m_nnul = nnul;
}
/**
- * gda_ddl_column_get_autoinc:
- * @self: a #GdaDdlColumn object
+ * gda_db_column_get_autoinc:
+ * @self: a #GdaDbColumn object
*
* Get value for autoinc key
*
@@ -761,16 +761,16 @@ gda_ddl_column_set_nnul (GdaDdlColumn *self,
* Since: 6.0
*/
gboolean
-gda_ddl_column_get_autoinc (GdaDdlColumn *self)
+gda_db_column_get_autoinc (GdaDbColumn *self)
{
g_return_val_if_fail (self,FALSE);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->m_autoinc;
}
/**
- * gda_ddl_column_set_autoinc:
- * @self: a #GdaDdlColumn object
+ * gda_db_column_set_autoinc:
+ * @self: a #GdaDbColumn object
* @autoinc: value to set
*
* Set value for auto-incremented key.
@@ -778,17 +778,17 @@ gda_ddl_column_get_autoinc (GdaDdlColumn *self)
* Since: 6.0
*/
void
-gda_ddl_column_set_autoinc (GdaDdlColumn *self,
- gboolean autoinc)
+gda_db_column_set_autoinc (GdaDbColumn *self,
+ gboolean autoinc)
{
g_return_if_fail (self);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
priv->m_autoinc = autoinc;
}
/**
- * gda_ddl_column_get_unique:
- * @self: a #GdaDdlColumn object
+ * gda_db_column_get_unique:
+ * @self: a #GdaDbColumn object
*
* Get value for unique key
*
@@ -797,16 +797,16 @@ gda_ddl_column_set_autoinc (GdaDdlColumn *self,
* Since: 6.0
*/
gboolean
-gda_ddl_column_get_unique (GdaDdlColumn *self)
+gda_db_column_get_unique (GdaDbColumn *self)
{
g_return_val_if_fail (self,FALSE);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->m_unique;
}
/**
- * gda_ddl_column_set_unique:
- * @self: a #GdaDdlColumn object
+ * gda_db_column_set_unique:
+ * @self: a #GdaDbColumn object
* @unique: value to set
*
* Set value for unique key.
@@ -814,17 +814,17 @@ gda_ddl_column_get_unique (GdaDdlColumn *self)
* Since: 6.0
*/
void
-gda_ddl_column_set_unique (GdaDdlColumn *self,
- gboolean unique)
+gda_db_column_set_unique (GdaDbColumn *self,
+ gboolean unique)
{
g_return_if_fail (self);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
priv->m_unique = unique;
}
/**
- * gda_ddl_column_get_comment:
- * @self: a #GdaDdlColumn object
+ * gda_db_column_get_comment:
+ * @self: a #GdaDbColumn object
*
* Get value for column comment.
*
@@ -834,17 +834,17 @@ gda_ddl_column_set_unique (GdaDdlColumn *self,
* Since: 6.0
*/
const gchar*
-gda_ddl_column_get_comment (GdaDdlColumn *self)
+gda_db_column_get_comment (GdaDbColumn *self)
{
g_return_val_if_fail (self,NULL);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->mp_comment;
}
/**
- * gda_ddl_column_set_comment:
- * @self: a #GdaDdlColumn object
+ * gda_db_column_set_comment:
+ * @self: a #GdaDbColumn object
* @comnt: comment to set
*
* Set value for column comment.
@@ -852,34 +852,34 @@ gda_ddl_column_get_comment (GdaDdlColumn *self)
* Since: 6.0
*/
void
-gda_ddl_column_set_comment (GdaDdlColumn *self,
- const gchar *comnt)
+gda_db_column_set_comment (GdaDbColumn *self,
+ const gchar *comnt)
{
g_return_if_fail (self);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
g_free (priv->mp_comment);
priv->mp_comment = g_strdup (comnt);
}
/**
- * gda_ddl_column_get_size:
- * @self: a #GdaDdlColumn instance
+ * gda_db_column_get_size:
+ * @self: a #GdaDbColumn instance
*
* Returns: Current value for column size.
*
* Since: 6.0
*/
guint
-gda_ddl_column_get_size (GdaDdlColumn *self)
+gda_db_column_get_size (GdaDbColumn *self)
{
g_return_val_if_fail (self,0);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->m_size;
}
/**
- * gda_ddl_column_set_size:
- * @self: a #GdaDdlColumn instance
+ * gda_db_column_set_size:
+ * @self: a #GdaDbColumn instance
* @size: value to set
*
* Set value for column size. This is relevant only for string column type.
@@ -887,17 +887,17 @@ gda_ddl_column_get_size (GdaDdlColumn *self)
* Since: 6.0
*/
void
-gda_ddl_column_set_size (GdaDdlColumn *self,
- guint size)
+gda_db_column_set_size (GdaDbColumn *self,
+ guint size)
{
g_return_if_fail (self);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
priv->m_size = size;
}
/**
- * gda_ddl_column_get_default:
- * @self: a #GdaDdlColumn instance
+ * gda_db_column_get_default:
+ * @self: a #GdaDbColumn instance
*
* Returns default value for the column. Can be %NULL if the default value hasn't been set.
*
@@ -906,33 +906,33 @@ gda_ddl_column_set_size (GdaDdlColumn *self,
* Since: 6.0
*/
const gchar*
-gda_ddl_column_get_default (GdaDdlColumn *self)
+gda_db_column_get_default (GdaDbColumn *self)
{
g_return_val_if_fail (self,NULL);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->mp_default;
}
/**
- * gda_ddl_column_set_default:
- * @self: a #GdaDdlColumn instance
+ * gda_db_column_set_default:
+ * @self: a #GdaDbColumn instance
* @value: default value to set for column as a string
*
* Since: 6.0
*/
void
-gda_ddl_column_set_default (GdaDdlColumn *self,
- const gchar *value)
+gda_db_column_set_default (GdaDbColumn *self,
+ const gchar *value)
{
g_return_if_fail (self);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
g_free(priv->mp_default);
priv->mp_default = g_strdup(value);
}
/**
- * gda_ddl_column_get_check:
- * @self: a #GdaDdlColumn instance
+ * gda_db_column_get_check:
+ * @self: a #GdaDbColumn instance
*
* Returns value of the check field.
*
@@ -941,16 +941,16 @@ gda_ddl_column_set_default (GdaDdlColumn *self,
* Since: 6.0
*/
const gchar*
-gda_ddl_column_get_check (GdaDdlColumn *self)
+gda_db_column_get_check (GdaDbColumn *self)
{
g_return_val_if_fail (self,NULL);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->mp_check;
}
/**
- * gda_ddl_column_set_check:
- * @self: a #GdaDdlColumn instance
+ * gda_db_column_set_check:
+ * @self: a #GdaDbColumn instance
* @value: value to set
*
* Sets check string to the column.
@@ -958,18 +958,18 @@ gda_ddl_column_get_check (GdaDdlColumn *self)
* Since: 6.0
*/
void
-gda_ddl_column_set_check (GdaDdlColumn *self,
- const gchar *value)
+gda_db_column_set_check (GdaDbColumn *self,
+ const gchar *value)
{
g_return_if_fail (self);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
g_free(priv->mp_check);
priv->mp_check = g_strdup(value);
}
/**
- * gda_ddl_column_prepare_create:
- * @self: a #GdaDdlColumn instance
+ * gda_db_column_prepare_create:
+ * @self: a #GdaDbColumn instance
* @op: a #GdaServerOperation instance to update for TABLE_CREATE operation
* @error: a #GError container
*
@@ -980,10 +980,10 @@ gda_ddl_column_set_check (GdaDdlColumn *self,
* Since: 6.0
*/
gboolean
-gda_ddl_column_prepare_create (GdaDdlColumn *self,
- GdaServerOperation *op,
- guint order,
- GError **error)
+gda_db_column_prepare_create (GdaDbColumn *self,
+ GdaServerOperation *op,
+ guint order,
+ GError **error)
{
GdaConnection *cnc;
const gchar *strtype;
@@ -991,13 +991,13 @@ gda_ddl_column_prepare_create (GdaDdlColumn *self,
g_return_val_if_fail(self,FALSE);
g_return_val_if_fail(op,FALSE);
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
if(!gda_server_operation_set_value_at (op, priv->mp_name, error, "/FIELDS_A/@COLUMN_NAME/%d", order))
return FALSE;
cnc = (GdaConnection*) g_object_get_data (G_OBJECT (op), "connection");
if (cnc == NULL) {
- g_set_error (error, GDA_DDL_COLUMN_ERROR, GDA_DDL_COLUMN_ERROR_TYPE,
+ g_set_error (error, GDA_DB_COLUMN_ERROR, GDA_DB_COLUMN_ERROR_TYPE,
_("Internal error: Operation should be prepared, setting a connection data"));
return FALSE;
}
@@ -1070,8 +1070,8 @@ gda_ddl_column_prepare_create (GdaDdlColumn *self,
}
/**
- * gda_ddl_column_prepare_add:
- * @self: a #GdaDdlColumn instance
+ * gda_db_column_prepare_add:
+ * @self: a #GdaDbColumn instance
* @op: #GdaServerOperation to add information
* @error: error storage container
*
@@ -1081,11 +1081,11 @@ gda_ddl_column_prepare_create (GdaDdlColumn *self,
* Returns: %TRUE if success, %FALSE otherwise.
*/
gboolean
-gda_ddl_column_prepare_add (GdaDdlColumn *self,
- GdaServerOperation *op,
- GError **error)
+gda_db_column_prepare_add (GdaDbColumn *self,
+ GdaServerOperation *op,
+ GError **error)
{
- GdaDdlColumnPrivate *priv = gda_ddl_column_get_instance_private (self);
+ GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
if(!gda_server_operation_set_value_at(op,priv->mp_name,error,
"/COLUMN_DEF_P/COLUMN_NAME/%d",priv->m_scale))
@@ -1135,22 +1135,22 @@ gda_ddl_column_prepare_add (GdaDdlColumn *self,
}
/**
- * gda_ddl_column_new_from_meta:
+ * gda_db_column_new_from_meta:
* @column: a #GdaMetaTableColumn instance
*
- * Create new #GdaDdlColumn instance from the corresponding #GdaMetaTableColumn
+ * Create new #GdaDbColumn instance from the corresponding #GdaMetaTableColumn
* object. If %NULL is passed this function works exactly as
- * gda_ddl_column_new()
+ * gda_db_column_new()
*
- * Returns: New object that should be freed with gda_ddl_column_free()
+ * Returns: New object that should be freed with gda_db_column_free()
*/
-GdaDdlColumn*
-gda_ddl_column_new_from_meta (GdaMetaTableColumn *column)
+GdaDbColumn*
+gda_db_column_new_from_meta (GdaMetaTableColumn *column)
{
if (!column)
- return gda_ddl_column_new();
+ return gda_db_column_new();
- GdaDdlColumn *gdacolumn = gda_ddl_column_new();
+ GdaDbColumn *gdacolumn = gda_db_column_new();
g_object_set (gdacolumn,
"name",column->column_name,
@@ -1159,7 +1159,7 @@ gda_ddl_column_new_from_meta (GdaMetaTableColumn *column)
"default",column->default_value,
NULL);
- gda_ddl_column_set_type (gdacolumn, column->gtype);
+ gda_db_column_set_type (gdacolumn, column->gtype);
return gdacolumn;
}
diff --git a/libgda/gda-db-column.h b/libgda/gda-db-column.h
new file mode 100644
index 000000000..371a0b45e
--- /dev/null
+++ b/libgda/gda-db-column.h
@@ -0,0 +1,111 @@
+/* gda-db-column.h
+ *
+ * Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+#ifndef GDA_DB_COLUMN_H
+#define GDA_DB_COLUMN_H
+
+#include <glib-object.h>
+#include <glib.h>
+#include <libxml/parser.h>
+#include "gda-db-buildable.h"
+#include "gda-server-operation.h"
+#include "gda-meta-struct.h"
+
+G_BEGIN_DECLS
+
+#define GDA_TYPE_DB_COLUMN (gda_db_column_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (GdaDbColumn, gda_db_column, GDA, DB_COLUMN, GObject)
+
+struct _GdaDbColumnClass
+{
+ GObjectClass parent;
+};
+
+/**
+ * GdaDbColumnError:
+ * @GDA_DB_COLUMN_ERROR_TYPE: Set if wrong column type was given in the xml file.
+ *
+ * Values used to describe the source of the error.
+ */
+typedef enum {
+ GDA_DB_COLUMN_ERROR_TYPE
+} GdaDbColumnError;
+
+#define GDA_DB_COLUMN_ERROR gda_db_column_error_quark()
+GQuark gda_db_column_error_quark (void);
+
+GdaDbColumn* gda_db_column_new (void);
+GdaDbColumn* gda_db_column_new_from_meta (GdaMetaTableColumn *column);
+
+const gchar* gda_db_column_get_name (GdaDbColumn *self);
+void gda_db_column_set_name (GdaDbColumn *self, const gchar *name);
+
+GType gda_db_column_get_gtype (GdaDbColumn *self);
+const gchar* gda_db_column_get_ctype (GdaDbColumn *self);
+void gda_db_column_set_type (GdaDbColumn *self, GType type);
+
+guint gda_db_column_get_scale (GdaDbColumn *self);
+void gda_db_column_set_scale (GdaDbColumn *self,
+ guint scale);
+
+gboolean gda_db_column_get_pkey (GdaDbColumn *self);
+void gda_db_column_set_pkey (GdaDbColumn *self,
+ gboolean pkey);
+
+gboolean gda_db_column_get_nnul (GdaDbColumn *self);
+void gda_db_column_set_nnul (GdaDbColumn *self,
+ gboolean nnul);
+
+gboolean gda_db_column_get_autoinc (GdaDbColumn *self);
+void gda_db_column_set_autoinc (GdaDbColumn *self,
+ gboolean autoinc);
+
+gboolean gda_db_column_get_unique (GdaDbColumn *self);
+void gda_db_column_set_unique (GdaDbColumn *self,
+ gboolean unique);
+
+const gchar* gda_db_column_get_comment (GdaDbColumn *self);
+void gda_db_column_set_comment (GdaDbColumn *self,
+ const gchar *comnt);
+
+guint gda_db_column_get_size (GdaDbColumn *self);
+void gda_db_column_set_size (GdaDbColumn *self,
+ guint size);
+
+const gchar* gda_db_column_get_default (GdaDbColumn *self);
+void gda_db_column_set_default (GdaDbColumn *self,
+ const gchar *value);
+
+const gchar* gda_db_column_get_check (GdaDbColumn *self);
+void gda_db_column_set_check (GdaDbColumn *self,
+ const gchar *value);
+
+gboolean gda_db_column_prepare_create (GdaDbColumn *self,
+ GdaServerOperation *op,
+ guint order,
+ GError **error);
+
+gboolean gda_db_column_prepare_add (GdaDbColumn *self,
+ GdaServerOperation *op,
+ GError **error);
+G_END_DECLS
+
+#endif /* GDA_DB_COLUMN_H */
+
diff --git a/libgda/gda-ddl-fkey.c b/libgda/gda-db-fkey.c
similarity index 61%
rename from libgda/gda-ddl-fkey.c
rename to libgda/gda-db-fkey.c
index e2f5a503e..52e8abfb3 100644
--- a/libgda/gda-ddl-fkey.c
+++ b/libgda/gda-db-fkey.c
@@ -1,4 +1,4 @@
-/* gda-ddl-fkey.c
+/* gda-db-fkey.c
*
* Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
*
@@ -17,9 +17,9 @@
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
-#include "gda-ddl-fkey.h"
+#include "gda-db-fkey.h"
#include <glib/gi18n-lib.h>
-#include "gda-ddl-buildable.h"
+#include "gda-db-buildable.h"
#include "gda-meta-struct.h"
typedef struct
@@ -32,29 +32,29 @@ typedef struct
/* /FKEY_S/FKEY_FIELDS_A/@FK_REF_PK_FIELD */
GList *mp_ref_field;
/* /FKEY_S/FKEY_ONUPDATE This action is reserved for ONUPDATE */
- GdaDdlFkeyReferenceAction m_onupdate;
+ GdaDbFkeyReferenceAction m_onupdate;
/* /FKEY_S/FKEY_ONDELETE This action is reserved for ONDELETE */
- GdaDdlFkeyReferenceAction m_ondelete;
-}GdaDdlFkeyPrivate;
+ GdaDbFkeyReferenceAction m_ondelete;
+}GdaDbFkeyPrivate;
/**
- * SECTION:gda-ddl-fkey
+ * SECTION:gda-db-fkey
* @short_description: Object to hold information for foregn key.
* @stability: Stable
* @include: libgda/libgda.h
*
* For generating database from xml file or for mapping
- * database to an xml file #GdaDdlFkey holds information about
+ * database to an xml file #GdaDbFkey holds information about
* foregn keys with a convenient set of methods to manipulate them.
- * #GdaDdlFkey implements #GdaDdlBuildable interface for parsing xml file.
+ * #GdaDbFkey implements #GdaDbBuildable interface for parsing xml file.
*/
-static void gda_ddl_fkey_buildable_interface_init (GdaDdlBuildableInterface *iface);
+static void gda_db_fkey_buildable_interface_init (GdaDbBuildableInterface *iface);
-G_DEFINE_TYPE_WITH_CODE (GdaDdlFkey, gda_ddl_fkey, G_TYPE_OBJECT,
- G_ADD_PRIVATE (GdaDdlFkey)
- G_IMPLEMENT_INTERFACE (GDA_TYPE_DDL_BUILDABLE,
- gda_ddl_fkey_buildable_interface_init))
+G_DEFINE_TYPE_WITH_CODE (GdaDbFkey, gda_db_fkey, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (GdaDbFkey)
+ G_IMPLEMENT_INTERFACE (GDA_TYPE_DB_BUILDABLE,
+ gda_db_fkey_buildable_interface_init))
static const gchar *OnAction[] = {
"NO ACTION",
@@ -66,17 +66,17 @@ static const gchar *OnAction[] = {
/* This is convenient way to name all nodes from xml file */
enum {
- GDA_DDL_FKEY_NODE,
- GDA_DDL_FKEY_REFTABLE,
- GDA_DDL_FKEY_ONUPDATE,
- GDA_DDL_FKEY_ONDELETE,
- GDA_DDL_FKEY_FKFIELD,
- GDA_DDL_FKEY_FKFIELD_NAME,
- GDA_DDL_FKEY_FKFIELD_REFIELD,
- GDA_DDL_FKEY_N_NODES
+ GDA_DB_FKEY_NODE,
+ GDA_DB_FKEY_REFTABLE,
+ GDA_DB_FKEY_ONUPDATE,
+ GDA_DB_FKEY_ONDELETE,
+ GDA_DB_FKEY_FKFIELD,
+ GDA_DB_FKEY_FKFIELD_NAME,
+ GDA_DB_FKEY_FKFIELD_REFIELD,
+ GDA_DB_FKEY_N_NODES
};
-const gchar *gdaddlfkeynodes[GDA_DDL_FKEY_N_NODES] = {
+const gchar *gdadbfkeynodes[GDA_DB_FKEY_N_NODES] = {
"fkey",
"reftable",
"onupdate",
@@ -87,40 +87,40 @@ const gchar *gdaddlfkeynodes[GDA_DDL_FKEY_N_NODES] = {
};
/**
- * gda_ddl_fkey_new:
+ * gda_db_fkey_new:
*
- * Create a new #GdaDdlFkey object.
+ * Create a new #GdaDbFkey object.
*
* Since: 6.0
*/
-GdaDdlFkey *
-gda_ddl_fkey_new (void)
+GdaDbFkey *
+gda_db_fkey_new (void)
{
- return g_object_new (GDA_TYPE_DDL_FKEY, NULL);
+ return g_object_new (GDA_TYPE_DB_FKEY, NULL);
}
/**
- * gda_ddl_fkey_new_from_meta:
+ * gda_db_fkey_new_from_meta:
* @metafkey: a #GdaMetaTableForeignKey instance
*
* Create a new instance from the corresponding meta object. If @metafkey is %NULL,
- * this function is identical to gda_ddl_fkey_new()
+ * this function is identical to gda_db_fkey_new()
*
*/
-GdaDdlFkey*
-gda_ddl_fkey_new_from_meta (GdaMetaTableForeignKey *metafkey)
+GdaDbFkey*
+gda_db_fkey_new_from_meta (GdaMetaTableForeignKey *metafkey)
{
if (!metafkey)
- return gda_ddl_fkey_new();
+ return gda_db_fkey_new();
GdaMetaDbObject *refobject = GDA_META_DB_OBJECT (metafkey->meta_table);
- GdaDdlFkey *fkey = gda_ddl_fkey_new ();
+ GdaDbFkey *fkey = gda_db_fkey_new ();
- gda_ddl_fkey_set_ref_table (fkey,refobject->obj_full_name);
+ gda_db_fkey_set_ref_table (fkey,refobject->obj_full_name);
for (gint i = 0; i < metafkey->cols_nb; i++)
- gda_ddl_fkey_set_field (fkey,
+ gda_db_fkey_set_field (fkey,
metafkey->fk_names_array[i],
metafkey->ref_pk_names_array[i]);
@@ -129,16 +129,16 @@ gda_ddl_fkey_new_from_meta (GdaMetaTableForeignKey *metafkey)
switch (policy)
{
case GDA_META_FOREIGN_KEY_NONE:
- gda_ddl_fkey_set_onupdate (fkey,GDA_DDL_FKEY_NO_ACTION);
+ gda_db_fkey_set_onupdate (fkey,GDA_DB_FKEY_NO_ACTION);
break;
case GDA_META_FOREIGN_KEY_CASCADE:
- gda_ddl_fkey_set_onupdate (fkey,GDA_DDL_FKEY_CASCADE);
+ gda_db_fkey_set_onupdate (fkey,GDA_DB_FKEY_CASCADE);
break;
case GDA_META_FOREIGN_KEY_RESTRICT:
- gda_ddl_fkey_set_onupdate (fkey,GDA_DDL_FKEY_RESTRICT);
+ gda_db_fkey_set_onupdate (fkey,GDA_DB_FKEY_RESTRICT);
break;
case GDA_META_FOREIGN_KEY_SET_DEFAULT:
- gda_ddl_fkey_set_onupdate (fkey,GDA_DDL_FKEY_SET_DEFAULT);
+ gda_db_fkey_set_onupdate (fkey,GDA_DB_FKEY_SET_DEFAULT);
break;
default:
break;
@@ -148,16 +148,16 @@ gda_ddl_fkey_new_from_meta (GdaMetaTableForeignKey *metafkey)
switch (policy)
{
case GDA_META_FOREIGN_KEY_NONE:
- gda_ddl_fkey_set_ondelete (fkey,GDA_DDL_FKEY_NO_ACTION);
+ gda_db_fkey_set_ondelete (fkey,GDA_DB_FKEY_NO_ACTION);
break;
case GDA_META_FOREIGN_KEY_CASCADE:
- gda_ddl_fkey_set_ondelete (fkey,GDA_DDL_FKEY_CASCADE);
+ gda_db_fkey_set_ondelete (fkey,GDA_DB_FKEY_CASCADE);
break;
case GDA_META_FOREIGN_KEY_RESTRICT:
- gda_ddl_fkey_set_ondelete (fkey,GDA_DDL_FKEY_RESTRICT);
+ gda_db_fkey_set_ondelete (fkey,GDA_DB_FKEY_RESTRICT);
break;
case GDA_META_FOREIGN_KEY_SET_DEFAULT:
- gda_ddl_fkey_set_ondelete (fkey,GDA_DDL_FKEY_SET_DEFAULT);
+ gda_db_fkey_set_ondelete (fkey,GDA_DB_FKEY_SET_DEFAULT);
break;
default:
break;
@@ -167,48 +167,48 @@ gda_ddl_fkey_new_from_meta (GdaMetaTableForeignKey *metafkey)
}
static void
-gda_ddl_fkey_finalize (GObject *object)
+gda_db_fkey_finalize (GObject *object)
{
- GdaDdlFkey *self = GDA_DDL_FKEY(object);
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkey *self = GDA_DB_FKEY(object);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
if (priv->mp_field) g_list_free_full (priv->mp_field, g_free);
if (priv->mp_ref_field) g_list_free_full (priv->mp_ref_field, g_free);
g_free(priv->mp_ref_table);
- G_OBJECT_CLASS (gda_ddl_fkey_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gda_db_fkey_parent_class)->finalize (object);
}
static void
-gda_ddl_fkey_class_init (GdaDdlFkeyClass *klass)
+gda_db_fkey_class_init (GdaDbFkeyClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gda_ddl_fkey_finalize;
+ object_class->finalize = gda_db_fkey_finalize;
}
static void
-gda_ddl_fkey_init (GdaDdlFkey *self)
+gda_db_fkey_init (GdaDbFkey *self)
{
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
priv->mp_field = NULL;
priv->mp_ref_field = NULL;
priv->mp_ref_table = NULL;
- priv->m_onupdate = GDA_DDL_FKEY_NO_ACTION;
- priv->m_ondelete = GDA_DDL_FKEY_NO_ACTION;
+ priv->m_onupdate = GDA_DB_FKEY_NO_ACTION;
+ priv->m_ondelete = GDA_DB_FKEY_NO_ACTION;
}
/**
- * gda_ddl_fkey_parse_node:
- * @self: #GdaDdlFkey object
+ * gda_db_fkey_parse_node:
+ * @self: #GdaDbFkey object
* @node: xml node to parse as #xmlNodePtr
* @error: #GError object to store error
*
- * Use this method to populate corresponding #GdaDdlFkey object from xml node. Usually,
- * this method is called from #GdaDdlCreator during parsing the input xml file.
+ * Use this method to populate corresponding #GdaDbFkey object from xml node. Usually,
+ * this method is called from #GdaDbCreator during parsing the input xml file.
*
* The corresponding DTD section suitable for parsing by this method should correspond
* th the following code:
@@ -229,7 +229,7 @@ gda_ddl_fkey_init (GdaDdlFkey *self)
* Since: 6.0
*/
static gboolean
-gda_ddl_fkey_parse_node (GdaDdlBuildable *buildable,
+gda_db_fkey_parse_node (GdaDbBuildable *buildable,
xmlNodePtr node,
GError **error)
{
@@ -243,15 +243,15 @@ gda_ddl_fkey_parse_node (GdaDdlBuildable *buildable,
* </fkey>
*/
xmlChar *name = NULL;
- if (g_strcmp0 ((gchar*)node->name,gdaddlfkeynodes[GDA_DDL_FKEY_NODE]))
+ if (g_strcmp0 ((gchar*)node->name,gdadbfkeynodes[GDA_DB_FKEY_NODE]))
return FALSE;
- GdaDdlFkey *self = GDA_DDL_FKEY (buildable);
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkey *self = GDA_DB_FKEY (buildable);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
xmlChar *prop = NULL;
- prop = xmlGetProp (node,(xmlChar *)gdaddlfkeynodes[GDA_DDL_FKEY_REFTABLE]);
+ prop = xmlGetProp (node,(xmlChar *)gdadbfkeynodes[GDA_DB_FKEY_REFTABLE]);
g_assert (prop); /* Bug with xml valdation */
@@ -259,16 +259,16 @@ gda_ddl_fkey_parse_node (GdaDdlBuildable *buildable,
xmlFree (prop);
prop = NULL;
- prop = xmlGetProp (node,(xmlChar *)gdaddlfkeynodes[GDA_DDL_FKEY_ONUPDATE]);
+ prop = xmlGetProp (node,(xmlChar *)gdadbfkeynodes[GDA_DB_FKEY_ONUPDATE]);
if (prop)
{
- priv->m_onupdate = GDA_DDL_FKEY_NO_ACTION;
+ priv->m_onupdate = GDA_DB_FKEY_NO_ACTION;
for (guint i = 0; i < G_N_ELEMENTS(OnAction);i++)
{
if (!g_strcmp0 ((gchar *)prop,OnAction[i]))
- priv->m_onupdate = (GdaDdlFkeyReferenceAction)i;
+ priv->m_onupdate = (GdaDbFkeyReferenceAction)i;
}
xmlFree (prop);
@@ -276,14 +276,14 @@ gda_ddl_fkey_parse_node (GdaDdlBuildable *buildable,
}
- prop = xmlGetProp (node,(xmlChar *)gdaddlfkeynodes[GDA_DDL_FKEY_ONDELETE]);
+ prop = xmlGetProp (node,(xmlChar *)gdadbfkeynodes[GDA_DB_FKEY_ONDELETE]);
if (prop)
{
for (guint i = 0; i < G_N_ELEMENTS(OnAction);i++)
{
if (!g_strcmp0 ((gchar *)prop,OnAction[i]))
- priv->m_ondelete = (GdaDdlFkeyReferenceAction)i;
+ priv->m_ondelete = (GdaDbFkeyReferenceAction)i;
}
xmlFree (prop);
@@ -296,15 +296,15 @@ gda_ddl_fkey_parse_node (GdaDdlBuildable *buildable,
for (xmlNodePtr it = node->children; it; it = it->next)
{
- if (!g_strcmp0 ((gchar *)it->name,gdaddlfkeynodes[GDA_DDL_FKEY_FKFIELD]))
+ if (!g_strcmp0 ((gchar *)it->name,gdadbfkeynodes[GDA_DB_FKEY_FKFIELD]))
{
- name = xmlGetProp (it,(xmlChar *)gdaddlfkeynodes[GDA_DDL_FKEY_FKFIELD_NAME]);
+ name = xmlGetProp (it,(xmlChar *)gdadbfkeynodes[GDA_DB_FKEY_FKFIELD_NAME]);
g_assert(name);
priv->mp_field = g_list_append (priv->mp_field,g_strdup ((const gchar *)name));
xmlFree (name);
- reffield = xmlGetProp (it,(xmlChar *)gdaddlfkeynodes[GDA_DDL_FKEY_FKFIELD_REFIELD]);
+ reffield = xmlGetProp (it,(xmlChar *)gdadbfkeynodes[GDA_DB_FKEY_FKFIELD_REFIELD]);
g_assert(reffield);
priv->mp_ref_field = g_list_append (priv->mp_ref_field,
g_strdup ((const gchar *)reffield));
@@ -315,8 +315,8 @@ gda_ddl_fkey_parse_node (GdaDdlBuildable *buildable,
}
/**
- * gda_ddl_fkey_write_node:
- * @self: An object #GdaDdlFkey
+ * gda_db_fkey_write_node:
+ * @self: An object #GdaDbFkey
* @writer: An object to #xmlTextWriterPtr instance
* @error: A place to store error
*
@@ -334,26 +334,26 @@ gda_ddl_fkey_parse_node (GdaDdlBuildable *buildable,
* Returns: TRUE if no error, FALSE otherwise
*/
static gboolean
-gda_ddl_fkey_write_node (GdaDdlBuildable *buildable,
+gda_db_fkey_write_node (GdaDbBuildable *buildable,
xmlNodePtr rootnode,
GError **error)
{
g_return_val_if_fail (buildable, FALSE);
g_return_val_if_fail (rootnode,FALSE);
- GdaDdlFkey *self = GDA_DDL_FKEY (buildable);
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkey *self = GDA_DB_FKEY (buildable);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
xmlNodePtr node = NULL;
- node = xmlNewChild (rootnode,NULL,(xmlChar*)gdaddlfkeynodes[GDA_DDL_FKEY_NODE],NULL);
+ node = xmlNewChild (rootnode,NULL,(xmlChar*)gdadbfkeynodes[GDA_DB_FKEY_NODE],NULL);
- xmlNewProp (node,BAD_CAST gdaddlfkeynodes[GDA_DDL_FKEY_REFTABLE],
+ xmlNewProp (node,BAD_CAST gdadbfkeynodes[GDA_DB_FKEY_REFTABLE],
BAD_CAST priv->mp_ref_table);
- xmlNewProp (node,BAD_CAST gdaddlfkeynodes[GDA_DDL_FKEY_ONUPDATE],
+ xmlNewProp (node,BAD_CAST gdadbfkeynodes[GDA_DB_FKEY_ONUPDATE],
BAD_CAST priv->m_onupdate);
- xmlNewProp (node,BAD_CAST gdaddlfkeynodes[GDA_DDL_FKEY_ONDELETE],
+ xmlNewProp (node,BAD_CAST gdadbfkeynodes[GDA_DB_FKEY_ONDELETE],
BAD_CAST priv->m_ondelete);
GList *it = priv->mp_field;
@@ -362,12 +362,12 @@ gda_ddl_fkey_write_node (GdaDdlBuildable *buildable,
for (; it && jt; it = it->next, jt=jt->next )
{
xmlNodePtr tnode = NULL;
- tnode = xmlNewChild (node,NULL,(xmlChar*)gdaddlfkeynodes[GDA_DDL_FKEY_FKFIELD],NULL);
+ tnode = xmlNewChild (node,NULL,(xmlChar*)gdadbfkeynodes[GDA_DB_FKEY_FKFIELD],NULL);
- xmlNewProp (tnode,(xmlChar*)gdaddlfkeynodes[GDA_DDL_FKEY_FKFIELD_NAME],
+ xmlNewProp (tnode,(xmlChar*)gdadbfkeynodes[GDA_DB_FKEY_FKFIELD_NAME],
BAD_CAST it->data);
- xmlNewProp (tnode,(xmlChar*)gdaddlfkeynodes[GDA_DDL_FKEY_FKFIELD_REFIELD],
+ xmlNewProp (tnode,(xmlChar*)gdadbfkeynodes[GDA_DB_FKEY_FKFIELD_REFIELD],
BAD_CAST jt->data);
}
@@ -375,15 +375,15 @@ gda_ddl_fkey_write_node (GdaDdlBuildable *buildable,
}
static void
-gda_ddl_fkey_buildable_interface_init (GdaDdlBuildableInterface *iface)
+gda_db_fkey_buildable_interface_init (GdaDbBuildableInterface *iface)
{
- iface->parse_node = gda_ddl_fkey_parse_node;
- iface->write_node = gda_ddl_fkey_write_node;
+ iface->parse_node = gda_db_fkey_parse_node;
+ iface->write_node = gda_db_fkey_write_node;
}
/**
- * gda_ddl_fkey_get_ondelete:
- * @self: An object #GdaDdlFkey
+ * gda_db_fkey_get_ondelete:
+ * @self: An object #GdaDbFkey
*
* Return: ON DELETE action as a string. If the action is not set then the string corresponding to
* NO_ACTION is returned.
@@ -391,110 +391,110 @@ gda_ddl_fkey_buildable_interface_init (GdaDdlBuildableInterface *iface)
* Since: 6.0
*/
const gchar *
-gda_ddl_fkey_get_ondelete (GdaDdlFkey *self)
+gda_db_fkey_get_ondelete (GdaDbFkey *self)
{
g_return_val_if_fail (self,NULL);
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
return OnAction[priv->m_ondelete];
}
/**
- * gda_ddl_fkey_get_ondelete_id:
- * @self: a #GdaDdlFkey object
+ * gda_db_fkey_get_ondelete_id:
+ * @self: a #GdaDbFkey object
*
* The default value is %NO_ACTION
*
- * Return: ON DELETE action as a #GdaDdlFkeyReferenceAction.
+ * Return: ON DELETE action as a #GdaDbFkeyReferenceAction.
*
* Since: 6.0
*/
-GdaDdlFkeyReferenceAction
-gda_ddl_fkey_get_ondelete_id (GdaDdlFkey *self)
+GdaDbFkeyReferenceAction
+gda_db_fkey_get_ondelete_id (GdaDbFkey *self)
{
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
return priv->m_ondelete;
}
/**
- * gda_ddl_fkey_set_onupdate:
- * @self: An object #GdaDdlFkey
- * @id: #GdaDdlFkeyReferenceAction action to set
+ * gda_db_fkey_set_onupdate:
+ * @self: An object #GdaDbFkey
+ * @id: #GdaDbFkeyReferenceAction action to set
*
* Set action for ON_UPDATE
*
* Since: 6.0
*/
void
-gda_ddl_fkey_set_onupdate (GdaDdlFkey *self,
- GdaDdlFkeyReferenceAction id)
+gda_db_fkey_set_onupdate (GdaDbFkey *self,
+ GdaDbFkeyReferenceAction id)
{
g_return_if_fail (self);
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
priv->m_onupdate = id;
}
/**
- * gda_ddl_fkey_set_ondelete:
- * @self: An object #GdaDdlFkey
- * @id: #GdaDdlFkeyReferenceAction action to set
+ * gda_db_fkey_set_ondelete:
+ * @self: An object #GdaDbFkey
+ * @id: #GdaDbFkeyReferenceAction action to set
*
* Set action for ON_DELETE
*
* Since: 6.0
*/
void
-gda_ddl_fkey_set_ondelete (GdaDdlFkey *self,
- GdaDdlFkeyReferenceAction id)
+gda_db_fkey_set_ondelete (GdaDbFkey *self,
+ GdaDbFkeyReferenceAction id)
{
g_return_if_fail (self);
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
priv->m_ondelete = id;
}
/**
- * gda_ddl_fkey_get_onupdate:
- * @self: a #GdaDdlFkey instance
+ * gda_db_fkey_get_onupdate:
+ * @self: a #GdaDbFkey instance
*
* Returns: ON_UPDATE action as a string. Never %NULL
*
* Since: 6.0
*/
const gchar *
-gda_ddl_fkey_get_onupdate (GdaDdlFkey *self)
+gda_db_fkey_get_onupdate (GdaDbFkey *self)
{
g_return_val_if_fail (self,NULL);
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
return OnAction[priv->m_onupdate];
}
/**
- * gda_ddl_fkey_get_onupdate_id:
- * @self: a #GdaDdlFkey instance
+ * gda_db_fkey_get_onupdate_id:
+ * @self: a #GdaDbFkey instance
*
- * Return: ON_UPDATE action as a #GdaDdlFkeyReferenceAction
+ * Return: ON_UPDATE action as a #GdaDbFkeyReferenceAction
*
* Since: 6.0
*/
-GdaDdlFkeyReferenceAction
-gda_ddl_fkey_get_onupdate_id (GdaDdlFkey *self)
+GdaDbFkeyReferenceAction
+gda_db_fkey_get_onupdate_id (GdaDbFkey *self)
{
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
return priv->m_onupdate;
}
/**
- * gda_ddl_fkey_get_ref_table:
- * @self: a #GdaDdlFkey object
+ * gda_db_fkey_get_ref_table:
+ * @self: a #GdaDbFkey object
*
* Return: Returns reference table name as a string or %NULL if table name
* hasn't been set.
@@ -502,18 +502,18 @@ gda_ddl_fkey_get_onupdate_id (GdaDdlFkey *self)
* Since: 6.0
*/
const gchar *
-gda_ddl_fkey_get_ref_table (GdaDdlFkey *self)
+gda_db_fkey_get_ref_table (GdaDbFkey *self)
{
g_return_val_if_fail (self, NULL);
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
return priv->mp_ref_table;
}
/**
- * gda_ddl_fkey_set_ref_table:
- * @self: #GdaDdlFkey object
+ * gda_db_fkey_set_ref_table:
+ * @self: #GdaDbFkey object
* @rtable: reference table name
*
* Set reference table
@@ -521,20 +521,20 @@ gda_ddl_fkey_get_ref_table (GdaDdlFkey *self)
* Since: 6.0
*/
void
-gda_ddl_fkey_set_ref_table (GdaDdlFkey *self,
+gda_db_fkey_set_ref_table (GdaDbFkey *self,
const gchar *rtable)
{
g_return_if_fail (self);
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
g_free (priv->mp_ref_table);
priv->mp_ref_table = g_strdup (rtable);
}
/**
- * gda_ddl_fkey_get_field_name:
- * @self: a #GdaDdlFkey object
+ * gda_db_fkey_get_field_name:
+ * @self: a #GdaDbFkey object
*
* Returns: (element-type utf8) (transfer none): A const #GList of strings where each string
* corresponds to a foreign key field or %NULL.
@@ -542,18 +542,18 @@ gda_ddl_fkey_set_ref_table (GdaDdlFkey *self,
* Since: 6.0
*/
const GList*
-gda_ddl_fkey_get_field_name (GdaDdlFkey *self)
+gda_db_fkey_get_field_name (GdaDbFkey *self)
{
g_return_val_if_fail (self, NULL);
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
return priv->mp_field;
}
/**
- * gda_ddl_fkey_get_ref_field:
- * @self: a #GdaDdlFkey object
+ * gda_db_fkey_get_ref_field:
+ * @self: a #GdaDbFkey object
*
* Returns: (element-type utf8) (transfer none): A #GList of strings where each string corresponds
* to a foreign key reference field or %NULL.
@@ -561,18 +561,18 @@ gda_ddl_fkey_get_field_name (GdaDdlFkey *self)
* Since: 6.0
*/
const GList *
-gda_ddl_fkey_get_ref_field (GdaDdlFkey *self)
+gda_db_fkey_get_ref_field (GdaDbFkey *self)
{
g_return_val_if_fail (self,NULL);
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
return priv->mp_ref_field;
}
/**
- * gda_ddl_fkey_set_field:
- * @self: An object #GdaDdlFkey
+ * gda_db_fkey_set_field:
+ * @self: An object #GdaDbFkey
* @field: Field name as a string
* @reffield: A reference field name as a string
*
@@ -581,7 +581,7 @@ gda_ddl_fkey_get_ref_field (GdaDdlFkey *self)
* Since: 6.0
*/
void
-gda_ddl_fkey_set_field (GdaDdlFkey *self,
+gda_db_fkey_set_field (GdaDbFkey *self,
const gchar *field,
const gchar *reffield)
{
@@ -589,15 +589,15 @@ gda_ddl_fkey_set_field (GdaDdlFkey *self,
g_return_if_fail (field);
g_return_if_fail (reffield);
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
priv->mp_field = g_list_append (priv->mp_field,(gpointer)field);
priv->mp_ref_field = g_list_append(priv->mp_ref_field,(gpointer)reffield);
}
/**
- * gda_ddl_fkey_prepare_create:
- * @self: a #GdaDdlFkey instance
+ * gda_db_fkey_prepare_create:
+ * @self: a #GdaDbFkey instance
* @op: a #GdaServerOperation to populate
* @error: error container
*
@@ -608,12 +608,12 @@ gda_ddl_fkey_set_field (GdaDdlFkey *self,
* Since: 6.0
*/
gboolean
-gda_ddl_fkey_prepare_create (GdaDdlFkey *self,
+gda_db_fkey_prepare_create (GdaDbFkey *self,
GdaServerOperation *op,
gint i,
GError **error)
{
- GdaDdlFkeyPrivate *priv = gda_ddl_fkey_get_instance_private (self);
+ GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
if (!gda_server_operation_set_value_at (op,
priv->mp_ref_table,
diff --git a/libgda/gda-db-fkey.h b/libgda/gda-db-fkey.h
new file mode 100644
index 000000000..ab5d6597f
--- /dev/null
+++ b/libgda/gda-db-fkey.h
@@ -0,0 +1,99 @@
+/* gda-db-fkey.h
+ *
+ * Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+#ifndef GDA_DB_FKEY_H
+#define GDA_DB_FKEY_H
+
+#include <glib-object.h>
+#include <gmodule.h>
+#include <glib.h>
+#include <libxml/parser.h>
+#include <libxml/xmlwriter.h>
+#include "gda-db-buildable.h"
+#include "gda-server-operation.h"
+#include "gda-meta-struct.h"
+
+G_BEGIN_DECLS
+
+#define GDA_TYPE_DB_FKEY (gda_db_fkey_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (GdaDbFkey, gda_db_fkey, GDA, DB_FKEY, GObject)
+
+struct _GdaDbFkeyClass {
+ GObjectClass parent_class;
+};
+
+/**
+ * GdaDbFkeyReferenceAction:
+ * @GDA_DB_FKEY_NO_ACTION: Action is not specified.
+ * @GDA_DB_FKEY_SET_NULL: Action value is set to %NULL
+ * @GDA_DB_FKEY_RESTRICT: Value is set to "RESTRICT"
+ * @GDA_DB_FKEY_SET_DEFAULT: Value is set to default behavior
+ * @GDA_DB_FKEY_CASCADE: Value is set to cascade
+ *
+ * Specify numeric value for the actions, e.g. "ON DELETE" and "ON UPDATE"
+ */
+typedef enum {
+ GDA_DB_FKEY_NO_ACTION,
+ GDA_DB_FKEY_SET_NULL,
+ GDA_DB_FKEY_RESTRICT,
+ GDA_DB_FKEY_SET_DEFAULT,
+ GDA_DB_FKEY_CASCADE
+} GdaDbFkeyReferenceAction;
+
+
+GdaDbFkey* gda_db_fkey_new (void);
+
+const GList* gda_db_fkey_get_field_name (GdaDbFkey *self);
+const GList* gda_db_fkey_get_ref_field (GdaDbFkey *self);
+
+void gda_db_fkey_set_field (GdaDbFkey *self,
+ const gchar *field,
+ const gchar *reffield);
+
+const gchar* gda_db_fkey_get_ref_table (GdaDbFkey *self);
+void gda_db_fkey_set_ref_table (GdaDbFkey *self,
+ const gchar *rtable);
+
+const gchar* gda_db_fkey_get_ondelete (GdaDbFkey *self);
+
+GdaDbFkeyReferenceAction
+ gda_db_fkey_get_ondelete_id (GdaDbFkey *self);
+
+void gda_db_fkey_set_ondelete (GdaDbFkey *self,
+ GdaDbFkeyReferenceAction id);
+
+const gchar* gda_db_fkey_get_onupdate (GdaDbFkey *self);
+
+GdaDbFkeyReferenceAction
+ gda_db_fkey_get_onupdate_id (GdaDbFkey *self);
+
+void gda_db_fkey_set_onupdate (GdaDbFkey *self,
+ GdaDbFkeyReferenceAction id);
+
+gboolean gda_db_fkey_prepare_create (GdaDbFkey *self,
+ GdaServerOperation *op,
+ gint i,
+ GError **error);
+GdaDbFkey *gda_db_fkey_new_from_meta (GdaMetaTableForeignKey *metafkey);
+
+G_END_DECLS
+
+#endif /* GDA_DB_FKEY_H */
+
diff --git a/libgda/gda-ddl-table.c b/libgda/gda-db-table.c
similarity index 64%
rename from libgda/gda-ddl-table.c
rename to libgda/gda-db-table.c
index 62b1fc79e..9d0010ddb 100644
--- a/libgda/gda-ddl-table.c
+++ b/libgda/gda-db-table.c
@@ -1,4 +1,4 @@
-/* gda-ddl-table.c
+/* gda-db-table.c
*
* Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
*
@@ -18,9 +18,9 @@
* Boston, MA 02110-1301, USA.
*/
-#include "gda-ddl-table.h"
-#include "gda-ddl-fkey.h"
-#include "gda-ddl-column.h"
+#include "gda-db-table.h"
+#include "gda-db-fkey.h"
+#include "gda-db-column.h"
#include <libgda/sql-parser/gda-sql-statement.h>
#include <libgda/gda-lockable.h>
#include "gda-server-provider.h"
@@ -28,36 +28,36 @@
#include "gda-meta-struct.h"
#include <glib/gi18n-lib.h>
-G_DEFINE_QUARK (gda_ddl_table_error,gda_ddl_table_error)
+G_DEFINE_QUARK (gda_db_table_error,gda_db_table_error)
typedef struct
{
gchar *mp_comment;
gboolean m_istemp;
- GList *mp_columns; /* Type GdaDdlColumn*/
- GList *mp_fkeys; /* List of all fkeys, GdaDdlFkey */
-} GdaDdlTablePrivate;
+ GList *mp_columns; /* Type GdaDbColumn*/
+ GList *mp_fkeys; /* List of all fkeys, GdaDbFkey */
+} GdaDbTablePrivate;
/**
- * SECTION:gda-ddl-table
- * @title: GdaDdlTable
+ * SECTION:gda-db-table
+ * @title: GdaDbTable
* @short_description: Object to represent table database object
- * @see_also: #GdaDdlView, #GdaDdlCreator
+ * @see_also: #GdaDbView, #GdaDbCreator
* @stability: Stable
* @include: libgda/libgda.h
*
* This object represents a table of a database. The table view can be constracted manually
- * using API or generated from xml file together with other databse objects. See #GdaDdlCreator.
- * #GdaDdlTable implements #GdaDdlBuildable interface for parsing xml file.
+ * using API or generated from xml file together with other databse objects. See #GdaDbCreator.
+ * #GdaDbTable implements #GdaDbBuildable interface for parsing xml file.
*/
-static void gda_ddl_table_buildable_interface_init (GdaDdlBuildableInterface *iface);
+static void gda_db_table_buildable_interface_init (GdaDbBuildableInterface *iface);
-G_DEFINE_TYPE_WITH_CODE (GdaDdlTable, gda_ddl_table, GDA_TYPE_DDL_BASE,
- G_ADD_PRIVATE (GdaDdlTable)
- G_IMPLEMENT_INTERFACE (GDA_TYPE_DDL_BUILDABLE,
- gda_ddl_table_buildable_interface_init))
+G_DEFINE_TYPE_WITH_CODE (GdaDbTable, gda_db_table, GDA_TYPE_DB_BASE,
+ G_ADD_PRIVATE (GdaDbTable)
+ G_IMPLEMENT_INTERFACE (GDA_TYPE_DB_BUILDABLE,
+ gda_db_table_buildable_interface_init))
enum {
PROP_0,
@@ -71,16 +71,16 @@ static GParamSpec *properties [N_PROPS] = {NULL};
/* This is a convenient way to name all nodes from xml file */
enum {
- GDA_DDL_TABLE_NODE,
- GDA_DDL_TABLE_NAME,
- GDA_DDL_TABLE_TEMP,
- GDA_DDL_TABLE_SPACE,
- GDA_DDL_TABLE_COMMENT,
+ GDA_DB_TABLE_NODE,
+ GDA_DB_TABLE_NAME,
+ GDA_DB_TABLE_TEMP,
+ GDA_DB_TABLE_SPACE,
+ GDA_DB_TABLE_COMMENT,
- GDA_DDL_TABLE_N_NODES
+ GDA_DB_TABLE_N_NODES
};
-const gchar *gdaddltablenodes[GDA_DDL_TABLE_N_NODES] = {
+const gchar *gdadbtablenodes[GDA_DB_TABLE_N_NODES] = {
"table",
"name",
"temptable",
@@ -89,49 +89,49 @@ const gchar *gdaddltablenodes[GDA_DDL_TABLE_N_NODES] = {
};
/**
- * gda_ddl_table_new:
+ * gda_db_table_new:
*
- * Returns: New instance of #GdaDdlTable.
+ * Returns: New instance of #GdaDbTable.
*/
-GdaDdlTable *
-gda_ddl_table_new (void)
+GdaDbTable *
+gda_db_table_new (void)
{
- return g_object_new (GDA_TYPE_DDL_TABLE, NULL);
+ return g_object_new (GDA_TYPE_DB_TABLE, NULL);
}
static void
-gda_ddl_table_finalize (GObject *object)
+gda_db_table_finalize (GObject *object)
{
- GdaDdlTable *self = (GdaDdlTable *)object;
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTable *self = (GdaDbTable *)object;
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
g_free (priv->mp_comment);
- G_OBJECT_CLASS (gda_ddl_table_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gda_db_table_parent_class)->finalize (object);
}
static void
-gda_ddl_table_dispose (GObject *object)
+gda_db_table_dispose (GObject *object)
{
- GdaDdlTable *self = (GdaDdlTable *)object;
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTable *self = (GdaDbTable *)object;
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
if (priv->mp_fkeys)
g_list_free_full (priv->mp_fkeys, (GDestroyNotify) g_object_unref);
if (priv->mp_columns)
g_list_free_full (priv->mp_columns, (GDestroyNotify)g_object_unref);
- G_OBJECT_CLASS (gda_ddl_table_parent_class)->dispose (object);
+ G_OBJECT_CLASS (gda_db_table_parent_class)->dispose (object);
}
static void
-gda_ddl_table_get_property (GObject *object,
+gda_db_table_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
- GdaDdlTable *self = GDA_DDL_TABLE (object);
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTable *self = GDA_DB_TABLE (object);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
switch (prop_id) {
case PROP_COMMENT:
@@ -147,13 +147,13 @@ gda_ddl_table_get_property (GObject *object,
}
static void
-gda_ddl_table_set_property (GObject *object,
+gda_db_table_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
- GdaDdlTable *self = GDA_DDL_TABLE (object);
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTable *self = GDA_DB_TABLE (object);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
switch (prop_id) {
case PROP_COMMENT:
@@ -169,14 +169,14 @@ gda_ddl_table_set_property (GObject *object,
}
static void
-gda_ddl_table_class_init (GdaDdlTableClass *klass)
+gda_db_table_class_init (GdaDbTableClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gda_ddl_table_finalize;
- object_class->dispose = gda_ddl_table_dispose;
- object_class->get_property = gda_ddl_table_get_property;
- object_class->set_property = gda_ddl_table_set_property;
+ object_class->finalize = gda_db_table_finalize;
+ object_class->dispose = gda_db_table_dispose;
+ object_class->get_property = gda_db_table_get_property;
+ object_class->set_property = gda_db_table_set_property;
properties[PROP_COMMENT] = g_param_spec_string ("comment",
"Comment",
@@ -193,9 +193,9 @@ gda_ddl_table_class_init (GdaDdlTableClass *klass)
}
static void
-gda_ddl_table_init (GdaDdlTable *self)
+gda_db_table_init (GdaDbTable *self)
{
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
priv->mp_columns = NULL;
priv->m_istemp = FALSE;
@@ -204,8 +204,8 @@ gda_ddl_table_init (GdaDdlTable *self)
}
/**
- * gda_ddl_table_parse_node:
- * @self: a #GdaDdlTable object
+ * gda_db_table_parse_node:
+ * @self: a #GdaDbTable object
* @node: instance of #xmlNodePtr to parse
* @error: #GError to handle an error
*
@@ -216,23 +216,23 @@ gda_ddl_table_init (GdaDdlTable *self)
* Since: 6.0
*/
static gboolean
-gda_ddl_table_parse_node (GdaDdlBuildable *buildable,
+gda_db_table_parse_node (GdaDbBuildable *buildable,
xmlNodePtr node,
GError **error)
{
g_return_val_if_fail (buildable,FALSE);
g_return_val_if_fail (node, FALSE);
- GdaDdlTable *self = GDA_DDL_TABLE (buildable);
+ GdaDbTable *self = GDA_DB_TABLE (buildable);
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
xmlChar *name = NULL;
- name = xmlGetProp (node,(xmlChar *)gdaddltablenodes[GDA_DDL_TABLE_NAME]);
+ name = xmlGetProp (node,(xmlChar *)gdadbtablenodes[GDA_DB_TABLE_NAME]);
g_assert (name); /* If here bug with xml validation */
- gda_ddl_base_set_name(GDA_DDL_BASE(self),(gchar *)name);
+ gda_db_base_set_name(GDA_DB_BASE(self),(gchar *)name);
- xmlChar *tempt = xmlGetProp (node,(xmlChar*)gdaddltablenodes[GDA_DDL_TABLE_TEMP]);
+ xmlChar *tempt = xmlGetProp (node,(xmlChar*)gdadbtablenodes[GDA_DB_TABLE_TEMP]);
if (tempt && (*tempt == 't' || *tempt == 't'))
{
@@ -242,7 +242,7 @@ gda_ddl_table_parse_node (GdaDdlBuildable *buildable,
for (xmlNodePtr it = node->children; it ; it = it->next)
{
- if (!g_strcmp0 ((gchar *) it->name,gdaddltablenodes[GDA_DDL_TABLE_COMMENT]))
+ if (!g_strcmp0 ((gchar *) it->name,gdadbtablenodes[GDA_DB_TABLE_COMMENT]))
{
xmlChar *comment = xmlNodeGetContent (it);
@@ -254,9 +254,9 @@ gda_ddl_table_parse_node (GdaDdlBuildable *buildable,
}
else if (!g_strcmp0 ((gchar *) it->name, "column"))
{
- GdaDdlColumn *column = gda_ddl_column_new ();
+ GdaDbColumn *column = gda_db_column_new ();
- if (!gda_ddl_buildable_parse_node(GDA_DDL_BUILDABLE (column),
+ if (!gda_db_buildable_parse_node(GDA_DB_BUILDABLE (column),
it, error))
{
g_object_unref(column);
@@ -267,10 +267,10 @@ gda_ddl_table_parse_node (GdaDdlBuildable *buildable,
}
else if (!g_strcmp0 ((gchar *) it->name, "fkey"))
{
- GdaDdlFkey *fkey;
- fkey = gda_ddl_fkey_new ();
+ GdaDbFkey *fkey;
+ fkey = gda_db_fkey_new ();
- if (!gda_ddl_buildable_parse_node (GDA_DDL_BUILDABLE(fkey), it, error)) {
+ if (!gda_db_buildable_parse_node (GDA_DB_BUILDABLE(fkey), it, error)) {
g_object_unref (fkey);
return FALSE;
} else
@@ -278,35 +278,35 @@ gda_ddl_table_parse_node (GdaDdlBuildable *buildable,
} /* end of else if */
} /* End of for loop */
return TRUE;
-} /* End of gda_ddl_column_parse_node */
+} /* End of gda_db_column_parse_node */
static gboolean
-gda_ddl_table_write_node (GdaDdlBuildable *buildable,
+gda_db_table_write_node (GdaDbBuildable *buildable,
xmlNodePtr rootnode,
GError **error)
{
g_return_val_if_fail (buildable,FALSE);
g_return_val_if_fail (rootnode,FALSE);
- GdaDdlTable *self = GDA_DDL_TABLE (buildable);
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTable *self = GDA_DB_TABLE (buildable);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
xmlNodePtr node = NULL;
- node = xmlNewChild (rootnode,NULL,(xmlChar*)gdaddltablenodes[GDA_DDL_TABLE_NODE],NULL);
- xmlNewProp (node,BAD_CAST gdaddltablenodes[GDA_DDL_TABLE_NAME],
- BAD_CAST gda_ddl_base_get_name (GDA_DDL_BASE(self)));
+ node = xmlNewChild (rootnode,NULL,(xmlChar*)gdadbtablenodes[GDA_DB_TABLE_NODE],NULL);
+ xmlNewProp (node,BAD_CAST gdadbtablenodes[GDA_DB_TABLE_NAME],
+ BAD_CAST gda_db_base_get_name (GDA_DB_BASE(self)));
- xmlNewProp (node,BAD_CAST gdaddltablenodes[GDA_DDL_TABLE_TEMP],
+ xmlNewProp (node,BAD_CAST gdadbtablenodes[GDA_DB_TABLE_TEMP],
BAD_CAST GDA_BOOL_TO_STR (priv->m_istemp));
xmlNewChild (node,NULL,
- (xmlChar*)gdaddltablenodes[GDA_DDL_TABLE_COMMENT],
+ (xmlChar*)gdadbtablenodes[GDA_DB_TABLE_COMMENT],
(xmlChar*)priv->mp_comment);
GList *it = NULL;
for (it = priv->mp_columns; it; it=it->next)
- if(!gda_ddl_buildable_write_node (GDA_DDL_BUILDABLE(GDA_DDL_COLUMN(it->data)),
+ if(!gda_db_buildable_write_node (GDA_DB_BUILDABLE(GDA_DB_COLUMN(it->data)),
node,error))
return FALSE;
@@ -314,15 +314,15 @@ gda_ddl_table_write_node (GdaDdlBuildable *buildable,
}
static void
-gda_ddl_table_buildable_interface_init (GdaDdlBuildableInterface *iface)
+gda_db_table_buildable_interface_init (GdaDbBuildableInterface *iface)
{
- iface->parse_node = gda_ddl_table_parse_node;
- iface->write_node = gda_ddl_table_write_node;
+ iface->parse_node = gda_db_table_parse_node;
+ iface->write_node = gda_db_table_write_node;
}
/**
- * gda_ddl_table_set_comment:
- * @self: an #GdaDdlTable object
+ * gda_db_table_set_comment:
+ * @self: an #GdaDbTable object
* @tablecomment: Comment to set as a string
*
* If @tablecomment is %NULL nothing is happened. @tablecomment will not be set
@@ -331,21 +331,21 @@ gda_ddl_table_buildable_interface_init (GdaDdlBuildableInterface *iface)
* Since: 6.0
*/
void
-gda_ddl_table_set_comment (GdaDdlTable *self,
+gda_db_table_set_comment (GdaDbTable *self,
const char *tablecomment)
{
g_return_if_fail (self);
if (tablecomment) {
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
g_free (priv->mp_comment);
priv->mp_comment = g_utf8_strup (tablecomment,g_utf8_strlen (tablecomment,-1));
}
}
/**
- * gda_ddl_table_set_is_temp:
- * @self: a #GdaDdlTable object
+ * gda_db_table_set_is_temp:
+ * @self: a #GdaDbTable object
* @istemp: Set if the table should be temporary
*
* Set if the table should be temporary or not. False is set by default.
@@ -353,31 +353,31 @@ gda_ddl_table_set_comment (GdaDdlTable *self,
* Since: 6.0
*/
void
-gda_ddl_table_set_is_temp (GdaDdlTable *self,
+gda_db_table_set_is_temp (GdaDbTable *self,
gboolean istemp)
{
g_return_if_fail (self);
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
priv->m_istemp = istemp;
}
/**
- * gda_ddl_table_get_comment:
- * @self: a #GdaDdlTable object
+ * gda_db_table_get_comment:
+ * @self: a #GdaDbTable object
*
* Returns: A comment string or %NULL if comment wasn't set.
*/
const char*
-gda_ddl_table_get_comment (GdaDdlTable *self)
+gda_db_table_get_comment (GdaDbTable *self)
{
g_return_val_if_fail (self, NULL);
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
return priv->mp_comment;
}
/**
- * gda_ddl_table_get_temp:
- * @self: a #GdaDdlTable object
+ * gda_db_table_get_temp:
+ * @self: a #GdaDbTable object
*
* Returns temp key. If %TRUE table should be temporary, %FALSE otherwise.
* If @self is %NULL, this function aborts. So check @self before calling this
@@ -386,20 +386,20 @@ gda_ddl_table_get_comment (GdaDdlTable *self)
* Since: 6.0
*/
gboolean
-gda_ddl_table_get_temp (GdaDdlTable *self)
+gda_db_table_get_temp (GdaDbTable *self)
{
g_return_val_if_fail (self,FALSE);
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
return priv->m_istemp;
}
gboolean
-gda_ddl_table_is_valid (GdaDdlTable *self)
+gda_db_table_is_valid (GdaDbTable *self)
{
g_return_val_if_fail (self,FALSE);
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
/* TODO: It may be worthwhile to have the same method for all children elements and
* call this method on each children member to make sure whole table is valid
@@ -411,50 +411,50 @@ gda_ddl_table_is_valid (GdaDdlTable *self)
}
/**
- * gda_ddl_table_get_columns:
- * @self: an #GdaDdlTable object
+ * gda_db_table_get_columns:
+ * @self: an #GdaDbTable object
*
* Use this method to obtain internal list of all columns. The internal list
* should not be freed.
*
- * Returns: (element-type Gda.DdlColumn) (transfer none): A list of #GdaDdlColumn objects or %NULL if the
internal list is
+ * Returns: (element-type Gda.DbColumn) (transfer none): A list of #GdaDbColumn objects or %NULL if the
internal list is
* not set or if %NULL is passed.
*
* Since: 6.0
*/
GList*
-gda_ddl_table_get_columns (GdaDdlTable *self)
+gda_db_table_get_columns (GdaDbTable *self)
{
g_return_val_if_fail (self, NULL);
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
return priv->mp_columns;
}
/**
- * gda_ddl_table_get_fkeys:
- * @self: A #GdaDdlTable object
+ * gda_db_table_get_fkeys:
+ * @self: A #GdaDbTable object
*
* Use this method to obtain internal list of all fkeys. The internal list
* should not be freed.
*
- * Returns: (transfer none) (element-type Gda.DdlFkey): A list of #GdaDdlFkey objects or %NULL if the
internal list is not
+ * Returns: (transfer none) (element-type Gda.DbFkey): A list of #GdaDbFkey objects or %NULL if the internal
list is not
* set or %NULL is passed
*
* Since: 6.0
*/
GList*
-gda_ddl_table_get_fkeys (GdaDdlTable *self)
+gda_db_table_get_fkeys (GdaDbTable *self)
{
g_return_val_if_fail (self, NULL);
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
return priv->mp_fkeys;
}
/**
- * gda_ddl_table_is_temp:
- * @self: a #GdaDdlTable object
+ * gda_db_table_is_temp:
+ * @self: a #GdaDbTable object
*
* Checks if the table is temporary
*
@@ -463,17 +463,17 @@ gda_ddl_table_get_fkeys (GdaDdlTable *self)
* Since: 6.0
*/
gboolean
-gda_ddl_table_get_is_temp (GdaDdlTable *self)
+gda_db_table_get_is_temp (GdaDbTable *self)
{
- g_return_val_if_fail (GDA_IS_DDL_TABLE(self), FALSE);
+ g_return_val_if_fail (GDA_IS_DB_TABLE(self), FALSE);
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
return priv->m_istemp;
}
/**
- * gda_ddl_table_prepare_create:
- * @self: a #GdaDdlTable instance
+ * gda_db_table_prepare_create:
+ * @self: a #GdaDbTable instance
* @op: an instance of #GdaServerOperation to populate.
* @error: error container
*
@@ -483,15 +483,15 @@ gda_ddl_table_get_is_temp (GdaDdlTable *self)
* Since: 6.0
*/
gboolean
-gda_ddl_table_prepare_create (GdaDdlTable *self,
+gda_db_table_prepare_create (GdaDbTable *self,
GdaServerOperation *op,
gboolean ifnotexists,
GError **error)
{
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
if (!gda_server_operation_set_value_at (op,
- gda_ddl_base_get_name (GDA_DDL_BASE(self)),
+ gda_db_base_get_name (GDA_DB_BASE(self)),
error,
"/TABLE_DEF_P/TABLE_NAME"))
return FALSE;
@@ -518,19 +518,19 @@ gda_ddl_table_prepare_create (GdaDdlTable *self,
gint i = 0; /* column order counter */
for (it = priv->mp_columns;it;it=it->next)
- if(!gda_ddl_column_prepare_create (GDA_DDL_COLUMN (it->data), op, i++, error))
+ if(!gda_db_column_prepare_create (GDA_DB_COLUMN (it->data), op, i++, error))
return FALSE;
i = 0;
for (it = priv->mp_fkeys;it;it=it->next)
- if(!gda_ddl_fkey_prepare_create (GDA_DDL_FKEY(it->data), op, i++, error))
+ if(!gda_db_fkey_prepare_create (GDA_DB_FKEY(it->data), op, i++, error))
return FALSE;
return TRUE;
}
static gint
-_gda_ddl_compare_column_meta(GdaMetaTableColumn *a,GdaDdlColumn *b)
+_gda_db_compare_column_meta(GdaMetaTableColumn *a,GdaDbColumn *b)
{
if (a && !b)
return 1;
@@ -540,14 +540,14 @@ _gda_ddl_compare_column_meta(GdaMetaTableColumn *a,GdaDdlColumn *b)
return 0;
const gchar *namea = a->column_name;
- const gchar *nameb = gda_ddl_column_get_name(b);
+ const gchar *nameb = gda_db_column_get_name(b);
return g_strcmp0(namea,nameb);
}
/**
- * gda_ddl_table_update:
- * @self: a #GdaDdlTable instance
+ * gda_db_table_update:
+ * @self: a #GdaDbTable instance
* @obj: The corresponding meta object to take data from
* @cnc: opened connection
* @error: error container
@@ -558,7 +558,7 @@ _gda_ddl_compare_column_meta(GdaMetaTableColumn *a,GdaDdlColumn *b)
* Returns: %TRUE if no error and %FALSE otherwise
*/
gboolean
-gda_ddl_table_update (GdaDdlTable *self,
+gda_db_table_update (GdaDbTable *self,
GdaMetaTable *obj,
GdaConnection *cnc,
GError **error)
@@ -570,11 +570,11 @@ gda_ddl_table_update (GdaDdlTable *self,
if (!gda_connection_is_opened(cnc))
return FALSE;
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
if (!obj->columns)
{
- g_set_error (error,GDA_DDL_TABLE_ERROR,GDA_DDL_TABLE_COLUMN_EMPTY,_("Empty column list"));
+ g_set_error (error,GDA_DB_TABLE_ERROR,GDA_DB_TABLE_COLUMN_EMPTY,_("Empty column list"));
return FALSE;
}
@@ -599,7 +599,7 @@ gda_ddl_table_update (GdaDdlTable *self,
goto on_error;
if(!gda_server_operation_set_value_at(op,
- gda_ddl_base_get_full_name(GDA_DDL_BASE(self)),
+ gda_db_base_get_full_name(GDA_DB_BASE(self)),
error,
"/COLUMN_DEF_P/TABLE_NAME"))
goto on_error;
@@ -609,14 +609,14 @@ gda_ddl_table_update (GdaDdlTable *self,
{
GSList *res = g_slist_find_custom (dbcolumns,
it->data,
- (GCompareFunc)_gda_ddl_compare_column_meta);
+ (GCompareFunc)_gda_db_compare_column_meta);
if (res) /* If object is present we need go to next element */
continue;
else
newcolumncount++; /* We need to count new column. See below */
- if(!gda_ddl_column_prepare_add(it->data,op,error))
+ if(!gda_db_column_prepare_add(it->data,op,error))
{
g_slist_free (res);
goto on_error;
@@ -638,8 +638,8 @@ on_error:
}
/**
- * gda_ddl_table_create:
- * @self: a #GdaDdlTable object
+ * gda_db_table_create:
+ * @self: a #GdaDbTable object
* @cnc: a #GdaConnection object
* @ifnotexists: Set to %TRUE if table should be created with "IFNOTEXISTS" option
* @error: container for error storage
@@ -652,7 +652,7 @@ on_error:
* Since: 6.0
*/
gboolean
-gda_ddl_table_create (GdaDdlTable *self,
+gda_db_table_create (GdaDbTable *self,
GdaConnection *cnc,
gboolean ifnotexists,
GError **error)
@@ -663,8 +663,8 @@ gda_ddl_table_create (GdaDdlTable *self,
if (!gda_connection_is_opened (cnc))
{
g_set_error (error,
- GDA_DDL_CREATOR_ERROR,
- GDA_DDL_CREATOR_CONNECTION_CLOSED,
+ GDA_DB_CATALOG_ERROR,
+ GDA_DB_CATALOG_CONNECTION_CLOSED,
_("Connection is not opened"));
return FALSE;
}
@@ -683,7 +683,7 @@ gda_ddl_table_create (GdaDdlTable *self,
error);
if (op) {
g_object_set_data_full (G_OBJECT (op), "connection", g_object_ref (cnc), g_object_unref);
- if (gda_ddl_table_prepare_create(self, op, ifnotexists, error)) {
+ if (gda_db_table_prepare_create(self, op, ifnotexists, error)) {
#ifdef GDA_DEBUG_NO
gchar* str = gda_server_operation_render (op, error);
g_message ("Operation: %s", str);
@@ -699,28 +699,28 @@ gda_ddl_table_create (GdaDdlTable *self,
}
/**
- * gda_ddl_table_new_from_meta:
+ * gda_db_table_new_from_meta:
* @obj: a #GdaMetaDbObject
*
- * Create new #GdaDdlTable instance from the corresponding #GdaMetaDbObject
+ * Create new #GdaDbTable instance from the corresponding #GdaMetaDbObject
* object. If %NULL is passed this function works exactly as
- * gda_ddl_table_new()
+ * gda_db_table_new()
*
* Since: 6.0
*/
-GdaDdlTable*
-gda_ddl_table_new_from_meta (GdaMetaDbObject *obj)
+GdaDbTable*
+gda_db_table_new_from_meta (GdaMetaDbObject *obj)
{
if (!obj)
- return gda_ddl_table_new();
+ return gda_db_table_new();
if (obj->obj_type != GDA_META_DB_TABLE)
return NULL;
GdaMetaTable *metatable = GDA_META_TABLE(obj);
- GdaDdlTable *table = gda_ddl_table_new();
+ GdaDbTable *table = gda_db_table_new();
- gda_ddl_base_set_names(GDA_DDL_BASE(table),
+ gda_db_base_set_names(GDA_DB_BASE(table),
obj->obj_catalog,
obj->obj_schema,
obj->obj_name);
@@ -728,9 +728,9 @@ gda_ddl_table_new_from_meta (GdaMetaDbObject *obj)
GSList *it = NULL;
for (it = metatable->columns; it; it = it->next)
{
- GdaDdlColumn *column = gda_ddl_column_new_from_meta (GDA_META_TABLE_COLUMN(it->data));
+ GdaDbColumn *column = gda_db_column_new_from_meta (GDA_META_TABLE_COLUMN(it->data));
- gda_ddl_table_append_column(table,column);
+ gda_db_table_append_column(table,column);
}
it = NULL;
@@ -739,9 +739,9 @@ gda_ddl_table_new_from_meta (GdaMetaDbObject *obj)
if (!GDA_META_TABLE_FOREIGN_KEY_IS_DECLARED(GDA_META_TABLE_FOREIGN_KEY(it->data)))
continue;
- GdaDdlFkey *fkey = gda_ddl_fkey_new_from_meta (GDA_META_TABLE_FOREIGN_KEY(it->data));
+ GdaDbFkey *fkey = gda_db_fkey_new_from_meta (GDA_META_TABLE_FOREIGN_KEY(it->data));
- gda_ddl_table_append_fkey (table,fkey);
+ gda_db_table_append_fkey (table,fkey);
}
@@ -749,8 +749,8 @@ gda_ddl_table_new_from_meta (GdaMetaDbObject *obj)
}
/**
- * gda_ddl_table_append_column:
- * @self: a #GdaDdlTable instance
+ * gda_db_table_append_column:
+ * @self: a #GdaDbTable instance
* @column: column to add
*
* Append @column to the internal list of columns
@@ -758,19 +758,19 @@ gda_ddl_table_new_from_meta (GdaMetaDbObject *obj)
* Since: 6.0
*/
void
-gda_ddl_table_append_column (GdaDdlTable *self,
- GdaDdlColumn *column)
+gda_db_table_append_column (GdaDbTable *self,
+ GdaDbColumn *column)
{
g_return_if_fail (self);
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
priv->mp_columns = g_list_append (priv->mp_columns,g_object_ref(column));
}
/**
- * gda_ddl_table_append_fkey:
- * @self: a #GdaDdlTable instance
+ * gda_db_table_append_fkey:
+ * @self: a #GdaDbTable instance
* @fkey: fkry to add
*
* Append @fkey to the internal list of columns
@@ -778,12 +778,12 @@ gda_ddl_table_append_column (GdaDdlTable *self,
* Since: 6.0
*/
void
-gda_ddl_table_append_fkey (GdaDdlTable *self,
- GdaDdlFkey *fkey)
+gda_db_table_append_fkey (GdaDbTable *self,
+ GdaDbFkey *fkey)
{
g_return_if_fail (self);
- GdaDdlTablePrivate *priv = gda_ddl_table_get_instance_private (self);
+ GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
priv->mp_fkeys = g_list_append (priv->mp_fkeys,g_object_ref(fkey));
}
diff --git a/libgda/gda-ddl-table.h b/libgda/gda-db-table.h
similarity index 52%
rename from libgda/gda-ddl-table.h
rename to libgda/gda-db-table.h
index a2ec6ab85..bab507642 100644
--- a/libgda/gda-ddl-table.h
+++ b/libgda/gda-db-table.h
@@ -17,12 +17,12 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __GDA_DDL_TABLE_H__
-#define __GDA_DDL_TABLE_H__
+#ifndef __GDA_DB_TABLE_H__
+#define __GDA_DB_TABLE_H__
-#include "gda-ddl-base.h"
-#include "gda-ddl-column.h"
-#include "gda-ddl-fkey.h"
+#include "gda-db-base.h"
+#include "gda-db-column.h"
+#include "gda-db-fkey.h"
#include <libxml/parser.h>
#include <libxml/xmlwriter.h>
#include "gda-server-operation.h"
@@ -31,59 +31,59 @@
G_BEGIN_DECLS
-#define GDA_TYPE_DDL_TABLE (gda_ddl_table_get_type())
+#define GDA_TYPE_DB_TABLE (gda_db_table_get_type())
-G_DECLARE_DERIVABLE_TYPE(GdaDdlTable, gda_ddl_table, GDA, DDL_TABLE, GdaDdlBase)
+G_DECLARE_DERIVABLE_TYPE(GdaDbTable, gda_db_table, GDA, DB_TABLE, GdaDbBase)
-struct _GdaDdlTableClass {
- GdaDdlBaseClass parent_class;
+struct _GdaDbTableClass {
+ GdaDbBaseClass parent_class;
};
/**
- * GdaDdlTableError:
- * @GDA_DDL_TABLE_COLUMN_EMPTY: Table doesn't contain columns
+ * GdaDbTableError:
+ * @GDA_DB_TABLE_COLUMN_EMPTY: Table doesn't contain columns
*
*/
typedef enum {
- GDA_DDL_TABLE_COLUMN_EMPTY,
-}GdaDdlTableError;
+ GDA_DB_TABLE_COLUMN_EMPTY,
+}GdaDbTableError;
-#define GDA_DDL_TABLE_ERROR gda_ddl_table_error_quark()
-GQuark gda_ddl_table_error_quark(void);
+#define GDA_DB_TABLE_ERROR gda_db_table_error_quark()
+GQuark gda_db_table_error_quark(void);
-GdaDdlTable* gda_ddl_table_new (void);
-gboolean gda_ddl_table_is_valid (GdaDdlTable *self);
-GList* gda_ddl_table_get_columns (GdaDdlTable *self);
-GList* gda_ddl_table_get_fkeys (GdaDdlTable *self);
+GdaDbTable* gda_db_table_new (void);
+gboolean gda_db_table_is_valid (GdaDbTable *self);
+GList* gda_db_table_get_columns (GdaDbTable *self);
+GList* gda_db_table_get_fkeys (GdaDbTable *self);
-void gda_ddl_table_append_column (GdaDdlTable *self,
- GdaDdlColumn *column);
+void gda_db_table_append_column (GdaDbTable *self,
+ GdaDbColumn *column);
-gboolean gda_ddl_table_get_is_temp (GdaDdlTable *self);
-void gda_ddl_table_set_is_temp (GdaDdlTable *self,
+gboolean gda_db_table_get_is_temp (GdaDbTable *self);
+void gda_db_table_set_is_temp (GdaDbTable *self,
gboolean istemp);
-gboolean gda_ddl_table_prepare_create (GdaDdlTable *self,
+gboolean gda_db_table_prepare_create (GdaDbTable *self,
GdaServerOperation *op,
gboolean ifnotexists,
GError **error);
-gboolean gda_ddl_table_update (GdaDdlTable *self,
+gboolean gda_db_table_update (GdaDbTable *self,
GdaMetaTable *obj,
GdaConnection *cnc,
GError **error);
-gboolean gda_ddl_table_create (GdaDdlTable *self,
+gboolean gda_db_table_create (GdaDbTable *self,
GdaConnection *cnc,
gboolean ifnotexists,
GError **error);
-GdaDdlTable *gda_ddl_table_new_from_meta (GdaMetaDbObject *obj);
+GdaDbTable *gda_db_table_new_from_meta (GdaMetaDbObject *obj);
-void gda_ddl_table_append_fkey (GdaDdlTable *self,
- GdaDdlFkey *fkey);
+void gda_db_table_append_fkey (GdaDbTable *self,
+ GdaDbFkey *fkey);
G_END_DECLS
-#endif /* end of include guard: GDA-DDL-TABLE_H */
+#endif /* end of include guard: GDA-DB-TABLE_H */
diff --git a/libgda/gda-ddl-view.c b/libgda/gda-db-view.c
similarity index 64%
rename from libgda/gda-ddl-view.c
rename to libgda/gda-db-view.c
index 9790e93f6..e415c96c2 100644
--- a/libgda/gda-ddl-view.c
+++ b/libgda/gda-db-view.c
@@ -1,4 +1,4 @@
-/* gda-ddl-view.c
+/* gda-db-view.c
*
* Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
*
@@ -19,9 +19,9 @@
*/
#include <glib/gi18n-lib.h>
-#include "gda-ddl-view.h"
-#include "gda-ddl-buildable.h"
-#include "gda-ddl-base.h"
+#include "gda-db-view.h"
+#include "gda-db-buildable.h"
+#include "gda-db-base.h"
#include "gda-lockable.h"
#include "gda-server-provider.h"
@@ -31,39 +31,39 @@ typedef struct
gboolean m_istemp;
gboolean m_ifnoexist;
gboolean m_replace;
-} GdaDdlViewPrivate;
+} GdaDbViewPrivate;
/**
- * SECTION:gda-ddl-view
+ * SECTION:gda-db-view
* @short_description: Object to represent view database object
- * @see_also: GdaDdlTable, GdaDdlCreator
+ * @see_also: GdaDbTable, GdaDbCreator
* @stability: Stable
* @include: libgda/libgda.h
*
* This object represents a view of a database. The view can be constracted manually
- * using API or generated from xml file together with other databse objects. See #GdaDdlCreator.
- * #GdaDdlView implements #GdaDdlBuildable interface for parsing xml file.
+ * using API or generated from xml file together with other databse objects. See #GdaDbCreator.
+ * #GdaDbView implements #GdaDbBuildable interface for parsing xml file.
*/
-static void gda_ddl_view_buildable_interface_init (GdaDdlBuildableInterface *iface);
+static void gda_db_view_buildable_interface_init (GdaDbBuildableInterface *iface);
-G_DEFINE_TYPE_WITH_CODE (GdaDdlView, gda_ddl_view, GDA_TYPE_DDL_BASE,
- G_ADD_PRIVATE (GdaDdlView)
- G_IMPLEMENT_INTERFACE (GDA_TYPE_DDL_BUILDABLE,
- gda_ddl_view_buildable_interface_init))
+G_DEFINE_TYPE_WITH_CODE (GdaDbView, gda_db_view, GDA_TYPE_DB_BASE,
+ G_ADD_PRIVATE (GdaDbView)
+ G_IMPLEMENT_INTERFACE (GDA_TYPE_DB_BUILDABLE,
+ gda_db_view_buildable_interface_init))
/* This is convenient way to name all nodes from xml file */
enum {
- GDA_DDL_VIEW_NODE,
- GDA_DDL_VIEW_IFNOEXIST,
- GDA_DDL_VIEW_TEMP,
- GDA_DDL_VIEW_REPLACE,
- GDA_DDL_VIEW_NAME,
- GDA_DDL_VIEW_DEFSTR,
- GDA_DDL_VIEW_N_NODES
+ GDA_DB_VIEW_NODE,
+ GDA_DB_VIEW_IFNOEXIST,
+ GDA_DB_VIEW_TEMP,
+ GDA_DB_VIEW_REPLACE,
+ GDA_DB_VIEW_NAME,
+ GDA_DB_VIEW_DEFSTR,
+ GDA_DB_VIEW_N_NODES
};
-const gchar *gdaddlviewnodes[GDA_DDL_VIEW_N_NODES] = {
+const gchar *gdadbviewnodes[GDA_DB_VIEW_N_NODES] = {
"view",
"ifnoexist",
"temp",
@@ -84,37 +84,37 @@ enum {
static GParamSpec *properties [N_PROPS] = {NULL};
/**
- * gda_ddl_view_new:
+ * gda_db_view_new:
*
- * Returns: A new instance of #GdaDdlView.
+ * Returns: A new instance of #GdaDbView.
*
* Since: 6.0
*/
-GdaDdlView*
-gda_ddl_view_new (void)
+GdaDbView*
+gda_db_view_new (void)
{
- return g_object_new (GDA_TYPE_DDL_VIEW, NULL);
+ return g_object_new (GDA_TYPE_DB_VIEW, NULL);
}
static void
-gda_ddl_view_finalize (GObject *object)
+gda_db_view_finalize (GObject *object)
{
- GdaDdlView *self = GDA_DDL_VIEW(object);
- GdaDdlViewPrivate *priv = gda_ddl_view_get_instance_private (self);
+ GdaDbView *self = GDA_DB_VIEW(object);
+ GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
g_free (priv->mp_defstring);
- G_OBJECT_CLASS (gda_ddl_view_parent_class)->finalize (object);
+ G_OBJECT_CLASS (gda_db_view_parent_class)->finalize (object);
}
static void
-gda_ddl_view_get_property (GObject *object,
+gda_db_view_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
- GdaDdlView *self = GDA_DDL_VIEW (object);
- GdaDdlViewPrivate *priv = gda_ddl_view_get_instance_private (self);
+ GdaDbView *self = GDA_DB_VIEW (object);
+ GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
switch (prop_id) {
case PROP_VIEW_TEMP:
@@ -136,13 +136,13 @@ gda_ddl_view_get_property (GObject *object,
}
static void
-gda_ddl_view_set_property (GObject *object,
+gda_db_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
- GdaDdlView *self = GDA_DDL_VIEW (object);
- GdaDdlViewPrivate *priv = gda_ddl_view_get_instance_private (self);
+ GdaDbView *self = GDA_DB_VIEW (object);
+ GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
switch (prop_id){
case PROP_VIEW_TEMP:
@@ -165,13 +165,13 @@ gda_ddl_view_set_property (GObject *object,
}
static void
-gda_ddl_view_class_init (GdaDdlViewClass *klass)
+gda_db_view_class_init (GdaDbViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = gda_ddl_view_finalize;
- object_class->get_property = gda_ddl_view_get_property;
- object_class->set_property = gda_ddl_view_set_property;
+ object_class->finalize = gda_db_view_finalize;
+ object_class->get_property = gda_db_view_get_property;
+ object_class->set_property = gda_db_view_set_property;
properties[PROP_VIEW_TEMP] =
g_param_spec_boolean ("istemp",
@@ -202,9 +202,9 @@ gda_ddl_view_class_init (GdaDdlViewClass *klass)
}
static void
-gda_ddl_view_init (GdaDdlView *self)
+gda_db_view_init (GdaDbView *self)
{
- GdaDdlViewPrivate *priv = gda_ddl_view_get_instance_private (self);
+ GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
priv->mp_defstring = NULL;
priv->mp_defstring = NULL;
@@ -212,11 +212,11 @@ gda_ddl_view_init (GdaDdlView *self)
}
static gboolean
-gda_ddl_view_parse_node (GdaDdlBuildable *buildable,
+gda_db_view_parse_node (GdaDbBuildable *buildable,
xmlNodePtr node,
GError **error)
{
- GdaDdlView *self = GDA_DDL_VIEW (buildable);
+ GdaDbView *self = GDA_DB_VIEW (buildable);
g_return_val_if_fail (node, FALSE);
/*
@@ -227,28 +227,28 @@ gda_ddl_view_parse_node (GdaDdlBuildable *buildable,
xmlChar *prop = NULL;
- prop = xmlGetProp (node,(xmlChar *)gdaddlviewnodes[GDA_DDL_VIEW_NAME]);
+ prop = xmlGetProp (node,(xmlChar *)gdadbviewnodes[GDA_DB_VIEW_NAME]);
g_assert (prop); /* Bug with xml valdation */
- gda_ddl_base_set_name(GDA_DDL_BASE(self),(gchar*)prop);
+ gda_db_base_set_name(GDA_DB_BASE(self),(gchar*)prop);
xmlFree (prop);
prop = NULL;
- prop = xmlGetProp (node,(xmlChar *)gdaddlviewnodes[GDA_DDL_VIEW_REPLACE]);
+ prop = xmlGetProp (node,(xmlChar *)gdadbviewnodes[GDA_DB_VIEW_REPLACE]);
if (prop)
g_object_set (G_OBJECT(self),"replace",*prop == 't' || *prop == 'T' ? TRUE : FALSE, NULL);
xmlFree (prop);
prop = NULL;
- prop = xmlGetProp (node,(xmlChar *)gdaddlviewnodes[GDA_DDL_VIEW_TEMP]);
+ prop = xmlGetProp (node,(xmlChar *)gdadbviewnodes[GDA_DB_VIEW_TEMP]);
if (prop)
g_object_set (G_OBJECT(self),"istemp",*prop == 't' || *prop == 'T' ? TRUE : FALSE, NULL);
xmlFree (prop);
prop = NULL;
- prop = xmlGetProp (node,(xmlChar *)gdaddlviewnodes[GDA_DDL_VIEW_IFNOEXIST]);
+ prop = xmlGetProp (node,(xmlChar *)gdadbviewnodes[GDA_DB_VIEW_IFNOEXIST]);
if (prop)
g_object_set (G_OBJECT(self),"ifnoexist",*prop == 't' || *prop == 'T' ? TRUE : FALSE, NULL);
@@ -259,10 +259,10 @@ gda_ddl_view_parse_node (GdaDdlBuildable *buildable,
*/
for (xmlNodePtr it = node->children; it ; it = it->next)
{
- if (!g_strcmp0 ((char *)it->name,gdaddlviewnodes[GDA_DDL_VIEW_DEFSTR]))
+ if (!g_strcmp0 ((char *)it->name,gdadbviewnodes[GDA_DB_VIEW_DEFSTR]))
{
xmlChar *def = xmlNodeGetContent (it);
- gda_ddl_view_set_defstring (self,(gchar*)def);
+ gda_db_view_set_defstring (self,(gchar*)def);
xmlFree (def);
}
}
@@ -271,150 +271,150 @@ gda_ddl_view_parse_node (GdaDdlBuildable *buildable,
}
static gboolean
-gda_ddl_view_write_node (GdaDdlBuildable *buildable,
+gda_db_view_write_node (GdaDbBuildable *buildable,
xmlNodePtr rootnode,
GError **error)
{
g_return_val_if_fail (buildable,FALSE);
g_return_val_if_fail (rootnode,FALSE);
- GdaDdlView *self = GDA_DDL_VIEW (buildable);
- GdaDdlViewPrivate *priv = gda_ddl_view_get_instance_private (self);
+ GdaDbView *self = GDA_DB_VIEW (buildable);
+ GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
xmlNodePtr node = NULL;
node = xmlNewChild (rootnode,
NULL,
- BAD_CAST gdaddlviewnodes[GDA_DDL_VIEW_NODE],
+ BAD_CAST gdadbviewnodes[GDA_DB_VIEW_NODE],
NULL);
xmlNewProp (node,
- BAD_CAST gdaddlviewnodes[GDA_DDL_VIEW_NODE],
- BAD_CAST gda_ddl_base_get_name (GDA_DDL_BASE(self)));
+ BAD_CAST gdadbviewnodes[GDA_DB_VIEW_NODE],
+ BAD_CAST gda_db_base_get_name (GDA_DB_BASE(self)));
xmlNewProp (node,
- BAD_CAST gdaddlviewnodes[GDA_DDL_VIEW_REPLACE],
+ BAD_CAST gdadbviewnodes[GDA_DB_VIEW_REPLACE],
BAD_CAST GDA_BOOL_TO_STR(priv->m_replace));
xmlNewProp (node,
- BAD_CAST gdaddlviewnodes[GDA_DDL_VIEW_TEMP],
+ BAD_CAST gdadbviewnodes[GDA_DB_VIEW_TEMP],
BAD_CAST GDA_BOOL_TO_STR(priv->m_istemp));
xmlNewProp (node,
- BAD_CAST gdaddlviewnodes[GDA_DDL_VIEW_IFNOEXIST],
+ BAD_CAST gdadbviewnodes[GDA_DB_VIEW_IFNOEXIST],
BAD_CAST GDA_BOOL_TO_STR(priv->m_ifnoexist));
xmlNewChild (node,
NULL,
- BAD_CAST gdaddlviewnodes[GDA_DDL_VIEW_DEFSTR],
+ BAD_CAST gdadbviewnodes[GDA_DB_VIEW_DEFSTR],
BAD_CAST priv->mp_defstring);
return TRUE;
}
static void
-gda_ddl_view_buildable_interface_init (GdaDdlBuildableInterface *iface)
+gda_db_view_buildable_interface_init (GdaDbBuildableInterface *iface)
{
- iface->parse_node = gda_ddl_view_parse_node;
- iface->write_node = gda_ddl_view_write_node;
+ iface->parse_node = gda_db_view_parse_node;
+ iface->write_node = gda_db_view_write_node;
}
/**
- * gda_ddl_view_get_istemp:
- * @self: a #GdaDdlView object
+ * gda_db_view_get_istemp:
+ * @self: a #GdaDbView object
*
* Returns: %TRUE if the view is temporary, %FALSE otherwise
* Since: 6.0
*/
gboolean
-gda_ddl_view_get_istemp (GdaDdlView *self)
+gda_db_view_get_istemp (GdaDbView *self)
{
g_return_val_if_fail (self, FALSE);
- GdaDdlViewPrivate *priv = gda_ddl_view_get_instance_private (self);
+ GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
return priv->m_istemp;
}
/**
- * gda_ddl_view_set_istemp:
- * @self: a #GdaDdlView object
+ * gda_db_view_set_istemp:
+ * @self: a #GdaDbView object
* @temp: value to set
*
* Since: 6.0
*/
void
-gda_ddl_view_set_istemp (GdaDdlView *self,gboolean temp)
+gda_db_view_set_istemp (GdaDbView *self,gboolean temp)
{
g_return_if_fail (self);
- GdaDdlViewPrivate *priv = gda_ddl_view_get_instance_private (self);
+ GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
priv->m_istemp = temp;
}
/**
- * gda_ddl_view_get_ifnoexist:
- * @self: a #GdaDdlView object
+ * gda_db_view_get_ifnoexist:
+ * @self: a #GdaDbView object
*
* Returns: %TRUE if th view should be created with "IF NOT EXISTS" key, %FALSE
* otherwise
* Since: 6.0
*/
gboolean
-gda_ddl_view_get_ifnoexist (GdaDdlView *self)
+gda_db_view_get_ifnoexist (GdaDbView *self)
{
g_return_val_if_fail (self,FALSE);
- GdaDdlViewPrivate *priv = gda_ddl_view_get_instance_private (self);
+ GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
return priv->m_ifnoexist;
}
/**
- * gda_ddl_view_set_ifnoexist:
- * @self: a #GdaDdlView object
+ * gda_db_view_set_ifnoexist:
+ * @self: a #GdaDbView object
* @noexist: a value to set
*
* Since: 6.0
*/
void
-gda_ddl_view_set_ifnoexist (GdaDdlView *self,
+gda_db_view_set_ifnoexist (GdaDbView *self,
gboolean noexist)
{
g_return_if_fail (self);
- GdaDdlViewPrivate *priv = gda_ddl_view_get_instance_private (self);
+ GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
priv->m_ifnoexist = noexist;
}
/**
- * gda_ddl_view_get_defstring:
- * @self: a #GdaDdlView object
+ * gda_db_view_get_defstring:
+ * @self: a #GdaDbView object
*
* Returns: view definition string
* Sinc: 6.0
*/
const gchar*
-gda_ddl_view_get_defstring (GdaDdlView *self)
+gda_db_view_get_defstring (GdaDbView *self)
{
g_return_val_if_fail (self,FALSE);
- GdaDdlViewPrivate *priv = gda_ddl_view_get_instance_private (self);
+ GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
return priv->mp_defstring;
}
/**
- * gda_ddl_view_set_defstring:
- * @self: a #GdaDdlView object
+ * gda_db_view_set_defstring:
+ * @self: a #GdaDbView object
* @str: view definition string to set. Should be valid SQL string
*
* Since: 6.0
*/
void
-gda_ddl_view_set_defstring (GdaDdlView *self,
+gda_db_view_set_defstring (GdaDbView *self,
const gchar *str)
{
g_return_if_fail (self);
- GdaDdlViewPrivate *priv = gda_ddl_view_get_instance_private (self);
+ GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
g_free (priv->mp_defstring);
priv->mp_defstring = g_strdup (str);
}
/**
- * gda_ddl_view_get_replace:
- * @self: a #GdaDdlView object
+ * gda_db_view_get_replace:
+ * @self: a #GdaDbView object
*
* Returns: %TRUE if the current view should replace the existing one in the
* database, %FALSE otherwise.
@@ -422,39 +422,39 @@ gda_ddl_view_set_defstring (GdaDdlView *self,
* Since: 6.0
*/
gboolean
-gda_ddl_view_get_replace (GdaDdlView *self)
+gda_db_view_get_replace (GdaDbView *self)
{
g_return_val_if_fail (self, FALSE);
- GdaDdlViewPrivate *priv = gda_ddl_view_get_instance_private (self);
+ GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
return priv->m_replace;
}
/**
- * gda_ddl_view_set_replace:
- * @self: a #GdaDdlView object
+ * gda_db_view_set_replace:
+ * @self: a #GdaDbView object
* @replace: a value to set
*
* Since: 6.0
*/
void
-gda_ddl_view_set_replace (GdaDdlView *self,
+gda_db_view_set_replace (GdaDbView *self,
gboolean replace)
{
g_return_if_fail (self);
- GdaDdlViewPrivate *priv = gda_ddl_view_get_instance_private (self);
+ GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
priv->m_replace = replace;
}
/**
- * gda_ddl_view_create:
- * @self: a #GdaDdlView instance
+ * gda_db_view_create:
+ * @self: a #GdaDbView instance
* @cnc: open connection for the operation
* @error: error container
*
* This method performs CREATE_VIEW operation over @cnc using data stored in @self
- * It is a convenient method to perform operation. See gda_ddl_view_prepare_create() if better
+ * It is a convenient method to perform operation. See gda_db_view_prepare_create() if better
* flexibility is needed.
*
* Returns: %TRUE if no error, %FASLE otherwise
@@ -462,7 +462,7 @@ gda_ddl_view_set_replace (GdaDdlView *self,
* Since: 6.0
*/
gboolean
-gda_ddl_view_create (GdaDdlView *self,
+gda_db_view_create (GdaDbView *self,
GdaConnection *cnc,
GError **error)
{
@@ -485,7 +485,7 @@ gda_ddl_view_create (GdaDdlView *self,
if (!op)
goto on_error;
- if (!gda_ddl_view_prepare_create(self,op,error))
+ if (!gda_db_view_prepare_create(self,op,error))
goto on_error;
if(!gda_server_provider_perform_operation(provider,cnc,op,error))
@@ -502,8 +502,8 @@ on_error:
}
/**
- * gda_ddl_view_prepare_create:
- * @self: a #GdaDdlView instance
+ * gda_db_view_prepare_create:
+ * @self: a #GdaDbView instance
* @op: #GdaServerOperation instance to populate
* @error: error container
*
@@ -512,17 +512,17 @@ on_error:
* Returns: %TRUE if succeeded and %FALSE otherwise.
*/
gboolean
-gda_ddl_view_prepare_create (GdaDdlView *self,
+gda_db_view_prepare_create (GdaDbView *self,
GdaServerOperation *op,
GError **error)
{
g_return_val_if_fail (self,FALSE);
g_return_val_if_fail (op,FALSE);
- GdaDdlViewPrivate *priv = gda_ddl_view_get_instance_private (self);
+ GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
if (!gda_server_operation_set_value_at(op,
- gda_ddl_base_get_name(GDA_DDL_BASE(self)),
+ gda_db_base_get_name(GDA_DB_BASE(self)),
error,
"/VIEW_DEF_P/VIEW_NAME"))
return FALSE;
@@ -555,25 +555,25 @@ gda_ddl_view_prepare_create (GdaDdlView *self,
}
/**
- * gda_ddl_view_new_from_meta:
+ * gda_db_view_new_from_meta:
* @view: a #GdaMetaView instance
*
- * Create new #GdaDdlView object from the corresponding #GdaMetaView object
+ * Create new #GdaDbView object from the corresponding #GdaMetaView object
*
- * Returns: New instance of #GdaDdlView
+ * Returns: New instance of #GdaDbView
*/
-GdaDdlView*
-gda_ddl_view_new_from_meta (GdaMetaView *view)
+GdaDbView*
+gda_db_view_new_from_meta (GdaMetaView *view)
{
if (!view)
- return gda_ddl_view_new();
+ return gda_db_view_new();
- GdaDdlView *ddlview = gda_ddl_view_new();
+ GdaDbView *dbview = gda_db_view_new();
- gda_ddl_view_set_defstring (ddlview,view->view_def);
- gda_ddl_view_set_replace (ddlview,view->is_updatable);
+ gda_db_view_set_defstring (dbview,view->view_def);
+ gda_db_view_set_replace (dbview,view->is_updatable);
- return ddlview;
+ return dbview;
}
diff --git a/libgda/gda-db-view.h b/libgda/gda-db-view.h
new file mode 100644
index 000000000..104f00087
--- /dev/null
+++ b/libgda/gda-db-view.h
@@ -0,0 +1,90 @@
+/* gda-db-view.h
+ *
+ * Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+#ifndef GDA_DB_VIEW_H
+#define GDA_DB_VIEW_H
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gmodule.h>
+#include "gda-db-base.h"
+#include "gda-db-buildable.h"
+#include "gda-meta-struct.h"
+#include "gda-server-operation.h"
+
+
+G_BEGIN_DECLS
+
+#define GDA_TYPE_DB_VIEW (gda_db_view_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (GdaDbView, gda_db_view, GDA, DB_VIEW, GdaDbBase)
+
+struct _GdaDbViewClass
+{
+ GdaDbBaseClass parent_class;
+};
+
+/**
+ * SECTION: GdaDbView
+ * @short_description: Object to handle information about view
+ * @title: GdaDbView
+ * @section_id:
+ * @see_also: #GdaDbTable #GdaDbCreator
+ * @stability: Stable
+ * @include: libgda/libgda.h
+ * @image:
+ *
+ * #GdaDbView object represents a representtaion of the view from the
+ * database. It implements #GdaDbBuildbale interface and allows one to
+ * read/write information about view structure from/to an xml file. See
+ * #GdaDbBuildable for more information.
+ */
+
+GdaDbView* gda_db_view_new (void);
+GdaDbView *gda_db_view_new_from_meta (GdaMetaView *view);
+
+gboolean gda_db_view_get_istemp (GdaDbView *self);
+void gda_db_view_set_istemp (GdaDbView *self,
+ gboolean temp);
+
+gboolean gda_db_view_get_ifnoexist (GdaDbView *self);
+void gda_db_view_set_ifnoexist (GdaDbView *self,
+ gboolean noexist);
+
+const gchar* gda_db_view_get_defstring (GdaDbView *self);
+void gda_db_view_set_defstring (GdaDbView *self,
+ const gchar *str);
+
+gboolean gda_db_view_get_replace (GdaDbView *self);
+void gda_db_view_set_replace (GdaDbView *self,
+ gboolean replace);
+
+gboolean gda_db_view_create (GdaDbView *self,
+ GdaConnection *cnc,
+ GError **error);
+
+gboolean gda_db_view_prepare_create (GdaDbView *self,
+ GdaServerOperation *op,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* GDA_DB_VIEW_H */
+
+
diff --git a/libgda/gda-init.c b/libgda/gda-init.c
index 315cde548..1d75a1723 100644
--- a/libgda/gda-init.c
+++ b/libgda/gda-init.c
@@ -57,7 +57,7 @@
xmlDtdPtr _gda_array_dtd = NULL;
xmlDtdPtr gda_paramlist_dtd = NULL;
xmlDtdPtr _gda_server_op_dtd = NULL;
-xmlDtdPtr _gda_ddl_creator_dtd = NULL;
+xmlDtdPtr _gda_db_catalog_dtd = NULL;
static gboolean numeric_locale_dyn = FALSE;
gchar *gda_numeric_locale = "";
@@ -247,29 +247,29 @@ gda_init (void)
_gda_server_op_dtd->name = xmlStrdup((xmlChar*) "serv_op");
g_free (file);
- /* GdaDdlCreator DTD */
- _gda_ddl_creator_dtd = NULL;
+ /* GdaDbCreator DTD */
+ _gda_db_catalog_dtd = NULL;
file = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, "dtd",
- "libgda-ddl-creator.dtd", NULL);
+ "libgda-db-catalog.dtd", NULL);
if (g_file_test (file, G_FILE_TEST_EXISTS))
- _gda_ddl_creator_dtd = xmlParseDTD (NULL, (xmlChar*)file);
+ _gda_db_catalog_dtd = xmlParseDTD (NULL, (xmlChar*)file);
else
{
if (g_getenv ("GDA_TOP_SRC_DIR"))
{
g_free (file);
file = g_build_filename (g_getenv ("GDA_TOP_SRC_DIR"), "libgda",
- "libgda-ddl-creator.dtd", NULL);
- _gda_ddl_creator_dtd = xmlParseDTD (NULL, (xmlChar*)file);
+ "libgda-db-catalog.dtd", NULL);
+ _gda_db_catalog_dtd = xmlParseDTD (NULL, (xmlChar*)file);
}
}
- if (!_gda_ddl_creator_dtd)
+ if (!_gda_db_catalog_dtd)
g_message (_("Could not parse '%s': "
- "Validation for XML files for GdaDdlCreator will not be performed (some weird errors may
occur)"),
+ "Validation for XML files for GdaDbCreator will not be performed (some weird errors may
occur)"),
file);
else
- _gda_ddl_creator_dtd->name = xmlStrdup((xmlChar*) "ddl-creator");
+ _gda_db_catalog_dtd->name = xmlStrdup((xmlChar*) "db-catalog");
g_free (file);
diff --git a/libgda/libgda-ddl-creator.dtd b/libgda/libgda-db-catalog.dtd
similarity index 100%
rename from libgda/libgda-ddl-creator.dtd
rename to libgda/libgda-db-catalog.dtd
diff --git a/libgda/libgda.h.in b/libgda/libgda.h.in
index 7ce8e50b9..ec1f1a30c 100644
--- a/libgda/libgda.h.in
+++ b/libgda/libgda.h.in
@@ -86,7 +86,7 @@
#include <libgda/gda-sql-builder.h>
-#include <libgda/gda-ddl-creator.h>
+#include <libgda/gda-db-catalog.h>
G_BEGIN_DECLS
diff --git a/libgda/meson.build b/libgda/meson.build
index 7a62c902a..8dd31c8db 100644
--- a/libgda/meson.build
+++ b/libgda/meson.build
@@ -14,7 +14,7 @@ dtdf = files([
'libgda-array.dtd',
'libgda-paramlist.dtd',
'libgda-server-operation.dtd',
- 'libgda-ddl-creator.dtd'
+ 'libgda-db-catalog.dtd'
])
install_data(dtdf,
@@ -83,13 +83,13 @@ libgda_headers = files([
'gda-data-access-wrapper.h',
'gda-data-proxy.h',
'gda-data-select.h',
- 'gda-ddl-creator.h',
- 'gda-ddl-table.h',
- 'gda-ddl-view.h',
- 'gda-ddl-column.h',
- 'gda-ddl-fkey.h',
- 'gda-ddl-base.h',
- 'gda-ddl-buildable.h',
+ 'gda-db-catalog.h',
+ 'gda-db-table.h',
+ 'gda-db-view.h',
+ 'gda-db-column.h',
+ 'gda-db-fkey.h',
+ 'gda-db-base.h',
+ 'gda-db-buildable.h',
'gda-decl.h',
'gda-holder.h',
'gda-lockable.h',
@@ -155,13 +155,13 @@ libgda_sources= files([
'gda-data-access-wrapper.c',
'gda-data-proxy.c',
'gda-data-select.c',
- 'gda-ddl-creator.c',
- 'gda-ddl-table.c',
- 'gda-ddl-view.c',
- 'gda-ddl-column.c',
- 'gda-ddl-fkey.c',
- 'gda-ddl-base.c',
- 'gda-ddl-buildable.c',
+ 'gda-db-catalog.c',
+ 'gda-db-table.c',
+ 'gda-db-view.c',
+ 'gda-db-column.c',
+ 'gda-db-fkey.c',
+ 'gda-db-base.c',
+ 'gda-db-buildable.c',
'gda-holder.c',
'gda-init.c',
'gda-lockable.c',
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 4cb8844c3..fbd2f9156 100755
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -27,11 +27,11 @@ libgda/gda-data-model-ldap.c
libgda/gda-data-pivot.c
libgda/gda-data-proxy.c
libgda/gda-data-select.c
-libgda/gda-ddl-column.c
-libgda/gda-ddl-creator.c
-libgda/gda-ddl-fkey.c
-libgda/gda-ddl-table.c
-libgda/gda-ddl-view.c
+libgda/gda-db-column.c
+libgda/gda-db-catalog.c
+libgda/gda-db-fkey.c
+libgda/gda-db-table.c
+libgda/gda-db-view.c
libgda/gda-holder.c
libgda/gda-init.c
libgda/gda-log.c
diff --git a/tests/ddl/Makefile.am b/tests/ddl/Makefile.am
index f7ee1a885..f83b68a8a 100644
--- a/tests/ddl/Makefile.am
+++ b/tests/ddl/Makefile.am
@@ -8,42 +8,48 @@ AM_CPPFLAGS = \
-DROOT_DIR=\""$(top_srcdir)"\"
test_programs = \
- check_ddl_creator \
- check_ddl_base \
- check_ddl_column \
- check_ddl_view \
- check_ddl_fkey
-
-check_ddl_creator_SOURCES = check-ddl-creator.c
-check_ddl_creator_LDADD = \
+ check_db_catalog \
+ check_db_base \
+ check_db_column \
+ check_db_view \
+ check_db_catalog_postgresql \
+ check_db_fkey
+
+check_db_catalog_SOURCES = check-db-catalog.c
+check_db_catalog_LDADD = \
$(top_builddir)/libgda/libgda-6.0.la \
$(COREDEPS_LIBS)
-check_ddl_base_SOURCES = check-ddl-base.c
-check_ddl_base_LDADD = \
+check_db_base_SOURCES = check-db-base.c
+check_db_base_LDADD = \
$(top_builddir)/libgda/libgda-6.0.la \
$(COREDEPS_LIBS)
-check_ddl_column_SOURCES = check-ddl-column.c
-check_ddl_column_LDADD = \
+check_db_column_SOURCES = check-db-column.c
+check_db_column_LDADD = \
$(top_builddir)/libgda/libgda-6.0.la \
$(COREDEPS_LIBS)
-check_ddl_view_SOURCES = check-ddl-view.c
-check_ddl_view_LDADD = \
+check_db_view_SOURCES = check-db-view.c
+check_db_view_LDADD = \
$(top_builddir)/libgda/libgda-6.0.la \
$(COREDEPS_LIBS)
-check_ddl_fkey_SOURCES = check-ddl-fkey.c
-check_ddl_fkey_LDADD = \
+check_db_fkey_SOURCES = check-db-fkey.c
+check_db_fkey_LDADD = \
+ $(top_builddir)/libgda/libgda-6.0.la \
+ $(COREDEPS_LIBS)
+
+check_db_catalog_postgresql_SOURCES = check-db-catalog-postgresql.c
+check_db_catalog_postgresql_LDADD = \
$(top_builddir)/libgda/libgda-6.0.la \
$(COREDEPS_LIBS)
include $(top_srcdir)/glib-tap.mk
EXTRA_DIST += column_test.xml \
- ddl-db.xml \
+ db-db.xml \
fkey_test.xml \
view_test.xml
-DISTCLEANFILES=ddl-test-out.xml ddl_test.db
+DISTCLEANFILES=db-test-out.xml db_test.db
diff --git a/tests/ddl/check-ddl-base.c b/tests/ddl/check-db-base.c
similarity index 52%
rename from tests/ddl/check-ddl-base.c
rename to tests/ddl/check-db-base.c
index 178b7d36f..9dbe6a9eb 100644
--- a/tests/ddl/check-ddl-base.c
+++ b/tests/ddl/check-db-base.c
@@ -1,4 +1,4 @@
-/* check-ddl-base.c
+/* check-db-base.c
*
* Copyright 2018 Pavlo Solntsev <p sun fun gmail com>
*
@@ -22,24 +22,24 @@
#include <glib/gi18n.h>
#include <locale.h>
#include <libgda/libgda.h>
-#include <libgda/gda-ddl-base.h>
+#include <libgda/gda-db-base.h>
#define GDA_BOOL_TO_STRING(x) x ? "TRUE" : "FALSE"
typedef struct {
- GdaDdlBase *obj;
+ GdaDbBase *obj;
}BaseFixture;
static void
-test_ddl_base_start (BaseFixture *self,
+test_db_base_start (BaseFixture *self,
gconstpointer user_data)
{
- self->obj = gda_ddl_base_new();
+ self->obj = gda_db_base_new();
}
static void
-test_ddl_base_finish (BaseFixture *self,
+test_db_base_finish (BaseFixture *self,
gconstpointer user_data)
{
if (self->obj)
@@ -47,133 +47,133 @@ test_ddl_base_finish (BaseFixture *self,
}
static void
-test_ddl_base_run1 (BaseFixture *self,
+test_db_base_run1 (BaseFixture *self,
gconstpointer user_data)
{
const gchar *catalog = "First";
const gchar *schema = "Second";
const gchar *name = "Third";
- gda_ddl_base_set_names (self->obj,catalog,schema,name);
+ gda_db_base_set_names (self->obj,catalog,schema,name);
- const gchar *ret_catalog = gda_ddl_base_get_catalog (self->obj);
+ const gchar *ret_catalog = gda_db_base_get_catalog (self->obj);
g_assert_cmpstr (ret_catalog, ==, catalog);
- const gchar *ret_schema = gda_ddl_base_get_schema (self->obj);
+ const gchar *ret_schema = gda_db_base_get_schema (self->obj);
g_assert_cmpstr (ret_schema, ==, schema);
- const gchar *ret_name = gda_ddl_base_get_name (self->obj);
+ const gchar *ret_name = gda_db_base_get_name (self->obj);
g_assert_cmpstr (ret_name, ==, name);
- const gchar *full_name = gda_ddl_base_get_full_name (self->obj);
+ const gchar *full_name = gda_db_base_get_full_name (self->obj);
g_assert_cmpstr (full_name, ==, "First.Second.Third");
}
static void
-test_ddl_base_run2 (BaseFixture *self,
+test_db_base_run2 (BaseFixture *self,
gconstpointer user_data)
{
const gchar *catalog = "First";
const gchar *schema = "Second";
const gchar *name = "Third";
- gda_ddl_base_set_catalog (self->obj,catalog);
+ gda_db_base_set_catalog (self->obj,catalog);
- const gchar *ret_catalog = gda_ddl_base_get_catalog (self->obj);
+ const gchar *ret_catalog = gda_db_base_get_catalog (self->obj);
g_assert_cmpstr (ret_catalog, ==, catalog);
- gda_ddl_base_set_schema (self->obj,schema);
+ gda_db_base_set_schema (self->obj,schema);
- const gchar *ret_schema = gda_ddl_base_get_schema (self->obj);
+ const gchar *ret_schema = gda_db_base_get_schema (self->obj);
g_assert_cmpstr (ret_schema, ==, schema);
- gda_ddl_base_set_name (self->obj,name);
+ gda_db_base_set_name (self->obj,name);
- const gchar *ret_name = gda_ddl_base_get_name (self->obj);
+ const gchar *ret_name = gda_db_base_get_name (self->obj);
g_assert_cmpstr (ret_name, ==, name);
- const gchar *full_name = gda_ddl_base_get_full_name (self->obj);
+ const gchar *full_name = gda_db_base_get_full_name (self->obj);
g_assert_cmpstr (full_name, ==, "First.Second.Third");
}
static void
-test_ddl_base_run3 (BaseFixture *self,
+test_db_base_run3 (BaseFixture *self,
gconstpointer user_data)
{
const gchar *schema = "Second";
const gchar *name = "Third";
- gda_ddl_base_set_names (self->obj,NULL,schema,name);
+ gda_db_base_set_names (self->obj,NULL,schema,name);
- const gchar *ret_catalog = gda_ddl_base_get_catalog (self->obj);
+ const gchar *ret_catalog = gda_db_base_get_catalog (self->obj);
g_assert_cmpstr (ret_catalog, ==, NULL);
- const gchar *ret_schema = gda_ddl_base_get_schema (self->obj);
+ const gchar *ret_schema = gda_db_base_get_schema (self->obj);
g_assert_cmpstr (ret_schema, ==, schema);
- const gchar *ret_name = gda_ddl_base_get_name (self->obj);
+ const gchar *ret_name = gda_db_base_get_name (self->obj);
g_assert_cmpstr (ret_name, ==, name);
- const gchar *full_name = gda_ddl_base_get_full_name (self->obj);
+ const gchar *full_name = gda_db_base_get_full_name (self->obj);
g_assert_cmpstr (full_name, ==, "Second.Third");
}
static void
-test_ddl_base_run4 (BaseFixture *self,
+test_db_base_run4 (BaseFixture *self,
gconstpointer user_data)
{
const gchar *name = "Third";
- gda_ddl_base_set_names (self->obj,NULL,NULL,name);
+ gda_db_base_set_names (self->obj,NULL,NULL,name);
- const gchar *ret_catalog = gda_ddl_base_get_catalog (self->obj);
+ const gchar *ret_catalog = gda_db_base_get_catalog (self->obj);
g_assert_cmpstr (ret_catalog, ==, NULL);
- const gchar *ret_schema = gda_ddl_base_get_schema (self->obj);
+ const gchar *ret_schema = gda_db_base_get_schema (self->obj);
g_assert_cmpstr (ret_schema, ==, NULL);
- const gchar *ret_name = gda_ddl_base_get_name (self->obj);
+ const gchar *ret_name = gda_db_base_get_name (self->obj);
g_assert_cmpstr (ret_name, ==, name);
- const gchar *full_name = gda_ddl_base_get_full_name (self->obj);
+ const gchar *full_name = gda_db_base_get_full_name (self->obj);
g_assert_cmpstr (full_name, ==, "Third");
}
static void
-test_ddl_base_run5 (BaseFixture *self,
+test_db_base_run5 (BaseFixture *self,
gconstpointer user_data)
{
const gchar *catalog = "First";
const gchar *name = "Third";
- const gchar *full_name = gda_ddl_base_get_full_name (self->obj);
+ const gchar *full_name = gda_db_base_get_full_name (self->obj);
g_assert_null (full_name);
- gda_ddl_base_set_name (self->obj,name);
+ gda_db_base_set_name (self->obj,name);
- const gchar *ret_name = gda_ddl_base_get_name (self->obj);
+ const gchar *ret_name = gda_db_base_get_name (self->obj);
g_assert_cmpstr (ret_name, ==, name);
- gda_ddl_base_set_catalog (self->obj,catalog);
+ gda_db_base_set_catalog (self->obj,catalog);
- const gchar *full_name2 = gda_ddl_base_get_full_name (self->obj);
+ const gchar *full_name2 = gda_db_base_get_full_name (self->obj);
/* Only catalog and name are set.
* In this case only name should be returned.
@@ -190,40 +190,40 @@ main (gint argc,
g_test_init (&argc,&argv,NULL);
- g_test_add ("/test-ddl/base-all",
+ g_test_add ("/test-db/base-all",
BaseFixture,
NULL,
- test_ddl_base_start,
- test_ddl_base_run1,
- test_ddl_base_finish);
+ test_db_base_start,
+ test_db_base_run1,
+ test_db_base_finish);
- g_test_add ("/test-ddl/base-separate",
+ g_test_add ("/test-db/base-separate",
BaseFixture,
NULL,
- test_ddl_base_start,
- test_ddl_base_run2,
- test_ddl_base_finish);
+ test_db_base_start,
+ test_db_base_run2,
+ test_db_base_finish);
- g_test_add ("/test-ddl/base-schema-name",
+ g_test_add ("/test-db/base-schema-name",
BaseFixture,
NULL,
- test_ddl_base_start,
- test_ddl_base_run3,
- test_ddl_base_finish);
+ test_db_base_start,
+ test_db_base_run3,
+ test_db_base_finish);
- g_test_add ("/test-ddl/base-name",
+ g_test_add ("/test-db/base-name",
BaseFixture,
NULL,
- test_ddl_base_start,
- test_ddl_base_run4,
- test_ddl_base_finish);
+ test_db_base_start,
+ test_db_base_run4,
+ test_db_base_finish);
- g_test_add ("/test-ddl/base-one",
+ g_test_add ("/test-db/base-one",
BaseFixture,
NULL,
- test_ddl_base_start,
- test_ddl_base_run5,
- test_ddl_base_finish);
+ test_db_base_start,
+ test_db_base_run5,
+ test_db_base_finish);
return g_test_run();
}
diff --git a/tests/ddl/check-db-catalog-postgresql.c b/tests/ddl/check-db-catalog-postgresql.c
new file mode 100644
index 000000000..e5fa0f598
--- /dev/null
+++ b/tests/ddl/check-db-catalog-postgresql.c
@@ -0,0 +1,334 @@
+/* check-db-catalog-postgresql.c
+ *
+ * Copyright 2018 Pavlo Solntsev <p sun fun gmail com>
+ * Copyright 2018 Daniel Espinosa <esodan gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <locale.h>
+#include <libgda/libgda.h>
+
+typedef struct {
+ GdaDbCatalog *catalog;
+ GdaConnection *cnc;
+ gboolean started_db;
+ gboolean cont;
+} CheckDbObject;
+
+
+
+static void create_users_table (CheckDbObject *self) {
+ GError *error = NULL;
+ gboolean res = FALSE;
+ GdaDbTable *table = NULL;
+ GdaDbColumn *column_id;
+ GdaDbColumn *column_name;
+ GdaDbColumn *column_ctime;
+ GdaDbColumn *column_ts;
+ GdaDbColumn *column_state;
+
+ if (self->cnc == NULL) {
+ return;
+ }
+
+ g_assert_nonnull (self->catalog);
+
+ table = gda_db_table_new ();
+ gda_db_base_set_name (GDA_DB_BASE(table), "users");
+
+ column_id = gda_db_column_new ();
+ gda_db_column_set_name (column_id,"id");
+ gda_db_column_set_type (column_id, G_TYPE_INT);
+ gda_db_column_set_autoinc (column_id, TRUE);
+ gda_db_column_set_pkey (column_id, TRUE);
+
+ gda_db_table_append_column (table, column_id);
+
+ column_name = gda_db_column_new ();
+ gda_db_column_set_name (column_name, "name");
+ gda_db_column_set_type (column_name, G_TYPE_STRING);
+ gda_db_column_set_size (column_name, 50);
+
+ gda_db_table_append_column (table, column_name);
+
+ column_ctime = gda_db_column_new ();
+ gda_db_column_set_name (column_ctime, "create_time");
+ gda_db_column_set_type (column_ctime, GDA_TYPE_TIME);
+
+ gda_db_table_append_column (table, column_ctime);
+
+ column_state = gda_db_column_new ();
+ gda_db_column_set_name (column_state, "state");
+ gda_db_column_set_type (column_state, G_TYPE_BOOLEAN);
+
+ gda_db_table_append_column (table,column_state);
+
+ column_ts = gda_db_column_new ();
+ gda_db_column_set_name (column_ts, "mytimestamp");
+ gda_db_column_set_type (column_ts, G_TYPE_DATE_TIME);
+
+ gda_db_table_append_column (table, column_ts);
+
+ gda_db_catalog_append_table (self->catalog, table);
+ res = gda_db_table_create (table, self->cnc, TRUE, &error);
+
+ g_object_unref (table);
+ g_object_unref (column_id);
+ g_object_unref (column_name);
+ g_object_unref (column_ctime);
+ g_object_unref (column_ts);
+ g_object_unref (column_state);
+
+ if (!res) {
+ g_warning ("Error Creating table: %s", error->message);
+ }
+ g_assert_true (res);
+}
+
+static void create_companies_table (CheckDbObject *self) {
+ GError *error = NULL;
+ gboolean res = FALSE;
+ GdaDbTable *table = NULL;
+ GdaDbColumn *column_id;
+ GdaDbColumn *column_name;
+ GdaDbColumn *column_ctime;
+ GdaDbColumn *column_ts;
+ GdaDbColumn *column_state;
+
+ if (self->cnc == NULL) {
+ return;
+ }
+
+ g_assert_nonnull (self->catalog);
+
+ table = gda_db_table_new ();
+ gda_db_base_set_name (GDA_DB_BASE(table), "companies");
+
+ column_id = gda_db_column_new ();
+ gda_db_column_set_name (column_id,"id");
+ gda_db_column_set_type (column_id, G_TYPE_INT);
+ gda_db_column_set_autoinc (column_id, TRUE);
+ gda_db_column_set_pkey (column_id, TRUE);
+
+ gda_db_table_append_column (table, column_id);
+
+ column_name = gda_db_column_new ();
+ gda_db_column_set_name (column_name, "name");
+ gda_db_column_set_type (column_name, G_TYPE_STRING);
+ gda_db_column_set_size (column_name, 50);
+
+ gda_db_table_append_column (table, column_name);
+
+ column_ctime = gda_db_column_new ();
+ gda_db_column_set_name (column_ctime, "create_time");
+ gda_db_column_set_type (column_ctime, GDA_TYPE_TIME);
+
+ gda_db_table_append_column (table, column_ctime);
+
+ column_state = gda_db_column_new ();
+ gda_db_column_set_name (column_state, "state");
+ gda_db_column_set_type (column_state, G_TYPE_BOOLEAN);
+
+ gda_db_table_append_column (table,column_state);
+
+ column_ts = gda_db_column_new ();
+ gda_db_column_set_name (column_ts, "mytimestamp");
+ gda_db_column_set_type (column_ts, G_TYPE_DATE_TIME);
+
+ gda_db_table_append_column (table, column_ts);
+
+ gda_db_catalog_append_table (self->catalog, table);
+ res = gda_db_table_create (table, self->cnc, TRUE, &error);
+
+ g_object_unref (table);
+ g_object_unref (column_id);
+ g_object_unref (column_name);
+ g_object_unref (column_ctime);
+ g_object_unref (column_ts);
+ g_object_unref (column_state);
+
+ if (!res) {
+ g_warning ("Error Creating table: %s", error->message);
+ }
+ g_assert_true (res);
+}
+
+
+static void create_countries_table (CheckDbObject *self) {
+ GError *error = NULL;
+ gboolean res = FALSE;
+ GdaDbTable *table = NULL;
+ GdaDbColumn *column_id;
+ GdaDbColumn *column_name;
+ GdaDbColumn *column_ctime;
+ GdaDbColumn *column_ts;
+ GdaDbColumn *column_state;
+
+ if (self->cnc == NULL) {
+ return;
+ }
+
+ g_assert_nonnull (self->catalog);
+
+ table = gda_db_table_new ();
+ gda_db_base_set_name (GDA_DB_BASE(table), "countries");
+
+ column_id = gda_db_column_new ();
+ gda_db_column_set_name (column_id,"id");
+ gda_db_column_set_type (column_id, G_TYPE_INT);
+ gda_db_column_set_autoinc (column_id, TRUE);
+ gda_db_column_set_pkey (column_id, TRUE);
+
+ gda_db_table_append_column (table, column_id);
+
+ column_name = gda_db_column_new ();
+ gda_db_column_set_name (column_name, "name");
+ gda_db_column_set_type (column_name, G_TYPE_STRING);
+ gda_db_column_set_size (column_name, 50);
+
+ gda_db_table_append_column (table, column_name);
+
+ column_ctime = gda_db_column_new ();
+ gda_db_column_set_name (column_ctime, "create_time");
+ gda_db_column_set_type (column_ctime, GDA_TYPE_TIME);
+
+ gda_db_table_append_column (table, column_ctime);
+
+ column_state = gda_db_column_new ();
+ gda_db_column_set_name (column_state, "state");
+ gda_db_column_set_type (column_state, G_TYPE_BOOLEAN);
+
+ gda_db_table_append_column (table,column_state);
+
+ column_ts = gda_db_column_new ();
+ gda_db_column_set_name (column_ts, "mytimestamp");
+ gda_db_column_set_type (column_ts, G_TYPE_DATE_TIME);
+
+ gda_db_table_append_column (table, column_ts);
+
+ gda_db_catalog_append_table (self->catalog, table);
+ res = gda_db_table_create (table, self->cnc, TRUE, &error);
+
+ g_object_unref (table);
+ g_object_unref (column_id);
+ g_object_unref (column_name);
+ g_object_unref (column_ctime);
+ g_object_unref (column_ts);
+ g_object_unref (column_state);
+
+ if (!res) {
+ g_warning ("Error Creating table: %s", error->message);
+ }
+ g_assert_true (res);
+}
+
+static void
+test_db_catalog_start (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ gda_init();
+ self->catalog = NULL;
+ self->cnc = NULL;
+ self->started_db = FALSE;
+ self->cont = FALSE;
+
+#ifdef CI_ENVIRONMENT
+ const gchar *cnc_string = "DB_NAME=test;HOST=postgres;USERNAME=test;PASSWORD=test1";
+#else
+ const gchar *cnc_string = "DB_NAME=test;HOST=localhost;USERNAME=test;PASSWORD=test1";
+#endif
+
+ self->cnc = gda_connection_new_from_string("Postgresql",
+ cnc_string,
+ NULL,
+ GDA_CONNECTION_OPTIONS_NONE,
+ NULL);
+ if (self->cnc == NULL) {
+ g_print ("Postgres test not run, please setup a database 'test', owned by 'test' role with password
'test1' at localhost\n");
+ g_print ("Test Skip.\n");
+ return;
+ }
+
+ g_assert_nonnull (self->cnc);
+
+ gboolean openres = gda_connection_open(self->cnc, NULL);
+ g_assert_true (openres);
+
+ self->catalog = gda_connection_create_db_catalog (self->cnc);
+
+ g_assert_nonnull (self->catalog);
+
+ /* Create DataBase structure */
+ create_users_table (self);
+ create_companies_table (self);
+ create_countries_table (self);
+ self->cont = TRUE;
+}
+
+static void
+test_db_catalog_finish (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ if (self->cnc != NULL) {
+ gda_connection_close(self->cnc,NULL);
+ g_object_unref (self->catalog);
+ g_object_unref (self->cnc);
+ }
+}
+
+
+static void
+test_tables (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ if (!self->cont) {
+ g_message ("Test skiped");
+ }
+ g_message ("Testing Tables...");
+ if (self->cnc == NULL) {
+ return;
+ }
+ GList *tables = gda_db_catalog_get_tables (self->catalog);
+ g_assert (tables != NULL);
+ g_assert (g_list_length (tables) != 0);
+ g_assert (g_list_length (tables) == 3);
+ GList *lt = NULL;
+ for (lt = tables; lt; lt = lt->next) {
+ GdaDbTable *table = (GdaDbTable *) lt->data;
+ g_message ("Table found: %s", gda_db_base_get_full_name (GDA_DB_BASE (table)));
+ }
+}
+
+gint
+main (gint argc,
+ gchar *argv[])
+{
+ setlocale (LC_ALL,"");
+
+ g_test_init (&argc,&argv,NULL);
+
+ g_test_add ("/test-db-postgresql/meta-tables",
+ CheckDbObject,
+ NULL,
+ test_db_catalog_start,
+ test_tables,
+ test_db_catalog_finish);
+
+ return g_test_run();
+}
diff --git a/tests/ddl/check-ddl-creator.c b/tests/ddl/check-db-catalog.c
similarity index 67%
rename from tests/ddl/check-ddl-creator.c
rename to tests/ddl/check-db-catalog.c
index 710a56b9b..dbf0e0fed 100644
--- a/tests/ddl/check-ddl-creator.c
+++ b/tests/ddl/check-db-catalog.c
@@ -1,4 +1,4 @@
-/* check-ddl-creator.c
+/* check-db-catalog.c
*
* Copyright 2018 Pavlo Solntsev <p sun fun gmail com>
*
@@ -22,8 +22,8 @@
#include <glib/gi18n.h>
#include <locale.h>
#include <libgda/libgda.h>
-#include <libgda/gda-ddl-creator.h>
-#include <libgda/gda-ddl-base.h>
+#include <libgda/gda-db-catalog.h>
+#include <libgda/gda-db-base.h>
#include <sql-parser/gda-sql-parser.h>
#include <libxml/parser.h>
@@ -39,30 +39,30 @@ enum {
typedef struct {
- GdaDdlCreator *creator;
+ GdaDbCatalog *catalog;
gchar *xmlfile;
GdaConnection *cnc;
GFile *file;
-} CheckDdlObject;
+} CheckDbObject;
typedef struct {
- GdaDdlCreator *creator;
+ GdaDbCatalog *catalog;
GdaConnection *cnc;
- GdaDdlColumn *column_id;
- GdaDdlColumn *column_name;
- GdaDdlColumn *column_ctime;
- GdaDdlColumn *column_ts;
- GdaDdlColumn *column_state;
- GdaDdlTable *table;
-} DdlCreatorCnc;
+ GdaDbColumn *column_id;
+ GdaDbColumn *column_name;
+ GdaDbColumn *column_ctime;
+ GdaDbColumn *column_ts;
+ GdaDbColumn *column_state;
+ GdaDbTable *table;
+} DbCatalogCnc;
static void
-test_ddl_creator_start (CheckDdlObject *self,
+test_db_catalog_start (CheckDbObject *self,
gconstpointer user_data)
{
gda_init();
self->xmlfile = NULL;
- self->creator = NULL;
+ self->catalog = NULL;
self->cnc = NULL;
self->file = NULL;
@@ -79,7 +79,7 @@ test_ddl_creator_start (CheckDdlObject *self,
g_assert_nonnull (self->xmlfile);
self->cnc = gda_connection_new_from_string("SQLite",
- "DB_DIR=.;DB_NAME=ddl_test",
+ "DB_DIR=.;DB_NAME=db_test",
NULL,
GDA_CONNECTION_OPTIONS_NONE,
NULL);
@@ -89,25 +89,25 @@ test_ddl_creator_start (CheckDdlObject *self,
gboolean openres = gda_connection_open(self->cnc,NULL);
g_assert_true (openres);
- self->creator = gda_connection_create_ddl_creator (self->cnc);
+ self->catalog = gda_connection_create_db_catalog (self->cnc);
- g_assert_nonnull (self->creator);
+ g_assert_nonnull (self->catalog);
self->file = g_file_new_for_path (self->xmlfile);
g_print ("GFile is %s\n",g_file_get_path(self->file));
}
static void
-test_ddl_creator_start_db (DdlCreatorCnc *self,
+test_db_catalog_start_db (DbCatalogCnc *self,
gconstpointer user_data)
{
gda_init();
self->cnc = NULL;
- self->creator = NULL;
+ self->catalog = NULL;
self->cnc = gda_connection_new_from_string ("SQLite",
- "DB_DIR=.;DB_NAME=ddl_types",
+ "DB_DIR=.;DB_NAME=db_types",
NULL,
GDA_CONNECTION_OPTIONS_NONE,
NULL);
@@ -117,71 +117,71 @@ test_ddl_creator_start_db (DdlCreatorCnc *self,
g_assert_true (open_res);
- self->creator = gda_connection_create_ddl_creator (self->cnc);
+ self->catalog = gda_connection_create_db_catalog (self->cnc);
- g_assert_nonnull (self->creator);
+ g_assert_nonnull (self->catalog);
- self->table = gda_ddl_table_new ();
- gda_ddl_base_set_name (GDA_DDL_BASE(self->table),"dntypes");
+ self->table = gda_db_table_new ();
+ gda_db_base_set_name (GDA_DB_BASE(self->table),"dntypes");
- self->column_id = gda_ddl_column_new ();
- gda_ddl_column_set_name (self->column_id,"id");
- gda_ddl_column_set_type (self->column_id, G_TYPE_INT);
- gda_ddl_column_set_autoinc (self->column_id, TRUE);
- gda_ddl_column_set_pkey (self->column_id, TRUE);
+ self->column_id = gda_db_column_new ();
+ gda_db_column_set_name (self->column_id,"id");
+ gda_db_column_set_type (self->column_id, G_TYPE_INT);
+ gda_db_column_set_autoinc (self->column_id, TRUE);
+ gda_db_column_set_pkey (self->column_id, TRUE);
- gda_ddl_table_append_column (self->table,self->column_id);
+ gda_db_table_append_column (self->table,self->column_id);
- self->column_name = gda_ddl_column_new ();
- gda_ddl_column_set_name (self->column_name,"name");
- gda_ddl_column_set_type (self->column_name, G_TYPE_STRING);
- gda_ddl_column_set_size (self->column_name, 50);
+ self->column_name = gda_db_column_new ();
+ gda_db_column_set_name (self->column_name,"name");
+ gda_db_column_set_type (self->column_name, G_TYPE_STRING);
+ gda_db_column_set_size (self->column_name, 50);
- gda_ddl_table_append_column (self->table,self->column_name);
+ gda_db_table_append_column (self->table,self->column_name);
- self->column_ctime = gda_ddl_column_new ();
- gda_ddl_column_set_name (self->column_ctime,"create_time");
- gda_ddl_column_set_type (self->column_ctime, GDA_TYPE_TIME);
+ self->column_ctime = gda_db_column_new ();
+ gda_db_column_set_name (self->column_ctime,"create_time");
+ gda_db_column_set_type (self->column_ctime, GDA_TYPE_TIME);
- gda_ddl_table_append_column (self->table,self->column_ctime);
+ gda_db_table_append_column (self->table,self->column_ctime);
- self->column_state = gda_ddl_column_new ();
- gda_ddl_column_set_name (self->column_state,"state");
- gda_ddl_column_set_type (self->column_state, G_TYPE_BOOLEAN);
+ self->column_state = gda_db_column_new ();
+ gda_db_column_set_name (self->column_state,"state");
+ gda_db_column_set_type (self->column_state, G_TYPE_BOOLEAN);
- gda_ddl_table_append_column (self->table,self->column_state);
+ gda_db_table_append_column (self->table,self->column_state);
- self->column_ts = gda_ddl_column_new ();
- gda_ddl_column_set_name (self->column_ts,"mytimestamp");
- gda_ddl_column_set_type (self->column_ts, G_TYPE_DATE_TIME);
+ self->column_ts = gda_db_column_new ();
+ gda_db_column_set_name (self->column_ts,"mytimestamp");
+ gda_db_column_set_type (self->column_ts, G_TYPE_DATE_TIME);
- gda_ddl_table_append_column (self->table,self->column_ts);
+ gda_db_table_append_column (self->table,self->column_ts);
- gda_ddl_creator_append_table (self->creator, self->table);
+ gda_db_catalog_append_table (self->catalog, self->table);
- open_res = gda_ddl_creator_perform_operation (self->creator,NULL);
+ open_res = gda_db_catalog_perform_operation (self->catalog,NULL);
g_assert_true (open_res);
}
static void
-test_ddl_creator_finish (CheckDdlObject *self,
+test_db_catalog_finish (CheckDbObject *self,
gconstpointer user_data)
{
gda_connection_close(self->cnc,NULL);
g_free (self->xmlfile);
g_object_unref (self->file);
- g_object_unref (self->creator);
+ g_object_unref (self->catalog);
g_object_unref (self->cnc);
}
static void
-test_ddl_creator_finish_db (DdlCreatorCnc *self,
+test_db_catalog_finish_db (DbCatalogCnc *self,
gconstpointer user_data)
{
gda_connection_close(self->cnc,NULL);
g_object_unref (self->cnc);
- g_object_unref (self->creator);
+ g_object_unref (self->catalog);
g_object_unref (self->column_id);
g_object_unref (self->column_name);
g_object_unref (self->column_ctime);
@@ -190,10 +190,10 @@ test_ddl_creator_finish_db (DdlCreatorCnc *self,
}
static void
-test_ddl_creator_parse_xml_path (CheckDdlObject *self,
+test_db_catalog_parse_xml_path (CheckDbObject *self,
gconstpointer user_data)
{
- gboolean res = gda_ddl_creator_parse_file_from_path(self->creator,
+ gboolean res = gda_db_catalog_parse_file_from_path(self->catalog,
self->xmlfile,
NULL);
@@ -201,39 +201,39 @@ test_ddl_creator_parse_xml_path (CheckDdlObject *self,
}
static void
-test_ddl_creator_parse_xml_file (CheckDdlObject *self,
+test_db_catalog_parse_xml_file (CheckDbObject *self,
gconstpointer user_data)
{
- gboolean res = gda_ddl_creator_parse_file (self->creator,self->file,NULL);
+ gboolean res = gda_db_catalog_parse_file (self->catalog,self->file,NULL);
g_assert_true (res);
}
static void
-test_ddl_creator_validate_xml (CheckDdlObject *self,
+test_db_catalog_validate_xml (CheckDbObject *self,
gconstpointer user_data)
{
- gboolean res = gda_ddl_creator_validate_file_from_path (self->xmlfile,NULL);
+ gboolean res = gda_db_catalog_validate_file_from_path (self->xmlfile,NULL);
g_assert_true (res);
}
static void
-test_ddl_creator_create_db (CheckDdlObject *self,
+test_db_catalog_create_db (CheckDbObject *self,
gconstpointer user_data)
{
- gboolean res = gda_ddl_creator_parse_file_from_path(self->creator,
+ gboolean res = gda_db_catalog_parse_file_from_path(self->catalog,
self->xmlfile,
NULL);
g_assert_true (res);
- res = gda_ddl_creator_write_to_path (self->creator,
- "ddl-test-out.xml",
+ res = gda_db_catalog_write_to_path (self->catalog,
+ "db-test-out.xml",
NULL);
g_assert_true (res);
GError *error = NULL;
- gboolean resop = gda_ddl_creator_perform_operation(self->creator,
+ gboolean resop = gda_db_catalog_perform_operation(self->catalog,
&error);
if (!resop)
@@ -243,7 +243,7 @@ test_ddl_creator_create_db (CheckDdlObject *self,
}
static void
-test_ddl_creator_parse_cnc (DdlCreatorCnc *self,
+test_db_catalog_parse_cnc (DbCatalogCnc *self,
gconstpointer user_data)
{
gboolean open_res;
@@ -276,31 +276,31 @@ test_ddl_creator_parse_cnc (DdlCreatorCnc *self,
model = gda_connection_execute_select_command (self->cnc,"SELECT * FROM dntypes",NULL);
g_assert_nonnull (model);
- GdaDdlCreator *creator = gda_connection_create_ddl_creator (self->cnc);
- open_res = gda_ddl_creator_parse_cnc (creator,NULL);
+ GdaDbCatalog *catalog = gda_connection_create_db_catalog (self->cnc);
+ open_res = gda_db_catalog_parse_cnc (catalog,NULL);
g_assert_true (open_res);
- GList *tables = gda_ddl_creator_get_tables (creator);
+ GList *tables = gda_db_catalog_get_tables (catalog);
g_assert_nonnull (tables);
gint raw = 0;
gint column_count = 0;
for (GList *it = tables; it; it = it->next)
{
- g_assert_cmpstr (dntypes,==,gda_ddl_base_get_name (GDA_DDL_BASE(it->data)));
- GList *columns = gda_ddl_table_get_columns (GDA_DDL_TABLE(it->data));
+ g_assert_cmpstr (dntypes,==,gda_db_base_get_name (GDA_DB_BASE(it->data)));
+ GList *columns = gda_db_table_get_columns (GDA_DB_TABLE(it->data));
g_assert_nonnull (columns);
column_count = 0;
for (GList *jt = columns;jt;jt=jt->next)
{
- GdaDdlColumn *column = GDA_DDL_COLUMN (jt->data);
- GType column_type = gda_ddl_column_get_gtype (column);
+ GdaDbColumn *column = GDA_DB_COLUMN (jt->data);
+ GType column_type = gda_db_column_get_gtype (column);
g_assert_true (column_type != G_TYPE_NONE);
- if (!g_strcmp0 ("id",gda_ddl_column_get_name (column)))
+ if (!g_strcmp0 ("id",gda_db_column_get_name (column)))
{
GError *error = NULL;
const GValue *value = gda_data_model_get_typed_value_at (model,
@@ -321,7 +321,7 @@ test_ddl_creator_parse_cnc (DdlCreatorCnc *self,
}
- if (!g_strcmp0 ("name",gda_ddl_column_get_name (column)))
+ if (!g_strcmp0 ("name",gda_db_column_get_name (column)))
{
const GValue *value = gda_data_model_get_typed_value_at (model,
column_count++,
@@ -338,7 +338,7 @@ test_ddl_creator_parse_cnc (DdlCreatorCnc *self,
}
- if (!g_strcmp0 ("state",gda_ddl_column_get_name (column)))
+ if (!g_strcmp0 ("state",gda_db_column_get_name (column)))
{
const GValue *value = gda_data_model_get_typed_value_at (model,
column_count++,
@@ -354,7 +354,7 @@ test_ddl_creator_parse_cnc (DdlCreatorCnc *self,
g_assert_true (TRUE && g_value_get_boolean (value));
}
- if (!g_strcmp0 ("create_time",gda_ddl_column_get_name (column)))
+ if (!g_strcmp0 ("create_time",gda_db_column_get_name (column)))
{
const GValue *value = gda_data_model_get_typed_value_at (model,
column_count++,
@@ -371,7 +371,7 @@ test_ddl_creator_parse_cnc (DdlCreatorCnc *self,
}
- if (!g_strcmp0 ("mytimestamp",gda_ddl_column_get_name (column)))
+ if (!g_strcmp0 ("mytimestamp",gda_db_column_get_name (column)))
{
const GValue *value = gda_data_model_get_typed_value_at (model,
column_count++,
@@ -395,7 +395,7 @@ test_ddl_creator_parse_cnc (DdlCreatorCnc *self,
raw++;
}
- g_object_unref (creator);
+ g_object_unref (catalog);
g_assert_true (open_res);
gda_value_free (value_name);
@@ -413,39 +413,39 @@ main (gint argc,
g_test_init (&argc,&argv,NULL);
- g_test_add ("/test-ddl/creator-parse-file",
- CheckDdlObject,
+ g_test_add ("/test-db/catalog-parse-file",
+ CheckDbObject,
NULL,
- test_ddl_creator_start,
- test_ddl_creator_parse_xml_file,
- test_ddl_creator_finish);
+ test_db_catalog_start,
+ test_db_catalog_parse_xml_file,
+ test_db_catalog_finish);
- g_test_add ("/test-ddl/creator-parse-path",
- CheckDdlObject,
+ g_test_add ("/test-db/catalog-parse-path",
+ CheckDbObject,
NULL,
- test_ddl_creator_start,
- test_ddl_creator_parse_xml_path,
- test_ddl_creator_finish);
+ test_db_catalog_start,
+ test_db_catalog_parse_xml_path,
+ test_db_catalog_finish);
- g_test_add ("/test-ddl/creator-create-db",
- CheckDdlObject,
+ g_test_add ("/test-db/catalog-create-db",
+ CheckDbObject,
NULL,
- test_ddl_creator_start,
- test_ddl_creator_create_db,
- test_ddl_creator_finish);
+ test_db_catalog_start,
+ test_db_catalog_create_db,
+ test_db_catalog_finish);
- g_test_add ("/test-ddl/creator-validate-xml",
- CheckDdlObject,
+ g_test_add ("/test-db/catalog-validate-xml",
+ CheckDbObject,
NULL,
- test_ddl_creator_start,
- test_ddl_creator_validate_xml,
- test_ddl_creator_finish);
- g_test_add ("/test-ddl/creator-parse-cnc",
- DdlCreatorCnc,
+ test_db_catalog_start,
+ test_db_catalog_validate_xml,
+ test_db_catalog_finish);
+ g_test_add ("/test-db/catalog-parse-cnc",
+ DbCatalogCnc,
NULL,
- test_ddl_creator_start_db,
- test_ddl_creator_parse_cnc,
- test_ddl_creator_finish_db);
+ test_db_catalog_start_db,
+ test_db_catalog_parse_cnc,
+ test_db_catalog_finish_db);
return g_test_run();
}
diff --git a/tests/ddl/check-db-column.c b/tests/ddl/check-db-column.c
new file mode 100644
index 000000000..a7b5be0ea
--- /dev/null
+++ b/tests/ddl/check-db-column.c
@@ -0,0 +1,337 @@
+/* check-db-column.c
+ *
+ * Copyright 2018 Pavlo Solntsev <p sun fun gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <locale.h>
+#include <libgda/libgda.h>
+#include <libgda/gda-db-column.h>
+
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xmlwriter.h>
+
+#define GDA_BOOL_TO_STRING(x) x ? "TRUE" : "FALSE"
+
+typedef struct {
+ GdaDbColumn *column;
+ gchar *xmlfile;
+ xmlDocPtr doc;
+ xmlNodePtr node;
+} CheckDbObject;
+
+static void
+test_db_column_check_name (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ const gchar *cname = gda_db_column_get_name (self->column);
+ g_assert_cmpstr (cname, ==,"column_name");
+
+ const gchar *inval = "TestName";
+
+ gda_db_column_set_name (self->column,inval);
+
+ const gchar *resval = gda_db_column_get_name (self->column);
+
+ g_assert_cmpstr (inval, ==, resval);
+}
+
+static void
+test_db_column_check_default (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ const gchar *cname = gda_db_column_get_default (self->column);
+ g_assert_cmpstr (cname, ==,"12.34");
+
+ const gchar *inval = "default value";
+
+ gda_db_column_set_default (self->column,inval);
+
+ const gchar *resval = gda_db_column_get_default (self->column);
+
+ g_assert_cmpstr (inval, ==, resval);
+}
+
+static void
+test_db_column_check_check (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ const gchar *cname = gda_db_column_get_check (self->column);
+ g_assert_cmpstr (cname, ==,"compound_id > 0");
+
+ const gchar *inval = "check string";
+
+ gda_db_column_set_check (self->column,inval);
+
+ const gchar *resval = gda_db_column_get_check (self->column);
+
+ g_assert_cmpstr (inval, ==, resval);
+}
+
+
+static void
+test_db_column_check_type (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ const gchar *ctype = gda_db_column_get_ctype (self->column);
+ g_assert_cmpstr (ctype, ==,"string");
+
+ GType gtype = gda_db_column_get_gtype (self->column);
+ g_assert_true (gtype == G_TYPE_STRING);
+
+ GType inval = G_TYPE_STRING;
+
+ gda_db_column_set_type (self->column,inval);
+
+ const GType resval = gda_db_column_get_gtype (self->column);
+
+ g_assert_true(inval == resval);
+}
+
+static void
+test_db_column_check_unique (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ gboolean res = FALSE;
+ res = gda_db_column_get_unique (self->column);
+ g_assert_true (res);
+
+ gboolean inval = TRUE;
+
+ gda_db_column_set_unique (self->column,inval);
+
+ gboolean resval = gda_db_column_get_unique (self->column);
+
+ g_assert_true(inval && resval);
+}
+
+static void
+test_db_column_check_pkey (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ gboolean res = FALSE;
+ res = gda_db_column_get_pkey (self->column);
+ g_assert_true (res); // it is true in the column_test.xml
+
+ gboolean inval = TRUE;
+
+ gda_db_column_set_pkey (self->column,inval);
+
+ gboolean resval = gda_db_column_get_pkey(self->column);
+
+ g_assert_true(inval && resval);
+}
+
+static void
+test_db_column_check_nnul (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ gboolean res = TRUE;
+
+ res = gda_db_column_get_nnul (self->column);
+ g_assert_false (res);
+
+ gboolean inval = TRUE;
+
+ gda_db_column_set_nnul (self->column,inval);
+
+ gboolean resval = gda_db_column_get_nnul(self->column);
+
+ g_assert_true(inval && resval);
+}
+
+static void
+test_db_column_check_autoinc (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ gboolean res = TRUE;
+
+ res = gda_db_column_get_autoinc (self->column);
+ g_assert_false (res);
+
+ gboolean inval = TRUE;
+
+ gda_db_column_set_autoinc (self->column,inval);
+
+ gboolean resval = gda_db_column_get_autoinc (self->column);
+
+ g_assert_true(inval && resval);
+}
+
+
+static void
+test_db_column_check_comment (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ const gchar* comstr = gda_db_column_get_comment (self->column);
+
+ g_assert_cmpstr (comstr, ==, "Simple_Comment");
+
+ const gchar *inval = "TestName";
+
+ gda_db_column_set_comment (self->column,inval);
+
+ const gchar *resval = gda_db_column_get_comment(self->column);
+
+ g_assert_cmpstr (inval, ==, resval);
+}
+
+static void
+test_db_column_check_size (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ guint size = gda_db_column_get_size (self->column);
+
+ g_assert_cmpuint (size, ==, 5);
+
+ guint inval = 81;
+
+ gda_db_column_set_size (self->column,inval);
+
+ guint resval = gda_db_column_get_size(self->column);
+
+ g_assert_cmpuint (inval, ==, resval);
+}
+
+static void
+test_db_column_startup (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ self->doc = NULL;
+ self->xmlfile = NULL;
+ self->column = NULL;
+ self->node = NULL;
+
+ const gchar *topsrcdir = g_getenv ("GDA_TOP_SRC_DIR");
+
+ g_print ("ENV: %s\n",topsrcdir);
+ g_assert_nonnull (topsrcdir);
+
+ self->xmlfile = g_build_filename(topsrcdir,
+ "tests",
+ "ddl",
+ "column_test.xml",NULL);
+
+ g_assert_nonnull (self->xmlfile);
+
+ self->doc = xmlParseFile(self->xmlfile);
+ g_assert_nonnull (self->doc);
+
+ self->node = xmlDocGetRootElement (self->doc);
+ g_assert_nonnull (self->node);
+
+ self->column = gda_db_column_new ();
+ g_assert_nonnull(self->column);
+
+ gboolean res = gda_db_buildable_parse_node (GDA_DB_BUILDABLE(self->column),
+ self->node,NULL);
+ g_assert_true (res);
+}
+
+static void
+test_db_column_cleanup (CheckDbObject *self,
+ gconstpointer user_data)
+{
+ g_free (self->xmlfile);
+ g_object_unref (self->column);
+ xmlFreeDoc (self->doc);
+}
+
+gint
+main (gint argc,
+ gchar *argv[])
+{
+ setlocale (LC_ALL,"");
+
+ g_test_init (&argc,&argv,NULL);
+
+
+ g_test_add ("/test-db/column-name",
+ CheckDbObject,
+ NULL,
+ test_db_column_startup,
+ test_db_column_check_name,
+ test_db_column_cleanup);
+
+ g_test_add ("/test-db/column-type",
+ CheckDbObject,
+ NULL,
+ test_db_column_startup,
+ test_db_column_check_type,
+ test_db_column_cleanup);
+
+ g_test_add ("/test-db/column-pkey",
+ CheckDbObject,
+ NULL,
+ test_db_column_startup,
+ test_db_column_check_pkey,
+ test_db_column_cleanup);
+
+ g_test_add ("/test-db/column-unique",
+ CheckDbObject,
+ NULL,
+ test_db_column_startup,
+ test_db_column_check_unique,
+ test_db_column_cleanup);
+
+ g_test_add ("/test-db/column-autoinc",
+ CheckDbObject,
+ NULL,
+ test_db_column_startup,
+ test_db_column_check_autoinc,
+ test_db_column_cleanup);
+
+ g_test_add ("/test-db/column-nnul",
+ CheckDbObject,
+ NULL,
+ test_db_column_startup,
+ test_db_column_check_nnul,
+ test_db_column_cleanup);
+
+ g_test_add ("/test-db/column-comment",
+ CheckDbObject,
+ NULL,
+ test_db_column_startup,
+ test_db_column_check_comment,
+ test_db_column_cleanup);
+
+ g_test_add ("/test-db/column-size",
+ CheckDbObject,
+ NULL,
+ test_db_column_startup,
+ test_db_column_check_size,
+ test_db_column_cleanup);
+
+ g_test_add ("/test-db/column-default",
+ CheckDbObject,
+ NULL,
+ test_db_column_startup,
+ test_db_column_check_default,
+ test_db_column_cleanup);
+
+ g_test_add ("/test-db/column-check",
+ CheckDbObject,
+ NULL,
+ test_db_column_startup,
+ test_db_column_check_check,
+ test_db_column_cleanup);
+
+ return g_test_run();
+}
diff --git a/tests/ddl/check-ddl-db-create.c b/tests/ddl/check-db-db-create.c
similarity index 84%
rename from tests/ddl/check-ddl-db-create.c
rename to tests/ddl/check-db-db-create.c
index 6d807a3f4..993880d00 100644
--- a/tests/ddl/check-ddl-db-create.c
+++ b/tests/ddl/check-db-db-create.c
@@ -1,4 +1,4 @@
-/* check-ddl-creator.c
+/* check-db-db-create.c
*
* Copyright 2018 Pavlo Solntsev <p sun fun gmail com>
*
@@ -22,15 +22,15 @@
#include <glib/gi18n.h>
#include <locale.h>
#include <libgda/libgda.h>
-#include <libgda/gda-ddl-creator.h>
-#include <libgda/gda-ddl-base.h>
+#include <libgda/gda-db-catalog.h>
+#include <libgda/gda-db-base.h>
#include <sql-parser/gda-sql-parser.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
typedef struct {
- GdaDdlCreator *creator;
+ GdaDbCatalog *catalog;
GdaConnection *cnc;
gchar *xmlfile;
@@ -38,11 +38,11 @@ typedef struct {
}CheckCreatedb;
static void
-test_ddl_db_create_start(CheckCreatedb *self,
+test_db_db_create_start(CheckCreatedb *self,
gconstpointer user_data)
{
gda_init ();
- self->creator = NULL;
+ self->catalog = NULL;
self->cnc = NULL;
const gchar *topsrcdir = g_getenv ("GDA_TOP_SRC_DIR");
@@ -52,13 +52,13 @@ test_ddl_db_create_start(CheckCreatedb *self,
self->xmlfile = g_build_filename(topsrcdir,
"tests",
- "ddl",
+ "db",
"check_db.xml",NULL);
g_assert_nonnull (self->xmlfile);
self->cnc = gda_connection_new_from_string ("SQLite",
- "DB_DIR=.;DB_NAME=ddl_test_create",
+ "DB_DIR=.;DB_NAME=db_test_create",
NULL,
GDA_CONNECTION_OPTIONS_NONE,
NULL);
@@ -68,26 +68,26 @@ test_ddl_db_create_start(CheckCreatedb *self,
gboolean res = gda_connection_open (self->cnc,NULL);
g_assert_true (res);
- self->creator = gda_connection_create_ddl_creator (self->cnc);
+ self->catalog = gda_connection_create_db_catalog (self->cnc);
- g_assert_nonnull (self->creator);
+ g_assert_nonnull (self->catalog);
- res = gda_ddl_creator_validate_file_from_path (self->xmlfile,NULL);
+ res = gda_db_catalog_validate_file_from_path (self->xmlfile,NULL);
g_assert_true (res);
- res = gda_ddl_creator_parse_file_from_path (self->creator,
+ res = gda_db_catalog_parse_file_from_path (self->catalog,
self->xmlfile,
NULL);
g_assert_true (res);
- res = gda_ddl_creator_perform_operation (self->creator,
+ res = gda_db_catalog_perform_operation (self->catalog,
NULL);
g_assert_true (res);
}
static void
-test_ddl_db_create_finish (CheckCreatedb *self,
+test_db_db_create_finish (CheckCreatedb *self,
gconstpointer user_data)
{
/* Dropping all tables */
@@ -112,12 +112,12 @@ test_ddl_db_create_finish (CheckCreatedb *self,
gda_connection_close (self->cnc, NULL);
g_free (self->xmlfile);
- g_object_unref (self->creator);
+ g_object_unref (self->catalog);
g_object_unref (self->cnc);
}
static void
-test_ddl_db_create_test1 (CheckCreatedb *self,
+test_db_db_create_test1 (CheckCreatedb *self,
gconstpointer user_data)
{
GValue *value_name = gda_value_new (G_TYPE_STRING);
@@ -169,12 +169,12 @@ main (gint argc,
g_test_init (&argc,&argv,NULL);
- g_test_add ("/test-ddl/CheckCreatedb",
+ g_test_add ("/test-db/CheckCreatedb",
CheckCreatedb,
NULL,
- test_ddl_db_create_start,
- test_ddl_db_create_test1,
- test_ddl_db_create_finish);
+ test_db_db_create_start,
+ test_db_db_create_test1,
+ test_db_db_create_finish);
return g_test_run();
}
diff --git a/tests/ddl/check-ddl-fkey.c b/tests/ddl/check-db-fkey.c
similarity index 80%
rename from tests/ddl/check-ddl-fkey.c
rename to tests/ddl/check-db-fkey.c
index e52c09784..d89cae124 100644
--- a/tests/ddl/check-ddl-fkey.c
+++ b/tests/ddl/check-db-fkey.c
@@ -1,4 +1,4 @@
-/* check-ddl-fkey.c
+/* check-db-fkey.c
*
* Copyright 2018 Pavlo Solntsev <p sun fun gmail com>
*
@@ -22,14 +22,14 @@
#include <glib/gi18n.h>
#include <locale.h>
#include <libgda/libgda.h>
-#include <libgda/gda-ddl-fkey.h>
+#include <libgda/gda-db-fkey.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlwriter.h>
typedef struct {
- GdaDdlFkey *fkey;
+ GdaDbFkey *fkey;
GList *fkfield;
GList *reffield;
@@ -44,18 +44,18 @@ typedef struct {
} CheckDdlObject;
static void
-test_ddl_fkey_run2 (CheckDdlObject *self,
+test_db_fkey_run2 (CheckDbObject *self,
gconstpointer user_data)
{
const gchar *reftable = NULL;
- reftable = gda_ddl_fkey_get_ref_table (self->fkey);
+ reftable = gda_db_fkey_get_ref_table (self->fkey);
g_assert_cmpstr (reftable, ==, self->reftable);
const GList *fkfield = NULL;
- fkfield = gda_ddl_fkey_get_field_name (self->fkey);
+ fkfield = gda_db_fkey_get_field_name (self->fkey);
g_assert_nonnull (fkfield);
@@ -67,31 +67,31 @@ test_ddl_fkey_run2 (CheckDdlObject *self,
const GList *reffield = NULL;
- reffield = gda_ddl_fkey_get_ref_field(self->fkey);
+ reffield = gda_db_fkey_get_ref_field(self->fkey);
g_assert_nonnull (reffield);
for (it = reffield, jt = self->reffield; it && jt; it = it->next, jt = jt->next)
g_assert_cmpstr(it->data, ==, jt->data);
- const gchar *onupdate = gda_ddl_fkey_get_onupdate (self->fkey);
+ const gchar *onupdate = gda_db_fkey_get_onupdate (self->fkey);
g_assert_cmpstr(onupdate, ==, self->onupdate);
- const gchar *ondelete = gda_ddl_fkey_get_ondelete (self->fkey);
+ const gchar *ondelete = gda_db_fkey_get_ondelete (self->fkey);
g_assert_cmpstr(ondelete, ==, self->ondelete);
}
static void
-test_ddl_fkey_run1 (void)
+test_db_fkey_run1 (void)
{
GdaDdlFkey *self = gda_ddl_fkey_new ();
g_object_unref (self);
}
static void
-test_ddl_fkey_run3 (CheckDdlObject *self,
+test_db_fkey_run3 (CheckDbObject *self,
gconstpointer user_data)
{
xmlNodePtr node = NULL;
@@ -117,7 +117,7 @@ test_ddl_fkey_run3 (CheckDdlObject *self,
}
static void
-test_ddl_fkey_start (CheckDdlObject *self,
+test_db_fkey_start (CheckDbObject *self,
gconstpointer user_data)
{
self->doc = NULL;
@@ -148,7 +148,7 @@ test_ddl_fkey_start (CheckDdlObject *self,
self->xmlfile = g_build_filename(topsrcdir,
"tests",
- "ddl",
+ "db",
"fkey_test.xml",NULL);
g_assert_nonnull (self->xmlfile);
@@ -159,7 +159,7 @@ test_ddl_fkey_start (CheckDdlObject *self,
xmlNodePtr node = xmlDocGetRootElement (self->doc);
g_assert_nonnull (node);
- self->fkey = gda_ddl_fkey_new ();
+ self->fkey = gda_db_fkey_new ();
g_assert_nonnull(self->fkey);
@@ -169,7 +169,7 @@ test_ddl_fkey_start (CheckDdlObject *self,
}
static void
-test_ddl_fkey_finish (CheckDdlObject *self,
+test_db_fkey_finish (CheckDbObject *self,
gconstpointer user_data)
{
g_free (self->xmlfile);
@@ -190,22 +190,22 @@ main (gint argc,
g_test_init (&argc,&argv,NULL);
- g_test_add_func ("/test-ddl/fkey-basic",
- test_ddl_fkey_run1);
+ g_test_add_func ("/test-db/fkey-basic",
+ test_db_fkey_run1);
- g_test_add ("/test-ddl/fkey-parse",
- CheckDdlObject,
+ g_test_add ("/test-db/fkey-parse",
+ CheckDbObject,
NULL,
- test_ddl_fkey_start,
- test_ddl_fkey_run2,
- test_ddl_fkey_finish);
+ test_db_fkey_start,
+ test_db_fkey_run2,
+ test_db_fkey_finish);
- g_test_add ("/test-ddl/fkey-write",
- CheckDdlObject,
+ g_test_add ("/test-db/fkey-write",
+ CheckDbObject,
NULL,
- test_ddl_fkey_start,
- test_ddl_fkey_run3,
- test_ddl_fkey_finish);
+ test_db_fkey_start,
+ test_db_fkey_run3,
+ test_db_fkey_finish);
return g_test_run();
}
diff --git a/tests/ddl/check-ddl-view.c b/tests/ddl/check-db-view.c
similarity index 64%
rename from tests/ddl/check-ddl-view.c
rename to tests/ddl/check-db-view.c
index 483c04034..231f2fd24 100644
--- a/tests/ddl/check-ddl-view.c
+++ b/tests/ddl/check-db-view.c
@@ -1,4 +1,4 @@
-/* check-ddl-view.c
+/* check-db-view.c
*
* Copyright 2018 Pavlo Solntsev <p sun fun gmail com>
*
@@ -22,14 +22,14 @@
#include <glib/gi18n.h>
#include <locale.h>
#include <libgda/libgda.h>
-#include <libgda/gda-ddl-view.h>
+#include <libgda/gda-db-view.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlwriter.h>
typedef struct {
- GdaDdlView *view;
+ GdaDbView *view;
gchar *name;
gchar *defstring;
@@ -39,72 +39,72 @@ typedef struct {
xmlDocPtr doc;
gchar *xmlfile;
-} CheckDdlObject;
+} CheckDbObject;
static void
-test_ddl_view_name (CheckDdlObject *self,
+test_db_view_name (CheckDbObject *self,
gconstpointer user_data)
{
const gchar *name = NULL;
- name = gda_ddl_base_get_name (GDA_DDL_BASE(self->view));
+ name = gda_db_base_get_name (GDA_DB_BASE(self->view));
g_assert_cmpstr (name, ==, "Summary");
}
static void
-test_ddl_view_temp (CheckDdlObject *self,
+test_db_view_temp (CheckDbObject *self,
gconstpointer user_data)
{
gboolean istemp = FALSE;
- istemp = gda_ddl_view_get_istemp(self->view);
+ istemp = gda_db_view_get_istemp(self->view);
g_assert_true (istemp);
}
static void
-test_ddl_view_replace (CheckDdlObject *self,
+test_db_view_replace (CheckDbObject *self,
gconstpointer user_data)
{
gboolean replace = FALSE;
- replace = gda_ddl_view_get_replace (self->view);
+ replace = gda_db_view_get_replace (self->view);
g_assert_true (replace);
}
static void
-test_ddl_view_ifnoexist (CheckDdlObject *self,
+test_db_view_ifnoexist (CheckDbObject *self,
gconstpointer user_data)
{
gboolean ifnoexist = FALSE;
- ifnoexist = gda_ddl_view_get_ifnoexist (self->view);
+ ifnoexist = gda_db_view_get_ifnoexist (self->view);
g_assert_true (ifnoexist);
}
static void
-test_ddl_view_defstr (CheckDdlObject *self,
+test_db_view_defstr (CheckDbObject *self,
gconstpointer user_data)
{
const gchar *defstr = NULL;
- defstr = gda_ddl_view_get_defstring (self->view);
+ defstr = gda_db_view_get_defstring (self->view);
g_assert_cmpstr (defstr, ==, "SELECT id,name FROM CUSTOMER");
}
static void
-test_ddl_view_general (void)
+test_db_view_general (void)
{
- GdaDdlView *self = gda_ddl_view_new ();
+ GdaDbView *self = gda_db_view_new ();
g_object_unref (self);
}
static void
-test_ddl_view_start (CheckDdlObject *self,
+test_db_view_start (CheckDbObject *self,
gconstpointer user_data)
{
self->doc = NULL;
@@ -135,18 +135,18 @@ test_ddl_view_start (CheckDdlObject *self,
xmlNodePtr node = xmlDocGetRootElement (self->doc);
g_assert_nonnull (node);
- self->view = gda_ddl_view_new ();
+ self->view = gda_db_view_new ();
g_assert_nonnull(self->view);
g_print("Before parse node\n");
- gboolean res = gda_ddl_buildable_parse_node(GDA_DDL_BUILDABLE(self->view),
+ gboolean res = gda_db_buildable_parse_node(GDA_DB_BUILDABLE(self->view),
node,NULL);
g_print("After parse node\n");
g_assert_true (res);
}
static void
-test_ddl_view_finish (CheckDdlObject *self,
+test_db_view_finish (CheckDbObject *self,
gconstpointer user_data)
{
g_free (self->xmlfile);
@@ -164,43 +164,43 @@ main (gint argc,
g_test_init (&argc,&argv,NULL);
- g_test_add_func ("/test-ddl/view-basic",
- test_ddl_view_general);
+ g_test_add_func ("/test-db/view-basic",
+ test_db_view_general);
- g_test_add ("/test-ddl/view-name",
- CheckDdlObject,
+ g_test_add ("/test-db/view-name",
+ CheckDbObject,
NULL,
- test_ddl_view_start,
- test_ddl_view_name,
- test_ddl_view_finish);
+ test_db_view_start,
+ test_db_view_name,
+ test_db_view_finish);
- g_test_add ("/test-ddl/view-temp",
- CheckDdlObject,
+ g_test_add ("/test-db/view-temp",
+ CheckDbObject,
NULL,
- test_ddl_view_start,
- test_ddl_view_temp,
- test_ddl_view_finish);
+ test_db_view_start,
+ test_db_view_temp,
+ test_db_view_finish);
- g_test_add ("/test-ddl/view-ifnoexist",
- CheckDdlObject,
+ g_test_add ("/test-db/view-ifnoexist",
+ CheckDbObject,
NULL,
- test_ddl_view_start,
- test_ddl_view_ifnoexist,
- test_ddl_view_finish);
+ test_db_view_start,
+ test_db_view_ifnoexist,
+ test_db_view_finish);
- g_test_add ("/test-ddl/view-replace",
- CheckDdlObject,
+ g_test_add ("/test-db/view-replace",
+ CheckDbObject,
NULL,
- test_ddl_view_start,
- test_ddl_view_replace,
- test_ddl_view_finish);
+ test_db_view_start,
+ test_db_view_replace,
+ test_db_view_finish);
- g_test_add ("/test-ddl/view-defstr",
- CheckDdlObject,
+ g_test_add ("/test-db/view-defstr",
+ CheckDbObject,
NULL,
- test_ddl_view_start,
- test_ddl_view_defstr,
- test_ddl_view_finish);
+ test_db_view_start,
+ test_db_view_defstr,
+ test_db_view_finish);
return g_test_run();
}
diff --git a/tests/ddl/meson.build b/tests/ddl/meson.build
index 7d3f6aff7..4eb576825 100644
--- a/tests/ddl/meson.build
+++ b/tests/ddl/meson.build
@@ -1,12 +1,12 @@
inc_testsh = include_directories ('.')
inc_testsh_dep = declare_dependency (include_directories : inc_testsh)
-ddl_sources = files([
- 'check-ddl-creator.c'
+db_sources = files([
+ 'check-db-catalog.c'
])
-tbc = executable('check-ddl-creator',
- ddl_sources,
+tbc = executable('check-db-catalog',
+ db_sources,
c_args: [
'-include',
meson.build_root() + '/config.h',
@@ -21,15 +21,15 @@ tbc = executable('check-ddl-creator',
],
install: false
)
-test('ddlcreator', tbc,
+test('dbcatalog', tbc,
env: [
'GDA_TOP_SRC_DIR='+meson.source_root(),
'GDA_TOP_BUILD_DIR='+meson.build_root()
]
)
-ddltb = executable('check_ddl_base',
- 'check-ddl-base.c',
+dbtb = executable('check_db_base',
+ 'check-db-base.c',
c_args: [
'-include',
meson.build_root() + '/config.h',
@@ -44,7 +44,7 @@ ddltb = executable('check_ddl_base',
],
install: false
)
-test('ddlbase', ddltb,
+test('dbbase', dbtb,
env: [
'GDA_TOP_SRC_DIR='+meson.source_root(),
'GDA_TOP_BUILD_DIR='+meson.build_root()
@@ -53,8 +53,8 @@ test('ddlbase', ddltb,
-ddltc = executable('check_ddl_column',
- 'check-ddl-column.c',
+dbtc = executable('check_db_column',
+ 'check-db-column.c',
c_args: [
'-include',
meson.build_root() + '/config.h',
@@ -69,15 +69,15 @@ ddltc = executable('check_ddl_column',
],
install: false
)
-test('ddlcolumn', ddltc,
+test('dbcolumn', dbtc,
env: [
'GDA_TOP_SRC_DIR='+meson.source_root(),
'GDA_TOP_BUILD_DIR='+meson.build_root()
]
)
-ddltv = executable('check_ddl_view',
- 'check-ddl-view.c',
+dbtv = executable('check_db_view',
+ 'check-db-view.c',
c_args: [
'-include',
meson.build_root() + '/config.h',
@@ -92,14 +92,14 @@ ddltv = executable('check_ddl_view',
],
install: false
)
-test('ddlview', ddltv,
+test('dbview', dbtv,
env: [
'GDA_TOP_SRC_DIR='+meson.source_root(),
'GDA_TOP_BUILD_DIR='+meson.build_root()
]
)
-ddlfkey = executable('check_ddl_fkey',
- 'check-ddl-fkey.c',
+dbfkey = executable('check_db_fkey',
+ 'check-db-fkey.c',
c_args: [
'-include',
meson.build_root() + '/config.h',
@@ -114,14 +114,14 @@ ddlfkey = executable('check_ddl_fkey',
],
install: false
)
-test('ddlfkey', ddlfkey,
+test('dbfkey', dbfkey,
env: [
'GDA_TOP_SRC_DIR='+meson.source_root(),
'GDA_TOP_BUILD_DIR='+meson.build_root()
]
)
-ddlcreate = executable('check_ddl_create',
- 'check-ddl-db-create.c',
+dbcreate = executable('check_db_create',
+ 'check-db-db-create.c',
c_args: [
'-include',
meson.build_root() + '/config.h',
@@ -136,19 +136,19 @@ ddlcreate = executable('check_ddl_create',
],
install: false
)
-test('ddlcreate', ddlcreate,
+test('dbcreate', dbcreate,
env: [
'GDA_TOP_SRC_DIR='+meson.source_root(),
'GDA_TOP_BUILD_DIR='+meson.build_root()
]
)
-ddl_creator_pg_sources = files([
- 'check-ddl-creator-postgresql.c'
+db_catalog_pg_sources = files([
+ 'check-db-catalog-postgresql.c'
])
-tcpg = executable('check-ddl-creator-postgresql',
- ddl_creator_pg_sources,
+tcpg = executable('check-db-catalog-postgresql',
+ db_catalog_pg_sources,
c_args: [
'-include',
meson.build_root() + '/config.h',
@@ -164,9 +164,9 @@ tcpg = executable('check-ddl-creator-postgresql',
],
install: false
)
-test('ddlcreator-postgresql', tcpg,
+test('dbcatalog-postgresql', tcpg,
env: [
'GDA_TOP_SRC_DIR='+meson.source_root(),
'GDA_TOP_BUILD_DIR='+meson.build_root()
]
- )
\ No newline at end of file
+ )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]