GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-847944e18e
db/dbmi_base/index.c File Reference

DBMI Library (base) - index management. More...

#include <string.h>
#include <stdlib.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
Include dependency graph for db/dbmi_base/index.c:

Go to the source code of this file.

Functions

void db_init_index (dbIndex *index)
 Initialize dbIndex. More...
 
void db_free_index (dbIndex *index)
 Free allocated dbIndex. More...
 
int db_alloc_index_columns (dbIndex *index, int ncols)
 Allocate index columns. More...
 
dbIndexdb_alloc_index_array (int count)
 Allocate index array. More...
 
void db_free_index_array (dbIndex *list, int count)
 Free index array. More...
 
int db_set_index_name (dbIndex *index, const char *name)
 Set index name. More...
 
const char * db_get_index_name (dbIndex *index)
 Get index name. More...
 
int db_set_index_table_name (dbIndex *index, const char *name)
 Set table name. More...
 
const char * db_get_index_table_name (dbIndex *index)
 Get table name. More...
 
int db_get_index_number_of_columns (dbIndex *index)
 Get number of columns. More...
 
int db_set_index_column_name (dbIndex *index, int column_num, const char *name)
 Set column name. More...
 
const char * db_get_index_column_name (dbIndex *index, int column_num)
 Get column number. More...
 
int db_set_index_type_unique (dbIndex *index)
 Set index type to unique. More...
 
int db_set_index_type_non_unique (dbIndex *index)
 Set index type to non-unique. More...
 
int db_test_index_type_unique (dbIndex *index)
 Test if type is unique. More...
 
void db_print_index (FILE *fd, dbIndex *index)
 Report index. More...
 

Detailed Description

DBMI Library (base) - index management.

(C) 1999-2009, 2011 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Joel Jones (CERL/UIUC), Radim Blazek
Doxygenized by Martin Landa <landa.martin gmail.com> (2011)

Definition in file db/dbmi_base/index.c.

Function Documentation

◆ db_alloc_index_array()

dbIndex* db_alloc_index_array ( int  count)

Allocate index array.

Parameters
countnumber of items
Returns
pointer to allocated dbIndex array

Definition at line 73 of file db/dbmi_base/index.c.

References count, db_calloc(), db_init_index(), and list.

Referenced by db__recv_index_array().

◆ db_alloc_index_columns()

int db_alloc_index_columns ( dbIndex index,
int  ncols 
)

Allocate index columns.

Parameters
indexpointer to dbIndex
ncolsnumber of columns to be allocated
Returns
DB_OK

Definition at line 56 of file db/dbmi_base/index.c.

Referenced by db_create_index2().

◆ db_free_index()

void db_free_index ( dbIndex index)

Free allocated dbIndex.

Parameters
indexpointer to dbIndex to be freed

Definition at line 39 of file db/dbmi_base/index.c.

References _db_index::columnNames, db_free_string(), db_free_string_array(), db_init_index(), _db_index::indexName, _db_index::numColumns, and _db_index::tableName.

Referenced by db_create_index2(), db_d_create_index(), and db_free_index_array().

◆ db_free_index_array()

void db_free_index_array ( dbIndex list,
int  count 
)

Free index array.

Parameters
listdbIndex array
countnumber of items in the array

Definition at line 92 of file db/dbmi_base/index.c.

References count, db_free(), and db_free_index().

Referenced by db_d_list_indexes().

◆ db_get_index_column_name()

const char* db_get_index_column_name ( dbIndex index,
int  column_num 
)

Get column number.

Parameters
indexpointer to dbIndex
column_numcolumn number
Returns
string buffer with name

Definition at line 194 of file db/dbmi_base/index.c.

References _, _db_index::columnNames, db_error(), db_get_string(), NULL, and _db_index::numColumns.

Referenced by db_print_index().

◆ db_get_index_name()

const char* db_get_index_name ( dbIndex index)

