GdaDbIndex

GdaDbIndex — Object to represent table index

Stability Level

Stable, unless otherwise indicated

Functions

Properties

GdaDbTable * table Read / Write

Types and Values

Object Hierarchy

    GObject
    ╰── GdaDbBase
        ╰── GdaDbIndex

Implemented Interfaces

GdaDbIndex implements GdaDdlModifiable.

Includes

#include <libgda/libgda.h>

Description

The object GdaDbIndex holds information about index in a table. Just populate the information using index API, set table as property, execute gda_ddl_modifiable_create() method. This method executes all needed DB manopulations to add the target index to the DB. This can be illustarted by the following example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
GdaDbTable *table = gda_db_table_new();
// Populate table as needed.
GdaDbIndex      *index = gda_db_index_new ();
GdaDbIndexField *field = gda_db_index_field_new ();
GdaDbColumn     *fcol  = gda_db_column_new ();
GError *error = NULL;

gda_db_index_set_unique (index, TRUE);
gda_db_base_set_name (GDA_DB_BASE (index), "MyIndex");

gda_db_column_set_name (fcol, "name");

gda_db_index_field_set_column (field, fcol);
gda_db_index_field_set_sort_order (field, GDA_DB_INDEX_SORT_ORDER_ASC);
gda_db_index_append_field (index, field);

g_object_unref (fcol);
g_object_unref (field);

g_object_set (index, "table", table, NULL);

res = gda_ddl_modifiable_create (GDA_DDL_MODIFIABLE(index), cnc, NULL, &error);

if (!res)
  g_print("Error during index addition\n");

Functions

gda_db_index_error_quark ()

GQuark
gda_db_index_error_quark (void);

gda_db_index_new ()

GdaDbIndex *
gda_db_index_new (void);

gda_db_index_set_unique ()

void
gda_db_index_set_unique (GdaDbIndex *self,
                         gboolean val);

If val is TRUE a "UNIQUE" will be added to the INDEX CREATE command, e.g. CREATE UNIQUE INDEX ...

Parameters

self

GdaDbIndex instance

 

val

if set to TRUE UNIQUE index type will be used.

 

Since: 6.0

Stability Level: Stable


gda_db_index_get_unique ()

gboolean
gda_db_index_get_unique (GdaDbIndex *self);

Parameters

self

instance os GdaDbIndex to use

 

Returns

state for UNIQUE. This method will abort if self is NULL

Since: 6.0

Stability Level: Stable


gda_db_index_append_field ()

void
gda_db_index_append_field (GdaDbIndex *self,
                           GdaDbIndexField *field);

Append to index filed to the current index instance, The self object will recieve full ownership of the field. After this call, the reference count for field will be increased and the instance of fiels must be destroyed by calling g_object_unref()

Parameters

self

an instance of GdaDbIndex

 

field

a field to set

 

Since: 6.0

Stability Level: Stable


gda_db_index_remove_field ()

void
gda_db_index_remove_field (GdaDbIndex *self,
                           const gchar *name);

Parameters

self

instance of GdaDbIndex

 

name

Name of the column where field should be removed.

 

Since: 6.0

Stability Level: Stable


gda_db_index_get_fields ()

GSList *
gda_db_index_get_fields (GdaDbIndex *self);

This function is thread safe, that is, cnc will be locked.

Parameters

self

an instance of GdaDbIndex

 

Returns

A list of GdaDbIndexField.

[transfer none][nullable][element-type Gda.DbIndexField]

Since: 6.0

Stability Level: Stable

Types and Values

GdaDbIndex

typedef struct _GdaDbIndex GdaDbIndex;

GDA_TYPE_DB_INDEX

#define GDA_TYPE_DB_INDEX (gda_db_index_get_type())

GDA_DB_INDEX_ERROR

#define GDA_DB_INDEX_ERROR gda_db_index_error_quark()

Property Details

The “table” property

  “table”                    GdaDbTable *

Table associated with index.

Owner: GdaDbIndex

Flags: Read / Write

See Also

GdaDbTable, GdaDbCatalog