GdaDictDatabase

GdaDictDatabase — Represents a database structure in the DBMS server

Synopsis

                    GdaDictDatabase;
GObject*            gda_dict_database_new               (GdaDict *dict);
void                gda_dict_database_add_constraint    (GdaDictDatabase *db,
                                                         GdaDictConstraint *cstr);
GdaDict*            gda_dict_database_get_dict          (GdaDictDatabase *db);
gboolean            gda_dict_database_update_dbms_data  (GdaDictDatabase *db,
                                                         GType limit_to_type,
                                                         const gchar *limit_obj_name,
                                                         GError **error);
void                gda_dict_database_stop_update_dbms_data
                                                        (GdaDictDatabase *db);
GSList*             gda_dict_database_get_tables        (GdaDictDatabase *db);
GdaDictTable*       gda_dict_database_get_table_by_name (GdaDictDatabase *db,
                                                         const gchar *name);
GdaDictTable*       gda_dict_database_get_table_by_xml_id
                                                        (GdaDictDatabase *db,
                                                         const gchar *xml_id);
GdaDictField*       gda_dict_database_get_field_by_name (GdaDictDatabase *db,
                                                         const gchar *fullname);
GdaDictField*       gda_dict_database_get_field_by_xml_id
                                                        (GdaDictDatabase *db,
                                                         const gchar *xml_id);
GSList*             gda_dict_database_get_all_constraints
                                                        (GdaDictDatabase *db);
GSList*             gda_dict_database_get_table_constraints
                                                        (GdaDictDatabase *db,
                                                         GdaDictTable *table);
GSList*             gda_dict_database_get_all_fk_constraints
                                                        (GdaDictDatabase *db);
GSList*             gda_dict_database_get_tables_fk_constraints
                                                        (GdaDictDatabase *db,
                                                         GdaDictTable *table1,
                                                         GdaDictTable *table2,
                                                         gboolean table1_has_fk);

Object Hierarchy

  GObject
   +----GdaObject
         +----GdaDictDatabase

Implemented Interfaces

GdaDictDatabase implements GdaXmlStorage.

Signals

  "constraint-added"                               : Run First
  "constraint-removed"                             : Run First
  "constraint-updated"                             : Run First
  "data-update-finished"                           : Run First
  "data-update-started"                            : Run First
  "field-added"                                    : Run First
  "field-removed"                                  : Run First
  "field-updated"                                  : Run First
  "table-added"                                    : Run First
  "table-removed"                                  : Run First
  "table-updated"                                  : Run First
  "update-progress"                                : Run First

Description

This object manages an internal dictionary mirroring the real database structure with objects such as GdaDictTable (composed of GdaDictfield objects) and GdaDictConstraint.

Details

GdaDictDatabase

typedef struct _GdaDictDatabase GdaDictDatabase;


gda_dict_database_new ()

GObject*            gda_dict_database_new               (GdaDict *dict);

Creates a new GdaDictDatabase object

dict :

a GdaDict object

Returns :

the new object

gda_dict_database_add_constraint ()

void                gda_dict_database_add_constraint    (GdaDictDatabase *db,
                                                         GdaDictConstraint *cstr);

Add the cstr constraint to the database. The cstr constraint is a user-defined constraint (which is not part of the database structure itself).

db :

a GdaDictDatabase object

cstr :

a GdaDictConstraint

gda_dict_database_get_dict ()

GdaDict*            gda_dict_database_get_dict          (GdaDictDatabase *db);

Fetch the GdaDict object to which the GdaDictDatabase belongs.

db :

a GdaDictDatabase object

Returns :

the GdaDict object

gda_dict_database_update_dbms_data ()

gboolean            gda_dict_database_update_dbms_data  (GdaDictDatabase *db,
                                                         GType limit_to_type,
                                                         const gchar *limit_obj_name,
                                                         GError **error);

Synchronises the database representation with the database structure which is stored in the DBMS. For this operation to succeed, the connection to the DBMS server MUST be opened (using the corresponding GdaConnection object).

db :

a GdaDictDatabase object

limit_to_type :

limit the DBMS update to this type, or 0 for no limit

limit_obj_name :

limit the DBMS update to objects of this name, or NULL for no limit

error :

location to store error, or NULL

Returns :

TRUE if no error

gda_dict_database_stop_update_dbms_data ()

void                gda_dict_database_stop_update_dbms_data
                                                        (GdaDictDatabase *db);

When the database updates its internal lists of DBMS objects, a call to this function will stop that update process. It has no effect when the database is not updating its DBMS data.

db :

a GdaDictDatabase object

gda_dict_database_get_tables ()

GSList*             gda_dict_database_get_tables        (GdaDictDatabase *db);

Get a list of all the tables within db

db :

a GdaDictDatabase object

Returns :

a new list of all the GdaDictTable objects

gda_dict_database_get_table_by_name ()

GdaDictTable*       gda_dict_database_get_table_by_name (GdaDictDatabase *db,
                                                         const gchar *name);

Get a reference to a GdaDictTable using its name.

db :

a GdaDictDatabase object

name :

the name of the requested table

Returns :

The GdaDictTable pointer or NULL if the requested table does not exist.

gda_dict_database_get_table_by_xml_id ()

GdaDictTable*       gda_dict_database_get_table_by_xml_id
                                                        (GdaDictDatabase *db,
                                                         const gchar *xml_id);

Get a reference to a GdaDictTable using its XML id.

db :

a GdaDictDatabase object

xml_id :

the XML id of the requested table