Get index name.

Parameters
indexpointer to dbIndex
Returns
string buffer with name

Definition at line 124 of file db/dbmi_base/index.c.

References db_get_string(), and _db_index::indexName.

Referenced by db_print_index().

◆ db_get_index_number_of_columns()

int db_get_index_number_of_columns ( dbIndex index)

Get number of columns.

Parameters
indexpointer to dbIndex
Returns
number of columns

Definition at line 162 of file db/dbmi_base/index.c.

References _db_index::numColumns.

Referenced by db_print_index().

◆ db_get_index_table_name()

const char* db_get_index_table_name ( dbIndex index)

Get table name.

Parameters
indexpointer to dbIndex
Returns
string buffer with name

Definition at line 150 of file db/dbmi_base/index.c.

References db_get_string(), and _db_index::tableName.

Referenced by db_print_index().

◆ db_init_index()

void db_init_index ( dbIndex index)

Initialize dbIndex.

Parameters
indexpointer to dbIndex to be initialized

Definition at line 25 of file db/dbmi_base/index.c.

References _db_index::columnNames, db_init_string(), _db_index::indexName, NULL, _db_index::numColumns, _db_index::tableName, and _db_index::unique.

Referenced by db_alloc_index_array(), db_create_index2(), db_d_create_index(), and db_free_index().

◆ db_print_index()

void db_print_index ( FILE *  fd,
dbIndex index 
)

Report index.

Parameters
fdfile where to print index info
indexpointer to dbIndex

Definition at line 254 of file db/dbmi_base/index.c.

References db_get_index_column_name(), db_get_index_name(), db_get_index_number_of_columns(), db_get_index_table_name(), and db_test_index_type_unique().

◆ db_set_index_column_name()

int db_set_index_column_name ( dbIndex index,
int  column_num,
const char *  name 
)

Set column name.

Parameters
indexpointer to dbIndex
column_numcolumn number
namename to be set
Returns
DB_OK on success
DB_FAILED on error

Definition at line 177 of file db/dbmi_base/index.c.

References _, _db_index::columnNames, db_error(), db_get_error_code(), db_set_string(), name, and _db_index::numColumns.

Referenced by db_create_index2().

◆ db_set_index_name()

int db_set_index_name ( dbIndex index,
const char *  name 
)

Set index name.

Parameters
indexpointer to dbIndex
namename to be set
Returns
DB_OK on success
DB_FAILED on error

Definition at line 112 of file db/dbmi_base/index.c.

References db_set_string(), _db_index::indexName, and name.

Referenced by db_create_index2().

◆ db_set_index_table_name()

int db_set_index_table_name ( dbIndex index,
const char *  name 
)

Set table name.

Parameters
indexpointer to dbIndex
namename to be set
Returns
DB_OK on success
DB_FAILED on error

Definition at line 138 of file db/dbmi_base/index.c.

References db_set_string(), name, and _db_index::tableName.

Referenced by db_create_index2().

◆ db_set_index_type_non_unique()

int db_set_index_type_non_unique ( dbIndex index)

Set index type to non-unique.

Todo:
return type void?
Parameters
indexpointer to dbIndex
Returns
0

Definition at line 228 of file db/dbmi_base/index.c.

References _db_index::unique.

◆ db_set_index_type_unique()

int db_set_index_type_unique ( dbIndex index)

Set index type to unique.

Todo:
return type void?
Parameters
indexpointer to dbIndex
Returns
0

Definition at line 212 of file db/dbmi_base/index.c.

References _db_index::unique.

Referenced by db_create_index2().

◆ db_test_index_type_unique()

int db_test_index_type_unique ( dbIndex index)

Test if type is unique.

Parameters
indexpointer to dbIndex
Returns
non-zero if True
zero if False

Definition at line 243 of file db/dbmi_base/index.c.

References _db_index::unique.

Referenced by db_print_index().