grass  7.8.6
About: GRASS (Geographic Resources Analysis Support System) is a raster- and vector-based GIS, image processing system, graphics production system and spatial modeling system.
  Fossies Dox: grass-7.8.6.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

table.c File Reference

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

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

Go to the source code of this file.

Functions

dbTabledb_alloc_table (int ncols)
 Allocate a table with a specific number of columns. More...
 
void db_init_table (dbTable *table)
 Initialize the table to zero. More...
 
void db_free_table (dbTable *table)
 Free the table. More...
 
int db_set_table_name (dbTable *table, const char *name)
 Set the name of the table. More...
 
const char * db_get_table_name (dbTable *table)
 Get the name of the table. More...
 
int db_set_table_description (dbTable *table, const char *description)
 Set the description of the table. More...
 
const char * db_get_table_description (dbTable *table)
 Get the description of the table. More...
 
int db_get_table_number_of_columns (dbTable *table)
 Return the number of columns of the table. More...
 
static void set_all_column_privs (dbTable *table, void(*set_column_priv)())
 
static int get_all_column_privs (dbTable *table, int(*get_column_priv)())
 
void db_set_table_select_priv_granted (dbTable *table)
 Grant selection privileges for all columns. More...
 
void db_set_table_select_priv_not_granted (dbTable *table)
 Set selection privileges not granted for all columns. More...
 
int db_get_table_select_priv (dbTable *table)
 Get table select privileges. More...
 
void db_set_table_update_priv_granted (dbTable *table)
 Grant update privileges for all columns. More...
 
void db_set_table_update_priv_not_granted (dbTable *table)
 Set update privileges not granted for all columns. More...
 
int db_get_table_update_priv (dbTable *table)
 Get table update privileges. More...
 
void db_set_table_insert_priv_granted (dbTable *table)
 Grant insert privileges for table. More...
 
void db_set_table_insert_priv_not_granted (dbTable *table)
 Set insert privileges not granted for table. More...
 
int db_get_table_insert_priv (dbTable *table)
 Get table insert privileges. More...
 
void db_set_table_delete_priv_granted (dbTable *table)
 Grant delete privileges for table. More...
 
void db_set_table_delete_priv_not_granted (dbTable *table)
 Set delete privileges not granted for table. More...
 
int db_get_table_delete_priv (dbTable *table)
 Get table delete privileges. More...
 
dbColumndb_get_table_column (dbTable *table, int idx)
 Returns column structure for given table and column number. More...
 
dbColumndb_get_table_column_by_name (dbTable *table, const char *name)
 Returns column structure for given table and column name. More...
 
int db_set_table_column (dbTable *table, int idx, dbColumn *column)
 Set a specific column for given table and column number. More...
 
int db_append_table_column (dbTable *table, dbColumn *column)
 Append a specific column to given table. More...
 
dbTabledb_clone_table (dbTable *src)
 Make a new exact copy of an existing table. More...
 
int db_table_to_sql (dbTable *table, dbString *sql)
 Create SQL CREATE sring from table definition. More...
 

Detailed Description

DBMI Library (base) - table 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 table.c.

Function Documentation

◆ db_alloc_table()

dbTable * db_alloc_table ( int  ncols)

Allocate a table with a specific number of columns.

Parameters
ncolsnumber of columns which should be allocated
Returns
allocated dbTable
NULL in case of an error

Definition at line 28 of file table.c.

References db_calloc(), db_free(), db_init_column(), db_init_table(), db_malloc(), ncols, NULL, and table.

Referenced by copy_table(), db__recv_table_definition(), db_alloc_cursor_table(), db_clone_table(), P_Create_Aux2_Table(), and P_Create_Aux4_Table().

◆ db_append_table_column()

int db_append_table_column ( dbTable table,
dbColumn column 
)

Append a specific column to given table.

Parameters
tablePointer to dbTable
columnPointer to a dbColumn to append. A copy of the column is stored, so the original column can be deleted.
Returns
DB_OK on success
DB_FAILURE on error

Definition at line 372 of file table.c.

References db_copy_column(), DB_FAILED, DB_OK, db_realloc(), and NULL.

◆ db_clone_table()

dbTable * db_clone_table ( dbTable src)

Make a new exact copy of an existing table.

New memory is allocated for the clone, the columns-content will be copied too.

Parameters
srcPointer to dbTable
Returns
A new alloacted clone of the given table on success
NULL on error

Definition at line 392 of file table.c.

References db_alloc_table(), db_copy_column(), db_copy_string(), db_get_table_number_of_columns(), NULL, and src.

◆ db_free_table()

void db_free_table ( dbTable table)

Free the table.

Parameters
tablepointer to dbTable

Definition at line 68 of file table.c.

References db_free(), db_free_column(), and db_free_string().

Referenced by db_column_sqltype(), db_d_create_table(), db_d_describe_table(), db_free_cursor(), db_get_column(), and Vect_write_ascii().

◆ db_get_table_column()

◆ db_get_table_column_by_name()

dbColumn * db_get_table_column_by_name ( dbTable table,
const char *  name 
)

Returns column structure for given table and column name.

Parameters
tablepointer to dbTable
namethe name of the column
Returns
pointer to dbColumn
NULL if not found

Definition at line 323 of file table.c.

References c, columns, db_get_string(), db_get_table_column(), name, and NULL.

◆ db_get_table_delete_priv()

int db_get_table_delete_priv ( dbTable table)

Get table delete privileges.

Parameters
tablepointer to dbTable
Returns
privileges

