GRASS GIS 8 Programmer's Manual
8.2.2dev(2023)-3d2c704037
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
70
typedef
struct
71
{
72
int
type
;
/* SQLP_S, SQLP_I, SQLP_D, SQLP_NULL, SQL_EXPR */
73
char
*
s
;
/* pointer to string or NULL */
74
int
i
;
75
double
d
;
76
struct
sqlpnode
*
expr
;
77
}
SQLPVALUE
;
78
79
typedef
struct
sqlpnode
80
{
81
int
node_type
;
/* Node type: SQLP_NODE_COLUMN, SQLP_NODE_VALUE, SQLP_NODE_EXPRESSION */
82
int
oper
;
/* Operator code */
83
struct
sqlpnode
*
left
;
/* left argument, sometimes NULL */
84
struct
sqlpnode
*
right
;
/* right argument, sometimes NULL */
85
char
*
column_name
;
86
SQLPVALUE
value
;
87
}
SQLPNODE
;
88
89
typedef
struct
90
{
91
char
*
stmt
;
/* input statement string */
92
char
*
cur
;
/* cursor for parser */
93
char
errmsg[
SQLP_MAX_ERR
+ 1];
94
int
command
;
95
char
table[
SQLP_MAX_TABLE
+ 1];
96
SQLPVALUE
*
Col
;
/* column names */
97
int
*
ColType
;
98
int
*
ColWidth
;
/* length */
99
int
*
ColDecim
;
/* decimals */
100
int
aCol
;
/* allocated */
101
int
nCol
;
/* number of columns */
102
SQLPVALUE
*
Val
;
/* values */
103
int
aVal
;
104
int
nVal
;
105
SQLPNODE
*
upperNodeptr
;
106
char
*
orderCol
;
/* column name which should be used for sorting (ORDER BY) or NULL (no sorting) */
107
int
orderDir
;
/* direction of ordering (ASC or DESC) */
108
}
SQLPSTMT
;
109
110
#include <
grass/defs/sqlp.h
>
111
112
extern
SQLPSTMT
*
sqlpStmt
;
113
114
#endif
SQLPVALUE
Definition:
sqlp.h:70
SQLPSTMT::nVal
int nVal
Definition:
sqlp.h:104
SQLPSTMT::Val
SQLPVALUE * Val
Definition:
sqlp.h:102
SQLPVALUE::expr
struct sqlpnode * expr
Definition:
sqlp.h:76
SQLPSTMT::Col
SQLPVALUE * Col
Definition:
sqlp.h:96
SQLPSTMT::cur
char * cur
Definition:
sqlp.h:92
SQLPVALUE::type
int type
Definition:
sqlp.h:72
SQLPSTMT::orderDir
int orderDir
Definition:
sqlp.h:107
SQLPSTMT::stmt
char * stmt
Definition:
sqlp.h:91
SQLPVALUE::d
double d
Definition:
sqlp.h:75
sqlpnode::oper
int oper
Definition:
sqlp.h:82
SQLPSTMT
Definition:
sqlp.h:89
SQLPSTMT::ColType
int * ColType
Definition:
sqlp.h:97
SQLPSTMT::aCol
int aCol
Definition:
sqlp.h:100
SQLPSTMT::ColDecim
int * ColDecim
Definition:
sqlp.h:99
SQLPSTMT::aVal
int aVal
Definition:
sqlp.h:103
sqlpnode::value
SQLPVALUE value
Definition:
sqlp.h:86
SQLPSTMT::upperNodeptr
SQLPNODE * upperNodeptr
Definition:
sqlp.h:105
sqlpStmt
SQLPSTMT * sqlpStmt
Definition:
sql.c:38
sqlp.h
SQLPNODE
struct sqlpnode SQLPNODE
SQLPSTMT::ColWidth
int * ColWidth
Definition:
sqlp.h:98
SQLPSTMT::nCol
int nCol
Definition:
sqlp.h:101
sqlpnode
Definition:
sqlp.h:79
SQLPSTMT::command
int command
Definition:
sqlp.h:94
sqlpnode::column_name
char * column_name
Definition:
sqlp.h:85
SQLPVALUE::i
int i
Definition:
sqlp.h:74
SQLPVALUE::s
char * s
Definition:
sqlp.h:73
sqlpnode::node_type
int node_type
Definition:
sqlp.h:81
sqlpnode::left
struct sqlpnode * left
Definition:
sqlp.h:83
SQLP_MAX_ERR
#define SQLP_MAX_ERR
Definition:
sqlp.h:58
SQLPSTMT::orderCol
char * orderCol
Definition:
sqlp.h:106
SQLP_MAX_TABLE
#define SQLP_MAX_TABLE
Definition:
sqlp.h:57
sqlpnode::right
struct sqlpnode * right
Definition:
sqlp.h:84
include
grass
sqlp.h
Generated on Tue Feb 14 2023 05:56:02 for GRASS GIS 8 Programmer's Manual by
1.8.13