GdaDictConstraint

GdaDictConstraint — Represents a constraint within a database

Functions

Properties

gboolean user-constraint Read / Write

Types and Values

Object Hierarchy

    GObject
    ╰── GdaObject
        ╰── GdaDictConstraint

Implemented Interfaces

GdaDictConstraint implements GdaXmlStorage and GdaReferer.

Description

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.

Functions

gda_dict_constraint_new ()

GdaDictConstraint *
gda_dict_constraint_new (GdaDictTable *table,
                         GdaDictConstraintType type);

Creates a new GdaDictConstraint object

Parameters

table

the GdaDictTable to which the constraint is attached

 

type

the type of constraint

 

Returns

the new object


gda_dict_constraint_new_with_db ()

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.

Parameters

db

a GdaDictDatabase object

 

Returns

the new uninitialized object


gda_dict_constraint_get_constraint_type ()

GdaDictConstraintType
gda_dict_constraint_get_constraint_type
                               (GdaDictConstraint *cstr);

Get the type of constraint the cstr object represents

Parameters

cstr

a GdaDictConstraint object

 

Returns

the constraint type


gda_dict_constraint_equal ()

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

Parameters

cstr1

the first GdaDictConstraint to compare

 

cstr2

the second GdaDictConstraint to compare

 

Returns

TRUE if the two constraints are equal and FALSE otherwise


gda_dict_constraint_get_table ()

GdaDictTable *
gda_dict_constraint_get_table (GdaDictConstraint *cstr);

Get the table to which the constraint is attached

Parameters

cstr

a GdaDictConstraint object

 

Returns

the GdaDictTable


gda_dict_constraint_uses_field ()

gboolean
gda_dict_constraint_uses_field (GdaDictConstraint *cstr,
                                GdaDictField *field);

Tests if field is part of the cstr constraint

Parameters

cstr

a GdaDictConstraint object

 

field

a GdaDictField object

 

Returns

TRUE if cstr uses field


gda_dict_constraint_pkey_set_fields ()

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

Parameters

cstr

a GdaDictConstraint object

 

fields

a list of GdaDictField objects

 

gda_dict_constraint_pkey_get_fields ()

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.

Parameters

cstr

a GdaDictConstraint object

 

Returns

a new list of fields


gda_dict_constraint_fkey_set_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.

Parameters

cstr

a GdaDictConstraint object

 

pairs

a list of GdaDictField objects

 

gda_dict_constraint_fkey_get_ref_table ()

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

Parameters

cstr

a GdaDictConstraint object

 

Returns

the GdaDictTable


gda_dict_constraint_fkey_get_fields ()

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())

Parameters

cstr

a GdaDictConstraint object

 

Returns

a new list of GdaDictConstraintFkeyPair pairs


gda_dict_constraint_fkey_set_actions ()

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

Parameters

cstr

a GdaDictConstraint object

 

on_update

the action undertaken when an UPDATE occurs

 

on_delete

the action undertaken when a DELETE occurs

 

gda_dict_constraint_fkey_get_actions ()

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

Parameters

cstr

a GdaDictConstraint object

 

on_update

an address to store the action undertaken when an UPDATE occurs

 

on_delete

an address to store the action undertaken when a DELETE occurs

 

gda_dict_constraint_unique_set_fields ()

void
gda_dict_constraint_unique_set_fields (GdaDictConstraint *cstr,
                                       const GSList *fields);

Parameters

cstr

a GdaDictConstraint object

 

gda_dict_constraint_unique_get_fields ()

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.

Parameters

cstr

a GdaDictConstraint object

 

Returns

a new list of fields


gda_dict_constraint_not_null_set_field ()

void
gda_dict_constraint_not_null_set_field
                               (GdaDictConstraint *cstr,
                                GdaDictField *field);


gda_dict_constraint_not_null_get_field ()

GdaDictField *
gda_dict_constraint_not_null_get_field
                               (GdaDictConstraint *cstr);

Types and Values

GdaDictConstraint

typedef struct _GdaDictConstraint GdaDictConstraint;


enum GdaDictConstraintType

Members

CONSTRAINT_PRIMARY_KEY

   

CONSTRAINT_FOREIGN_KEY

   

CONSTRAINT_UNIQUE

   

CONSTRAINT_NOT_NULL

   

CONSTRAINT_CHECK_EXPR

   

CONSTRAINT_CHECK_IN_LIST

   

CONSTRAINT_CHECK_SETOF_LIST

   

CONSTRAINT_UNKNOWN

   

enum GdaDictConstraintFkAction

Members

CONSTRAINT_FK_ACTION_CASCADE

   

CONSTRAINT_FK_ACTION_SET_NULL

   

CONSTRAINT_FK_ACTION_SET_DEFAULT

   

CONSTRAINT_FK_ACTION_SET_VALUE

   

CONSTRAINT_FK_ACTION_NO_ACTION

   

Property Details

The “user-constraint” property

  “user-constraint”          gboolean

Flags: Read / Write

Default value: FALSE