Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
Description
Some code in sql_table.cc is not friendly to pluggable data types:
In mysql_prepare_alter_table():
if ((def->real_field_type() == MYSQL_TYPE_DATE || |
def->real_field_type() == MYSQL_TYPE_NEWDATE ||
|
def->real_field_type() == MYSQL_TYPE_DATETIME ||
|
def->real_field_type() == MYSQL_TYPE_DATETIME2) &&
|
!alter_ctx->datetime_field &&
|
!(~def->flags & (NO_DEFAULT_VALUE_FLAG | NOT_NULL_FLAG)) &&
|
thd->variables.sql_mode & MODE_NO_ZERO_DATE)
|
{
|
alter_ctx->datetime_field= def;
|
alter_ctx->error_if_not_empty= TRUE;
|
}
|
|
In mysql_alter_table():
switch (alter_ctx.datetime_field->real_field_type()) |
{
|
case MYSQL_TYPE_DATE: |
case MYSQL_TYPE_NEWDATE: |
f_val= "0000-00-00"; |
t_type= MYSQL_TIMESTAMP_DATE;
|
break; |
case MYSQL_TYPE_DATETIME: |
case MYSQL_TYPE_DATETIME2: |
f_val= "0000-00-00 00:00:00"; |
t_type= MYSQL_TIMESTAMP_DATETIME;
|
break; |
default: |
/* Shouldn't get here. */ |
DBUG_ASSERT(0);
|
}
|
Let's split this code into two new virtual methods in Type_handler:
virtual const Name default_value() const; |
virtual bool validate_implicit_default_value(THD *thd, |
const Column_definition &def) |
const; |
Attachments
Issue Links
- blocks
-
MDEV-4912 Data type plugin API version 1
- Closed