maria-discuss team mailing list archive
-
maria-discuss team
-
Mailing list archive
-
Message #00221
Re: Decimal operations
Hi, Oleg!
On Aug 18, Oleg Tsarev wrote:
>
> Hello,
>
> I don't understand how right work with decimal type.
> As you talk, i change column types from CHAR(...) to DECIMAL in my patch:
> http://www.percona.com/docs/wiki/patches:response_time_distribution
>
> Now i have trouble with decimal precision/scale.
>
> Here is my definition of system table INFORMATION_SCHEMA.QUERY_RESPONSE_TIME:
>
> ST_FIELD_INFO query_response_time_fields_info[] =
> {
> {"TIME", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, "time", SKIP_OPEN_TABLE },
> {"COUNT", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, MY_I_S_UNSIGNED, "count", SKIP_OPEN_TABLE },
> {"TOTAL", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, MY_I_S_UNSIGNED, "total", SKIP_OPEN_TABLE },
> {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE }
> };
>
> So, i want use DECIMAL(20,6) for columns time and total, and
> DECIMAL(14,0) for columns count.
>
> 1) Does above definiton correct, or should include some information
> about precision/scale?
It is not correct. If you want to use DECIMAL you need to write
MYSQL_TYPE_DECIMAL, not MYSQL_TYPE_LONG or MYSQL_TYPE_LONGLONG.
See sql_show.cc or sql_profile.cc for other information_schema tables
with DECIMAL columns.
Regards,
Sergei
References