![]() |
![]() |
![]() |
GNOME Data Access 3.0 manual | ![]() |
---|---|---|---|---|
GdaDictConstraint; enum GdaDictConstraintType; enum GdaDictConstraintFkAction; GdaDictConstraint* gda_dict_constraint_new (GdaDictTable *table, GdaDictConstraintType type); GdaDictConstraint* gda_dict_constraint_new_with_db (GdaDictDatabase *db); GdaDictConstraintType gda_dict_constraint_get_constraint_type (GdaDictConstraint *cstr); gboolean gda_dict_constraint_equal (GdaDictConstraint *cstr1, GdaDictConstraint *cstr2); GdaDictTable* gda_dict_constraint_get_table (GdaDictConstraint *cstr); gboolean gda_dict_constraint_uses_field (GdaDictConstraint *cstr, GdaDictField *field); void gda_dict_constraint_pkey_set_fields (GdaDictConstraint *cstr, const GSList *fields); GSList* gda_dict_constraint_pkey_get_fields (GdaDictConstraint *cstr); void gda_dict_constraint_fkey_set_fields (GdaDictConstraint *cstr, const GSList *pairs); GdaDictTable* gda_dict_constraint_fkey_get_ref_table (GdaDictConstraint *cstr); GSList* gda_dict_constraint_fkey_get_fields (GdaDictConstraint *cstr); void gda_dict_constraint_fkey_set_actions (GdaDictConstraint *cstr, GdaDictConstraintFkAction on_update, GdaDictConstraintFkAction on_delete); void gda_dict_constraint_fkey_get_actions (GdaDictConstraint *cstr, GdaDictConstraintFkAction *on_update, GdaDictConstraintFkAction *on_delete); void gda_dict_constraint_unique_set_fields (GdaDictConstraint *cstr, const GSList *fields); GSList* gda_dict_constraint_unique_get_fields (GdaDictConstraint *cstr); void gda_dict_constraint_not_null_set_field (GdaDictConstraint *cstr, GdaDictField *field); GdaDictField* gda_dict_constraint_not_null_get_field (GdaDictConstraint *cstr);
Any type of constraint in a database is represented by one instance of the class (see the possible types of constraints). As some constraints may not depend exclusively on a table, all the constraints are attached to the database itself.
It implements the GdaXmlStorage and GdaReferer interfaces.
typedef enum { CONSTRAINT_PRIMARY_KEY, CONSTRAINT_FOREIGN_KEY, CONSTRAINT_UNIQUE, CONSTRAINT_NOT_NULL, CONSTRAINT_CHECK_EXPR, CONSTRAINT_CHECK_IN_LIST, CONSTRAINT_CHECK_SETOF_LIST, CONSTRAINT_UNKNOWN } GdaDictConstraintType;
typedef enum { CONSTRAINT_FK_ACTION_CASCADE, CONSTRAINT_FK_ACTION_SET_NULL, CONSTRAINT_FK_ACTION_SET_DEFAULT, CONSTRAINT_FK_ACTION_SET_VALUE, CONSTRAINT_FK_ACTION_NO_ACTION } GdaDictConstraintFkAction;
GdaDictConstraint* gda_dict_constraint_new (GdaDictTable *table, GdaDictConstraintType type);
Creates a new GdaDictConstraint object
|
the GdaDictTable to which the constraint is attached |
|
the type of constraint |
Returns : |
the new object |
GdaDictConstraint* gda_dict_constraint_new_with_db (GdaDictDatabase *db);
Creates a new GdaDictConstraint object without specifying anything about the constraint except the database it is attached to. This is usefull only when the object is going to be loaded from an XML node.
|
a GdaDictDatabase object |
Returns : |
the new uninitialized object |
GdaDictConstraintType gda_dict_constraint_get_constraint_type (GdaDictConstraint *cstr);
Get the type of constraint the cstr
object represents
|
a GdaDictConstraint object |
Returns : |
the constraint type |
gboolean gda_dict_constraint_equal (GdaDictConstraint *cstr1, GdaDictConstraint *cstr2);
Compares two GdaDictConstraint objects to see if they are equal, without taking into account the name of the constraints or weather they are user or system defined
|
the first GdaDictConstraint to compare |
|
the second GdaDictConstraint to compare |
Returns : |
TRUE if the two constraints are equal and FALSE otherwise |
GdaDictTable* gda_dict_constraint_get_table (GdaDictConstraint *cstr);
Get the table to which the constraint is attached
|
a GdaDictConstraint object |
Returns : |
the GdaDictTable |
gboolean gda_dict_constraint_uses_field (GdaDictConstraint *cstr, GdaDictField *field);
Tests if field
is part of the cstr
constraint
|
a GdaDictConstraint object |
|
a GdaDictField object |
Returns : |
TRUE if cstr uses field
|
void gda_dict_constraint_pkey_set_fields (GdaDictConstraint *cstr, const GSList *fields);
Sets the fields which make the primary key represented by cstr
. All the fields
must belong to the same GdaDictTable to which the constraint is attached
|
a GdaDictConstraint object |
|
a list of GdaDictField objects |
GSList* gda_dict_constraint_pkey_get_fields (GdaDictConstraint *cstr);
Get the list of fields composing the primary key constraint which cstr
represents. The
returned list is allocated and must be de-allocated by the caller.
|
a GdaDictConstraint object |
Returns : |
a new list of fields |
void gda_dict_constraint_fkey_set_fields (GdaDictConstraint *cstr, const GSList *pairs);
Sets the field pairs which make the foreign key represented by cstr
. All the field pairs
must list a field which belong to the same GdaDictTable to which the constraint is attached
and a field which belongs to a GdaDictTable which is different from the one just mentionned and which
is within the same database.
The pairs are of type GdaDictConstraintFkeyPair.
|
a GdaDictConstraint object |
|
a list of GdaDictConstraintFkeyPair objects |
GdaDictTable* gda_dict_constraint_fkey_get_ref_table (GdaDictConstraint *cstr);
Get the GdaDictTable at the other end of the foreign key relation represented by this constraint
|
a GdaDictConstraint object |
Returns : |
the GdaDictTable |
GSList* gda_dict_constraint_fkey_get_fields (GdaDictConstraint *cstr);
Get the list of field pairs composing the foreign key constraint which cstr
represents. In the returned
list, each pair item is allocated and it's up to the caller to free the list and each pair, and the
reference count for each pointer to GObjects in each pair is NOT INCREASED, which means the caller of this
function DOES NOT hold any reference on the mentionned GObjects (if he needs to, it has to call g_object_ref()
)
|
a GdaDictConstraint object |
Returns : |
a new list of GdaDictConstraintFkeyPair pairs |
void gda_dict_constraint_fkey_set_actions (GdaDictConstraint *cstr, GdaDictConstraintFkAction on_update, GdaDictConstraintFkAction on_delete);
Sets the actions undertaken by the DBMS when some actions occur on the referenced data
|
a GdaDictConstraint object |
|
the action undertaken when an UPDATE occurs |
|
the action undertaken when a DELETE occurs |
void gda_dict_constraint_fkey_get_actions (GdaDictConstraint *cstr, GdaDictConstraintFkAction *on_update, GdaDictConstraintFkAction *on_delete);
Get the actions undertaken by the DBMS when some actions occur on the referenced data
|
a GdaDictConstraint object |
|
an address to store the action undertaken when an UPDATE occurs |
|
an address to store the action undertaken when a DELETE occurs |
void gda_dict_constraint_unique_set_fields (GdaDictConstraint *cstr, const GSList *fields);
|
a GdaDictConstraint object |
|
GSList* gda_dict_constraint_unique_get_fields (GdaDictConstraint *cstr);
Get the list of fields represented by this UNIQUE constraint. It's up to the caller to free the list.
|
a GdaDictConstraint object |
Returns : |
a new list of fields |
void gda_dict_constraint_not_null_set_field (GdaDictConstraint *cstr, GdaDictField *field);
|
|
|
GdaDictField* gda_dict_constraint_not_null_get_field (GdaDictConstraint *cstr);
|
|
Returns : |