GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
cursor.c File Reference

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

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

Go to the source code of this file.

Functions

void db_init_cursor (dbCursor *cursor)
 Initialize dbCursor. More...
 
int db_alloc_cursor_table (dbCursor *cursor, int ncols)
 Allocate table for cursor. More...
 
void db_free_cursor (dbCursor *cursor)
 Free allocated dbCursor. More...
 
dbTabledb_get_cursor_table (dbCursor *cursor)
 Get table allocated by cursor. More...
 
void db_set_cursor_table (dbCursor *cursor, dbTable *table)
 Set table for given cursor. More...
 
dbToken db_get_cursor_token (dbCursor *cursor)
 Get cursor token. More...
 
void db_set_cursor_token (dbCursor *cursor, dbToken token)
 Set cursor token. More...
 
void db_set_cursor_type_readonly (dbCursor *cursor)
 Set cursor to be read-only (select) More...
 
void db_set_cursor_type_update (dbCursor *cursor)
 Set cursor to be writable (update) More...
 
void db_set_cursor_type_insert (dbCursor *cursor)
 Set cursor to be writable (insert) More...
 
int db_test_cursor_type_fetch (dbCursor *cursor)
 Check cursor type. More...
 
int db_test_cursor_type_update (dbCursor *cursor)
 Check if cursor type is 'update'. More...
 
int db_test_cursor_type_insert (dbCursor *cursor)
 Check if cursor type is 'insert'. More...
 
void db_set_cursor_mode (dbCursor *cursor, int mode)
 Set cursor mode. More...
 
void db_set_cursor_mode_scroll (dbCursor *cursor)
 Set 'scroll' cursor mode. More...
 
void db_unset_cursor_mode_scroll (dbCursor *cursor)
 Unset 'scroll' cursor mode. More...
 
void db_unset_cursor_mode (dbCursor *cursor)
 Unset cursor mode. More...
 
void db_set_cursor_mode_insensitive (dbCursor *cursor)
 Set 'intensive' cursor mode. More...
 
void db_unset_cursor_mode_insensitive (dbCursor *cursor)
 Unset 'intensive' cursor mode. More...
 
int db_test_cursor_mode_scroll (dbCursor *cursor)
 Check if cursor mode is 'scroll'. More...
 
int db_test_cursor_mode_insensitive (dbCursor *cursor)
 Check if cursor mode is 'intensive'. More...
 
int db_alloc_cursor_column_flags (dbCursor *cursor)
 Allocate columns' flags for cursor. More...
 
void db_free_cursor_column_flags (dbCursor *cursor)
 Free columns' flags of cursor. More...
 
void db_set_cursor_column_for_update (dbCursor *cursor, int col)
 Set Column flag to 'update'. More...
 
void db_unset_cursor_column_for_update (dbCursor *cursor, int col)
 Unset 'update' column flag. More...
 
int db_test_cursor_column_for_update (dbCursor *cursor, int col)
 Check if column flag is 'update'. More...
 
int db_test_cursor_any_column_for_update (dbCursor *cursor)
 Check if columns' flag is 'update'. More...
 
void db_set_cursor_column_flag (dbCursor *cursor, int col)
 Set column's flag. More...
 
void db_unset_cursor_column_flag (dbCursor *cursor, int col)
 Unset column's flag. More...
 
int db_test_cursor_column_flag (dbCursor *cursor, int col)
 Checks column's flag. More...
 
int db_get_cursor_number_of_columns (dbCursor *cursor)
 Get number of columns. More...
 
int db_test_cursor_any_column_flag (dbCursor *cursor)
 Checks columns' flag. More...
 

Detailed Description

DBMI Library (base) - cursors management.

(C) 1999-2009 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

Definition in file cursor.c.

Function Documentation

◆ db_alloc_cursor_column_flags()

int db_alloc_cursor_column_flags ( dbCursor cursor)

Allocate columns' flags for cursor.

Parameters
cursorpointer to dbCursor
Returns
DB_OK on success
error code on failure

Definition at line 276 of file cursor.c.

◆ db_alloc_cursor_table()

int db_alloc_cursor_table ( dbCursor cursor,
int  ncols 
)

Allocate table for cursor.

Parameters
cursorpointer to dbCursor
ncolsnumber of column in table
Returns
DB_OK on success
error code on error

Definition at line 38 of file cursor.c.

◆ db_free_cursor()

void db_free_cursor ( dbCursor cursor)

Free allocated dbCursor.

Parameters
cursorpointer to dbCursor

Definition at line 51 of file cursor.c.

References _db_cursor::column_flags, db_free_cursor_column_flags(), db_free_table(), db_init_cursor(), and _db_cursor::table.