Returns :

The GdaDictTable pointer or NULL if the requested table does not exist.

gda_dict_database_get_field_by_name ()

GdaDictField*       gda_dict_database_get_field_by_name (GdaDictDatabase *db,
                                                         const gchar *fullname);

Get a reference to a GdaDictField specifying the full name (table_name.field_name) of the requested field.

db :

a GdaDictDatabase object

fullname :

the name of the requested table field

Returns :

The GdaDictField pointer or NULL if the requested field does not exist.

gda_dict_database_get_field_by_xml_id ()

GdaDictField*       gda_dict_database_get_field_by_xml_id
                                                        (GdaDictDatabase *db,
                                                         const gchar *xml_id);

Get a reference to a GdaDictField specifying its XML id

db :

a GdaDictDatabase object

xml_id :

the XML id of the requested table field

Returns :

The GdaDictField pointer or NULL if the requested field does not exist.

gda_dict_database_get_all_constraints ()

GSList*             gda_dict_database_get_all_constraints
                                                        (GdaDictDatabase *db);

Get a list of all the constraints applied to the database. Constraints are represented as GdaDictConstraint objects and represent any type of constraint.

db :

a GdaDictDatabase object

Returns :

a new list of the constraints

gda_dict_database_get_table_constraints ()

GSList*             gda_dict_database_get_table_constraints
                                                        (GdaDictDatabase *db,
                                                         GdaDictTable *table);

Get all the constraints applicable to table

db :

a GdaDictDatabase object

table :

a GdaDictTable, part of db

Returns :

a new GSList of GdaDictConstraint objects

gda_dict_database_get_all_fk_constraints ()

GSList*             gda_dict_database_get_all_fk_constraints
                                                        (GdaDictDatabase *db);

Get a list of all the constraints applied to the database which represent a foreign constrains. Constraints are represented as GdaDictConstraint objects.

db :

a GdaDictDatabase object

Returns :

a new list of the constraints

gda_dict_database_get_tables_fk_constraints ()

GSList*             gda_dict_database_get_tables_fk_constraints
                                                        (GdaDictDatabase *db,
                                                         GdaDictTable *table1,
                                                         GdaDictTable *table2,
                                                         gboolean table1_has_fk);

Get a list of all the constraints applied to the database which represent a foreign key constrains, between table1 and table2. If table1 or table2 are NULL, then the returned foreign key constraints are the ones between any table and table1 or table2.

Constraints are represented as GdaDictConstraint objects.

db :

a GdaDictDatabase object

table1 :

a GdaDictTable, or NULL

table2 :

a GdaDictTable, or NULL

table1_has_fk :

TRUE if the returned constraints are the one for which table1 contains the foreign key

Returns :

a new list of the constraints

Signal Details

The "constraint-added" signal

void                user_function                      (GdaDictDatabase   *gdadictdatabase,
                                                        GdaDictConstraint *arg1,
                                                        gpointer           user_data)            : Run First

dbdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.

The "constraint-removed" signal

void                user_function                      (GdaDictDatabase   *gdadictdatabase,
                                                        GdaDictConstraint *arg1,
                                                        gpointer           user_data)            : Run First

dbdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.

The "constraint-updated" signal

void                user_function                      (GdaDictDatabase   *gdadictdatabase,
                                                        GdaDictConstraint *arg1,
                                                        gpointer           user_data)            : Run First

dbdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.

The "data-update-finished" signal

void                user_function                      (GdaDictDatabase *gdadictdatabase,
                                                        gpointer         user_data)            : Run First

dbdatabase :

the object which received the signal.

user_data :

user data set when the signal handler was connected.

The "data-update-started" signal

void                user_function                      (GdaDictDatabase *gdadictdatabase,
                                                        gpointer         user_data)            : Run First

dbdatabase :

the object which received the signal.

user_data :

user data set when the signal handler was connected.

The "field-added" signal

void                user_function                      (GdaDictDatabase *gdadictdatabase,
                                                        GdaDictField    *arg1,
                                                        gpointer         user_data)            : Run First

dbdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.

The "field-removed" signal

void                user_function                      (GdaDictDatabase *gdadictdatabase,
                                                        GdaDictField    *arg1,
                                                        gpointer         user_data)            : Run First

dbdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.

The "field-updated" signal

void                user_function                      (GdaDictDatabase *gdadictdatabase,
                                                        GdaDictField    *arg1,
                                                        gpointer         user_data)            : Run First

dbdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.

The "table-added" signal

void                user_function                      (GdaDictDatabase *gdadictdatabase,
                                                        GdaDictTable    *arg1,
                                                        gpointer         user_data)            : Run First

dbdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.

The "table-removed" signal

void                user_function                      (GdaDictDatabase *gdadictdatabase,
                                                        GdaDictTable    *arg1,
                                                        gpointer         user_data)            : Run First

dbdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.

The "table-updated" signal

void                user_function                      (GdaDictDatabase *gdadictdatabase,
                                                        GdaDictTable    *arg1,
                                                        gpointer         user_data)            : Run First

dbdatabase :

the object which received the signal.

arg1 :

user_data :

user data set when the signal handler was connected.

The "update-progress" signal

void                user_function                      (GdaDictDatabase *gdadictdatabase,
                                                        gchar           *arg1,
                                                        guint            arg2,
                                                        guint            arg3,
                                                        gpointer         user_data)            : Run First

dbdatabase :

the object which received the signal.

arg1 :

arg2 :

arg3 :

user_data :

user data set when the signal handler was connected.