GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71933
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dbmi_base/column.c File Reference

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

#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/dbmi.h>
Include dependency graph for dbmi_base/column.c:

Go to the source code of this file.

Functions

dbValuedb_get_column_value (dbColumn *column)
 Returns column value for given column structure. More...
 
dbValuedb_get_column_default_value (dbColumn *column)
 Returns column default value for given column structure. More...
 
void db_set_column_sqltype (dbColumn *column, int sqltype)
 Define column sqltype for column. More...
 
void db_set_column_host_type (dbColumn *column, int type)
 Set column host data type. More...
 
int db_get_column_scale (dbColumn *column)
 Get column scale. More...
 
void db_set_column_scale (dbColumn *column, int scale)
 Set column scale. More...
 
int db_get_column_precision (dbColumn *column)
 Get column precision. More...
 
void db_set_column_precision (dbColumn *column, int precision)
 Set column precision. More...
 
int db_get_column_sqltype (dbColumn *column)
 Returns column sqltype for column. More...
 
int db_get_column_host_type (dbColumn *column)
 Get column host type. More...
 
void db_set_column_has_defined_default_value (dbColumn *column)
 Set default value identificator. More...
 
void db_set_column_has_undefined_default_value (dbColumn *column)
 Unset default value identificator. More...
 
void db_unset_column_has_default_value (dbColumn *column)
 Unset default value identificator. More...
 
int db_test_column_has_default_value (dbColumn *column)
 Check if column has defined default value. More...
 
int db_test_column_has_defined_default_value (dbColumn *column)
 Check if column has defined default value. More...
 
int db_test_column_has_undefined_default_value (dbColumn *column)
 Check if column has defined default value. More...
 
void db_set_column_use_default_value (dbColumn *column)
 Set default value to be used. More...
 
void db_unset_column_use_default_value (dbColumn *column)
 Unset default value to be used. More...
 
int db_test_column_use_default_value (dbColumn *column)
 Checks if default value is used. More...
 
void db_set_column_null_allowed (dbColumn *column)
 Set null value to be allowed. More...
 
void db_unset_column_null_allowed (dbColumn *column)
 Unset null value to be allowed. More...
 
int db_test_column_null_allowed (dbColumn *column)
 Checks if null value is allowed. More...
 
int db_get_column_length (dbColumn *column)
 Get column's length. More...
 
void db_set_column_length (dbColumn *column, int length)
 Set column's length. More...
 
void db_set_column_select_priv_granted (dbColumn *column)
 Set select privilages to be granted. More...
 
void db_set_column_select_priv_not_granted (dbColumn *column)
 Unset select privilages. More...
 
int db_get_column_select_priv (dbColumn *column)
 Get select privilages. More...
 
void db_set_column_update_priv_granted (dbColumn *column)
 Set update privilages to be granted. More...
 
void db_set_column_update_priv_not_granted (dbColumn *column)
 Unset update privilages. More...
 
int db_get_column_update_priv (dbColumn *column)
 Get update privilages. More...
 
void db_init_column (dbColumn *column)
 Initialize dbColumn. More...
 
int db_set_column_name (dbColumn *column, const char *name)
 Set column name. More...
 
const char * db_get_column_name (dbColumn *column)
 Returns column name for given column. More...
 
int db_set_column_description (dbColumn *column, const char *description)
 Set column description. More...
 
const char * db_get_column_description (dbColumn *column)
 Returns column description for given column. More...
 
void db_free_column (dbColumn *column)
 Frees column structure. More...
 
dbColumndb_copy_column (dbColumn *dest, dbColumn *src)
 Copy a db column from source to destination. More...
 

Detailed Description

DBMI Library (base) - columns 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 dbmi_base/column.c.

Function Documentation

dbColumn* db_copy_column ( dbColumn dest,
dbColumn src 
)

Copy a db column from source to destination.