Referenced by db_close_cursor(), and db_d_close_cursor().

◆ db_free_cursor_column_flags()

void db_free_cursor_column_flags ( dbCursor cursor)

Free columns' flags of cursor.

Parameters
cursorpointer to dbCursor

Definition at line 295 of file cursor.c.

References _db_cursor::column_flags, db_free(), and NULL.

Referenced by db_free_cursor().

◆ db_get_cursor_number_of_columns()

int db_get_cursor_number_of_columns ( dbCursor cursor)

Get number of columns.

Parameters
cursorpointer to dbCursor

Definition at line 394 of file cursor.c.

Referenced by db_bind_update().

◆ db_get_cursor_table()

dbTable* db_get_cursor_table ( dbCursor cursor)

Get table allocated by cursor.

Parameters
cursorpointer to dbCursor
Returns
pointer to dbTable

Definition at line 67 of file cursor.c.

References _db_cursor::table.

Referenced by db_open_insert_cursor().

◆ db_get_cursor_token()

dbToken db_get_cursor_token ( dbCursor cursor)

Get cursor token.

Parameters
cursorpointer to dbCursor
Returns
pointer to dbToken

Definition at line 90 of file cursor.c.

References _db_cursor::token.

◆ db_init_cursor()

void db_init_cursor ( dbCursor cursor)

Initialize dbCursor.

Parameters
cursorpointer to dbCursor to be initialized

Definition at line 23 of file cursor.c.

References G_zero(), and _db_cursor::token.

Referenced by db_free_cursor().

◆ db_set_cursor_column_flag()

void db_set_cursor_column_flag ( dbCursor cursor,
int  col 
)

Set column's flag.

Parameters
cursorpointer to dbCursor
colcolumn index (starting with '0')

Definition at line 357 of file cursor.c.

References _db_cursor::column_flags.

Referenced by db_set_cursor_column_for_update().

◆ db_set_cursor_column_for_update()

void db_set_cursor_column_for_update ( dbCursor cursor,
int  col 
)

Set Column flag to 'update'.

Parameters
cursorpointer to dbCursor
colcolumn index (starting with '0')

Definition at line 308 of file cursor.c.

References db_set_cursor_column_flag().

◆ db_set_cursor_mode()

void db_set_cursor_mode ( dbCursor cursor,
int  mode 
)

Set cursor mode.

Modes:

  • DB_SCROLL
  • DB_INSENSITIVE
Parameters
cursorpointer to dbCursor
modecursor mode

Definition at line 187 of file cursor.c.

◆ db_set_cursor_mode_insensitive()

void db_set_cursor_mode_insensitive ( dbCursor cursor)

Set 'intensive' cursor mode.

Parameters
cursorpointer to dbCursor

Definition at line 227 of file cursor.c.

References DB_INSENSITIVE, and _db_cursor::mode.

◆ db_set_cursor_mode_scroll()

void db_set_cursor_mode_scroll ( dbCursor cursor)

Set 'scroll' cursor mode.

Parameters
cursorpointer to dbCursor

Definition at line 197 of file cursor.c.

References DB_SCROLL, and _db_cursor::mode.

◆ db_set_cursor_table()

void db_set_cursor_table ( dbCursor cursor,
dbTable table 
)

Set table for given cursor.

Parameters
cursorpointer to dbCursor
tablepointer to dbTable

Definition at line 78 of file cursor.c.

◆ db_set_cursor_token()

void db_set_cursor_token ( dbCursor cursor,
dbToken  token 
)

Set cursor token.

Parameters
cursorpointer to dbCursor
tokenpointer to dbToken

Definition at line 101 of file cursor.c.

References _db_cursor::token.

◆ db_set_cursor_type_insert()

void db_set_cursor_type_insert ( dbCursor cursor)

Set cursor to be writable (insert)

Parameters
cursorpointer to dbCursor

Definition at line 131 of file cursor.c.

References DB_INSERT, and _db_cursor::type.

◆ db_set_cursor_type_readonly()

void db_set_cursor_type_readonly ( dbCursor cursor)

Set cursor to be read-only (select)

Parameters
cursorpointer to dbCursor

Definition at line 111 of file cursor.c.

References DB_READONLY, and _db_cursor::type.

◆ db_set_cursor_type_update()

void db_set_cursor_type_update ( dbCursor cursor)

Set cursor to be writable (update)

Parameters
cursorpointer to dbCursor

Definition at line 121 of file cursor.c.

References DB_UPDATE, and _db_cursor::type.

◆ db_test_cursor_any_column_flag()

int db_test_cursor_any_column_flag ( dbCursor cursor)

Checks columns' flag.

Is any cursor column flag set?

