123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757 |
- /*! \page dbmilib GRASS DataBase Management Interface
- by GRASS Development Team
- http://grass.osgeo.org
- \section dbmiIntro Introduction
- The attribute management was completely changed in GRASS 6 to achieve
- multi-attribute capabilities managed within external databases. The
- former <tt>dig_cats/</tt> files (GRASS 5) are not used any more and
- all vector attributes are stored in external database. Connection with
- database is done through <b>DBMI library</b> (DataBase Management
- Interface) with its integrated drivers. At time of this writing
- following DBMI drivers for attribute storage are available:
- - DBF: xBase files (default)
- - ODBC: to interface from http://www.unixodbc.org
- - PostgreSQL driver (note that PostgreSQL can also be accessed through ODBC): http://www.postgresql.org
- - mySQL: http://mysql.com/
- - SQLite: http://www.sqlite.org
- These drivers are compiled depending on present DB related libraries
- and 'configure' settings. Only the DBF driver is always compiled. The
- default DBMI driver is defined in dbmi.h
- \code
- #define DB_DEFAULT_DRIVER "sqlite"
- \endcode
- In general records in table are linked to vector entities by field number
- and category number. The field number identifies a database table and the
- category number identifies the record record. I.e. for unique combination
- <tt>mapset + map + field + category</tt> exists one unique combination
- <tt>driver + database + table + row</tt>. Each element may have none, one or
- more categories (cats). More cats are distinguished by field number (field).
- The flexibility of this approach even supports the extreme case, that one
- vector entity may be linked to attributes in different tables in different
- databases connected by different drivers at the same time.
- The DBMI library contains drivers such as DBF, SQLite, ODBC, MySQL and
- PostgreSQL. The functionality of the database support varies with the
- capabilities of the underlying RDBMS. Main features are
- multi-attributes support for various data types, also multiple tables
- may optionally be linked to one or many vector entity/ies. SQL
- (Structured Query Language) is used for all drivers, but in a limited
- implementation.
- For DBMI architecture details please read Blazek et al. 2002 (see below).
- \section dbmiFunc DBMI library functions
- The <tt>db_*()</tt> functions are the programmer's API for GRASS DBMI
- programming. There are three groups:
- - <b>dbmi_base</b>: contains functions for modules, drivers (<tt>../../db/drivers/</tt>)
- - <b>dbmi_client</b>: contains functions for modules
- - <b>dbmi_driver</b>: contains functions for drivers (<tt>../../db/drivers/</tt>)
- \section dbmiBase DBMI BASE functions
- Allocation:
- - db_store()
-
- - db_malloc()
- - db_calloc()
- - db_realloc()
- - db_free()
- String manipulation:
- - db_char_to_lowercase()
- - db_char_to_uppercase()
- - db_Cstring_to_lowercase()
- - db_Cstring_to_uppercase()
- - db_nocase_compare()
- Column properties:
- - db_get_column_value()
- - db_get_column_default_value()
- - db_set_column_sqltype()
- - db_set_column_host_type()
- - db_get_column_scale()
- - db_set_column_scale()
- - db_get_column_precision()
- - db_set_column_precision()
- - db_get_column_sqltype()
- - db_get_column_host_type()
- - db_set_column_has_defined_default_value()
- - db_set_column_has_undefined_default_value()
- - db_unset_column_has_default_value()
- - db_test_column_has_default_value()
- - db_test_column_has_defined_default_value()
- - db_test_column_has_undefined_default_value()
- - db_set_column_use_default_value()
- - db_unset_column_use_default_value()
- - db_test_column_use_default_value()
- - db_set_column_null_allowed()
- - db_unset_column_null_allowed()
- - db_test_column_null_allowed()
- - db_get_column_length()
- - db_set_column_length()
- - db_set_column_select_priv_granted()
- - db_set_column_select_priv_not_granted()
- - db_get_column_select_priv()
- - db_set_column_update_priv_granted()
- - db_set_column_update_priv_not_granted()
- - db_get_column_update_priv()
- - db_init_column()
- - db_set_column_name()
- - db_get_column_name()
- - db_set_column_description()
- - db_get_column_description()
- - db_free_column()
- - db_copy_column()
- - db_convert_Cstring_to_column_value()
-
- - db_convert_Cstring_to_column_default_value()
- - db_convert_column_value_to_string()
- - db_convert_column_default_value_to_string()
- Connection settings:
- - db_set_connection()
- - db_get_connection()
- Cursor management:
- - db_init_cursor()
- - db_alloc_cursor_table()
- - db_free_cursor()
- - db_get_cursor_table()
- - db_set_cursor_table()
- - db_get_cursor_token()
- - db_set_cursor_token()
-
- - db_set_cursor_type_readonly()
- - db_set_cursor_type_update()
- - db_set_cursor_type_insert()
- - db_test_cursor_type_fetch()
- - db_test_cursor_type_update()
- - db_test_cursor_type_insert()
- - db_set_cursor_mode()
- - db_set_cursor_mode_scroll()
- - db_unset_cursor_mode_scroll()
- - db_unset_cursor_mode()
- - db_set_cursor_mode_insensitive()
- - db_unset_cursor_mode_insensitive()
- - db_test_cursor_mode_scroll()
- - db_test_cursor_mode_insensitive()
- - db_alloc_cursor_column_flags()
- - db_free_cursor_column_flags()
- - db_set_cursor_column_for_update()
- - db_unset_cursor_column_for_update()
- - db_test_cursor_column_for_update()
- - db_test_cursor_any_column_for_update()
- - db_set_cursor_column_flag()
- - db_unset_cursor_column_flag()
- - db_test_cursor_column_flag()
- - db_get_cursor_number_of_columns()
- - db_test_cursor_any_column_flag()
- DateTime conversion:
- - db_convert_value_datetime_into_string()
- - db_convert_Cstring_to_value_datetime()
- DBmscap management:
- - db_dbmscap_filename()
- - db_has_dbms()
- - db_copy_dbmscap_entry()
- - db_read_dbmscap()
- - db_free_dbmscap()
- Default settings:
- - db_get_default_driver_name()
- - db_get_default_database_name()
- - db_get_default_schema_name()
- - db_get_default_group_name()
- - db_set_default_connection()
- Dirent (directory entities) array:
- - db_dirent()
- - db_free_dirent_array()
- - db_alloc_dirent_array()
- Report errors:
- - db_on_error()
- - db_set_error_who()
- - db_get_error_who()
- - db_error()
- - db_protocol_error()
- - db_syserror()
- - db_get_error_code()
- - db_memory_error()
- - db_procedure_not_implemented()
- - db_noproc_error()
- - db_clear_error()
- - db_print_error()
- - db_debug_on()
- - db_debug_off()
- - db_debug()
- - db_get_error_msg()
- - db_auto_print_errors()
- - db_auto_print_protocol_errors()
- Handle management:
- - db_init_handle()
- - db_set_handle()
- - db_get_handle_dbname()
- - db_get_handle_dbschema()
- - db_free_handle()
- - db_free_handle_array()
- - db_alloc_handle_array()
- Index management:
- - db_init_index()
- - db_free_index()
- - db_alloc_index_columns()
- - db_alloc_index_array()
- - db_free_index_array()
- - db_set_index_name()
-
- - db_get_index_name()
- - db_set_index_table_name()
- - db_get_index_table_name()
- - db_get_index_number_of_columns()
- - db_set_index_column_name()
- - db_get_index_column_name()
- - db_set_index_type_unique()
- - db_set_index_type_non_unique()
- - db_test_index_type_unique()
- - db_print_index()
- Range functions:
- - db_interval_range()
- Login functions:
- - db_set_login()
- - db_get_login()
- Return codes (internal use only):
- - db__send_success()
- - db__send_failure()
- - db__recv_return_code()
- Data type conversion:
- - db_sqltype_to_Ctype()
- - db_sqltype_name()
- String manipulation:
- - db_init_string()
- - db_set_string()
-
- - db_set_string_no_copy()
- - db_sizeof_string()
- - db_zero_string()
- - db_enlarge_string()
- - db_get_string()
- - db_free_string()
- - db_free_string_array()
- - db_alloc_string_array()
- - db_append_string()
- - db_copy_string()
- - db_double_quote_string()
- Table/privileges management:
- - db_alloc_table()
- - db_init_table()
- - db_free_table()
- - db_set_table_name()
- - db_get_table_name()
- - db_set_table_description()
- - db_get_table_description()
- - db_get_table_number_of_columns()
- - db_set_table_select_priv_granted()
- - db_set_table_select_priv_not_granted()
- - db_get_table_select_priv()
- - db_set_table_update_priv_granted()
- - db_set_table_update_priv_not_granted()
- - db_get_table_update_priv()
- - db_set_table_insert_priv_granted()
- - db_set_table_insert_priv_not_granted()
- - db_get_table_insert_priv()
- - db_set_table_delete_priv_granted()
- - db_set_table_delete_priv_not_granted()
- - db_get_table_delete_priv()
- - db_get_table_column()
- - db_get_table_column_by_name()
- - db_set_table_column()
- - db_append_table_column()
- - db_clone_table()
- - db_table_to_sql()
- Token management:
- - db_find_token()
- - db_drop_token()
- - db_new_token()
- Value management:
- - db_test_value_isnull()
- - db_get_value_int()
- - db_get_value_double()
- - db_get_value_as_double()
- - db_get_value_string()
- - db_get_value_year()
- - db_get_value_month()
- - db_get_value_day()
- - db_get_value_hour()
- - db_get_value_minute()
- - db_get_value_seconds()
- - db_set_value_null()
- - db_set_value_not_null()
- - db_set_value_int()
- - db_set_value_double()
- - db_set_value_string()
- - db_set_value_year()
- - db_set_value_month()
- - db_set_value_day()
- - db_set_value_hour()
- - db_set_value_minute()
- - db_set_value_seconds()
- - db_test_value_datetime_current()
- - db_set_value_datetime_current()
- - db_set_value_datetime_not_current()
- - db_copy_value()
- - db_CatValArray_init()
- - db_CatValArray_free()
- - db_CatValArray_alloc()
- - db_CatValArray_realloc()
- - db_convert_Cstring_to_value()
- - db_convert_value_to_string()
- Misc:
- - db_isdir()
- - db_legal_tablename()
- - db_whoami
- \section dbmiClient DBMI CLIENT functions
- - db_add_column()
- - db_begin_transaction()
- - db_bind_update()
- - db_CatValArray_get_value()
- - db_CatValArray_get_value_double()
- - db_CatValArray_get_value_int()
- - db_CatValArray_sort()
- - db_CatValArray_sort_by_value()
- - db_close_cursor()
-
- - db_close_database()
- - db_close_database_shutdown_driver()
-
- - db_column_Ctype()
- - db_column_sqltype()
- - db_commit_transaction()
- - db_copy_table()
- - db_copy_table_where()
-
- - db_copy_table_select()
- - db_copy_table_by_ints()
-
- - db_create_database()
- - db_create_index()
- - db_create_table()
- - db_delete()
- - db_delete_database()
- - db_delete_table()
-
- - db_describe_table()
- - db_drop_column()
- - db_drop_index()
- - db_drop_table()
- - db_execute_immediate()
- - db_fetch()
- - db_find_database()
- - db_get_column()
-
- - db_get_num_rows()
- - db_get_table_number_of_rows()
-
- - db_grant_on_table()
- - db_gversion()
-
- - db_insert()
- - db_list_databases()
- - db_list_drivers()
- - db_list_indexes()
- - db_list_tables()
- - db_open_database()
- - db_open_insert_cursor()
- - db_open_select_cursor()
-
- - db_open_update_cursor()
- - db_print_column_definition()
-
- - db_print_table_definition()
- - db_start_driver_open_database()
- - db_select_CatValArray()
- - db_select_int()
- - db_select_value()
- - db_shutdown_driver()
- - db_start_driver()
-
- - db_table_exists()
- - db_update()
- \section dbmiDriver DBMI DRIVER functions
- - db_driver()
- - db_driver_mkdir()
- - db_d_add_column()
- - db_d_append_error()
-
- - db_d_begin_transaction()
- - db_d_bind_update()
- - db_d_close_cursor()
- - db_d_close_database()
- - db_d_commit_transaction()
- - db_d_create_database()
- - db_d_create_index()
- - db_d_create_table()
- - db_d_delete()
- - db_d_delete_database()
- - db_d_describe_table()
- - db_d_drop_column()
- - db_d_drop_index()
- - db_d_drop_table()
- - db_d_execute_immediate()
- - db_d_fetch()
- - db_d_find_database()
- - db_d_get_num_rows()
- - db_driver_mkdir()
- - db_d_grant_on_table()
- - db_d_init_error()
-
- - db_d_insert()
- - db_d_list_databases()
- - db_d_list_indexes()
- - db_d_list_tables()
- - db_d_open_database()
- - db_d_open_insert_cursor()
- - db_d_open_select_cursor()
- - db_d_open_update_cursor()
- - db_d_report_error()
- - db_d_update()
-
- \section dbmiReferences References
- Text based on: R. Blazek, M. Neteler, and R. Micarelli. The new GRASS 5.1
- vector architecture. In Open source GIS - GRASS users conference 2002,
- Trento, Italy, 11-13 September 2002. University of Trento, Italy, 2002.
- http://www.ing.unitn.it/~grass/proceedings/proceedings/pdfs/Blazek_Radim.pdf
- \section dbmiSeeAlso See Also
-
- GRASS Vector Architecture: \ref vectorlib
- \section dbmiAuthors Authors
- - Joel Jones (CERL/UIUC)
- - Radim Blazek
- */
|