GRASS Programmer's Manual
6.4.3(2013)-r
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
Pages
c_create_idx.c
Go to the documentation of this file.
1
15
#include <string.h>
16
#include <grass/dbmi.h>
17
#include "
macros.h
"
18
28
int
db_create_index
(dbDriver *
driver
, dbIndex * index)
29
{
30
int
ret_code;
31
32
/* start the procedure call */
33
db__set_protocol_fds
(driver->send, driver->recv);
34
DB_START_PROCEDURE_CALL
(DB_PROC_CREATE_INDEX);
35
36
/* send the arguments to the procedure */
37
DB_SEND_INDEX
(index);
38
39
/* get the return code for the procedure call */
40
DB_RECV_RETURN_CODE
(&ret_code);
41
42
if
(ret_code != DB_OK)
43
return
ret_code;
/* ret_code SHOULD == DB_FAILED */
44
45
/* get results */
46
DB_RECV_STRING
(&index->indexName);
47
48
return
DB_OK;
49
}
50
61
int
db_create_index2
(dbDriver *
driver
,
const
char
*table_name,
62
const
char
*column_name)
63
{
64
int
ret;
65
dbIndex index;
66
char
buf[1000];
67
const
char
*tbl;
68
69
db_init_index
(&index);
70
db_alloc_index_columns
(&index, 1);
71
72
tbl = strchr(table_name,
'.'
);
73
if
(tbl ==
NULL
)
74
tbl = table_name;
75
else
76
tbl++;
77
78
sprintf(buf,
"%s_%s"
, tbl, column_name);
79
db_set_index_name
(&index, buf);
80
81
db_set_index_table_name
(&index, table_name);
82
db_set_index_column_name
(&index, 0, column_name);
83
db_set_index_type_unique
(&index);
84
85
ret =
db_create_index
(driver, &index);
86
87
db_free_index
(&index);
88
89
return
ret;
90
}
lib
db
dbmi_client
c_create_idx.c
Generated on Thu Sep 26 2013 09:47:58 for GRASS Programmer's Manual by
1.8.4