Parameters
cursorpointer to dbCursor
Returns
1 if true
0 if false

Definition at line 414 of file cursor.c.

Referenced by db_d_update(), and db_test_cursor_any_column_for_update().

◆ db_test_cursor_any_column_for_update()

int db_test_cursor_any_column_for_update ( dbCursor cursor)

Check if columns' flag is 'update'.

Parameters
cursorpointer to dbCursor
Returns
1 if true
0 if false

Definition at line 346 of file cursor.c.

References db_test_cursor_any_column_flag().

◆ db_test_cursor_column_flag()

int db_test_cursor_column_flag ( dbCursor cursor,
int  col 
)

Checks column's flag.

Parameters
cursorpointer to dbCursor
colcolumn index (starting with '0')
Returns
1 if flag is defined
0 otherwise

Definition at line 384 of file cursor.c.

References _db_cursor::column_flags.

Referenced by db_test_cursor_column_for_update().

◆ db_test_cursor_column_for_update()

int db_test_cursor_column_for_update ( dbCursor cursor,
int  col 
)

Check if column flag is 'update'.

Parameters
cursorpointer to dbCursor
colcolumn index (starting with '0')
Returns
1 if true
0 if false

Definition at line 333 of file cursor.c.

References db_test_cursor_column_flag().

◆ db_test_cursor_mode_insensitive()

int db_test_cursor_mode_insensitive ( dbCursor cursor)

Check if cursor mode is 'intensive'.

Parameters
cursorpointer to dbCursor
Returns
1 if true
0 if false

Definition at line 263 of file cursor.c.

References DB_INSENSITIVE, and _db_cursor::mode.

◆ db_test_cursor_mode_scroll()

int db_test_cursor_mode_scroll ( dbCursor cursor)

Check if cursor mode is 'scroll'.

Parameters
cursorpointer to dbCursor
Returns
1 if true
0 if false

Definition at line 250 of file cursor.c.

References DB_SCROLL, and _db_cursor::mode.

◆ db_test_cursor_type_fetch()

int db_test_cursor_type_fetch ( dbCursor cursor)

Check cursor type.

Parameters
cursorpointer to dbCursor
Returns
1 for known cursor type
0 for unknown cursor type

Definition at line 144 of file cursor.c.

References DB_INSERT, DB_READONLY, DB_UPDATE, and _db_cursor::type.

◆ db_test_cursor_type_insert()

int db_test_cursor_type_insert ( dbCursor cursor)

Check if cursor type is 'insert'.

Parameters
cursorpointer to dbCursor
Returns
1 if cursor type is 'insert'
0 otherwise

Definition at line 172 of file cursor.c.

References DB_INSERT, and _db_cursor::type.

Referenced by db_d_insert().

◆ db_test_cursor_type_update()

int db_test_cursor_type_update ( dbCursor cursor)

Check if cursor type is 'update'.

Parameters
cursorpointer to dbCursor
Returns
1 if cursor type is 'update'
0 otherwise

Definition at line 159 of file cursor.c.

References DB_UPDATE, and _db_cursor::type.

Referenced by db_d_delete(), and db_d_update().

◆ db_unset_cursor_column_flag()

void db_unset_cursor_column_flag ( dbCursor cursor,
int  col 
)

Unset column's flag.

Parameters
cursorpointer to dbCursor
colcolumn index (starting with '0')

Definition at line 369 of file cursor.c.

References _db_cursor::column_flags.

Referenced by db_unset_cursor_column_for_update().

◆ db_unset_cursor_column_for_update()

void db_unset_cursor_column_for_update ( dbCursor cursor,
int  col 
)

Unset 'update' column flag.

Parameters
cursorpointer to dbCursor
colcolumn index (starting with '0')

Definition at line 319 of file cursor.c.

References db_unset_cursor_column_flag().

◆ db_unset_cursor_mode()

void db_unset_cursor_mode ( dbCursor cursor)

Unset cursor mode.

Parameters
cursorpointer to dbCursor

Definition at line 217 of file cursor.c.

References _db_cursor::mode.

◆ db_unset_cursor_mode_insensitive()

void db_unset_cursor_mode_insensitive ( dbCursor cursor)

Unset 'intensive' cursor mode.

Parameters
cursorpointer to dbCursor

Definition at line 237 of file cursor.c.

References DB_INSENSITIVE, and _db_cursor::mode.

◆ db_unset_cursor_mode_scroll()

void db_unset_cursor_mode_scroll ( dbCursor cursor)

Unset 'scroll' cursor mode.

Parameters
cursorpointer to dbCursor

Definition at line 207 of file cursor.c.

References DB_SCROLL, and _db_cursor::mode.