Parameters
srcThe column to copy from
destAn allocated column to copy to which will be initialized. In case dest is NULL a new column will be allocated and returned
Returns
The pointer of copied/allocated column

Definition at line 473 of file dbmi_base/column.c.

References _db_column::columnName, _db_column::dataLen, db_calloc(), db_copy_string(), db_copy_value(), db_init_column(), _db_column::defaultValue, _db_column::description, _db_column::hasDefaultValue, _db_column::hostDataType, NULL, _db_column::nullAllowed, _db_column::precision, _db_column::scale, _db_column::select, _db_column::sqlDataType, _db_column::update, _db_column::useDefaultValue, and _db_column::value.

Referenced by db_append_table_column(), db_clone_table(), db_get_column(), and db_set_table_column().

void db_free_column ( dbColumn column)

Frees column structure.

Parameters
columnpointer to dbColumn

Definition at line 454 of file dbmi_base/column.c.

References _db_column::columnName, db_free_string(), _db_column::defaultValue, _db_column::description, _db_value::s, and _db_column::value.

Referenced by db_d_add_column(), and db_free_table().

dbValue* db_get_column_default_value ( dbColumn column)

Returns column default value for given column structure.

Parameters
columnpointer to dbColumn
Returns
pointer to dbValue

Definition at line 39 of file dbmi_base/column.c.

References _db_column::defaultValue.

Referenced by db__recv_column_default_value(), db__send_column_default_value(), db_convert_column_default_value_to_string(), and db_convert_Cstring_to_column_default_value().

const char* db_get_column_description ( dbColumn column)

Returns column description for given column.

Parameters
columnpointer to dbColumn
Returns
pointer to string with column's description

Definition at line 444 of file dbmi_base/column.c.

References db_get_string(), and _db_column::description.

Referenced by db_print_column_definition().

int db_get_column_host_type ( dbColumn column)

Get column host type.

Parameters
columnpointer to dbColumn
Returns
data type (see include/dbmi.h)

Definition at line 154 of file dbmi_base/column.c.

References _db_column::hostDataType.

int db_get_column_length ( dbColumn column)

Get column's length.

Parameters
columnpointer to dbColumn
Returns
length

Definition at line 303 of file dbmi_base/column.c.

References _db_column::dataLen.

Referenced by db_print_column_definition(), and db_table_to_sql().

const char* db_get_column_name ( dbColumn column)

Returns column name for given column.

Parameters
columnpointer to dbColumn
Returns
pointer to string with column name

Definition at line 418 of file dbmi_base/column.c.

References _db_column::columnName, and db_get_string().

Referenced by db_column_sqltype(), db_get_column(), db_print_column_definition(), db_table_to_sql(), Vect_get_column_names(), Vect_get_column_names_types(), and Vect_write_ascii().

int db_get_column_precision ( dbColumn column)

Get column precision.

Parameters
columnpointer to dbColumn
Returns
precision

Definition at line 117 of file dbmi_base/column.c.

References _db_column::precision.

Referenced by db_print_column_definition().

int db_get_column_scale ( dbColumn column)

Get column scale.

Parameters
columnpointer to dbColumn
Returns
scale

Definition at line 94 of file dbmi_base/column.c.

References _db_column::scale.

Referenced by db_print_column_definition().

int db_get_column_select_priv ( dbColumn column)

Get select privilages.

Parameters
columnpointer to dbColumn
Returns
privilages

Definition at line 346 of file dbmi_base/column.c.

References _db_column::select.

Referenced by db_get_table_select_priv(), and db_print_column_definition().

int db_get_column_update_priv ( dbColumn column)

Get update privilages.

Parameters
columnpointer to dbColumn
Returns
privilages

Definition at line 378 of file dbmi_base/column.c.

References _db_column::update.

Referenced by db_get_table_update_priv(), and db_print_column_definition().

dbValue* db_get_column_value ( dbColumn column)

Returns column value for given column structure.

Parameters
columnpointer to dbColumn
Returns
pointer to dbValue

