Re: [Maria-developers] MDEV-16991 review.

Hi Alexey, On 11/25/2018 03:00 AM, Alexey Botchkov wrote:
This is intentional, for strict data type control. Simple enums have some problems. For example, you can pass enums to a function that expects an integer data type. I want any mistakes like this to cause a compilation error. I would avoid using the traditional enums. Can you please leave it as is? I just found that C++11 introduced enum classes. They don't convert to int implicitly, and don't export their values to the public name space. https://www.codeguru.com/cpp/cpp/article.php/c19083/C-2011-Stronglytyped-Enu... We have enabled C++11 in 10.4 So now this could be changed to: class enum date_conv_mode_t { CONV_NONE= 0U, FUZZY_DATES= 1U, TIME_ONLY= 4U, INTERVAL_hhmmssff= 8U, INTERVAL_DAY= 16U, RANGE0_LAST= INTERVAL_DAY, NO_ZERO_IN_DATE= (1UL << 23), // MODE_NO_ZERO_IN_DATE NO_ZERO_DATE= (1UL << 24), // MODE_NO_ZERO_DATE INVALID_DATES= (1UL << 25) // MODE_INVALID_DATES }; We could try this.
Thanks. Fixed.
Thanks for noticing this. I've changed them all to "static const".
Changing all functions that accept both &warn and nsec to accept a pointer to MYSQL_TIME_STATUS instead, like this: < xxxx(thd, &status->warnings, and status->nanoseconds);
xxxx(thd, &status);
is a very good idea. I'd avoid mix "thd" to MYSQL_TIME_STATUS though. It's a pure C structure. Does it sound OK?
When the line fits the entire call, I do like this: a. Datetime dt(thd, item, Datetime::Options opt(mode, thd)); When the line does not fit, I tried both ways: b. Datetime dt(thd, item->arguments()[0], Datetime::Options opt(TIME_CONV_NONE, thd)); and c. Datetime::Options opt(TIME_CONV_NONE, thd); Datetime dt(thd, item->arguments()[0], opt); and "c" looked easier to read for me than "b". But this causes a constructor call indeed. Although, in case of date_mode_t this is very cheap (as cheap as copying of a 4 byte m_mode value), it's still a good idea to avoid this. I'll change like you suggest. Moreover, it's very likely that date_mode_t can change to something mode complex in the future. So an extra constructor call can get more expensive.
Best regards. HF

Hi Alexey, On 11/25/2018 09:05 AM, Alexander Barkov wrote:
I tried this, but this does not save anything. See the attached patch. git diff --stat sql/sql_time.cc | 6 +++--- sql/sql_type.cc | 2 +- sql/sql_type.h | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) In all other places "*warn" and "nsec" come from different places (not from the same MYSQL_TIME_STATUS). Btw, MYSQL_TIME_STATUS is actually an interface to low level pure C conversion functions like str_to_xxx() and number_to_xxx(). Let's not propagate it all around the code. Can we leave the relevant code as is? Thanks.
participants (1)
-
Alexander Barkov