diff --git a/deps/oblib/src/lib/timezone/ob_time_convert.cpp b/deps/oblib/src/lib/timezone/ob_time_convert.cpp index ee1f63e0c0..3125d4e435 100644 --- a/deps/oblib/src/lib/timezone/ob_time_convert.cpp +++ b/deps/oblib/src/lib/timezone/ob_time_convert.cpp @@ -139,7 +139,7 @@ static const int32_t DAYS_PER_YEAR[2]= #define EPOCH_YEAR2 70 #define EPOCH_WDAY 4 // 1970-1-1 is thursday. #define LEAP_YEAR_COUNT(y) ((y) / 4 - (y) / 100 + (y) / 400) -#define IS_LEAP_YEAR(y) ((((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) ? 1 : 0) +#define IS_LEAP_YEAR(y) (y == 0 ? 0 : ((((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) ? 1 : 0)) #define YEAR_MAX_YEAR 2155 #define YEAR_MIN_YEAR 1901 #define YEAR_BASE_YEAR 1900 diff --git a/src/sql/engine/expr/ob_expr_align_date4cmp.cpp b/src/sql/engine/expr/ob_expr_align_date4cmp.cpp index cb90a9b0a6..194dae6d36 100644 --- a/src/sql/engine/expr/ob_expr_align_date4cmp.cpp +++ b/src/sql/engine/expr/ob_expr_align_date4cmp.cpp @@ -31,7 +31,7 @@ static const int8_t DAYS_OF_MON[2][12 + 1] = { {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} }; -#define IS_LEAP_YEAR(y) ((((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) ? 1 : 0) +#define IS_LEAP_YEAR(y) (y == 0 ? 0 : ((((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) ? 1 : 0)) ObExprAlignDate4Cmp::ObExprAlignDate4Cmp(common::ObIAllocator &alloc) : ObFuncExprOperator(alloc, T_FUN_SYS_ALIGN_DATE4CMP, N_ALIGN_DATE4CMP, 3, VALID_FOR_GENERATED_COL, NOT_ROW_DIMENSION) diff --git a/src/sql/engine/expr/ob_expr_operator.cpp b/src/sql/engine/expr/ob_expr_operator.cpp index 76f775a2df..879ce22622 100644 --- a/src/sql/engine/expr/ob_expr_operator.cpp +++ b/src/sql/engine/expr/ob_expr_operator.cpp @@ -51,7 +51,7 @@ static const int8_t DAYS_PER_MON[2][12 + 1] = { {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} }; -#define IS_LEAP_YEAR(y) ((((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) ? 1 : 0) +#define IS_LEAP_YEAR(y) (y == 0 ? 0 : ((((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0)) ? 1 : 0)) const char *ObExprTRDateFormat::FORMATS_TEXT[FORMAT_MAX_TYPE] =