Definition at line 27 of file dbmi_base/column.c.

References _db_column::value.

Referenced by db__recv_column_value(), db__send_column_value(), db_convert_column_value_to_string(), db_convert_Cstring_to_column_value(), db_select_CatValArray(), db_select_int(), db_select_value(), NetA_init_distinct(), NetA_init_timetable_from_db(), P_Aux_to_Vector(), and Vect_write_ascii().

void db_init_column ( dbColumn column)

Initialize dbColumn.

Parameters
columnpointer to dbColumn to be initialized

Definition at line 388 of file dbmi_base/column.c.

References _db_column::columnName, db_init_string(), db_zero(), _db_column::defaultValue, _db_column::description, _db_value::s, and _db_column::value.

Referenced by db_alloc_table(), db_copy_column(), and db_d_add_column().

int db_set_column_description ( dbColumn column,
const char *  description 
)

Set column description.

Parameters
columnpointer to dbColumn
descriptioncolumn's description
Returns
DB_OK on success
error code on failure

Definition at line 432 of file dbmi_base/column.c.

References db_set_string(), and _db_column::description.

void db_set_column_has_defined_default_value ( dbColumn column)

Set default value identificator.

Parameters
columnpointer to dbColumn

Definition at line 164 of file dbmi_base/column.c.

References _db_column::hasDefaultValue.

void db_set_column_has_undefined_default_value ( dbColumn column)

Unset default value identificator.

Todo:
Replace by db_unset_column_has_default_value() ?
Parameters
columnpointer to dbColumn

Definition at line 176 of file dbmi_base/column.c.

References _db_column::hasDefaultValue.

void db_set_column_host_type ( dbColumn column,
int  type 
)

Set column host data type.

Parameters
columnpointer to dbColumn
typedata type

Definition at line 82 of file dbmi_base/column.c.

References _db_column::hostDataType.

void db_set_column_length ( dbColumn column,
int  length 
)

Set column's length.

Parameters
columnpointer to dbColumn
lengthvalue

Definition at line 314 of file dbmi_base/column.c.

References _db_column::dataLen.

int db_set_column_name ( dbColumn column,
const char *  name 
)

Set column name.

Parameters
columnpointer to dbColumn
namecolumn name
Returns
DB_OK on success
error code on failure

Definition at line 406 of file dbmi_base/column.c.

References _db_column::columnName, and db_set_string().

Referenced by P_Create_Aux2_Table(), and P_Create_Aux4_Table().

void db_set_column_null_allowed ( dbColumn column)

Set null value to be allowed.

Parameters
columnpointer to dbColumn

Definition at line 268 of file dbmi_base/column.c.

References _db_column::nullAllowed.

void db_set_column_precision ( dbColumn column,
int  precision 
)

Set column precision.

Parameters
columnpointer to dbColumn
precisionvalue

Definition at line 128 of file dbmi_base/column.c.

References _db_column::precision.

void db_set_column_scale ( dbColumn column,
int  scale 
)

Set column scale.

Parameters
columnpointer to dbColumn
scalecolumn scale value

Definition at line 105 of file dbmi_base/column.c.

References _db_column::scale.

void db_set_column_select_priv_granted ( dbColumn column)

Set select privilages to be granted.

Parameters
columnpointer to dbColumn

Definition at line 324 of file dbmi_base/column.c.

References DB_GRANTED, and _db_column::select.

Referenced by db_set_table_select_priv_granted().

void db_set_column_select_priv_not_granted ( dbColumn column)

Unset select privilages.

Parameters
columnpointer to dbColumn

Definition at line 334 of file dbmi_base/column.c.

References DB_NOT_GRANTED, and _db_column::select.

Referenced by db_set_table_select_priv_not_granted().

void db_set_column_sqltype ( dbColumn column,
int  sqltype 
)

Define column sqltype for column.

The function db_sqltype_name() returns sqltype description.

