3 #include <grass/dbmi.h>
16 table = (dbTable *)
db_malloc(
sizeof(dbTable));
18 return (table =
NULL);
22 table->columns = (dbColumn *)
db_calloc(
sizeof(dbColumn), ncols);
23 if (table->columns ==
NULL) {
25 return (table =
NULL);
27 table->numColumns = ncols;
28 for (i = 0; i < ncols; i++)
42 db_zero((
void *)table,
sizeof(dbTable));
59 for (i = 0; i < table->numColumns; i++)
118 return table->numColumns;
127 static void set_all_column_privs(dbTable * table,
void (*set_column_priv) ())
133 for (col = 0; col < ncols; col++) {
135 set_column_priv(column);
145 static int get_all_column_privs(dbTable * table,
int (*get_column_priv) ())
147 int priv, col, ncols;
151 for (col = 0; col < ncols; col++) {
153 priv = get_column_priv(column);
154 if (priv != DB_GRANTED)
234 table->priv_insert = DB_GRANTED;
245 table->priv_insert = DB_NOT_GRANTED;
256 return table->priv_insert;
267 table->priv_delete = DB_GRANTED;
278 table->priv_delete = DB_NOT_GRANTED;
289 return table->priv_delete;
311 for (col = 0; col < ncols; col++) {
331 case DB_SQL_TYPE_CHARACTER:
335 case DB_SQL_TYPE_TEXT:
336 G_warning(
"Type TEXT converted to 'VARCHAR(250)'");
339 case DB_SQL_TYPE_SMALLINT:
340 case DB_SQL_TYPE_INTEGER:
343 case DB_SQL_TYPE_REAL:
344 case DB_SQL_TYPE_DOUBLE_PRECISION:
345 case DB_SQL_TYPE_DECIMAL:
346 case DB_SQL_TYPE_NUMERIC:
347 case DB_SQL_TYPE_INTERVAL:
350 case DB_SQL_TYPE_DATE:
353 case DB_SQL_TYPE_TIME:
356 case DB_SQL_TYPE_TIMESTAMP:
360 G_warning(
"Unknown column type (%s)", colname);
dbColumn * db_get_table_column(dbTable *table, int n)
returns column structure for given table and column number
int db_table_to_sql(dbTable *table, dbString *sql)
Create SQL CREATE sring from table definition.
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
const char * db_sqltype_name(int sqltype)
returns sqltype description
const char * db_get_column_name(dbColumn *column)
returns column name for given column
dbTable * db_alloc_table(int ncols)
int db_set_table_name(dbTable *table, const char *name)
int db_get_table_select_priv(dbTable *table)
void db_set_column_select_priv_granted(dbColumn *column)
void db_set_column_select_priv_not_granted(dbColumn *column)
void db_set_table_update_priv_not_granted(dbTable *table)
void db_set_table_update_priv_granted(dbTable *table)
int db_get_column_update_priv(dbColumn *column)
void * db_calloc(int n, int m)
void db_init_column(dbColumn *column)
int db_get_column_select_priv(dbColumn *column)
int db_get_column_length(dbColumn *column)
int db_get_table_update_priv(dbTable *table)
int db_append_string(dbString *x, const char *s)
int db_sqltype_to_Ctype(int sqltype)
void db_set_table_insert_priv_granted(dbTable *table)
int db_get_column_sqltype(dbColumn *column)
returns column sqltype for column (the function db_sqltype_name() returns sqltype description) ...
const char * db_get_table_description(dbTable *table)
int db_get_table_number_of_columns(dbTable *table)
int db_get_table_delete_priv(dbTable *table)
void db_set_table_insert_priv_not_granted(dbTable *table)
int db_get_table_insert_priv(dbTable *table)
void db_init_table(dbTable *table)
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
void db_set_table_select_priv_granted(dbTable *table)
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
void db_free_table(dbTable *table)
void db_set_column_update_priv_granted(dbColumn *column)
char * db_get_string(dbString *x)
void db_set_table_delete_priv_granted(dbTable *table)
void db_zero(void *s, int n)
int G_debug(int level, const char *msg,...)
Print debugging message.
int db_set_string(dbString *x, const char *s)
int db_set_table_description(dbTable *table, const char *description)
void db_set_column_update_priv_not_granted(dbColumn *column)
void db_set_table_delete_priv_not_granted(dbTable *table)
void db_set_table_select_priv_not_granted(dbTable *table)
const char * db_get_table_name(dbTable *table)
void db_free_string(dbString *x)
void db_free_column(dbColumn *column)
frees column structure
void db_init_string(dbString *x)