support last_day in mysql mode

This commit is contained in:
jg0
2021-07-27 21:39:15 +08:00
committed by wangzelin.wzl
parent 09edba0ff6
commit 74d0236609
45 changed files with 26893 additions and 25079 deletions

View File

@ -561,6 +561,22 @@ typedef enum ObItemType {
T_FUN_SYS_NLS_UPPER = 1577,
T_FUN_KEEP_WM_CONCAT = 1578,
T_FUN_WM_CONCAT = 1579,
T_FUN_TOP_FRE_HIST = 1580,
T_FUN_UNISTR = 1581,
T_FUN_PLSQL_VARIABLE = 1582,
T_FUN_ASCIISTR = 1583,
T_FUN_PL_AGG_UDF = 1584,
T_FUN_SYS_AT_TIME_ZONE = 1585,
T_FUN_SYS_AT_LOCAL = 1586,
T_FUN_HYBRID_HIST = 1587,
T_FUN_SYS_RAWTONHEX = 1588,
T_FUN_SYS_TIMESTAMP = 1589,
T_FUN_SYS_GET_FORMAT = 1590,
T_FUN_SYS_MAKEDATE = 1591,
T_FUN_SYS_PERIOD_ADD = 1592,
T_FUN_SYS_UTC_TIME = 1593,
T_FUN_SYS_UTC_DATE = 1594,
T_FUN_SYS_TIME_FORMAT = 1595,
///< @note add new oracle only function type before this line
T_FUN_SYS_END = 2000,

View File

@ -308,7 +308,7 @@ END_P SET_VAR DELIMITER
%type <node> create_tenant_stmt opt_tenant_option_list alter_tenant_stmt drop_tenant_stmt
%type <node> create_restore_point_stmt drop_restore_point_stmt
%type <node> create_resource_stmt drop_resource_stmt alter_resource_stmt
%type <node> cur_timestamp_func cur_time_func cur_date_func now_synonyms_func utc_timestamp_func sys_interval_func sysdate_func
%type <node> cur_timestamp_func cur_time_func cur_date_func now_synonyms_func utc_timestamp_func utc_time_func utc_date_func sys_interval_func sysdate_func
%type <node> opt_create_resource_pool_option_list create_resource_pool_option alter_resource_pool_option_list alter_resource_pool_option
%type <node> opt_shrink_unit_option unit_id_list
%type <node> opt_resource_unit_option_list resource_unit_option
@ -424,7 +424,7 @@ END_P SET_VAR DELIMITER
%type <node> create_savepoint_stmt rollback_savepoint_stmt release_savepoint_stmt
%type <node> opt_qb_name
%type <node> opt_force_purge
%type <node> opt_sql_throttle_for_priority opt_sql_throttle_using_cond sql_throttle_one_or_more_metrics sql_throttle_metric
%type <node> opt_sql_throttle_for_priority opt_sql_throttle_using_cond sql_throttle_one_or_more_metrics sql_throttle_metric get_format_unit
%start sql_stmt
%%
////////////////////////////////////////////////////////////////
@ -2126,6 +2126,14 @@ MOD '(' expr ',' expr ')'
{
$$ = $1;
}
| utc_time_func
{
$$ = $1;
}
| utc_date_func
{
$$ = $1;
}
| CAST '(' expr AS cast_data_type ')'
{
//cast_data_type is a T_CAST_ARGUMENT rather than a T_INT to avoid being parameterized automatically
@ -2202,6 +2210,13 @@ MOD '(' expr ',' expr ')'
make_name_node($$, result->malloc_pool_, "time");
malloc_non_terminal_node($$, result->malloc_pool_, T_FUN_SYS, 2, $$, params);
}
| TIMESTAMP '(' expr ')'
{
ParseNode *params = NULL;
malloc_non_terminal_node(params, result->malloc_pool_, T_EXPR_LIST, 1, $3);
make_name_node($$, result->malloc_pool_, "timestamp");
malloc_non_terminal_node($$, result->malloc_pool_, T_FUN_SYS, 2, $$, params);
}
| MONTH '(' expr ')'
{
ParseNode *params = NULL;
@ -2237,6 +2252,13 @@ MOD '(' expr ',' expr ')'
make_name_node($$, result->malloc_pool_, "second");
malloc_non_terminal_node($$, result->malloc_pool_, T_FUN_SYS, 2, $$, params);
}
| GET_FORMAT '(' get_format_unit ',' expr ')'
{
ParseNode *params = NULL;
malloc_non_terminal_node(params, result->malloc_pool_, T_EXPR_LIST, 2, $3, $5);
make_name_node($$, result->malloc_pool_, "get_format");
malloc_non_terminal_node($$, result->malloc_pool_, T_FUN_SYS, 2, $$, params);
}
| MINUTE '(' expr ')'
{
ParseNode *params = NULL;
@ -2482,7 +2504,11 @@ INTERVAL '(' expr ',' expr ')'
;
utc_timestamp_func:
UTC_TIMESTAMP '(' ')'
UTC_TIMESTAMP
{
malloc_non_terminal_node($$, result->malloc_pool_, T_FUN_SYS_UTC_TIMESTAMP, 1, NULL);
}
| UTC_TIMESTAMP '(' ')'
{
malloc_non_terminal_node($$, result->malloc_pool_, T_FUN_SYS_UTC_TIMESTAMP, 1, NULL);
}
@ -2492,6 +2518,33 @@ UTC_TIMESTAMP '(' ')'
}
;
utc_time_func:
UTC_TIME
{
malloc_non_terminal_node($$, result->malloc_pool_, T_FUN_SYS_UTC_TIME, 1, NULL);
}
| UTC_TIME '(' ')'
{
malloc_non_terminal_node($$, result->malloc_pool_, T_FUN_SYS_UTC_TIME, 1, NULL);
}
| UTC_TIME '(' INTNUM ')'
{
malloc_non_terminal_node($$, result->malloc_pool_, T_FUN_SYS_UTC_TIME, 1, $3);
}
;
utc_date_func:
UTC_DATE
{
malloc_non_terminal_node($$, result->malloc_pool_, T_FUN_SYS_UTC_DATE, 1, NULL);
}
| UTC_DATE '(' ')'
{
malloc_non_terminal_node($$, result->malloc_pool_, T_FUN_SYS_UTC_DATE, 1, NULL);
}
;
sysdate_func:
SYSDATE '(' ')'
{
@ -4236,6 +4289,24 @@ DATETIME { $$[0] = T_DATETIME; $$[1] = 0; }
| TIME { $$[0] = T_TIME; $$[1] = 0; }
;
get_format_unit:
DATETIME
{
malloc_terminal_node($$, result->malloc_pool_, T_INT);
$$->value_ = GET_FORMAT_DATETIME;
}
| DATE
{
malloc_terminal_node($$, result->malloc_pool_, T_INT);
$$->value_ = GET_FORMAT_DATE;
}
| TIME
{
malloc_terminal_node($$, result->malloc_pool_, T_INT);
$$->value_ = GET_FORMAT_TIME;
}
;
data_type:
int_type_i opt_int_length_i opt_unsigned_i opt_zerofill_i
{

File diff suppressed because it is too large Load Diff

View File

@ -502,6 +502,22 @@ const char* get_type_name(int type)
case T_FUN_SYS_NLS_UPPER : return "T_FUN_SYS_NLS_UPPER";
case T_FUN_KEEP_WM_CONCAT : return "T_FUN_KEEP_WM_CONCAT";
case T_FUN_WM_CONCAT : return "T_FUN_WM_CONCAT";
case T_FUN_TOP_FRE_HIST : return "T_FUN_TOP_FRE_HIST";
case T_FUN_UNISTR : return "T_FUN_UNISTR";
case T_FUN_PLSQL_VARIABLE : return "T_FUN_PLSQL_VARIABLE";
case T_FUN_ASCIISTR : return "T_FUN_ASCIISTR";
case T_FUN_PL_AGG_UDF : return "T_FUN_PL_AGG_UDF";
case T_FUN_SYS_AT_TIME_ZONE : return "T_FUN_SYS_AT_TIME_ZONE";
case T_FUN_SYS_AT_LOCAL : return "T_FUN_SYS_AT_LOCAL";
case T_FUN_HYBRID_HIST : return "T_FUN_HYBRID_HIST";
case T_FUN_SYS_RAWTONHEX : return "T_FUN_SYS_RAWTONHEX";
case T_FUN_SYS_TIMESTAMP : return "T_FUN_SYS_TIMESTAMP";
case T_FUN_SYS_GET_FORMAT : return "T_FUN_SYS_GET_FORMAT";
case T_FUN_SYS_MAKEDATE : return "T_FUN_SYS_MAKEDATE";
case T_FUN_SYS_PERIOD_ADD : return "T_FUN_SYS_PERIOD_ADD";
case T_FUN_SYS_UTC_TIME : return "T_FUN_SYS_UTC_TIME";
case T_FUN_SYS_UTC_DATE : return "T_FUN_SYS_UTC_DATE";
case T_FUN_SYS_TIME_FORMAT : return "T_FUN_SYS_TIME_FORMAT";
case T_FUN_SYS_END : return "T_FUN_SYS_END";
case T_MAX_OP : return "T_MAX_OP";
case T_FUN_MATCH_AGAINST : return "T_FUN_MATCH_AGAINST";