#define DB_SQL_TYPE_UNKNOWN 0
#define DB_SQL_TYPE_CHARACTER 1
#define DB_SQL_TYPE_SMALLINT 2
#define DB_SQL_TYPE_INTEGER 3
#define DB_SQL_TYPE_REAL 4
#define DB_SQL_TYPE_DOUBLE_PRECISION 6
#define DB_SQL_TYPE_DECIMAL 7
#define DB_SQL_TYPE_NUMERIC 8
#define DB_SQL_TYPE_DATE 9
#define DB_SQL_TYPE_TIME 10
#define DB_SQL_TYPE_TIMESTAMP 11
#define DB_SQL_TYPE_INTERVAL 12
#define DB_SQL_TYPE_TEXT 13
#define DB_SQL_TYPE_SERIAL 21
Parameters
columnpointer to dbColumn
sqltypeSQL data type (see list)

Definition at line 71 of file dbmi_base/column.c.

References _db_column::sqlDataType.

Referenced by P_Create_Aux2_Table(), and P_Create_Aux4_Table().

void db_set_column_update_priv_granted ( dbColumn column)

Set update privilages to be granted.

Parameters
columnpointer to dbColumn

Definition at line 356 of file dbmi_base/column.c.

References DB_GRANTED, and _db_column::update.

Referenced by db_set_table_update_priv_granted().

void db_set_column_update_priv_not_granted ( dbColumn column)

Unset update privilages.

Parameters
columnpointer to dbColumn

Definition at line 366 of file dbmi_base/column.c.

References DB_NOT_GRANTED, and _db_column::update.

Referenced by db_set_table_update_priv_not_granted().

void db_set_column_use_default_value ( dbColumn column)

Set default value to be used.

Parameters
columnpointer to dbColumn

Definition at line 235 of file dbmi_base/column.c.

References _db_column::useDefaultValue.

int db_test_column_has_default_value ( dbColumn column)

Check if column has defined default value.

Parameters
columnpointer to dbColumn
Returns
1 if true
0 if false

Definition at line 199 of file dbmi_base/column.c.

References _db_column::hasDefaultValue.

Referenced by db_print_column_definition().

int db_test_column_has_defined_default_value ( dbColumn column)

Check if column has defined default value.

Parameters
columnpointer to dbColumn
Returns
1 if true
0 if false

Definition at line 212 of file dbmi_base/column.c.

References _db_column::hasDefaultValue.

int db_test_column_has_undefined_default_value ( dbColumn column)

Check if column has defined default value.

Parameters
columnpointer to dbColumn
Returns
1 if false
0 if true

Definition at line 225 of file dbmi_base/column.c.

References _db_column::hasDefaultValue.

int db_test_column_null_allowed ( dbColumn column)

Checks if null value is allowed.

Parameters
columnpointer to dbColumn
Returns
1 if true
0 if false

Definition at line 291 of file dbmi_base/column.c.

References _db_column::nullAllowed.

Referenced by db_print_column_definition().

int db_test_column_use_default_value ( dbColumn column)

Checks if default value is used.

Parameters
columnpointer to dbColumn
Returns
1 if true
0 if false

Definition at line 258 of file dbmi_base/column.c.

References _db_column::useDefaultValue.

void db_unset_column_has_default_value ( dbColumn column)

Unset default value identificator.

Parameters
columnpointer to dbColumn

Definition at line 186 of file dbmi_base/column.c.

References _db_column::hasDefaultValue.

void db_unset_column_null_allowed ( dbColumn column)

Unset null value to be allowed.

Parameters
columnpointer to dbColumn

Definition at line 278 of file dbmi_base/column.c.

References _db_column::nullAllowed.

void db_unset_column_use_default_value ( dbColumn column)

Unset default value to be used.

Parameters
columnpointer to dbColumn

Definition at line 245 of file dbmi_base/column.c.

References _db_column::useDefaultValue.