Definition at line 293 of file table.c.

Referenced by db_print_table_definition().

◆ db_get_table_description()

const char * db_get_table_description ( dbTable table)

Get the description of the table.

Parameters
tablepointer to dbTable
Returns
description of the table

Definition at line 126 of file table.c.

References db_get_string().

Referenced by db_print_table_definition().

◆ db_get_table_insert_priv()

int db_get_table_insert_priv ( dbTable table)

Get table insert privileges.

Parameters
tablepointer to dbTable
Returns
prilileges

Definition at line 261 of file table.c.

Referenced by db_print_table_definition().

◆ db_get_table_name()

const char * db_get_table_name ( dbTable table)

Get the name of the table.

Parameters
tablepointer to dbTable
Returns
name of the table

Definition at line 101 of file table.c.

References db_get_string().

Referenced by db_print_table_definition(), and db_table_to_sql().

◆ db_get_table_number_of_columns()

int db_get_table_number_of_columns ( dbTable table)

◆ db_get_table_select_priv()

int db_get_table_select_priv ( dbTable table)

Get table select privileges.

Parameters
tablepointer to dbTable
Returns
privilages

Definition at line 197 of file table.c.

References db_get_column_select_priv(), and get_all_column_privs().

◆ db_get_table_update_priv()

int db_get_table_update_priv ( dbTable table)

Get table update privileges.

Parameters
tablepointer to dbTable
Returns
privilages

Definition at line 229 of file table.c.

References db_get_column_update_priv(), and get_all_column_privs().

◆ db_init_table()

void db_init_table ( dbTable table)

Initialize the table to zero.

Parameters
tablepointer to dbTable

Definition at line 56 of file table.c.

References db_init_string(), and db_zero().

Referenced by db_alloc_table().

◆ db_set_table_column()

int db_set_table_column ( dbTable table,
int  idx,
dbColumn column 
)

Set a specific column for given table and column number.

Parameters
tablePointer to dbTable
idxColumn index (starting with '0'). The index must be in range.
columnPointer to a dbColumn to insert. A copy of the column stored, so the original column can be deleted.
Returns
DB_OK on success
DB_FAILURE on error

Definition at line 354 of file table.c.

References db_copy_column(), DB_FAILED, and DB_OK.

◆ db_set_table_delete_priv_granted()

void db_set_table_delete_priv_granted ( dbTable table)

Grant delete privileges for table.

Parameters
tablepointer to dbTable

Definition at line 271 of file table.c.

References DB_GRANTED.

◆ db_set_table_delete_priv_not_granted()

void db_set_table_delete_priv_not_granted ( dbTable table)

Set delete privileges not granted for table.

Parameters
tablepointer to dbTable

Definition at line 281 of file table.c.

References DB_NOT_GRANTED.

◆ db_set_table_description()

int db_set_table_description ( dbTable table,
const char *  description 
)

Set the description of the table.

Parameters
tablepointer to dbTable
namedescription of the table
Returns
DB_OK

Definition at line 114 of file table.c.

References db_set_string().

Referenced by P_Create_Aux2_Table(), and P_Create_Aux4_Table().

◆ db_set_table_insert_priv_granted()

void db_set_table_insert_priv_granted ( dbTable table)

Grant insert privileges for table.

Parameters
tablepointer to dbTable

Definition at line 239 of file table.c.

References DB_GRANTED.

◆ db_set_table_insert_priv_not_granted()

void db_set_table_insert_priv_not_granted ( dbTable table)

Set insert privileges not granted for table.

Parameters
tablepointer to dbTable

Definition at line 249 of file table.c.

References DB_NOT_GRANTED.

◆ db_set_table_name()

int db_set_table_name ( dbTable table,
const char *  name 
)

Set the name of the table.

Parameters
tablepointer to dbTable
nameThe name of the table
Returns
DB_OK on success

Definition at line 89 of file table.c.

References db_set_string(), and name.

Referenced by copy_table(), db_d_describe_table(), P_Create_Aux2_Table(), and P_Create_Aux4_Table().

◆ db_set_table_select_priv_granted()

void db_set_table_select_priv_granted ( dbTable table)

Grant selection privileges for all columns.

Parameters
tablepointer to dbTable

Definition at line 175 of file table.c.

References db_set_column_select_priv_granted(), and set_all_column_privs().

◆ db_set_table_select_priv_not_granted()

void db_set_table_select_priv_not_granted ( dbTable table)

Set selection privileges not granted for all columns.

Parameters
tablepointer to dbTable

Definition at line 185 of file table.c.

References db_set_column_select_priv_not_granted(), and set_all_column_privs().

◆ db_set_table_update_priv_granted()

void db_set_table_update_priv_granted ( dbTable table)

Grant update privileges for all columns.

Parameters
tablepointer to dbTable

Definition at line 207 of file table.c.

References db_set_column_update_priv_granted(), and set_all_column_privs().

◆ db_set_table_update_priv_not_granted()

void db_set_table_update_priv_not_granted ( dbTable table)

Set update privileges not granted for all columns.

Parameters
tablepointer to dbTable

Definition at line 217 of file table.c.

References db_set_column_update_priv_not_granted(), and set_all_column_privs().

◆ db_table_to_sql()

◆ get_all_column_privs()

static int get_all_column_privs ( dbTable table,
int(*)()  get_column_priv 
)
static

◆ set_all_column_privs()

static void set_all_column_privs ( dbTable table,
void(*)()  set_column_priv 
)
static