38 #include <grass/sqlp.h>
46 val->s = (
char *)realloc(val->s, len);
55 val->type = SQLP_NULL;
63 to->type = from->type;
69 to->s = strdup(from->s);
78 sqlpStmt->cur = sqlpStmt->stmt;
80 sqlpStmt->errmsg[0] =
'\0';
81 sqlpStmt->table[0] =
'\0';
84 sqlpStmt->upperNodeptr =
NULL;
85 sqlpStmt->orderCol =
NULL;
98 strncpy(sqlpStmt->table, tbl, SQLP_MAX_TABLE);
121 sqlpStmt->ColType[i] =
type;
122 sqlpStmt->ColWidth[i] =
width;
123 sqlpStmt->ColDecim[i] = decimals;
140 sqlpStmt->Val[i].s =
NULL;
141 sqlpStmt->Val[i].i = 0;
142 sqlpStmt->Val[i].d = 0.0;
144 sqlpStmt->Val[i].type =
type;
150 sqlpStmt->Val[i].i = intval;
153 sqlpStmt->Val[i].d = dblval;
163 SQLPNODE * expval,
int type)
173 sqlpStmt->Val[i].s =
NULL;
174 sqlpStmt->Val[i].i = 0;
175 sqlpStmt->Val[i].d = 0.0;
177 sqlpStmt->Val[i].type =
type;
183 sqlpStmt->Val[i].i = intval;
186 sqlpStmt->Val[i].d = dblval;
189 sqlpStmt->Val[i].expr = expval;
202 sqlpStmt->orderCol = (
char *)realloc(sqlpStmt->orderCol, strlen(col) + 1);
203 strcpy(sqlpStmt->orderCol, col);
204 sqlpStmt->orderDir = dir;
213 np = (SQLPNODE *) calloc(1,
sizeof(SQLPNODE));
223 np->node_type = SQLP_NODE_EXPRESSION;
237 np->node_type = SQLP_NODE_COLUMN;
238 np->column_name = strdup(name);
249 np->node_type = SQLP_NODE_VALUE;
251 np->value.type =
type;
253 np->value.s = strdup(strval);
254 np->value.i = intval;
255 np->value.d = dblval;
272 free(np->column_name);
288 *ptr = tolower(*ptr);
292 if (strcmp(oper,
"=") == 0)
294 else if (strcmp(oper,
"<") == 0)
296 else if (strcmp(oper,
"<=") == 0)
298 else if (strcmp(oper,
">") == 0)
300 else if (strcmp(oper,
">=") == 0)
302 else if (strcmp(oper,
"<>") == 0)
304 else if (strcmp(oper,
"~") == 0)
306 else if (strcmp(oper,
"+") == 0)
308 else if (strcmp(oper,
"-") == 0)
310 else if (strcmp(oper,
"*") == 0)
312 else if (strcmp(oper,
"/") == 0)
314 else if (strcmp(oper,
"and") == 0)
316 else if (strcmp(oper,
"or") == 0)
318 else if (strcmp(oper,
"not") == 0)
int sqpAllocVal(SQLPSTMT *st, int n)
void sqpColumn(char *col)
void sqpFreeNode(SQLPNODE *np)
SQLPNODE * sqpNewColumnNode(char *name)
int sqpInitParser(SQLPSTMT *st)
void sqpColumnDef(char *col, int type, int width, int decimals)
void sqpInitValue(SQLPVALUE *val)
char * sqpOperatorName(int oper)
int sqpOperatorCode(char *oper)
SQLPNODE * sqpNewValueNode(char *strval, int intval, double dblval, int type)
SQLPNODE * sqpNewNode(void)
void sqpOrderColumn(char *col, int dir)
void sqpCopyValue(SQLPVALUE *from, SQLPVALUE *to)
int sqpAllocCol(SQLPSTMT *st, int n)
SQLPNODE * sqpNewExpressionNode(int oper, SQLPNODE *left, SQLPNODE *right)
int sqpSaveStr(SQLPVALUE *val, char *c)
void sqpAssignment(char *col, char *strval, int intval, double dblval, SQLPNODE *expval, int type)
void sqpValue(char *strval, int intval, double dblval, int type)
void sqpCommand(int command)