[libgda: 1/2] Misc corrections in GdaDB module
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda: 1/2] Misc corrections in GdaDB module
- Date: Fri, 22 Feb 2019 20:03:57 +0000 (UTC)
commit 9f4fead500cb284ed50a5f8560e7b9c9de107988
Author: Pavlo Solntsev <p sun fun gmail com>
Date: Fri Feb 15 14:12:34 2019 -0600
Misc corrections in GdaDB module
This path includes misc correction for documentation, parameter
checking, formating. White spaces were removed.
libgda/gda-connection.c | 4 +-
libgda/gda-db-base.c | 66 +++++-----
libgda/gda-db-buildable.c | 24 ++--
libgda/gda-db-buildable.h | 11 +-
libgda/gda-db-catalog.c | 230 +++++++++++++++++++----------------
libgda/gda-db-catalog.h | 11 +-
libgda/gda-db-column.c | 302 ++++++++++++++++++++++++----------------------
libgda/gda-db-column.h | 5 +-
libgda/gda-db-fkey.c | 154 +++++++++++------------
libgda/gda-db-table.c | 255 ++++++++++++++++++++------------------
libgda/gda-db-view.c | 214 ++++++++++++++++----------------
libgda/gda-db-view.h | 16 ---
12 files changed, 675 insertions(+), 617 deletions(-)
---
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index 568e91fe5..1ff77be86 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -7224,8 +7224,8 @@ gda_connection_operation_get_sql_identifier_at_path (GdaConnection *cnc, GdaServ
* gda_connection_create_db_catalog:
* @cnc: A #GdaConnection object to use
*
- * 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
+ * A convenient method to create a new #GdaDbCatalog 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:
*
* GdaDbCatalog *catalog = gda_db_catalog_new ();
diff --git a/libgda/gda-db-base.c b/libgda/gda-db-base.c
index db55ef303..98bd1ee6a 100644
--- a/libgda/gda-db-base.c
+++ b/libgda/gda-db-base.c
@@ -29,14 +29,14 @@ typedef struct
} GdaDbBasePrivate;
/**
- * SECTION:gda-db-base
+ * SECTION:gda-db-base
* @short_description: The basic class for all database objects
* @see_also: #GdaDbTable, #GdaDbView
* @stability: Stable
* @include: libgda/libgda.h
*
* This is a basic class for database objects, e.g. #GdaDbTable and #GdaDbView. It is not common to
- * use it directly.
+ * use it directly.
*/
G_DEFINE_TYPE_WITH_PRIVATE (GdaDbBase, gda_db_base, G_TYPE_OBJECT)
@@ -46,7 +46,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (GdaDbBase, gda_db_base, G_TYPE_OBJECT)
*
* Create a new #GdaDbBase instance
*
- * Returns: a new #GdaDbBase instance
+ * Returns: a new #GdaDbBase instance
*/
GdaDbBase*
gda_db_base_new (void)
@@ -95,7 +95,7 @@ gda_db_base_init (GdaDbBase *self)
* @name: a table name associated with the table
*
* Sets database object names. @catalog and @schema can be %NULL but
- * @name always should be a valid, not %NULL string. The @name must be always
+ * @name always should be a valid, not %NULL string. The @name must be
* set. If @catalog is %NULL @schema may not be %NULL but if @schema is
* %NULL @catalog also should be %NULL.
*
@@ -132,12 +132,12 @@ gda_db_base_set_names (GdaDbBase *self,
fullnamestr = g_string_new (NULL);
if (priv->m_catalog && priv->m_schema)
- g_string_printf (fullnamestr,"%s.%s.%s",priv->m_catalog,
- priv->m_schema,priv->m_name);
+ g_string_printf (fullnamestr, "%s.%s.%s", priv->m_catalog,
+ priv->m_schema, priv->m_name);
else if (priv->m_schema)
- g_string_printf (fullnamestr,"%s.%s",priv->m_schema,priv->m_name);
+ g_string_printf (fullnamestr, "%s.%s", priv->m_schema, priv->m_name);
else
- g_string_printf (fullnamestr,"%s",priv->m_name);
+ g_string_printf (fullnamestr, "%s", priv->m_name);
priv->m_fullname = g_strdup (fullnamestr->str);
g_string_free (fullnamestr, TRUE);
@@ -159,7 +159,7 @@ gda_db_base_set_names (GdaDbBase *self,
const gchar*
gda_db_base_get_full_name (GdaDbBase *self)
{
- g_return_val_if_fail (self,NULL);
+ g_return_val_if_fail (self, NULL);
GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
@@ -168,12 +168,12 @@ gda_db_base_get_full_name (GdaDbBase *self)
fullnamestr = g_string_new (NULL);
if (priv->m_catalog && priv->m_schema && priv->m_name)
- g_string_printf (fullnamestr,"%s.%s.%s",priv->m_catalog,
- priv->m_schema,priv->m_name);
+ g_string_printf (fullnamestr, "%s.%s.%s", priv->m_catalog,
+ priv->m_schema, priv->m_name);
else if (priv->m_schema && priv->m_name)
- g_string_printf (fullnamestr,"%s.%s",priv->m_schema,priv->m_name);
+ g_string_printf (fullnamestr, "%s.%s", priv->m_schema, priv->m_name);
else if (priv->m_name)
- g_string_printf (fullnamestr,"%s",priv->m_name);
+ g_string_printf (fullnamestr, "%s", priv->m_name);
else
return NULL;
@@ -194,9 +194,9 @@ gda_db_base_get_full_name (GdaDbBase *self)
* Since: 6.0
*/
const gchar*
-gda_db_base_get_catalog (GdaDbBase *self)
+gda_db_base_get_catalog (GdaDbBase *self)
{
- g_return_val_if_fail (self,NULL);
+ g_return_val_if_fail (self, NULL);
GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
@@ -209,14 +209,14 @@ gda_db_base_get_catalog (GdaDbBase *self)
*
* Returns current schema name. The returned string should not be freed.
*
- * Returns: Current catalog or %NULL
+ * Returns: Current scheme or %NULL
*
* Since: 6.0
*/
const gchar*
-gda_db_base_get_schema (GdaDbBase *self)
+gda_db_base_get_schema (GdaDbBase *self)
{
- g_return_val_if_fail (self,NULL);
+ g_return_val_if_fail (self, NULL);
GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
@@ -234,9 +234,9 @@ gda_db_base_get_schema (GdaDbBase *self)
* Since: 6.0
*/
const gchar*
-gda_db_base_get_name (GdaDbBase *self)
+gda_db_base_get_name (GdaDbBase *self)
{
- g_return_val_if_fail (self,NULL);
+ g_return_val_if_fail (self, NULL);
GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
@@ -247,7 +247,7 @@ gda_db_base_get_name (GdaDbBase *self)
* gda_db_base_set_catalog:
* @self: a #GdaDbBase instance
* @catalog: Catalog name as a string
- *
+ *
* Set catalog name
*
* Since: 6.0
@@ -269,7 +269,7 @@ gda_db_base_set_catalog (GdaDbBase *self,
* @self: a #GdaDbBase instance
* @schema: Schema name as a string
*
- * Set object schema.
+ * Set object schema. If @schema is %NULL the function just returns.
*
* Since: 6.0
*/
@@ -279,6 +279,9 @@ gda_db_base_set_schema (GdaDbBase *self,
{
g_return_if_fail (self);
+ if (!schema)
+ return;
+
GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
g_free (priv->m_schema);
@@ -289,8 +292,8 @@ gda_db_base_set_schema (GdaDbBase *self,
* gda_db_base_set_name:
* @self: a #GdaDbBase instance
* @name: Object name as a string
- *
- * Set object name
+ *
+ * Set object name. If @name is %NULL the function just returns.
*
* Since: 6.0
*/
@@ -300,6 +303,9 @@ gda_db_base_set_name (GdaDbBase *self,
{
g_return_if_fail (self);
+ if (!name)
+ return;
+
GdaDbBasePrivate *priv = gda_db_base_get_instance_private (self);
g_free (priv->m_name);
@@ -311,7 +317,7 @@ gda_db_base_set_name (GdaDbBase *self,
* @a: first #GdaDbBase object
* @b: second #GdaDbBase object
*
- * Compares two objects similar to g_strcmp().
+ * Compares two objects similar to g_strcmp().
*
* Returns: 0 if catalog, schema and name are the same
*
@@ -327,15 +333,15 @@ gda_db_base_compare (GdaDbBase *a,
return -1;
else if (a && !b)
return 1;
-
- gint res = g_strcmp0 (gda_db_base_get_name(a),gda_db_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_db_base_get_catalog(a),gda_db_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_db_base_get_schema(a),gda_db_base_get_schema(b));
+ return g_strcmp0(gda_db_base_get_schema(a), gda_db_base_get_schema(b));
else
return res;
}
diff --git a/libgda/gda-db-buildable.c b/libgda/gda-db-buildable.c
index f84132298..8bd28f91e 100644
--- a/libgda/gda-db-buildable.c
+++ b/libgda/gda-db-buildable.c
@@ -32,7 +32,7 @@ G_DEFINE_INTERFACE (GdaDbBuildable, gda_db_buildable, G_TYPE_OBJECT)
* @include: libgda/gda-db-buildable.h
*
* #GdaDbBuildable represents an interface for writing and reading xml nodes. #GdaDbTable and
- * #GdaDbView implement this interface.
+ * #GdaDbView implement this interface.
*/
static void
@@ -45,9 +45,9 @@ gda_db_buildable_default_init (GdaDbBuildableInterface *iface)
* 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
+ * @error: (nullable): an object to store the error
*
- * Parse xml node
+ * This method parse XML node and populate @self object.
*
* Returns: %TRUE on success, %FALSE if an error occurred
* Since: 6.0
@@ -58,23 +58,23 @@ gda_db_buildable_parse_node (GdaDbBuildable *self,
xmlNodePtr node,
GError **error)
{
- GdaDbBuildableInterface *iface;
+ GdaDbBuildableInterface *iface = NULL;
- g_return_val_if_fail (GDA_IS_DB_BUILDABLE (self),FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL,FALSE);
+ g_return_val_if_fail (GDA_IS_DB_BUILDABLE (self), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
iface = GDA_DB_BUILDABLE_GET_IFACE (self);
- g_return_val_if_fail (iface->parse_node != NULL,FALSE);
+ g_return_val_if_fail (iface->parse_node != NULL, FALSE);
return iface->parse_node (self, node, error);
}
/**
* gda_db_buildable_write_node:
- * @self: an instance of #GdaDbBuildable where data should be taken
+ * @self: an instance of #GdaDbBuildable where data should be taken
* @node: a node to write data in
* @error: (nullable): an object to store error
*
- * Write content from the @self to the @node
+ * Write content from the @self to the @node
*
* Returns: %TRUE on success, %FALSE if an error occurred
* Since: 6.0
@@ -87,11 +87,11 @@ gda_db_buildable_write_node (GdaDbBuildable *self,
{
GdaDbBuildableInterface *iface;
- g_return_val_if_fail (GDA_IS_DB_BUILDABLE (self),FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL,FALSE);
+ g_return_val_if_fail (GDA_IS_DB_BUILDABLE (self), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
iface = GDA_DB_BUILDABLE_GET_IFACE (self);
- g_return_val_if_fail (iface->write_node != NULL,FALSE);
+ g_return_val_if_fail (iface->write_node != NULL, FALSE);
return iface->write_node (self, node, error);
}
diff --git a/libgda/gda-db-buildable.h b/libgda/gda-db-buildable.h
index d2ee275c6..dd82b55e7 100644
--- a/libgda/gda-db-buildable.h
+++ b/libgda/gda-db-buildable.h
@@ -29,7 +29,8 @@
G_BEGIN_DECLS
#define GDA_TYPE_DB_BUILDABLE gda_db_buildable_get_type ()
-G_DECLARE_INTERFACE(GdaDbBuildable, gda_db_buildable,GDA, DB_BUILDABLE,GObject)
+
+G_DECLARE_INTERFACE(GdaDbBuildable, gda_db_buildable, GDA, DB_BUILDABLE, GObject)
struct _GdaDbBuildableInterface
{
@@ -45,12 +46,12 @@ struct _GdaDbBuildableInterface
};
gboolean gda_db_buildable_parse_node (GdaDbBuildable *self,
- xmlNodePtr node,
- GError **error);
+ xmlNodePtr node,
+ GError **error);
gboolean gda_db_buildable_write_node (GdaDbBuildable *self,
- xmlNodePtr node,
- GError **error);
+ xmlNodePtr node,
+ GError **error);
G_END_DECLS
diff --git a/libgda/gda-db-catalog.c b/libgda/gda-db-catalog.c
index 7c67af571..f89400422 100644
--- a/libgda/gda-db-catalog.c
+++ b/libgda/gda-db-catalog.c
@@ -45,17 +45,20 @@ typedef struct
/**
* SECTION:gda-db-catalog
* @title: GdaDbCatalog
- * @short_description: Object to constract database representation from an xml file or by reading the
existing datatabase
+ * @short_description: Object to constract database representation from an xml file or by reading
+ * the existing datatabase
* @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_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().
- *
+ * This is a main object that represents overall database. The best way to create an instance of
+ * #GdaDbCatalog is to call gda_connection_create_db_catalog(). This object may be also constracted
+ * from an xml file using gda_db_catalog_parse_file() or gda_db_catalog_parse_file_from_path() or
+ * didrectly from the open connection using gda_db_catalog_parse_cnc().
+ *
+ * The database can be updated or modified using gda_db_catalog_perform_operation() and dumped to
+ * a file using gda_db_catalog_write_to_path() or gda_db_catalog_write_to_file().
+ *
*/
G_DEFINE_TYPE_WITH_PRIVATE (GdaDbCatalog, gda_db_catalog, G_TYPE_OBJECT)
@@ -207,7 +210,7 @@ static gboolean
_gda_db_catalog_validate_doc (xmlDocPtr doc,
GError **error)
{
- g_return_val_if_fail (doc,FALSE);
+ g_return_val_if_fail (doc, FALSE);
xmlValidCtxtPtr ctx = NULL;
@@ -222,7 +225,7 @@ _gda_db_catalog_validate_doc (xmlDocPtr doc,
goto on_error;
}
- int valid = xmlValidateDtd (ctx,doc,_gda_db_catalog_dtd);
+ int valid = xmlValidateDtd (ctx, doc,_gda_db_catalog_dtd);
if (!valid)
{
@@ -249,7 +252,7 @@ on_error:
*
* Internal method to populate #GdaDbCatalog from @doc instance.
*
- * Returns: %TRUE if no errors, %FALSE otherwise.
+ * Returns: %TRUE if no errors, %FALSE otherwise.
*
*/
static gboolean
@@ -257,8 +260,8 @@ _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);
+ g_return_val_if_fail (self, FALSE);
+ g_return_val_if_fail (doc, FALSE);
xmlChar *schema_name = NULL;
xmlNodePtr node = NULL;
@@ -279,7 +282,7 @@ _gda_db_catalog_parse_doc (GdaDbCatalog *self,
schema_name = xmlGetProp(node,(xmlChar *)"name");
// g_assert (schema_name); /* If schema_name == NULL we have problem with validation */
if (schema_name)
- g_object_set (self,"schema_name",(char*)schema_name,NULL);
+ g_object_set (self, "schema_name", (char*)schema_name, NULL);
xmlFree (schema_name);
@@ -313,7 +316,7 @@ _gda_db_catalog_parse_doc (GdaDbCatalog *self,
goto on_error;
}
else
- priv->mp_views = g_list_append (priv->mp_views,view);
+ priv->mp_views = g_list_append (priv->mp_views, view);
} /* end of else if */
} /* End of for loop */
@@ -337,12 +340,12 @@ on_error:
* |[<!-- language="DTD" -->
* <!ELEMENT schema (table+, view*)>
* <!ATTLIST schema name CDATA #IMPLIED>
- *
+ *
* <!ELEMENT table (comment?,column+, fkey*)>
* <!ATTLIST table temptable (TRUE|FALSE) "FALSE">
* <!ATTLIST table name CDATA #REQUIRED>
* <!ATTLIST table space CDATA #IMPLIED>
- *
+ *
* <!ELEMENT column (comment?, value?, check?)>
* <!ATTLIST column name CDATA #REQUIRED>
* <!ATTLIST column type CDATA #REQUIRED>
@@ -350,29 +353,29 @@ on_error:
* <!ATTLIST column unique (TRUE|FALSE) "FALSE">
* <!ATTLIST column autoinc (TRUE|FALSE) "FALSE">
* <!ATTLIST column nnul (TRUE|FALSE) "FALSE">
- *
+ *
* <!ELEMENT comment (#PCDATA)>
* <!ELEMENT value (#PCDATA)>
* <!ATTLIST value size CDATA #IMPLIED>
* <!ATTLIST value scale CDATA #IMPLIED>
- *
+ *
* <!ELEMENT check (#PCDATA)>
- *
+ *
* <!ELEMENT fkey (fk_field?)>
* <!ATTLIST fkey reftable CDATA #IMPLIED>
* <!ATTLIST fkey onupdate (RESTRICT|CASCADE|SET_NULL|NO_ACTION|SET_DEFAULT) #IMPLIED>
* <!ATTLIST fkey ondelete (RESTRICT|CASCADE|SET_NULL|NO_ACTION|SET_DEFAULT) #IMPLIED>
- *
+ *
* <!ELEMENT fk_field (#PCDATA)>
* <!ATTLIST fk_field name CDATA #REQUIRED>
* <!ATTLIST fk_field reffield CDATA #REQUIRED>
- *
+ *
* <!ELEMENT view (definition)>
* <!ATTLIST view name CDATA #REQUIRED>
* <!ATTLIST view replace (TRUE|FALSE) "FALSE">
* <!ATTLIST view temp (TRUE|FALSE) "FALSE">
* <!ATTLIST view ifnotexists (TRUE|FALSE) "TRUE">
- *
+ *
* <!ELEMENT definition (#PCDATA)>
* ]|
*
@@ -381,8 +384,9 @@ on_error:
* (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.
+ * returned if fails. The @xmlfile will be validated internally using
+ * gda_db_catalog_validate_to_file() or gda_db_catalog_validate_to_path() methods.
+ * The same methods can be used to validate xmlfile before parsing it.
*/
gboolean
gda_db_catalog_parse_file_from_path (GdaDbCatalog *self,
@@ -395,7 +399,7 @@ gda_db_catalog_parse_file_from_path (GdaDbCatalog *self,
xmlDocPtr doc = NULL;
- doc = xmlParseFile(xmlfile);
+ doc = xmlParseFile (xmlfile);
if (!doc)
{
@@ -406,7 +410,7 @@ gda_db_catalog_parse_file_from_path (GdaDbCatalog *self,
goto on_error;
}
- if (!_gda_db_catalog_validate_doc (doc,error))
+ if (!_gda_db_catalog_validate_doc (doc, error))
{
g_set_error (error,
GDA_DB_CATALOG_ERROR,
@@ -415,9 +419,9 @@ gda_db_catalog_parse_file_from_path (GdaDbCatalog *self,
goto on_error;
}
- if (!_gda_db_catalog_parse_doc (self,doc,error))
+ if (!_gda_db_catalog_parse_doc (self, doc, error))
goto on_error;
-
+
xmlFreeDoc (doc);
return TRUE;
@@ -442,8 +446,8 @@ gboolean
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_db_catalog_dtd,FALSE);
+ g_return_val_if_fail (xmlfile, FALSE);
+ g_return_val_if_fail (_gda_db_catalog_dtd, FALSE);
xmlDocPtr doc = NULL;
@@ -458,7 +462,7 @@ gda_db_catalog_validate_file_from_path (const gchar *xmlfile,
goto on_error;
}
- if (!_gda_db_catalog_validate_doc (doc,error))
+ if (!_gda_db_catalog_validate_doc (doc, error))
goto on_error;
xmlFreeDoc (doc);
@@ -474,13 +478,15 @@ on_error:
* gda_db_catalog_get_tables:
* @self: a #GdaDbCatalog object
*
- * Returns: (element-type Gda.DbTable) (transfer none): a list of tables
+ * Returns: (element-type Gda.DbTable) (transfer none): a list of tables as #GdaDbTable or %NULL.
*
* Since: 6.0
*/
GList*
gda_db_catalog_get_tables (GdaDbCatalog *self)
{
+ g_return_val_if_fail (self, NULL);
+
GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
return priv->mp_tables;
}
@@ -489,13 +495,15 @@ gda_db_catalog_get_tables (GdaDbCatalog *self)
* gda_db_catalog_get_views:
* @self: a #GdaDbCatalog object
*
- * Returns: (element-type Gda.DbView) (transfer none): a list of views
+ * Returns: (element-type Gda.DbView) (transfer none): a list of views as #GdaDbView or %NULL
*
* Since: 6.0
*/
GList*
gda_db_catalog_get_views (GdaDbCatalog *self)
{
+ g_return_val_if_fail (self, NULL);
+
GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
return priv->mp_views;
}
@@ -516,13 +524,13 @@ gda_db_catalog_get_table (GdaDbCatalog *self,
const gchar *schema,
const gchar *name)
{
- g_return_val_if_fail (self,NULL);
- g_return_val_if_fail (name,NULL);
+ g_return_val_if_fail (self, NULL);
+ g_return_val_if_fail (name, NULL);
GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
GdaDbBase *iobj = gda_db_base_new ();
- gda_db_base_set_names (iobj,catalog,schema,name);
+ gda_db_base_set_names (iobj, catalog, schema, name);
GList *it = NULL;
@@ -542,9 +550,9 @@ gda_db_catalog_get_table (GdaDbCatalog *self,
* @self: a #GdaDbCatalog object
* @name: view name
*
- * Convenient function to return a view based on name
+ * Convenient function to return a view based on name.
*
- * Returns: table as #GdaDbView or %NULL
+ * Returns: table as #GdaDbView or %NULL if the view is not found.
*
*/
const GdaDbView*
@@ -561,10 +569,10 @@ gda_db_catalog_get_view (GdaDbCatalog *self,
gda_db_base_set_names (iobj,catalog,schema,name);
for (it = priv->mp_views; it; it = it->next)
- if (!gda_db_base_compare (iobj,GDA_DB_BASE(it)))
+ if (!gda_db_base_compare (iobj, GDA_DB_BASE(it)))
{
g_object_unref (iobj);
- return GDA_DB_VIEW(it);
+ return GDA_DB_VIEW(it);
}
g_object_unref (iobj);
@@ -579,7 +587,7 @@ gda_db_catalog_get_view (GdaDbCatalog *self,
* object. If %NULL is passed this function works exactly as
* gda_db_table_new()
*
- * This method should not be part of the public API.
+ * This method should not be part of the public API.
*
* Since: 6.0
*/
@@ -587,25 +595,25 @@ static GdaDbTable*
_gda_db_table_new_from_meta (GdaMetaDbObject *obj)
{
if (!obj)
- return gda_db_table_new();
+ return gda_db_table_new ();
if (obj->obj_type != GDA_META_DB_TABLE)
return NULL;
GdaMetaTable *metatable = GDA_META_TABLE(obj);
- GdaDbTable *table = gda_db_table_new();
+ GdaDbTable *table = gda_db_table_new ();
gda_db_base_set_names(GDA_DB_BASE(table),
- obj->obj_catalog,
- obj->obj_schema,
- obj->obj_name);
+ obj->obj_catalog,
+ obj->obj_schema,
+ obj->obj_name);
GSList *it = NULL;
for (it = metatable->columns; it; it = it->next)
{
GdaDbColumn *column = gda_db_column_new_from_meta (GDA_META_TABLE_COLUMN(it->data));
- gda_db_table_append_column(table,column);
+ gda_db_table_append_column (table, column);
}
it = NULL;
@@ -616,7 +624,7 @@ _gda_db_table_new_from_meta (GdaMetaDbObject *obj)
GdaDbFkey *fkey = gda_db_fkey_new_from_meta (GDA_META_TABLE_FOREIGN_KEY(it->data));
- gda_db_table_append_fkey (table,fkey);
+ gda_db_table_append_fkey (table, fkey);
}
@@ -629,17 +637,17 @@ _gda_db_table_new_from_meta (GdaMetaDbObject *obj)
*
* Create new #GdaDbView object from the corresponding #GdaMetaView object
*
- * This method should not be part of the public API.
+ * This method should not be part of the public API.
*
- * Returns: New instance of #GdaDbView
+ * Returns: New instance of #GdaDbView
*/
static GdaDbView*
_gda_db_view_new_from_meta (GdaMetaView *view)
{
if (!view)
- return gda_db_view_new();
+ return gda_db_view_new ();
- GdaDbView *dbview = gda_db_view_new();
+ GdaDbView *dbview = gda_db_view_new ();
gda_db_view_set_defstring (dbview,view->view_def);
gda_db_view_set_replace (dbview,view->is_updatable);
@@ -647,25 +655,28 @@ _gda_db_view_new_from_meta (GdaMetaView *view)
return dbview;
}
-/**
+/**
* gda_db_catalog_parse_cnc:
- * @self: a #GdaDbCatalog instance
+ * @self: a #GdaDbCatalog instance
* @error: error storage object
*
- * Parse cnc to populate @self object. This method should be called every time after database was
- * modified or @self was just created.
+ * Parse internal cnc to populate @self object. This method should be called every time after
+ * database was modified or @self was just created using gda_connection_create_db_catalog(). The
+ * method will return %FALSE if no internal #GdaConnection available.
*
* Returns: Returns %TRUE if succeeded, %FALSE otherwise.
+ *
+ * Since: 6.0
*/
gboolean
gda_db_catalog_parse_cnc (GdaDbCatalog *self,
GError **error)
{
- g_return_val_if_fail (self,FALSE);
+ g_return_val_if_fail (self, FALSE);
GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
- if (!gda_connection_is_opened (priv->cnc))
+ if (!priv->cnc && !gda_connection_is_opened (priv->cnc))
return FALSE;
if(!gda_connection_update_meta_store (priv->cnc, NULL, error))
@@ -676,7 +687,9 @@ gda_db_catalog_parse_cnc (GdaDbCatalog *self,
GdaMetaStruct *mstruct = NULL;
mstore = gda_connection_get_meta_store (priv->cnc);
- mstruct = (GdaMetaStruct*) g_object_new (GDA_TYPE_META_STRUCT, "meta-store", mstore, "features",
GDA_META_STRUCT_FEATURE_ALL, NULL);
+ mstruct = (GdaMetaStruct*) g_object_new (GDA_TYPE_META_STRUCT,
+ "meta-store", mstore,
+ "features", GDA_META_STRUCT_FEATURE_ALL, NULL);
GSList *dblist = NULL;
@@ -694,7 +707,7 @@ gda_db_catalog_parse_cnc (GdaDbCatalog *self,
{
if(GDA_META_DB_OBJECT(it->data)->obj_type == GDA_META_DB_TABLE)
{
- GdaDbTable *table = _gda_db_table_new_from_meta(it->data);
+ GdaDbTable *table = _gda_db_table_new_from_meta (it->data);
if (!table)
continue;
@@ -704,8 +717,8 @@ gda_db_catalog_parse_cnc (GdaDbCatalog *self,
if(GDA_META_DB_OBJECT(it->data)->obj_type == GDA_META_DB_VIEW)
{
- GdaDbView *view = _gda_db_view_new_from_meta(it->data);
- priv->mp_views = g_list_append (priv->mp_views,view);
+ GdaDbView *view = _gda_db_view_new_from_meta (it->data);
+ priv->mp_views = g_list_append (priv->mp_views, view);
continue;
}
}
@@ -726,7 +739,8 @@ on_error:
* @self: a #GdaDbCatalog instance
* @table: table to append
*
- * This method append @table to the total list of all tables stored in @self.
+ * This method append @table to the total list of all tables stored in @self. This method increase
+ * reference count for @table.
*
* Since: 6.0
*/
@@ -738,7 +752,7 @@ gda_db_catalog_append_table (GdaDbCatalog *self,
GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
- priv->mp_tables = g_list_append (priv->mp_tables,g_object_ref (table));
+ priv->mp_tables = g_list_append (priv->mp_tables, g_object_ref (table));
}
/**
@@ -746,7 +760,8 @@ gda_db_catalog_append_table (GdaDbCatalog *self,
* @self: a #GdaDbCatalog instance
* @view: view to append
*
- * This method append @view to the total list of all views stored in @self.
+ * This method append @view to the total list of all views stored in @self. This method increase
+ * reference count for @view.
*
* Since: 6.0
*/
@@ -758,7 +773,7 @@ gda_db_catalog_append_view (GdaDbCatalog *self,
GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
- priv->mp_views = g_list_append (priv->mp_views,g_object_ref (view));
+ priv->mp_views = g_list_append (priv->mp_views, g_object_ref (view));
}
/**
@@ -771,20 +786,20 @@ gda_db_catalog_append_view (GdaDbCatalog *self,
* method to work with database. For retrieving information from database to an
* 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.
+ * Connection can be added as a property using g_object_set() call and 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 #GdaDbCatalog
- * instance. If the table doesn't exist in database, it will be created (CREATE_TABLE).
+ * 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
* column exists but has different parameters, e.g. nonnull it will not be
- * modified.
+ * modified.
*
- * Note: Pkeys are not checked. This is a limitation that should be removed. The corresponding
- * issue was open on gitlab page.
+ * Note: Pkeys are not checked. This is a limitation that should be removed. The corresponding
+ * issue was open on gitlab page.
*/
gboolean
gda_db_catalog_perform_operation (GdaDbCatalog *self,
@@ -810,7 +825,10 @@ gda_db_catalog_perform_operation (GdaDbCatalog *self,
return FALSE;
GdaMetaStore *mstore = gda_connection_get_meta_store (priv->cnc);
- GdaMetaStruct *mstruct = (GdaMetaStruct*) g_object_new (GDA_TYPE_META_STRUCT, "meta-store", mstore,
"features", GDA_META_STRUCT_FEATURE_ALL, NULL);
+ GdaMetaStruct *mstruct = (GdaMetaStruct*) g_object_new (GDA_TYPE_META_STRUCT,
+ "meta-store", mstore,
+ "features", GDA_META_STRUCT_FEATURE_ALL,
+ NULL);
// We need information about catalog, schema, name for each object we would
// like to check
@@ -829,7 +847,7 @@ gda_db_catalog_perform_operation (GdaDbCatalog *self,
{
/* SQLite accepts only one possible value for schema: "main".
* Other databases may also ignore schema and reference objects only by database and
- * name, e.g. db_name.table_name
+ * name, e.g. db_name.table_name
* */
g_value_set_string (catalog, gda_db_base_get_catalog(it->data));
g_value_set_string (schema , gda_db_base_get_schema (it->data));
@@ -875,8 +893,8 @@ gda_db_catalog_perform_operation (GdaDbCatalog *self,
* gda_db_catalog_write_to_file:
* @self: a #GdaDbCatalog instance
* @file: a #GFile to write database description
- * @error: container to hold error
- *
+ * @error: container to hold error
+ *
* This method writes database description as xml file.
* Similar to gda_db_catalog_write_to_path()
*
@@ -889,11 +907,11 @@ 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);
-
+ g_return_val_if_fail (self, FALSE);
+ g_return_val_if_fail (file, FALSE);
+
gchar *filepath = g_file_get_path (file);
- gboolean res = gda_db_catalog_write_to_path (self,filepath,error);
+ gboolean res = gda_db_catalog_write_to_path (self, filepath, error);
g_free (filepath);
return res;
}
@@ -906,7 +924,7 @@ gda_db_catalog_write_to_file (GdaDbCatalog *self,
*
* Save content of @self to a user friendly xml file.
*
- * Returns: %TRUE is no error, %FLASE otherwise.
+ * Returns: %TRUE is no error, %FLASE otherwise.
*
* Since: 6.0
*/
@@ -917,7 +935,7 @@ gda_db_catalog_write_to_path (GdaDbCatalog *self,
{
g_return_val_if_fail (self,FALSE);
g_return_val_if_fail (path,FALSE);
-
+
GdaDbCatalogPrivate *priv = gda_db_catalog_get_instance_private (self);
xmlDocPtr doc = NULL;
@@ -925,17 +943,17 @@ gda_db_catalog_write_to_path (GdaDbCatalog *self,
doc = xmlNewDoc (BAD_CAST "1.0");
node_root = xmlNewNode (NULL, BAD_CAST "schema");
-
+
if (priv->mp_schemaname)
- xmlNewProp (node_root,(xmlChar*)"name",(xmlChar*)priv->mp_schemaname);
+ xmlNewProp (node_root, (xmlChar*)"name",(xmlChar*)priv->mp_schemaname);
- xmlDocSetRootElement (doc,node_root);
+ xmlDocSetRootElement (doc, node_root);
GList *it = NULL;
-
+
for (it = priv->mp_tables; it; it=it->next)
if (!gda_db_buildable_write_node (GDA_DB_BUILDABLE(GDA_DB_TABLE(it->data)),
- node_root,error))
+ node_root, error))
goto on_error;
for (it = priv->mp_views; it; it=it->next)
@@ -943,15 +961,15 @@ gda_db_catalog_write_to_path (GdaDbCatalog *self,
node_root,error))
goto on_error;
- xmlSaveFormatFileEnc (path,doc,"UTF-8",1);
+ xmlSaveFormatFileEnc (path, doc, "UTF-8", 1);
xmlFreeDoc (doc);
- xmlCleanupParser();
-
+ xmlCleanupParser ();
+
return TRUE;
on_error:
xmlFreeDoc (doc);
- xmlCleanupParser();
+ xmlCleanupParser ();
return FALSE;
}
@@ -960,7 +978,7 @@ on_error:
* @self: an instance of #GdaDbCatalog
* @xmlfile: xml file as #GFile instance
* @error: Error container
- *
+ *
* For detailed description see gda_db_catalog_parse_file_from_path()
*
* Since: 6.0
@@ -970,42 +988,44 @@ 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_db_catalog_dtd,FALSE);
+ g_return_val_if_fail (self, FALSE);
+ g_return_val_if_fail (xmlfile, FALSE);
+ g_return_val_if_fail (_gda_db_catalog_dtd, FALSE);
GFileInputStream *istream = NULL;
xmlDocPtr doc = NULL;
- istream = g_file_read (xmlfile,NULL,error);
+ istream = g_file_read (xmlfile, NULL, error);
if(!istream)
{
g_set_error (error,
GDA_DB_CATALOG_ERROR,
GDA_DB_CATALOG_FILE_READ,
- _("Can't open stream for reading file '%s'"), g_file_get_basename(xmlfile));
+ _("Can't open stream for reading file '%s'"), g_file_get_basename (xmlfile));
return FALSE;
}
xmlParserCtxtPtr ctxt = NULL;
- char buffer[10];
+ int buffer_size = 10;
+ char buffer[buffer_size];
int ctxt_res = 0;
- ctxt = xmlCreatePushParserCtxt (NULL,NULL,buffer,ctxt_res,NULL);
+ ctxt = xmlCreatePushParserCtxt (NULL, NULL, buffer, ctxt_res, NULL);
if (!ctxt)
{
g_set_error (error,
GDA_DB_CATALOG_ERROR,
GDA_DB_CATALOG_FILE_READ,
- _("Can't create parse context for '%s'"), g_file_get_basename(xmlfile));
+ _("Can't create parse context for '%s'"), g_file_get_basename (xmlfile));
goto on_error;
}
int rescheck;
- while ((ctxt_res = g_input_stream_read ((GInputStream*)istream,buffer,9,NULL,error)) > 0)
+ while ((ctxt_res = g_input_stream_read ((GInputStream*)istream, buffer, buffer_size-1,
+ NULL, error)) > 0)
{
- rescheck = xmlParseChunk(ctxt,buffer,ctxt_res,0);
-
+ rescheck = xmlParseChunk (ctxt, buffer, ctxt_res, 0);
+
if (rescheck != 0)
{
g_set_error (error,
@@ -1017,7 +1037,7 @@ gda_db_catalog_parse_file (GdaDbCatalog *self,
}
}
- xmlParseChunk (ctxt,buffer,0,1);
+ xmlParseChunk (ctxt, buffer, 0, 1);
doc = ctxt->myDoc;
ctxt_res = ctxt->wellFormed;
@@ -1040,7 +1060,7 @@ gda_db_catalog_parse_file (GdaDbCatalog *self,
goto on_error;
}
- if (!_gda_db_catalog_validate_doc(doc, error))
+ if (!_gda_db_catalog_validate_doc (doc, error))
{
g_set_error (error,
GDA_DB_CATALOG_ERROR,
diff --git a/libgda/gda-db-catalog.h b/libgda/gda-db-catalog.h
index 8aedfb724..239777b6a 100644
--- a/libgda/gda-db-catalog.h
+++ b/libgda/gda-db-catalog.h
@@ -34,25 +34,26 @@ G_BEGIN_DECLS
G_DECLARE_DERIVABLE_TYPE (GdaDbCatalog, gda_db_catalog, GDA, DB_CATALOG, GObject)
-struct _GdaDbCatalogClass {
+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_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_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.
+ * These error are primary for developers to troubleshoot the problem rather than for user.
*/
typedef enum {
GDA_DB_CATALOG_CONTEXT_NULL,
diff --git a/libgda/gda-db-column.c b/libgda/gda-db-column.c
index ca431c833..fd51968e7 100644
--- a/libgda/gda-db-column.c
+++ b/libgda/gda-db-column.c
@@ -1,6 +1,6 @@
/* gda-db-column.c
*
- * Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
+ * Copyright (C) 2018-2019 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
@@ -44,38 +44,38 @@ typedef struct
gboolean m_autoinc; /* property */
gboolean m_unique; /* property */
gboolean m_pkey; /* property */
-}GdaDbColumnPrivate;
+} GdaDbColumnPrivate;
/**
* SECTION:gda-db-column
- * @short_description: Object to represent table column
+ * @short_description: Object to represent table column
* @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 #GdaDbCreator.
+ * using API or generated from xml file together with other databse objects. See #GdaDbCatalog.
* #GdaDbColumn implements #GdaDbBuildable interface for parsing xml file.
*/
/* All nodes in xml should be accessed using enum below */
enum {
- 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
+ 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 *gdadbcolumnnode[GDA_DB_COLUMN_N_NODES] = {
+static const gchar *gdadbcolumnnode[GDA_DB_COLUMN_N_NODES] = {
"column",
"name",
"type",
@@ -114,9 +114,7 @@ enum {
};
static void
-_gda_db_column_set_type (GdaDbColumn *self,
- const gchar *type,
- GError **error);
+_gda_db_column_set_type (GdaDbColumn *self, const gchar *type, GError **error);
static GParamSpec *properties [N_PROPS] = {NULL};
@@ -159,34 +157,34 @@ gda_db_column_get_property (GObject *object,
switch (prop_id) {
case PROP_COLUMN_NAME:
- g_value_set_string (value,priv->mp_name);
+ g_value_set_string (value, priv->mp_name);
break;
case PROP_COLUMN_SIZE:
- g_value_set_uint (value,priv->m_size);
+ g_value_set_uint (value, priv->m_size);
break;
case PROP_COLUMN_NNUL:
- g_value_set_boolean (value,priv->m_nnul);
+ g_value_set_boolean (value, priv->m_nnul);
break;
case PROP_COLUMN_UNIQUE:
- g_value_set_boolean (value,priv->m_unique);
+ g_value_set_boolean (value, priv->m_unique);
break;
case PROP_COLUMN_PKEY:
- g_value_set_boolean (value,priv->m_pkey);
+ g_value_set_boolean (value, priv->m_pkey);
break;
case PROP_COLUMN_AUTOINC:
- g_value_set_boolean (value,priv->m_autoinc);
+ g_value_set_boolean (value, priv->m_autoinc);
break;
case PROP_COLUMN_DEFAULT:
- g_value_set_string (value,priv->mp_default);
+ g_value_set_string (value, priv->mp_default);
break;
case PROP_COLUMN_CHECK:
- g_value_set_string (value,priv->mp_check);
+ g_value_set_string (value, priv->mp_check);
break;
case PROP_COLUMN_COMMENT:
- g_value_set_string (value,priv->mp_comment);
+ g_value_set_string (value, priv->mp_comment);
break;
case PROP_COLUMN_SCALE:
- g_value_set_uint (value,priv->m_scale);
+ g_value_set_uint (value, priv->m_scale);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -254,35 +252,35 @@ gda_db_column_class_init (GdaDbColumnClass *klass)
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);
+ g_param_spec_string ("name", "Name", "Column name", NULL, G_PARAM_READWRITE);
properties[PROP_COLUMN_SIZE] =
- g_param_spec_uint ("size","Size","Column size",0,9999,80,G_PARAM_READWRITE);
+ g_param_spec_uint ("size", "Size", "Column size", 0, 9999, 80, G_PARAM_READWRITE);
properties[PROP_COLUMN_NNUL] =
- g_param_spec_boolean ("nnul","NotNULL","Can value be NULL",TRUE,G_PARAM_READWRITE);
+ g_param_spec_boolean ("nnul", "NotNULL", "Can value be NULL", TRUE, G_PARAM_READWRITE);
properties[PROP_COLUMN_AUTOINC] =
- g_param_spec_boolean ("autoinc","Autoinc","Can value be autoincremented",FALSE,
+ g_param_spec_boolean ("autoinc", "Autoinc", "Can value be autoincremented", FALSE,
G_PARAM_READWRITE);
properties[PROP_COLUMN_UNIQUE] =
- g_param_spec_boolean ("unique","Unique","Can value be unique",FALSE,G_PARAM_READWRITE);
+ g_param_spec_boolean ("unique", "Unique", "Can value be unique", FALSE, G_PARAM_READWRITE);
properties[PROP_COLUMN_PKEY] =
- g_param_spec_boolean ("pkey","Pkey","Is is primery key",FALSE,G_PARAM_READWRITE);
+ g_param_spec_boolean ("pkey", "Pkey", "Is is primery key", FALSE, G_PARAM_READWRITE);
properties[PROP_COLUMN_DEFAULT] =
- g_param_spec_string ("default","Default","Default value",NULL,G_PARAM_READWRITE);
+ g_param_spec_string ("default", "Default", "Default value", NULL,G_PARAM_READWRITE);
properties[PROP_COLUMN_CHECK] =
- g_param_spec_string ("check","Check","Column check string",NULL,G_PARAM_READWRITE);
+ g_param_spec_string ("check", "Check", "Column check string", NULL, G_PARAM_READWRITE);
properties[PROP_COLUMN_COMMENT] =
- g_param_spec_string ("comment","Comment","Column comment",NULL,G_PARAM_READWRITE);
+ g_param_spec_string ("comment", "Comment", "Column comment", NULL, G_PARAM_READWRITE);
properties[PROP_COLUMN_SCALE] =
- g_param_spec_uint ("scale","Scale","Number of decimal for numeric type",0,64,2,
+ g_param_spec_uint ("scale", "Scale", "Number of decimal for numeric type", 0, 64, 2,
G_PARAM_READWRITE);
g_object_class_install_properties (object_class, N_PROPS, properties);
}
@@ -325,55 +323,63 @@ gda_db_column_parse_node (GdaDbBuildable *buildable,
g_return_val_if_fail (buildable,FALSE);
g_return_val_if_fail (node,FALSE);
- /*TODO: Appropriate error should be set an returned.
- * It should be added to the header file first
+ /*TODO: Appropriate error should be set an returned.
+ * It should be added to the header file first
*/
- if (g_strcmp0 ((gchar *)node->name,gdadbcolumnnode[GDA_DB_COLUMN_NODE]))
+ if (g_strcmp0 ((gchar *)node->name, gdadbcolumnnode[GDA_DB_COLUMN_NODE]))
return FALSE;
GdaDbColumn *self = GDA_DB_COLUMN (buildable);
GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
- xmlChar *name = xmlGetProp (node,(xmlChar *)gdadbcolumnnode[GDA_DB_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 *)gdadbcolumnnode[GDA_DB_COLUMN_ATYPE]);
g_assert (type); /* If here buf with validation */
- _gda_db_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 *)gdadbcolumnnode[GDA_DB_COLUMN_PKEY]);
if (cprop)
{
- g_object_set (G_OBJECT(self),"pkey",*cprop == 't' || *cprop == 'T' ? TRUE : FALSE, NULL);
+ g_object_set (G_OBJECT(self),
+ "pkey", *cprop == 't' || *cprop == 'T' ? TRUE : FALSE,
+ NULL);
xmlFree (cprop);
}
/* We need scale only for NUMBERIC data type, e.g. float, double */
- cprop = xmlGetProp (node,(xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_UNIQUE]);
+ cprop = xmlGetProp (node, (xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_UNIQUE]);
if (cprop)
{
- g_object_set (G_OBJECT(self),"unique",*cprop == 't' || *cprop == 'T' ? TRUE : FALSE,NULL);
+ g_object_set (G_OBJECT(self),
+ "unique", *cprop == 't' || *cprop == 'T' ? TRUE : FALSE,
+ NULL);
xmlFree (cprop);
}
- cprop = xmlGetProp (node,(xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_AUTOINC]);
+ cprop = xmlGetProp (node, (xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_AUTOINC]);
if (cprop)
{
- g_object_set (G_OBJECT(self),"autoinc",*cprop == 't' || *cprop == 'T' ? TRUE : FALSE,NULL);
+ g_object_set (G_OBJECT(self),
+ "autoinc", *cprop == 't' || *cprop == 'T' ? TRUE : FALSE,
+ NULL);
xmlFree (cprop);
}
- cprop = xmlGetProp (node,(xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_NNUL]);
+ cprop = xmlGetProp (node, (xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_NNUL]);
if (cprop)
{
- g_object_set (G_OBJECT(self),"nnul",*cprop == 't' || *cprop == 'T' ? TRUE : FALSE,NULL);
+ g_object_set (G_OBJECT(self),
+ "nnul",*cprop == 't' || *cprop == 'T' ? TRUE : FALSE,
+ NULL);
xmlFree (cprop);
}
@@ -385,44 +391,44 @@ gda_db_column_parse_node (GdaDbBuildable *buildable,
if (value)
{
- g_object_set (G_OBJECT (self),"default",(gchar *)value,NULL);
+ g_object_set (G_OBJECT (self), "default", (gchar *)value, NULL);
xmlFree (value);
}
- xmlChar *nprop = xmlGetProp (it,BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_SIZE]);
+ xmlChar *nprop = xmlGetProp (it, BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_SIZE]);
guint64 tint = 0;
if (nprop)
{
- tint = g_ascii_strtoull ((gchar*)nprop,NULL,10);
+ tint = g_ascii_strtoull ((gchar*)nprop, NULL, 10);
xmlFree (nprop);
- g_object_set (G_OBJECT (self),"size",tint,NULL);
+ g_object_set (G_OBJECT (self), "size", tint, NULL);
}
-
+
if (priv->m_gtype == G_TYPE_FLOAT ||
priv->m_gtype == G_TYPE_DOUBLE ||
priv->m_gtype == GDA_TYPE_NUMERIC)
{
- nprop = xmlGetProp (it,(xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_SCALE]);
+ nprop = xmlGetProp (it, (xmlChar *)gdadbcolumnnode[GDA_DB_COLUMN_SCALE]);
if (nprop)
{
- guint64 tint = g_ascii_strtoull ((gchar*)nprop,NULL,10);
- g_object_set (G_OBJECT(self),"scale",tint,NULL);
+ guint64 tint = g_ascii_strtoull ((gchar*)nprop, NULL, 10);
+ g_object_set (G_OBJECT(self), "scale", tint, NULL);
xmlFree (nprop);
}
}
}
- if (!g_strcmp0 ((char *)it->name,gdadbcolumnnode[GDA_DB_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);
+ g_object_set (G_OBJECT (self), "check", check,NULL);
xmlFree (check);
}
- if (!g_strcmp0 ((char *)it->name,gdadbcolumnnode[GDA_DB_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);
+ g_object_set (G_OBJECT (self), "comment", comment,NULL);
xmlFree (comment);
}
} /* End of for loop */
@@ -434,8 +440,8 @@ 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);
+ g_return_val_if_fail (buildable, FALSE);
+ g_return_val_if_fail (rootnode, FALSE);
GdaDbColumn *self = GDA_DB_COLUMN (buildable);
@@ -472,47 +478,47 @@ gda_db_column_write_node (GdaDbBuildable *buildable,
BAD_CAST GDA_BOOL_TO_STR(priv->m_nnul));
if (priv->mp_comment)
- xmlNewChild (node,NULL,
+ xmlNewChild (node, NULL,
BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_COMMENT],
BAD_CAST priv->mp_comment);
-
+
xmlNodePtr nodevalue = NULL;
-
+
if (priv->mp_default)
{
nodevalue = xmlNewChild (node,
NULL,
BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_VALUE],
BAD_CAST priv->mp_default);
-
+
if (priv->m_size > 0)
{
/* temp string to convert gint to gchar* */
GString *sizestr = g_string_new (NULL);
- g_string_printf (sizestr,"%d",priv->m_size);
-
+ g_string_printf (sizestr, "%d", priv->m_size);
+
xmlNewProp (nodevalue,
BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_SIZE],
BAD_CAST sizestr->str);
-
+
g_string_free (sizestr,TRUE);
-
+
/* We need to write down scale if column type is numeric */
if (priv->m_gtype == G_TYPE_FLOAT ||
priv->m_gtype == G_TYPE_DOUBLE ||
priv->m_gtype == GDA_TYPE_NUMERIC)
{
GString *scale_str = g_string_new (NULL);
- g_string_printf (scale_str,"%d",priv->m_scale);
-
+ g_string_printf (scale_str, "%d", priv->m_scale);
+
xmlNewProp (nodevalue,
BAD_CAST gdadbcolumnnode[GDA_DB_COLUMN_SCALE],
BAD_CAST scale_str->str);
-
- g_string_free (scale_str,TRUE);
+
+ g_string_free (scale_str, TRUE);
}
}
- }
+ }
if (priv->mp_check)
xmlNewChild (node,NULL,
@@ -556,7 +562,7 @@ _gda_db_column_set_type (GdaDbColumn *self,
* gda_db_column_get_name:
* @self: a #GdaDbColumn instance
*
- * Returns name of the column
+ * Returns name of the column
*
* Returns: Column name as a string or %NULL.
*
@@ -565,7 +571,7 @@ _gda_db_column_set_type (GdaDbColumn *self,
const gchar*
gda_db_column_get_name (GdaDbColumn *self)
{
- g_return_val_if_fail (self,NULL);
+ g_return_val_if_fail (self, NULL);
GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->mp_name;
@@ -584,6 +590,7 @@ void
gda_db_column_set_name (GdaDbColumn *self,
const gchar *name)
{
+ g_return_val_if_fail (self, NULL);
GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
g_free (priv->mp_name);
@@ -601,7 +608,7 @@ gda_db_column_set_name (GdaDbColumn *self,
GType
gda_db_column_get_gtype (GdaDbColumn *self)
{
- g_return_val_if_fail (self,GDA_TYPE_NULL);
+ g_return_val_if_fail (self, GDA_TYPE_NULL);
GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->m_gtype;
@@ -610,8 +617,8 @@ gda_db_column_get_gtype (GdaDbColumn *self)
/**
* gda_db_column_get_ctype:
* @self: a #GdaDbColumn object
- *
- * Returns column type as a string derivied from #GType
+ *
+ * Returns column type as a string derivied from #GType
*
* Returns: column type as a string or %NULL
*
@@ -620,7 +627,7 @@ gda_db_column_get_gtype (GdaDbColumn *self)
const gchar*
gda_db_column_get_ctype (GdaDbColumn *self)
{
- g_return_val_if_fail (self,NULL);
+ g_return_val_if_fail (self, NULL);
GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->mp_type;
}
@@ -695,7 +702,7 @@ gda_db_column_set_scale (GdaDbColumn *self,
gboolean
gda_db_column_get_pkey (GdaDbColumn *self)
{
- g_return_val_if_fail (self,FALSE);
+ g_return_val_if_fail (self, FALSE);
GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->m_pkey;
}
@@ -720,16 +727,16 @@ gda_db_column_set_pkey (GdaDbColumn *self,
* gda_db_column_get_nnul:
* @self: a @GdaDbColumn object
*
- * Specify if the column's value can be NULL.
+ * Specify if the column's value can be NULL.
*
- * Returns: %TRUE if value can be %NULL, %FALSE otherwise.
+ * Returns: %TRUE if value can be %NULL, %FALSE otherwise.
*
* Since: 6.0
*/
gboolean
gda_db_column_get_nnul (GdaDbColumn *self)
{
- g_return_val_if_fail (self,FALSE);
+ g_return_val_if_fail (self, FALSE);
GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->m_nnul;
}
@@ -755,7 +762,7 @@ gda_db_column_set_nnul (GdaDbColumn *self,
* @self: a #GdaDbColumn object
*
* Get value for autoinc key
- *
+ *
* Returns: %TRUE if column should be auto-incremented, %FALSE otherwise.
*
* Since: 6.0
@@ -763,7 +770,7 @@ gda_db_column_set_nnul (GdaDbColumn *self,
gboolean
gda_db_column_get_autoinc (GdaDbColumn *self)
{
- g_return_val_if_fail (self,FALSE);
+ g_return_val_if_fail (self, FALSE);
GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->m_autoinc;
}
@@ -771,7 +778,7 @@ gda_db_column_get_autoinc (GdaDbColumn *self)
/**
* gda_db_column_set_autoinc:
* @self: a #GdaDbColumn object
- * @autoinc: value to set
+ * @autoinc: value to set
*
* Set value for auto-incremented key.
*
@@ -791,7 +798,7 @@ gda_db_column_set_autoinc (GdaDbColumn *self,
* @self: a #GdaDbColumn object
*
* Get value for unique key
- *
+ *
* Returns: %TRUE if column should have a unique value, %FALSE otherwise.
*
* Since: 6.0
@@ -799,7 +806,7 @@ gda_db_column_set_autoinc (GdaDbColumn *self,
gboolean
gda_db_column_get_unique (GdaDbColumn *self)
{
- g_return_val_if_fail (self,FALSE);
+ g_return_val_if_fail (self, FALSE);
GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->m_unique;
}
@@ -807,7 +814,7 @@ gda_db_column_get_unique (GdaDbColumn *self)
/**
* gda_db_column_set_unique:
* @self: a #GdaDbColumn object
- * @unique: value to set
+ * @unique: value to set
*
* Set value for unique key.
*
@@ -826,9 +833,9 @@ gda_db_column_set_unique (GdaDbColumn *self,
* gda_db_column_get_comment:
* @self: a #GdaDbColumn object
*
- * Get value for column comment.
- *
- * Returns: Column comment as a string.
+ * Get value for column comment.
+ *
+ * Returns: Column comment as a string.
* %NULL is returned if comment is not set.
*
* Since: 6.0
@@ -836,7 +843,7 @@ gda_db_column_set_unique (GdaDbColumn *self,
const gchar*
gda_db_column_get_comment (GdaDbColumn *self)
{
- g_return_val_if_fail (self,NULL);
+ g_return_val_if_fail (self, NULL);
GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->mp_comment;
@@ -847,8 +854,8 @@ gda_db_column_get_comment (GdaDbColumn *self)
* @self: a #GdaDbColumn object
* @comnt: comment to set
*
- * Set value for column comment.
- *
+ * Set value for column comment.
+ *
* Since: 6.0
*/
void
@@ -865,14 +872,14 @@ gda_db_column_set_comment (GdaDbColumn *self,
* gda_db_column_get_size:
* @self: a #GdaDbColumn instance
*
- * Returns: Current value for column size.
+ * Returns: Current value for column size.
*
* Since: 6.0
*/
guint
gda_db_column_get_size (GdaDbColumn *self)
{
- g_return_val_if_fail (self,0);
+ g_return_val_if_fail (self, 0);
GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->m_size;
}
@@ -898,7 +905,7 @@ gda_db_column_set_size (GdaDbColumn *self,
/**
* 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.
*
* Returns: Default value for the column as a string.
@@ -908,7 +915,7 @@ gda_db_column_set_size (GdaDbColumn *self,
const gchar*
gda_db_column_get_default (GdaDbColumn *self)
{
- g_return_val_if_fail (self,NULL);
+ g_return_val_if_fail (self, NULL);
GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
return priv->mp_default;
}
@@ -927,13 +934,13 @@ gda_db_column_set_default (GdaDbColumn *self,
g_return_if_fail (self);
GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
g_free(priv->mp_default);
- priv->mp_default = g_strdup(value);
+ priv->mp_default = g_strdup (value);
}
/**
* gda_db_column_get_check:
* @self: a #GdaDbColumn instance
- *
+ *
* Returns value of the check field.
*
* Returns: Column check string
@@ -964,7 +971,7 @@ gda_db_column_set_check (GdaDbColumn *self,
g_return_if_fail (self);
GdaDbColumnPrivate *priv = gda_db_column_get_instance_private (self);
g_free(priv->mp_check);
- priv->mp_check = g_strdup(value);
+ priv->mp_check = g_strdup (value);
}
/**
@@ -995,14 +1002,19 @@ gda_db_column_prepare_create (GdaDbColumn *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_DB_COLUMN_ERROR, GDA_DB_COLUMN_ERROR_TYPE,
- _("Internal error: Operation should be prepared, setting a connection data"));
- return FALSE;
- }
+
+ if (cnc == NULL)
+ {
+ 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;
+ }
+
strtype = gda_server_provider_get_default_dbms_type (gda_connection_get_provider (cnc),
cnc, priv->m_gtype);
+
if(!gda_server_operation_set_value_at (op, strtype, error, "/FIELDS_A/@COLUMN_TYPE/%d", order))
return FALSE;
@@ -1026,11 +1038,11 @@ gda_db_column_prepare_create (GdaDbColumn *self,
/* We need to set scale only for numeric column type */
if (priv->m_gtype == G_TYPE_FLOAT ||
priv->m_gtype == G_TYPE_DOUBLE ||
- priv->m_gtype == GDA_TYPE_NUMERIC)
+ priv->m_gtype == GDA_TYPE_NUMERIC)
{
- numstr = g_strdup_printf ("%d",priv->m_scale);
-
- if(!gda_server_operation_set_value_at(op,numstr,error,"/FIELDS_A/@COLUMN_SCALE/%d",order))
+ numstr = g_strdup_printf ("%d", priv->m_scale);
+
+ if(!gda_server_operation_set_value_at (op, numstr, error, "/FIELDS_A/@COLUMN_SCALE/%d", order))
{
g_free (numstr);
return FALSE;
@@ -1058,11 +1070,11 @@ gda_db_column_prepare_create (GdaDbColumn *self,
"/FIELDS_A/@COLUMN_PKEY/%d",order))
return FALSE;
- if(!gda_server_operation_set_value_at (op,priv->mp_default, error,
+ if(!gda_server_operation_set_value_at (op, priv->mp_default, error,
"/FIELDS_A/@COLUMN_DEFAULT/%d", order))
return FALSE;
- if(!gda_server_operation_set_value_at (op,priv->mp_check,error,
+ if(!gda_server_operation_set_value_at (op, priv->mp_check,error,
"/FIELDS_A/@COLUMN_CHECK/%d", order))
return FALSE;
@@ -1087,19 +1099,19 @@ gda_db_column_prepare_add (GdaDbColumn *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))
+ if(!gda_server_operation_set_value_at (op, priv->mp_name, error,
+ "/COLUMN_DEF_P/COLUMN_NAME/%d", priv->m_scale))
return FALSE;
- if(!gda_server_operation_set_value_at(op,priv->mp_type,error,
- "/COLUMN_DEF_P/COLUMN_TYPE/%d",priv->m_scale))
+ if(!gda_server_operation_set_value_at (op,priv->mp_type, error,
+ "/COLUMN_DEF_P/COLUMN_TYPE/%d", priv->m_scale))
return FALSE;
gchar *sizestr = NULL;
- sizestr = g_strdup_printf ("%d",priv->m_size);
+ sizestr = g_strdup_printf ("%d", priv->m_size);
- if(!gda_server_operation_set_value_at(op,sizestr,error,
- "/COLUMN_DEF_P/COLUMN_SIZE/%d",priv->m_scale))
+ if(!gda_server_operation_set_value_at (op, sizestr, error,
+ "/COLUMN_DEF_P/COLUMN_SIZE/%d", priv->m_scale))
{
g_free (sizestr);
return FALSE;
@@ -1107,28 +1119,28 @@ gda_db_column_prepare_add (GdaDbColumn *self,
else
g_free (sizestr);
- if(!gda_server_operation_set_value_at(op,GDA_BOOL_TO_STR (priv->m_nnul),error,
- "/COLUMN_DEF_P/COLUMN_NNUL/%d",priv->m_scale))
+ if(!gda_server_operation_set_value_at (op, GDA_BOOL_TO_STR (priv->m_nnul), error,
+ "/COLUMN_DEF_P/COLUMN_NNUL/%d", priv->m_scale))
return FALSE;
- if(!gda_server_operation_set_value_at(op,GDA_BOOL_TO_STR (priv->m_autoinc),error,
- "/COLUMN_DEF_P/COLUMN_AUTOINC/%d",priv->m_scale))
+ if(!gda_server_operation_set_value_at (op, GDA_BOOL_TO_STR (priv->m_autoinc), error,
+ "/COLUMN_DEF_P/COLUMN_AUTOINC/%d", priv->m_scale))
return FALSE;
- if(!gda_server_operation_set_value_at(op,GDA_BOOL_TO_STR (priv->m_unique),error,
- "/COLUMN_DEF_P/COLUMN_UNIQUE/%d",priv->m_scale))
+ if(!gda_server_operation_set_value_at (op, GDA_BOOL_TO_STR (priv->m_unique), error,
+ "/COLUMN_DEF_P/COLUMN_UNIQUE/%d", priv->m_scale))
return FALSE;
- if(!gda_server_operation_set_value_at(op,GDA_BOOL_TO_STR (priv->m_pkey),error,
- "/COLUMN_DEF_P/COLUMN_PKEY/%d",priv->m_scale))
+ if(!gda_server_operation_set_value_at (op, GDA_BOOL_TO_STR (priv->m_pkey), error,
+ "/COLUMN_DEF_P/COLUMN_PKEY/%d", priv->m_scale))
return FALSE;
- if(!gda_server_operation_set_value_at(op,priv->mp_default,error,
- "/COLUMN_DEF_P/COLUMN_DEFAULT/%d",priv->m_scale))
+ if(!gda_server_operation_set_value_at (op, priv->mp_default, error,
+ "/COLUMN_DEF_P/COLUMN_DEFAULT/%d", priv->m_scale))
return FALSE;
- if(!gda_server_operation_set_value_at(op,priv->mp_check,error,
- "/COLUMN_DEF_P/COLUMN_CHECK/%d",priv->m_scale))
+ if(!gda_server_operation_set_value_at (op, priv->mp_check, error,
+ "/COLUMN_DEF_P/COLUMN_CHECK/%d", priv->m_scale))
return FALSE;
return TRUE;
@@ -1148,15 +1160,15 @@ GdaDbColumn*
gda_db_column_new_from_meta (GdaMetaTableColumn *column)
{
if (!column)
- return gda_db_column_new();
+ return gda_db_column_new ();
- GdaDbColumn *gdacolumn = gda_db_column_new();
+ GdaDbColumn *gdacolumn = gda_db_column_new ();
g_object_set (gdacolumn,
- "name",column->column_name,
- "pkey",column->pkey,
- "nnul",column->nullok,
- "default",column->default_value,
+ "name", column->column_name,
+ "pkey", column->pkey,
+ "nnul", column->nullok,
+ "default", column->default_value,
NULL);
gda_db_column_set_type (gdacolumn, column->gtype);
diff --git a/libgda/gda-db-column.h b/libgda/gda-db-column.h
index 371a0b45e..56482c8a5 100644
--- a/libgda/gda-db-column.h
+++ b/libgda/gda-db-column.h
@@ -42,9 +42,10 @@ struct _GdaDbColumnClass
* 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.
+ * Values used to describe the source of the error.
*/
-typedef enum {
+typedef enum
+{
GDA_DB_COLUMN_ERROR_TYPE
} GdaDbColumnError;
diff --git a/libgda/gda-db-fkey.c b/libgda/gda-db-fkey.c
index 52e8abfb3..8dd5a1f07 100644
--- a/libgda/gda-db-fkey.c
+++ b/libgda/gda-db-fkey.c
@@ -1,6 +1,6 @@
/* gda-db-fkey.c
*
- * Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
+ * Copyright (C) 2018-2019 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
@@ -66,24 +66,24 @@ static const gchar *OnAction[] = {
/* This is convenient way to name all nodes from xml file */
enum {
- 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
+ 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 *gdadbfkeynodes[GDA_DB_FKEY_N_NODES] = {
- "fkey",
- "reftable",
- "onupdate",
- "ondelete",
- "fk_field",
- "name",
- "reffield"
+static const gchar *gdadbfkeynodes[GDA_DB_FKEY_N_NODES] = {
+ "fkey",
+ "reftable",
+ "onupdate",
+ "ondelete",
+ "fk_field",
+ "name",
+ "reffield"
};
/**
@@ -102,8 +102,8 @@ gda_db_fkey_new (void)
/**
* gda_db_fkey_new_from_meta:
* @metafkey: a #GdaMetaTableForeignKey instance
- *
- * Create a new instance from the corresponding meta object. If @metafkey is %NULL,
+ *
+ * Create a new instance from the corresponding meta object. If @metafkey is %NULL,
* this function is identical to gda_db_fkey_new()
*
*/
@@ -111,13 +111,13 @@ GdaDbFkey*
gda_db_fkey_new_from_meta (GdaMetaTableForeignKey *metafkey)
{
if (!metafkey)
- return gda_db_fkey_new();
+ return gda_db_fkey_new ();
GdaMetaDbObject *refobject = GDA_META_DB_OBJECT (metafkey->meta_table);
GdaDbFkey *fkey = gda_db_fkey_new ();
-
- gda_db_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_db_fkey_set_field (fkey,
@@ -129,35 +129,35 @@ gda_db_fkey_new_from_meta (GdaMetaTableForeignKey *metafkey)
switch (policy)
{
case GDA_META_FOREIGN_KEY_NONE:
- gda_db_fkey_set_onupdate (fkey,GDA_DB_FKEY_NO_ACTION);
+ gda_db_fkey_set_onupdate (fkey, GDA_DB_FKEY_NO_ACTION);
break;
case GDA_META_FOREIGN_KEY_CASCADE:
- gda_db_fkey_set_onupdate (fkey,GDA_DB_FKEY_CASCADE);
+ gda_db_fkey_set_onupdate (fkey, GDA_DB_FKEY_CASCADE);
break;
case GDA_META_FOREIGN_KEY_RESTRICT:
- gda_db_fkey_set_onupdate (fkey,GDA_DB_FKEY_RESTRICT);
+ gda_db_fkey_set_onupdate (fkey, GDA_DB_FKEY_RESTRICT);
break;
case GDA_META_FOREIGN_KEY_SET_DEFAULT:
- gda_db_fkey_set_onupdate (fkey,GDA_DB_FKEY_SET_DEFAULT);
+ gda_db_fkey_set_onupdate (fkey, GDA_DB_FKEY_SET_DEFAULT);
break;
default:
break;
}
-
+
policy = GDA_META_TABLE_FOREIGN_KEY_ON_DELETE_POLICY(metafkey);
switch (policy)
{
case GDA_META_FOREIGN_KEY_NONE:
- gda_db_fkey_set_ondelete (fkey,GDA_DB_FKEY_NO_ACTION);
+ gda_db_fkey_set_ondelete (fkey, GDA_DB_FKEY_NO_ACTION);
break;
case GDA_META_FOREIGN_KEY_CASCADE:
- gda_db_fkey_set_ondelete (fkey,GDA_DB_FKEY_CASCADE);
+ gda_db_fkey_set_ondelete (fkey, GDA_DB_FKEY_CASCADE);
break;
case GDA_META_FOREIGN_KEY_RESTRICT:
- gda_db_fkey_set_ondelete (fkey,GDA_DB_FKEY_RESTRICT);
+ gda_db_fkey_set_ondelete (fkey, GDA_DB_FKEY_RESTRICT);
break;
case GDA_META_FOREIGN_KEY_SET_DEFAULT:
- gda_db_fkey_set_ondelete (fkey,GDA_DB_FKEY_SET_DEFAULT);
+ gda_db_fkey_set_ondelete (fkey, GDA_DB_FKEY_SET_DEFAULT);
break;
default:
break;
@@ -175,7 +175,7 @@ gda_db_fkey_finalize (GObject *object)
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_free (priv->mp_ref_table);
G_OBJECT_CLASS (gda_db_fkey_parent_class)->finalize (object);
}
@@ -208,7 +208,7 @@ gda_db_fkey_init (GdaDbFkey *self)
* @error: #GError object to store error
*
* Use this method to populate corresponding #GdaDbFkey object from xml node. Usually,
- * this method is called from #GdaDbCreator during parsing the input xml file.
+ * this method is called from #GdaDbCatalog during parsing the input xml file.
*
* The corresponding DTD section suitable for parsing by this method should correspond
* th the following code:
@@ -230,12 +230,12 @@ gda_db_fkey_init (GdaDbFkey *self)
*/
static gboolean
gda_db_fkey_parse_node (GdaDbBuildable *buildable,
- xmlNodePtr node,
- GError **error)
+ xmlNodePtr node,
+ GError **error)
{
- g_return_val_if_fail (buildable,FALSE);
+ g_return_val_if_fail (buildable, FALSE);
g_return_val_if_fail (node, FALSE);
-
+
/*
* <fkey reftable="products" onupdate="NO_ACTION" ondelete="NO_ACTION">
* <fk_field name="column_name" reffield="column_name"/>
@@ -243,7 +243,7 @@ gda_db_fkey_parse_node (GdaDbBuildable *buildable,
* </fkey>
*/
xmlChar *name = NULL;
- if (g_strcmp0 ((gchar*)node->name,gdadbfkeynodes[GDA_DB_FKEY_NODE]))
+ if (g_strcmp0 ((gchar*)node->name, gdadbfkeynodes[GDA_DB_FKEY_NODE]))
return FALSE;
GdaDbFkey *self = GDA_DB_FKEY (buildable);
@@ -251,7 +251,7 @@ gda_db_fkey_parse_node (GdaDbBuildable *buildable,
xmlChar *prop = NULL;
- prop = xmlGetProp (node,(xmlChar *)gdadbfkeynodes[GDA_DB_FKEY_REFTABLE]);
+ prop = xmlGetProp (node, (xmlChar *)gdadbfkeynodes[GDA_DB_FKEY_REFTABLE]);
g_assert (prop); /* Bug with xml valdation */
@@ -259,15 +259,15 @@ gda_db_fkey_parse_node (GdaDbBuildable *buildable,
xmlFree (prop);
prop = NULL;
- prop = xmlGetProp (node,(xmlChar *)gdadbfkeynodes[GDA_DB_FKEY_ONUPDATE]);
+ prop = xmlGetProp (node, (xmlChar *)gdadbfkeynodes[GDA_DB_FKEY_ONUPDATE]);
if (prop)
{
priv->m_onupdate = GDA_DB_FKEY_NO_ACTION;
- for (guint i = 0; i < G_N_ELEMENTS(OnAction);i++)
+ for (guint i = 0; i < G_N_ELEMENTS(OnAction); i++)
{
- if (!g_strcmp0 ((gchar *)prop,OnAction[i]))
+ if (!g_strcmp0 ((gchar *)prop, OnAction[i]))
priv->m_onupdate = (GdaDbFkeyReferenceAction)i;
}
@@ -275,14 +275,13 @@ gda_db_fkey_parse_node (GdaDbBuildable *buildable,
prop = NULL;
}
-
- prop = xmlGetProp (node,(xmlChar *)gdadbfkeynodes[GDA_DB_FKEY_ONDELETE]);
+ prop = xmlGetProp (node, (xmlChar *)gdadbfkeynodes[GDA_DB_FKEY_ONDELETE]);
if (prop)
{
- for (guint i = 0; i < G_N_ELEMENTS(OnAction);i++)
+ for (guint i = 0; i < G_N_ELEMENTS(OnAction); i++)
{
- if (!g_strcmp0 ((gchar *)prop,OnAction[i]))
+ if (!g_strcmp0 ((gchar *)prop, OnAction[i]))
priv->m_ondelete = (GdaDbFkeyReferenceAction)i;
}
@@ -296,15 +295,15 @@ gda_db_fkey_parse_node (GdaDbBuildable *buildable,
for (xmlNodePtr it = node->children; it; it = it->next)
{
- if (!g_strcmp0 ((gchar *)it->name,gdadbfkeynodes[GDA_DB_FKEY_FKFIELD]))
+ if (!g_strcmp0 ((gchar *)it->name, gdadbfkeynodes[GDA_DB_FKEY_FKFIELD]))
{
- name = xmlGetProp (it,(xmlChar *)gdadbfkeynodes[GDA_DB_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));
+ priv->mp_field = g_list_append (priv->mp_field, g_strdup ((const gchar *)name));
xmlFree (name);
- reffield = xmlGetProp (it,(xmlChar *)gdadbfkeynodes[GDA_DB_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));
@@ -335,25 +334,26 @@ gda_db_fkey_parse_node (GdaDbBuildable *buildable,
*/
static gboolean
gda_db_fkey_write_node (GdaDbBuildable *buildable,
- xmlNodePtr rootnode,
- GError **error)
+ xmlNodePtr rootnode,
+ GError **error)
{
g_return_val_if_fail (buildable, FALSE);
g_return_val_if_fail (rootnode,FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FASLE);
GdaDbFkey *self = GDA_DB_FKEY (buildable);
GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
xmlNodePtr node = NULL;
- node = xmlNewChild (rootnode,NULL,(xmlChar*)gdadbfkeynodes[GDA_DB_FKEY_NODE],NULL);
+ node = xmlNewChild (rootnode, NULL, (xmlChar*)gdadbfkeynodes[GDA_DB_FKEY_NODE], NULL);
- xmlNewProp (node,BAD_CAST gdadbfkeynodes[GDA_DB_FKEY_REFTABLE],
+ xmlNewProp (node, BAD_CAST gdadbfkeynodes[GDA_DB_FKEY_REFTABLE],
BAD_CAST priv->mp_ref_table);
-
- xmlNewProp (node,BAD_CAST gdadbfkeynodes[GDA_DB_FKEY_ONUPDATE],
+
+ xmlNewProp (node, BAD_CAST gdadbfkeynodes[GDA_DB_FKEY_ONUPDATE],
BAD_CAST priv->m_onupdate);
- xmlNewProp (node,BAD_CAST gdadbfkeynodes[GDA_DB_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_db_fkey_write_node (GdaDbBuildable *buildable,
for (; it && jt; it = it->next, jt=jt->next )
{
xmlNodePtr tnode = NULL;
- tnode = xmlNewChild (node,NULL,(xmlChar*)gdadbfkeynodes[GDA_DB_FKEY_FKFIELD],NULL);
+ tnode = xmlNewChild (node, NULL,(xmlChar*)gdadbfkeynodes[GDA_DB_FKEY_FKFIELD], NULL);
- xmlNewProp (tnode,(xmlChar*)gdadbfkeynodes[GDA_DB_FKEY_FKFIELD_NAME],
+ xmlNewProp (tnode, (xmlChar*)gdadbfkeynodes[GDA_DB_FKEY_FKFIELD_NAME],
BAD_CAST it->data);
- xmlNewProp (tnode,(xmlChar*)gdadbfkeynodes[GDA_DB_FKEY_FKFIELD_REFIELD],
+ xmlNewProp (tnode, (xmlChar*)gdadbfkeynodes[GDA_DB_FKEY_FKFIELD_REFIELD],
BAD_CAST jt->data);
}
@@ -386,14 +386,14 @@ gda_db_fkey_buildable_interface_init (GdaDbBuildableInterface *iface)
* @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.
+ * NO_ACTION is returned.
*
* Since: 6.0
*/
const gchar *
gda_db_fkey_get_ondelete (GdaDbFkey *self)
{
- g_return_val_if_fail (self,NULL);
+ g_return_val_if_fail (self, NULL);
GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
@@ -403,7 +403,7 @@ gda_db_fkey_get_ondelete (GdaDbFkey *self)
/**
* gda_db_fkey_get_ondelete_id:
* @self: a #GdaDbFkey object
- *
+ *
* The default value is %NO_ACTION
*
* Return: ON DELETE action as a #GdaDbFkeyReferenceAction.
@@ -413,6 +413,8 @@ gda_db_fkey_get_ondelete (GdaDbFkey *self)
GdaDbFkeyReferenceAction
gda_db_fkey_get_ondelete_id (GdaDbFkey *self)
{
+ g_return_val_if_fail (self, NULL);
+
GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
return priv->m_ondelete;
@@ -429,7 +431,7 @@ gda_db_fkey_get_ondelete_id (GdaDbFkey *self)
*/
void
gda_db_fkey_set_onupdate (GdaDbFkey *self,
- GdaDbFkeyReferenceAction id)
+ GdaDbFkeyReferenceAction id)
{
g_return_if_fail (self);
@@ -449,7 +451,7 @@ gda_db_fkey_set_onupdate (GdaDbFkey *self,
*/
void
gda_db_fkey_set_ondelete (GdaDbFkey *self,
- GdaDbFkeyReferenceAction id)
+ GdaDbFkeyReferenceAction id)
{
g_return_if_fail (self);
@@ -469,7 +471,7 @@ gda_db_fkey_set_ondelete (GdaDbFkey *self,
const gchar *
gda_db_fkey_get_onupdate (GdaDbFkey *self)
{
- g_return_val_if_fail (self,NULL);
+ g_return_val_if_fail (self, NULL);
GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
@@ -522,7 +524,7 @@ gda_db_fkey_get_ref_table (GdaDbFkey *self)
*/
void
gda_db_fkey_set_ref_table (GdaDbFkey *self,
- const gchar *rtable)
+ const gchar *rtable)
{
g_return_if_fail (self);
@@ -563,7 +565,7 @@ gda_db_fkey_get_field_name (GdaDbFkey *self)
const GList *
gda_db_fkey_get_ref_field (GdaDbFkey *self)
{
- g_return_val_if_fail (self,NULL);
+ g_return_val_if_fail (self, NULL);
GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
@@ -582,8 +584,8 @@ gda_db_fkey_get_ref_field (GdaDbFkey *self)
*/
void
gda_db_fkey_set_field (GdaDbFkey *self,
- const gchar *field,
- const gchar *reffield)
+ const gchar *field,
+ const gchar *reffield)
{
g_return_if_fail (self);
g_return_if_fail (field);
@@ -591,8 +593,8 @@ gda_db_fkey_set_field (GdaDbFkey *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);
+ priv->mp_field = g_list_append (priv->mp_field, (gpointer)field);
+ priv->mp_ref_field = g_list_append(priv->mp_ref_field, (gpointer)reffield);
}
/**
@@ -601,7 +603,7 @@ gda_db_fkey_set_field (GdaDbFkey *self,
* @op: a #GdaServerOperation to populate
* @error: error container
*
- * Prepare @op object for execution by populating with information stored in @self.
+ * Prepare @op object for execution by populating with information stored in @self.
*
* Returns: %TRUE if no error or %FALSE otherwise.
*
@@ -609,9 +611,9 @@ gda_db_fkey_set_field (GdaDbFkey *self,
*/
gboolean
gda_db_fkey_prepare_create (GdaDbFkey *self,
- GdaServerOperation *op,
- gint i,
- GError **error)
+ GdaServerOperation *op,
+ gint i,
+ GError **error)
{
GdaDbFkeyPrivate *priv = gda_db_fkey_get_instance_private (self);
diff --git a/libgda/gda-db-table.c b/libgda/gda-db-table.c
index e45e4e1b8..2263f146d 100644
--- a/libgda/gda-db-table.c
+++ b/libgda/gda-db-table.c
@@ -1,6 +1,6 @@
/* gda-db-table.c
*
- * Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
+ * Copyright (C) 2018-2019 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
@@ -28,7 +28,7 @@
#include "gda-meta-struct.h"
#include <glib/gi18n-lib.h>
-G_DEFINE_QUARK (gda_db_table_error,gda_db_table_error)
+G_DEFINE_QUARK (gda_db_table_error, gda_db_table_error)
typedef struct
{
@@ -43,12 +43,12 @@ typedef struct
* SECTION:gda-db-table
* @title: GdaDbTable
* @short_description: Object to represent table database object
- * @see_also: #GdaDbView, #GdaDbCreator
+ * @see_also: #GdaDbView, #GdaDbCatalog
* @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 #GdaDbCreator.
+ * using API or generated from xml file together with other databse objects. See #GdaDbCatalog.
* #GdaDbTable implements #GdaDbBuildable interface for parsing xml file.
*/
@@ -71,27 +71,29 @@ static GParamSpec *properties [N_PROPS] = {NULL};
/* This is a convenient way to name all nodes from xml file */
enum {
- GDA_DB_TABLE_NODE,
- GDA_DB_TABLE_NAME,
- GDA_DB_TABLE_TEMP,
- GDA_DB_TABLE_SPACE,
- GDA_DB_TABLE_COMMENT,
+ GDA_DB_TABLE_NODE,
+ GDA_DB_TABLE_NAME,
+ GDA_DB_TABLE_TEMP,
+ GDA_DB_TABLE_SPACE,
+ GDA_DB_TABLE_COMMENT,
- GDA_DB_TABLE_N_NODES
+ GDA_DB_TABLE_N_NODES
};
-const gchar *gdadbtablenodes[GDA_DB_TABLE_N_NODES] = {
- "table",
- "name",
- "temptable",
- "space",
- "comment"
+static const gchar *gdadbtablenodes[GDA_DB_TABLE_N_NODES] = {
+ "table",
+ "name",
+ "temptable",
+ "space",
+ "comment"
};
/**
* gda_db_table_new:
*
* Returns: New instance of #GdaDbTable.
+ *
+ * Since: 6.0
*/
GdaDbTable *
gda_db_table_new (void)
@@ -126,31 +128,30 @@ gda_db_table_dispose (GObject *object)
static void
gda_db_table_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
GdaDbTable *self = GDA_DB_TABLE (object);
GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
switch (prop_id) {
case PROP_COMMENT:
- g_value_set_string (value,priv->mp_comment);
+ g_value_set_string (value, priv->mp_comment);
break;
case PROP_ISTEMP:
- g_value_set_boolean (value,priv->m_istemp);
+ g_value_set_boolean (value, priv->m_istemp);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
-
}
static void
gda_db_table_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
GdaDbTable *self = GDA_DB_TABLE (object);
GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
@@ -189,7 +190,7 @@ gda_db_table_class_init (GdaDbTableClass *klass)
NULL,
G_PARAM_READWRITE);
- g_object_class_install_properties (object_class,N_PROPS,properties);
+ g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
@@ -217,10 +218,10 @@ gda_db_table_init (GdaDbTable *self)
*/
static gboolean
gda_db_table_parse_node (GdaDbBuildable *buildable,
- xmlNodePtr node,
- GError **error)
+ xmlNodePtr node,
+ GError **error)
{
- g_return_val_if_fail (buildable,FALSE);
+ g_return_val_if_fail (buildable, FALSE);
g_return_val_if_fail (node, FALSE);
GdaDbTable *self = GDA_DB_TABLE (buildable);
@@ -228,53 +229,54 @@ gda_db_table_parse_node (GdaDbBuildable *buildable,
GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
xmlChar *name = NULL;
- name = xmlGetProp (node,(xmlChar *)gdadbtablenodes[GDA_DB_TABLE_NAME]);
+ name = xmlGetProp (node, (xmlChar *)gdadbtablenodes[GDA_DB_TABLE_NAME]);
g_assert (name); /* If here bug with xml validation */
- gda_db_base_set_name(GDA_DB_BASE(self),(gchar *)name);
+ gda_db_base_set_name(GDA_DB_BASE(self), (gchar*)name);
- xmlChar *tempt = xmlGetProp (node,(xmlChar*)gdadbtablenodes[GDA_DB_TABLE_TEMP]);
+ xmlChar *tempt = xmlGetProp (node, (xmlChar*)gdadbtablenodes[GDA_DB_TABLE_TEMP]);
if (tempt && (*tempt == 't' || *tempt == 't'))
{
- g_object_set (G_OBJECT(self),"istemp",TRUE,NULL);
+ g_object_set (G_OBJECT(self), "istemp", TRUE, NULL);
xmlFree (tempt);
}
for (xmlNodePtr it = node->children; it ; it = it->next)
{
- if (!g_strcmp0 ((gchar *) it->name,gdadbtablenodes[GDA_DB_TABLE_COMMENT]))
+ if (!g_strcmp0 ((gchar *) it->name, gdadbtablenodes[GDA_DB_TABLE_COMMENT]))
{
xmlChar *comment = xmlNodeGetContent (it);
if (comment)
{
- g_object_set (G_OBJECT(self),"comment", (char *)comment,NULL);
+ g_object_set (G_OBJECT(self), "comment", (char*)comment, NULL);
xmlFree (comment);
}
}
- else if (!g_strcmp0 ((gchar *) it->name, "column"))
+ else if (!g_strcmp0 ((gchar *)it->name, "column"))
{
GdaDbColumn *column = gda_db_column_new ();
- if (!gda_db_buildable_parse_node(GDA_DB_BUILDABLE (column),
- it, error))
+ if (!gda_db_buildable_parse_node(GDA_DB_BUILDABLE (column), it, error))
{
g_object_unref(column);
return FALSE;
}
else
- priv->mp_columns = g_list_append (priv->mp_columns,column);
+ priv->mp_columns = g_list_append (priv->mp_columns, column);
}
- else if (!g_strcmp0 ((gchar *) it->name, "fkey"))
+ else if (!g_strcmp0 ((gchar*)it->name, "fkey"))
{
GdaDbFkey *fkey;
fkey = gda_db_fkey_new ();
- if (!gda_db_buildable_parse_node (GDA_DB_BUILDABLE(fkey), it, error)) {
+ if (!gda_db_buildable_parse_node (GDA_DB_BUILDABLE(fkey), it, error))
+ {
g_object_unref (fkey);
return FALSE;
- } else
- priv->mp_fkeys = g_list_append (priv->mp_fkeys,fkey);
+ }
+ else
+ priv->mp_fkeys = g_list_append (priv->mp_fkeys, fkey);
} /* end of else if */
} /* End of for loop */
return TRUE;
@@ -282,32 +284,31 @@ gda_db_table_parse_node (GdaDbBuildable *buildable,
static gboolean
gda_db_table_write_node (GdaDbBuildable *buildable,
- xmlNodePtr rootnode,
- GError **error)
+ xmlNodePtr rootnode,
+ GError **error)
{
- g_return_val_if_fail (buildable,FALSE);
- g_return_val_if_fail (rootnode,FALSE);
+ g_return_val_if_fail (buildable, FALSE);
+ g_return_val_if_fail (rootnode, FALSE);
GdaDbTable *self = GDA_DB_TABLE (buildable);
GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
xmlNodePtr node = NULL;
- node = xmlNewChild (rootnode,NULL,(xmlChar*)gdadbtablenodes[GDA_DB_TABLE_NODE],NULL);
- xmlNewProp (node,BAD_CAST gdadbtablenodes[GDA_DB_TABLE_NAME],
+ 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 gdadbtablenodes[GDA_DB_TABLE_TEMP],
+ xmlNewProp (node, BAD_CAST gdadbtablenodes[GDA_DB_TABLE_TEMP],
BAD_CAST GDA_BOOL_TO_STR (priv->m_istemp));
- xmlNewChild (node,NULL,
+ xmlNewChild (node, NULL,
(xmlChar*)gdadbtablenodes[GDA_DB_TABLE_COMMENT],
(xmlChar*)priv->mp_comment);
GList *it = NULL;
for (it = priv->mp_columns; it; it=it->next)
- if(!gda_db_buildable_write_node (GDA_DB_BUILDABLE(GDA_DB_COLUMN(it->data)),
- node,error))
+ if(!gda_db_buildable_write_node (GDA_DB_BUILDABLE(GDA_DB_COLUMN(it->data)), node,error))
return FALSE;
return TRUE;
@@ -332,15 +333,16 @@ gda_db_table_buildable_interface_init (GdaDbBuildableInterface *iface)
*/
void
gda_db_table_set_comment (GdaDbTable *self,
- const char *tablecomment)
+ const char *tablecomment)
{
g_return_if_fail (self);
- if (tablecomment) {
+ if (tablecomment)
+ {
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));
- }
+ priv->mp_comment = g_utf8_strup (tablecomment, g_utf8_strlen (tablecomment, -1));
+ }
}
/**
@@ -348,7 +350,7 @@ gda_db_table_set_comment (GdaDbTable *self,
* @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.
+ * Set if the table should be temporary or not. %FALSE is set by default.
*
* Since: 6.0
*/
@@ -366,6 +368,8 @@ gda_db_table_set_is_temp (GdaDbTable *self,
* @self: a #GdaDbTable object
*
* Returns: A comment string or %NULL if comment wasn't set.
+ *
+ * Since: 6.0
*/
const char*
gda_db_table_get_comment (GdaDbTable *self)
@@ -388,16 +392,27 @@ gda_db_table_get_comment (GdaDbTable *self)
gboolean
gda_db_table_get_temp (GdaDbTable *self)
{
- g_return_val_if_fail (self,FALSE);
+ g_return_val_if_fail (self, FALSE);
GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
return priv->m_istemp;
}
+/**
+ * gda_db_table_is_valid:
+ * @self: a #GdaDbTable instance
+ *
+ * This method returns %TRUE if at least one column is added to the table. It ruturns %FALSE if the
+ * table has no columns.
+ *
+ * Returns: %TRUE or %FALSE
+ *
+ * Since: 6.0
+ */
gboolean
gda_db_table_is_valid (GdaDbTable *self)
{
- g_return_val_if_fail (self,FALSE);
+ g_return_val_if_fail (self, FALSE);
GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
@@ -417,10 +432,11 @@ gda_db_table_is_valid (GdaDbTable *self)
* Use this method to obtain internal list of all columns. The internal list
* should not be freed.
*
- * 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.
+ * 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_db_table_get_columns (GdaDbTable *self)
@@ -438,8 +454,8 @@ gda_db_table_get_columns (GdaDbTable *self)
* Use this method to obtain internal list of all fkeys. The internal list
* should not be freed.
*
- * 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
+ * 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
*/
@@ -480,13 +496,15 @@ gda_db_table_get_is_temp (GdaDbTable *self)
* Populate @op with information stored in @self. This method sets @op to execute CREATE_TABLE
* operation.
*
+ * Returns: %TRUE if no error occured and %FALSE otherwise.
+ *
* Since: 6.0
*/
gboolean
gda_db_table_prepare_create (GdaDbTable *self,
- GdaServerOperation *op,
- gboolean ifnotexists,
- GError **error)
+ GdaServerOperation *op,
+ gboolean ifnotexists,
+ GError **error)
{
GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
@@ -530,7 +548,8 @@ gda_db_table_prepare_create (GdaDbTable *self,
}
static gint
-_gda_db_compare_column_meta(GdaMetaTableColumn *a,GdaDbColumn *b)
+_gda_db_compare_column_meta (GdaMetaTableColumn *a,
+ GdaDbColumn *b)
{
if (a && !b)
return 1;
@@ -540,9 +559,9 @@ _gda_db_compare_column_meta(GdaMetaTableColumn *a,GdaDbColumn *b)
return 0;
const gchar *namea = a->column_name;
- const gchar *nameb = gda_db_column_get_name(b);
+ const gchar *nameb = gda_db_column_get_name (b);
- return g_strcmp0(namea,nameb);
+ return g_strcmp0 (namea,nameb);
}
/**
@@ -559,22 +578,23 @@ _gda_db_compare_column_meta(GdaMetaTableColumn *a,GdaDbColumn *b)
*/
gboolean
gda_db_table_update (GdaDbTable *self,
- GdaMetaTable *obj,
- GdaConnection *cnc,
- GError **error)
+ GdaMetaTable *obj,
+ GdaConnection *cnc,
+ GError **error)
{
- g_return_val_if_fail (self,FALSE);
- g_return_val_if_fail (obj,FALSE);
- g_return_val_if_fail (cnc,FALSE);
+ g_return_val_if_fail (self, FALSE);
+ g_return_val_if_fail (obj, FALSE);
+ g_return_val_if_fail (cnc, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- if (!gda_connection_is_opened(cnc))
+ if (!gda_connection_is_opened (cnc))
return FALSE;
GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
if (!obj->columns)
{
- g_set_error (error,GDA_DB_TABLE_ERROR,GDA_DB_TABLE_COLUMN_EMPTY,_("Empty column list"));
+ g_set_error (error, GDA_DB_TABLE_ERROR, GDA_DB_TABLE_COLUMN_EMPTY, _("Empty column list"));
return FALSE;
}
@@ -586,22 +606,22 @@ gda_db_table_update (GdaDbTable *self,
dbcolumns = obj->columns;
- gda_lockable_lock((GdaLockable*)cnc);
+ gda_lockable_lock ((GdaLockable*)cnc);
provider = gda_connection_get_provider (cnc);
- op = gda_server_provider_create_operation(provider,
- cnc,
- GDA_SERVER_OPERATION_ADD_COLUMN,
- NULL,
- error);
+ op = gda_server_provider_create_operation (provider,
+ cnc,
+ GDA_SERVER_OPERATION_ADD_COLUMN,
+ NULL,
+ error);
if (!op)
goto on_error;
- if(!gda_server_operation_set_value_at(op,
- gda_db_base_get_full_name(GDA_DB_BASE(self)),
- error,
- "/COLUMN_DEF_P/TABLE_NAME"))
+ if(!gda_server_operation_set_value_at (op,
+ gda_db_base_get_full_name (GDA_DB_BASE(self)),
+ error,
+ "/COLUMN_DEF_P/TABLE_NAME"))
goto on_error;
gint newcolumncount = 0;
@@ -616,7 +636,7 @@ gda_db_table_update (GdaDbTable *self,
else
newcolumncount++; /* We need to count new column. See below */
- if(!gda_db_column_prepare_add(it->data,op,error))
+ if(!gda_db_column_prepare_add (it->data, op, error))
{
g_slist_free (res);
goto on_error;
@@ -624,16 +644,16 @@ gda_db_table_update (GdaDbTable *self,
}
if (newcolumncount != 0) /* Run operation only if at least on column is present*/
- if(!gda_server_provider_perform_operation(provider,cnc,op,error))
+ if(!gda_server_provider_perform_operation (provider, cnc, op, error))
goto on_error;
g_object_unref(op);
- gda_lockable_unlock((GdaLockable*)cnc);
+ gda_lockable_unlock ((GdaLockable*)cnc);
return TRUE;
on_error:
g_object_unref(op);
- gda_lockable_unlock((GdaLockable*)cnc);
+ gda_lockable_unlock ((GdaLockable*)cnc);
return FALSE;
}
@@ -653,12 +673,13 @@ on_error:
*/
gboolean
gda_db_table_create (GdaDbTable *self,
- GdaConnection *cnc,
- gboolean ifnotexists,
- GError **error)
+ GdaConnection *cnc,
+ gboolean ifnotexists,
+ GError **error)
{
g_return_val_if_fail (self, FALSE);
g_return_val_if_fail (cnc, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (!gda_connection_is_opened (cnc))
{
@@ -668,7 +689,7 @@ gda_db_table_create (GdaDbTable *self,
_("Connection is not opened"));
return FALSE;
}
- gda_lockable_lock(GDA_LOCKABLE(cnc));
+ gda_lockable_lock (GDA_LOCKABLE(cnc));
GdaServerProvider *provider = NULL;
GdaServerOperation *op = NULL;
@@ -676,24 +697,27 @@ gda_db_table_create (GdaDbTable *self,
provider = gda_connection_get_provider (cnc);
- op = gda_server_provider_create_operation(provider,
- cnc,
- GDA_SERVER_OPERATION_CREATE_TABLE,
- NULL,
- error);
- if (op) {
- g_object_set_data_full (G_OBJECT (op), "connection", g_object_ref (cnc), g_object_unref);
- if (gda_db_table_prepare_create(self, op, ifnotexists, error)) {
+ op = gda_server_provider_create_operation (provider,
+ cnc,
+ GDA_SERVER_OPERATION_CREATE_TABLE,
+ NULL,
+ error);
+ if (op)
+ {
+ g_object_set_data_full (G_OBJECT (op), "connection", g_object_ref (cnc), g_object_unref);
+
+ 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);
- g_free (str);
+ gchar* str = gda_server_operation_render (op, error);
+ g_message ("Operation: %s", str);
+ g_free (str);
#endif
- res = gda_server_provider_perform_operation(provider, cnc, op, error);
+ res = gda_server_provider_perform_operation (provider, cnc, op, error);
+ }
+ g_object_unref (op);
}
- g_object_unref (op);
- }
- gda_lockable_unlock(GDA_LOCKABLE(cnc));
+ gda_lockable_unlock (GDA_LOCKABLE(cnc));
return res;
}
@@ -709,13 +733,14 @@ gda_db_table_create (GdaDbTable *self,
*/
void
gda_db_table_append_column (GdaDbTable *self,
- GdaDbColumn *column)
+ GdaDbColumn *column)
{
g_return_if_fail (self);
+ g_return_if_fail (column);
GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
- priv->mp_columns = g_list_append (priv->mp_columns,g_object_ref(column));
+ priv->mp_columns = g_list_append (priv->mp_columns, g_object_ref (column));
}
/**
@@ -729,12 +754,12 @@ gda_db_table_append_column (GdaDbTable *self,
*/
void
gda_db_table_append_fkey (GdaDbTable *self,
- GdaDbFkey *fkey)
+ GdaDbFkey *fkey)
{
g_return_if_fail (self);
GdaDbTablePrivate *priv = gda_db_table_get_instance_private (self);
- priv->mp_fkeys = g_list_append (priv->mp_fkeys,g_object_ref(fkey));
+ priv->mp_fkeys = g_list_append (priv->mp_fkeys, g_object_ref (fkey));
}
diff --git a/libgda/gda-db-view.c b/libgda/gda-db-view.c
index 9ac71432c..4ab0e9875 100644
--- a/libgda/gda-db-view.c
+++ b/libgda/gda-db-view.c
@@ -1,6 +1,6 @@
/* gda-db-view.c
*
- * Copyright (C) 2018 Pavlo Solntsev <p sun fun gmail com>
+ * Copyright (C) 2018-2019 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
@@ -36,12 +36,12 @@ typedef struct
/**
* SECTION:gda-db-view
* @short_description: Object to represent view database object
- * @see_also: GdaDbTable, GdaDbCreator
+ * @see_also: #GdaDbTable, #GdaDbCatalog
* @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 #GdaDbCreator.
+ * using API or generated from xml file together with other databse objects. See #GdaDbCatalog.
* #GdaDbView implements #GdaDbBuildable interface for parsing xml file.
*/
@@ -54,31 +54,31 @@ G_DEFINE_TYPE_WITH_CODE (GdaDbView, gda_db_view, GDA_TYPE_DB_BASE,
/* This is convenient way to name all nodes from xml file */
enum {
- 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
+ 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 *gdadbviewnodes[GDA_DB_VIEW_N_NODES] = {
- "view",
- "ifnoexist",
- "temp",
- "replace",
- "name",
- "definition"
+static const gchar *gdadbviewnodes[GDA_DB_VIEW_N_NODES] = {
+ "view",
+ "ifnoexist",
+ "temp",
+ "replace",
+ "name",
+ "definition"
};
enum {
- PROP_0,
- PROP_VIEW_TEMP,
- PROP_VIEW_REPLACE,
- PROP_VIEW_IFNOEXIST,
- PROP_VIEW_DEFSTR,
- N_PROPS
+ PROP_0,
+ PROP_VIEW_TEMP,
+ PROP_VIEW_REPLACE,
+ PROP_VIEW_IFNOEXIST,
+ PROP_VIEW_DEFSTR,
+ N_PROPS
};
static GParamSpec *properties [N_PROPS] = {NULL};
@@ -109,14 +109,15 @@ gda_db_view_finalize (GObject *object)
static void
gda_db_view_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
GdaDbView *self = GDA_DB_VIEW (object);
GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
- switch (prop_id) {
+ switch (prop_id)
+ {
case PROP_VIEW_TEMP:
g_value_set_boolean (value,priv->m_istemp);
break;
@@ -132,19 +133,20 @@ gda_db_view_get_property (GObject *object,
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
- }
+ }
}
static void
gda_db_view_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
GdaDbView *self = GDA_DB_VIEW (object);
GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
- switch (prop_id){
+ switch (prop_id)
+ {
case PROP_VIEW_TEMP:
priv->m_istemp = g_value_get_boolean (value);
break;
@@ -161,7 +163,7 @@ gda_db_view_set_property (GObject *object,
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
- }
+ }
}
static void
@@ -198,7 +200,7 @@ gda_db_view_class_init (GdaDbViewClass *klass)
FALSE,
G_PARAM_READWRITE);
- g_object_class_install_properties (object_class,N_PROPS,properties);
+ g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
@@ -213,70 +215,74 @@ gda_db_view_init (GdaDbView *self)
static gboolean
gda_db_view_parse_node (GdaDbBuildable *buildable,
- xmlNodePtr node,
- GError **error)
+ xmlNodePtr node,
+ GError **error)
{
- GdaDbView *self = GDA_DB_VIEW (buildable);
g_return_val_if_fail (node, FALSE);
+ g_return_val_if_fail (node, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ GdaDbView *self = GDA_DB_VIEW (buildable);
/*
* <view name="Total" replace="TRUE" temp="TRUE" ifnoexists="TRUE">
* <definition>SELECT id,name FROM CUSTOMER</definition>
* </view>
*/
-
+
xmlChar *prop = NULL;
- prop = xmlGetProp (node,(xmlChar *)gdadbviewnodes[GDA_DB_VIEW_NAME]);
+ prop = xmlGetProp (node, (xmlChar *)gdadbviewnodes[GDA_DB_VIEW_NAME]);
g_assert (prop); /* Bug with xml valdation */
- gda_db_base_set_name(GDA_DB_BASE(self),(gchar*)prop);
+ gda_db_base_set_name (GDA_DB_BASE(self), (gchar*)prop);
xmlFree (prop);
prop = NULL;
- prop = xmlGetProp (node,(xmlChar *)gdadbviewnodes[GDA_DB_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);
+ g_object_set (G_OBJECT(self), "replace", *prop == 't' || *prop == 'T' ? TRUE : FALSE, NULL);
xmlFree (prop);
prop = NULL;
- prop = xmlGetProp (node,(xmlChar *)gdadbviewnodes[GDA_DB_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);
+ g_object_set (G_OBJECT(self), "istemp", *prop == 't' || *prop == 'T' ? TRUE : FALSE, NULL);
xmlFree (prop);
prop = NULL;
- prop = xmlGetProp (node,(xmlChar *)gdadbviewnodes[GDA_DB_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);
+ g_object_set (G_OBJECT(self), "ifnoexist", *prop == 't' || *prop == 'T' ? TRUE : FALSE, NULL);
xmlFree (prop);
prop = NULL;
-/* Loop here is for the following expension if we need to add more children
- * nodes it will be easy to add
+/* Loop here is for the following expension if we need to add more children
+ * nodes it will be easy to add
*/
for (xmlNodePtr it = node->children; it ; it = it->next)
{
if (!g_strcmp0 ((char *)it->name,gdadbviewnodes[GDA_DB_VIEW_DEFSTR]))
{
xmlChar *def = xmlNodeGetContent (it);
- gda_db_view_set_defstring (self,(gchar*)def);
+ gda_db_view_set_defstring (self, (gchar*)def);
xmlFree (def);
}
}
-
+
return TRUE;
}
static gboolean
gda_db_view_write_node (GdaDbBuildable *buildable,
- xmlNodePtr rootnode,
- GError **error)
+ xmlNodePtr rootnode,
+ GError **error)
{
- g_return_val_if_fail (buildable,FALSE);
- g_return_val_if_fail (rootnode,FALSE);
+ g_return_val_if_fail (buildable, FALSE);
+ g_return_val_if_fail (rootnode, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
GdaDbView *self = GDA_DB_VIEW (buildable);
GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
@@ -286,7 +292,7 @@ gda_db_view_write_node (GdaDbBuildable *buildable,
NULL,
BAD_CAST gdadbviewnodes[GDA_DB_VIEW_NODE],
NULL);
-
+
xmlNewProp (node,
BAD_CAST gdadbviewnodes[GDA_DB_VIEW_NODE],
BAD_CAST gda_db_base_get_name (GDA_DB_BASE(self)));
@@ -341,7 +347,8 @@ gda_db_view_get_istemp (GdaDbView *self)
* Since: 6.0
*/
void
-gda_db_view_set_istemp (GdaDbView *self,gboolean temp)
+gda_db_view_set_istemp (GdaDbView *self,
+ gboolean temp)
{
g_return_if_fail (self);
GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
@@ -359,7 +366,7 @@ gda_db_view_set_istemp (GdaDbView *self,gboolean temp)
gboolean
gda_db_view_get_ifnoexist (GdaDbView *self)
{
- g_return_val_if_fail (self,FALSE);
+ g_return_val_if_fail (self, FALSE);
GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
return priv->m_ifnoexist;
}
@@ -373,7 +380,7 @@ gda_db_view_get_ifnoexist (GdaDbView *self)
*/
void
gda_db_view_set_ifnoexist (GdaDbView *self,
- gboolean noexist)
+ gboolean noexist)
{
g_return_if_fail (self);
GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
@@ -390,7 +397,7 @@ gda_db_view_set_ifnoexist (GdaDbView *self,
const gchar*
gda_db_view_get_defstring (GdaDbView *self)
{
- g_return_val_if_fail (self,FALSE);
+ g_return_val_if_fail (self, FALSE);
GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
return priv->mp_defstring;
}
@@ -455,7 +462,7 @@ gda_db_view_set_replace (GdaDbView *self,
*
* This method performs CREATE_VIEW operation over @cnc using data stored in @self
* It is a convenient method to perform operation. See gda_db_view_prepare_create() if better
- * flexibility is needed.
+ * flexibility is needed.
*
* Returns: %TRUE if no error, %FASLE otherwise
*
@@ -463,42 +470,42 @@ gda_db_view_set_replace (GdaDbView *self,
*/
gboolean
gda_db_view_create (GdaDbView *self,
- GdaConnection *cnc,
- GError **error)
+ GdaConnection *cnc,
+ GError **error)
{
- g_return_val_if_fail (self,FALSE);
- g_return_val_if_fail (cnc,FALSE);
- g_return_val_if_fail (gda_connection_is_opened(cnc),FALSE);
+ g_return_val_if_fail (self, FALSE);
+ g_return_val_if_fail (cnc && gda_connection_is_opened(cnc), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- gda_lockable_lock((GdaLockable*)cnc);
+ gda_lockable_lock ((GdaLockable*)cnc);
GdaServerProvider *provider = NULL;
GdaServerOperation *op = NULL;
-
+
provider = gda_connection_get_provider (cnc);
- op = gda_server_provider_create_operation(provider,
- cnc,
- GDA_SERVER_OPERATION_CREATE_VIEW,
- NULL,
- error);
+ op = gda_server_provider_create_operation (provider,
+ cnc,
+ GDA_SERVER_OPERATION_CREATE_VIEW,
+ NULL,
+ error);
if (!op)
goto on_error;
- if (!gda_db_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))
+ if(!gda_server_provider_perform_operation (provider, cnc, op, error))
goto on_error;
g_object_unref (op);
- gda_lockable_unlock((GdaLockable*)cnc);
+ gda_lockable_unlock ((GdaLockable*)cnc);
return TRUE;
on_error:
if (op) g_object_unref (op);
- gda_lockable_unlock((GdaLockable*)cnc);
- return FALSE;
+ gda_lockable_unlock ((GdaLockable*)cnc);
+ return FALSE;
}
/**
@@ -509,51 +516,50 @@ on_error:
*
* Populate @op with information needed to perform CREATE_VIEW operation.
*
- * Returns: %TRUE if succeeded and %FALSE otherwise.
+ * Returns: %TRUE if succeeded and %FALSE otherwise.
*/
gboolean
gda_db_view_prepare_create (GdaDbView *self,
- GdaServerOperation *op,
- GError **error)
+ GdaServerOperation *op,
+ GError **error)
{
- g_return_val_if_fail (self,FALSE);
- g_return_val_if_fail (op,FALSE);
+ g_return_val_if_fail (self, FALSE);
+ g_return_val_if_fail (op, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
GdaDbViewPrivate *priv = gda_db_view_get_instance_private (self);
- if (!gda_server_operation_set_value_at(op,
- gda_db_base_get_name(GDA_DB_BASE(self)),
- error,
- "/VIEW_DEF_P/VIEW_NAME"))
+ if (!gda_server_operation_set_value_at (op,
+ gda_db_base_get_name (GDA_DB_BASE(self)),
+ error,
+ "/VIEW_DEF_P/VIEW_NAME"))
return FALSE;
- if (!gda_server_operation_set_value_at(op,
- GDA_BOOL_TO_STR(priv->m_replace),
- error,
- "/VIEW_DEF_P/VIEW_OR_REPLACE"))
+ if (!gda_server_operation_set_value_at (op,
+ GDA_BOOL_TO_STR(priv->m_replace),
+ error,
+ "/VIEW_DEF_P/VIEW_OR_REPLACE"))
return FALSE;
- if (!gda_server_operation_set_value_at(op,
- GDA_BOOL_TO_STR(priv->m_ifnoexist),
- error,
- "/VIEW_DEF_P/VIEW_IFNOTEXISTS"))
+ if (!gda_server_operation_set_value_at (op,
+ GDA_BOOL_TO_STR(priv->m_ifnoexist),
+ error,
+ "/VIEW_DEF_P/VIEW_IFNOTEXISTS"))
return FALSE;
- if (!gda_server_operation_set_value_at(op,
- GDA_BOOL_TO_STR(priv->m_istemp),
- error,
- "/VIEW_DEF_P/VIEW_TEMP"))
+ if (!gda_server_operation_set_value_at (op,
+ GDA_BOOL_TO_STR(priv->m_istemp),
+ error,
+ "/VIEW_DEF_P/VIEW_TEMP"))
return FALSE;
- if (!gda_server_operation_set_value_at(op,
- priv->mp_defstring,
- error,
- "/VIEW_DEF_P/VIEW_DEF"))
+ if (!gda_server_operation_set_value_at (op,
+ priv->mp_defstring,
+ error,
+ "/VIEW_DEF_P/VIEW_DEF"))
return FALSE;
return TRUE;
}
-
-
diff --git a/libgda/gda-db-view.h b/libgda/gda-db-view.h
index 173d3d917..92cfb12e3 100644
--- a/libgda/gda-db-view.h
+++ b/libgda/gda-db-view.h
@@ -40,22 +40,6 @@ 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);
gboolean gda_db_view_get_istemp (GdaDbView *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]