GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-d6dec75dd4
sqlp.h
Go to the documentation of this file.
1
#ifndef GRASS_SQLP_H
2
#define GRASS_SQLP_H
3
4
/* SQL Parser */
5
6
/* KEYWORD OPS */
7
8
/* SQL COMMANDS */
9
#define SQLP_CREATE 1
10
#define SQLP_DROP 2
11
#define SQLP_INSERT 3
12
#define SQLP_SELECT 4
13
#define SQLP_UPDATE 5
14
#define SQLP_DELETE 6
15
#define SQLP_ADD_COLUMN 7
16
#define SQLP_DROP_COLUMN 8
17
18
/* SQL OPERATORS */
19
/* Arithmetical */
20
#define SQLP_ADD 1
/* + */
21
#define SQLP_SUBTR 2
/* - */
22
#define SQLP_MLTP 3
/* * */
23
#define SQLP_DIV 4
/* / */
24
25
/* Comparison */
26
#define SQLP_EQ 11
/* = */
27
#define SQLP_LT 12
/* < */
28
#define SQLP_LE 13
/* <= */
29
#define SQLP_GT 14
/* > */
30
#define SQLP_GE 15
/* >= */
31
#define SQLP_NE 16
/* <> */
32
#define SQLP_MTCH 17
/* ~ */
33
34
#define SQLP_ISNULL 18
/* IS NULL */
35
#define SQLP_NOTNULL 19
/* IS NULL */
36
37
/* Logical */
38
#define SQLP_AND 21
39
#define SQLP_OR 22
40
#define SQLP_NOT 23
41
42
/* SQL VALUE TYPES, NOT COLUMN TYPES */
43
#define SQLP_NULL 1
/* value NULL -> unknown type */
44
#define SQLP_S 2
/* string */
45
#define SQLP_I 3
/* integer */
46
#define SQLP_D 4
/* float */
47
#define SQLP_BOOL 5
/* used only for type of expression */
48
#define SQLP_EXPR 6
/* expression XXX */
49
50
/* SQL COLUMN TYPES */
51
#define SQLP_VARCHAR 1
52
#define SQLP_INTEGER 2
53
#define SQLP_DOUBLE 3
54
#define SQLP_DATE 4
55
#define SQLP_TIME 5
56
57
#define SQLP_MAX_TABLE 200
58
#define SQLP_MAX_ERR 500
59
60
/* Condition node */
61
#define SQLP_NODE_COLUMN 1
62
#define SQLP_NODE_VALUE 2
63
#define SQLP_NODE_EXPRESSION 3
64
65
/* Order direction */
66
#define SORT_ASC 1
67
#define SORT_DESC 2
68
69
typedef
struct
{
70
int
type
;
/* SQLP_S, SQLP_I, SQLP_D, SQLP_NULL, SQL_EXPR */
71
char
*
s
;
/* pointer to string or NULL */
72
int
i
;
73
double
d
;
74
struct
sqlpnode
*
expr
;
75
}
SQLPVALUE
;
76
77
typedef
struct
sqlpnode
{
78
int
node_type
;
/* Node type: SQLP_NODE_COLUMN, SQLP_NODE_VALUE,
79
SQLP_NODE_EXPRESSION */
80
int
oper
;
/* Operator code */
81
struct
sqlpnode
*
left
;
/* left argument, sometimes NULL */
82
struct
sqlpnode
*
right
;
/* right argument, sometimes NULL */
83
char
*
column_name
;
84
SQLPVALUE
value
;
85
}
SQLPNODE
;
86
87
typedef
struct
{
88
char
*
stmt
;
/* input statement string */
89
char
*
cur
;
/* cursor for parser */
90
char
errmsg[
SQLP_MAX_ERR
+ 1];
91
int
command
;
92
char
table[
SQLP_MAX_TABLE
+ 1];
93
SQLPVALUE
*
Col
;
/* column names */
94
int
*
ColType
;
95
int
*
ColWidth
;
/* length */
96
int
*
ColDecim
;
/* decimals */
97
int
aCol
;
/* allocated */
98
int
nCol
;
/* number of columns */
99
SQLPVALUE
*
Val
;
/* values */
100
int
aVal
;
101
int
nVal
;
102
SQLPNODE
*
upperNodeptr
;
103
char
*
orderCol
;
/* column name which should be used for sorting (ORDER BY)
104
or NULL (no sorting) */
105
int
orderDir
;
/* direction of ordering (ASC or DESC) */
106
}
SQLPSTMT
;
107
108
#include <
grass/defs/sqlp.h
>
109
110
extern
SQLPSTMT
*
sqlpStmt
;
111
112
#endif
sqlp.h
SQLPNODE
struct sqlpnode SQLPNODE
SQLP_MAX_ERR
#define SQLP_MAX_ERR
Definition:
sqlp.h:58
SQLP_MAX_TABLE
#define SQLP_MAX_TABLE
Definition:
sqlp.h:57
sqlpStmt
SQLPSTMT * sqlpStmt
Definition:
sql.c:37
SQLPSTMT
Definition:
sqlp.h:87
SQLPSTMT::nCol
int nCol
Definition:
sqlp.h:98
SQLPSTMT::stmt
char * stmt
Definition:
sqlp.h:88
SQLPSTMT::aCol
int aCol
Definition:
sqlp.h:97
SQLPSTMT::Col
SQLPVALUE * Col
Definition:
sqlp.h:93
SQLPSTMT::upperNodeptr
SQLPNODE * upperNodeptr
Definition:
sqlp.h:102
SQLPSTMT::orderCol
char * orderCol
Definition:
sqlp.h:103
SQLPSTMT::ColWidth
int * ColWidth
Definition:
sqlp.h:95
SQLPSTMT::orderDir
int orderDir
Definition:
sqlp.h:105
SQLPSTMT::command
int command
Definition:
sqlp.h:91
SQLPSTMT::nVal
int nVal
Definition:
sqlp.h:101
SQLPSTMT::aVal
int aVal
Definition:
sqlp.h:100
SQLPSTMT::ColType
int * ColType
Definition:
sqlp.h:94
SQLPSTMT::cur
char * cur
Definition:
sqlp.h:89
SQLPSTMT::Val
SQLPVALUE * Val
Definition:
sqlp.h:99
SQLPSTMT::ColDecim
int * ColDecim
Definition:
sqlp.h:96
SQLPVALUE
Definition:
sqlp.h:69
SQLPVALUE::d
double d
Definition:
sqlp.h:73
SQLPVALUE::s
char * s
Definition:
sqlp.h:71
SQLPVALUE::expr
struct sqlpnode * expr
Definition:
sqlp.h:74
SQLPVALUE::i
int i
Definition:
sqlp.h:72
SQLPVALUE::type
int type
Definition:
sqlp.h:70
sqlpnode
Definition:
sqlp.h:77
sqlpnode::left
struct sqlpnode * left
Definition:
sqlp.h:81
sqlpnode::column_name
char * column_name
Definition:
sqlp.h:83
sqlpnode::right
struct sqlpnode * right
Definition:
sqlp.h:82
sqlpnode::oper
int oper
Definition:
sqlp.h:80
sqlpnode::value
SQLPVALUE value
Definition:
sqlp.h:84
sqlpnode::node_type
int node_type
Definition:
sqlp.h:78
include
grass
sqlp.h
Generated on Sun Dec 22 2024 07:38:21 for GRASS GIS 8 Programmer's Manual by
1.9.1