/* * FiveSqlDef.ch — Shared constant definitions for FiveSql engine * * Copyright (c) 2025 Charles KWON (Charles KWON OhJun) * Email: charleskwonohjun@gmail.com * * All rights reserved. */ #ifndef FIVESQLDEF_CH #define FIVESQLDEF_CH /* Token types produced by the lexical analyzer */ #define TK_END 0 /* End of input */ #define TK_NAME 1 /* Identifier or keyword */ #define TK_TEXT 2 /* String literal */ #define TK_NUM 3 /* Numeric literal */ #define TK_COMMA 4 /* , */ #define TK_DOT 5 /* . */ #define TK_STAR 6 /* * */ #define TK_LPAR 7 /* ( */ #define TK_RPAR 8 /* ) */ #define TK_EQ 9 /* = */ #define TK_NEQ 10 /* <> or != */ #define TK_LT 11 /* < */ #define TK_GT 12 /* > */ #define TK_LTE 13 /* <= */ #define TK_GTE 14 /* >= */ #define TK_QMARK 15 /* ? (parameter placeholder) */ #define TK_PLUS 16 /* + */ #define TK_MINUS 17 /* - */ #define TK_SLASH 18 /* / */ #define TK_PIPES 19 /* || (string concatenation) */ /* Token array element indices */ #define TK_TYPE 1 #define TK_VALUE 2 /* Expression AST node types */ #define ND_LIT 1 /* Literal value */ #define ND_COL 2 /* Column reference */ #define ND_FN 3 /* Function call */ #define ND_BIN 4 /* Binary operation */ #define ND_UNI 5 /* Unary operation */ #define ND_CASE 6 /* CASE expression */ #define ND_SUB 7 /* Subquery */ #define ND_LIST 8 /* Value list */ #define ND_PAR 9 /* Bound parameter */ #define ND_NIL 10 /* NULL value */ #define ND_RANGE 11 /* BETWEEN range */ #define ND_WINDOW 12 /* Window function */ #define ND_FRAME 13 /* Window frame specification */ #define ND_LATERAL 14 /* LATERAL subquery */ /* Error codes */ #define SQL_ERR_NONE 0 #define SQL_ERR_SYNTAX 1001 #define SQL_ERR_NO_TABLE 1002 #define SQL_ERR_NO_FIELD 1003 #define SQL_ERR_TYPE 1004 #define SQL_ERR_LOCKED 1005 #define SQL_ERR_GRAMMAR 1006 #define SQL_ERR_UNSUPPORTED 1007 #define SQL_ERR_TXN 1008 /* Recognized aggregate function names */ #define AGG_FUNCTIONS "COUNT,SUM,AVG,MIN,MAX,GROUP_CONCAT,STRING_AGG,LISTAGG,JSON_ARRAYAGG,JSON_OBJECTAGG,XMLAGG,ANY_VALUE,BOOL_AND,BOOL_OR" /* Recognized scalar function names */ #define SCALAR_FUNCTIONS "UPPER,LOWER,TRIM,LTRIM,RTRIM,SUBSTR,SUBSTRING,LEN,LENGTH,REPLACE,SPACE,REPLICATE,STUFF,CHARINDEX,CONCAT,ABS,ROUND,INT,FLOOR,CEILING,CEIL,MOD,POWER,SQRT,SIGN,YEAR,MONTH,DAY,NOW,DATE,TIME,DTOS,DTOC,CTOD,STOD,CAST,CONVERT,STR,VAL,ALLTRIM,IIF,COALESCE,NULLIF,DATEADD,DATEDIFF,EOMONTH,INSTR,REVERSE,PADL,PADR,PADC,ISNUMERIC,ISDATE,ISVALID,TYPEOF,TYPE,FORMAT,HB_HOUR,HB_MINUTE,HB_SECOND,HB_DATETIME,HB_TTOC,HB_CTOT,TIMESTAMP,ROUND_BANKER,EXISTS,EXTRACT,POSITION,OVERLAY,ARRAY,ROW,JSON_VALUE,JSON_QUERY,JSON_EXISTS,JSON_TABLE,JSON_OBJECT,JSON_ARRAY,JSON_OBJECTAGG,JSON_ARRAYAGG,XMLELEMENT,XMLFOREST,XMLAGG,GREATEST,LEAST,LPAD,RPAD,ANY_VALUE,BOOL_AND,BOOL_OR" #endif