149
static Item *default_value_item(enum_field_types field_type,
150
const charset_info_st *charset,
151
bool default_null, const string *default_value,
152
const string *default_bin_value)
149
static Item* default_value_item(enum_field_types field_type, const charset_info_st& charset, bool default_null,
150
const string& default_value, const string& default_bin_value)
154
Item *default_item= NULL;
157
152
if (default_null)
159
153
return new Item_null();
164
157
case DRIZZLE_TYPE_LONG:
165
158
case DRIZZLE_TYPE_LONGLONG:
166
default_item= new Item_int(default_value->c_str(),
167
(int64_t) internal::my_strtoll10(default_value->c_str(),
170
default_value->length());
172
if (error && error != -1) /* was an error and wasn't a negative number */
161
Item* default_item= new Item_int(default_value.c_str(), (int64_t) internal::my_strtoll10(default_value.c_str(), NULL, &error), default_value.length());
163
if (error && error != -1) /* was an error and wasn't a negative number */
179
170
case DRIZZLE_TYPE_DOUBLE:
180
default_item= new Item_float(default_value->c_str(),
181
default_value->length());
171
return new Item_float(default_value.c_str(), default_value.length());
183
172
case DRIZZLE_TYPE_NULL:
186
175
case DRIZZLE_TYPE_TIMESTAMP:
187
176
case DRIZZLE_TYPE_DATETIME:
192
181
case DRIZZLE_TYPE_IPV6:
193
182
case DRIZZLE_TYPE_MICROTIME:
194
183
case DRIZZLE_TYPE_BOOLEAN:
195
default_item= new Item_string(default_value->c_str(),
196
default_value->length(),
197
system_charset_info);
184
// return new Item_string(*default_value, system_charset_info); // crash
185
return new Item_string(default_value.data(), default_value.size(), system_charset_info);
199
186
case DRIZZLE_TYPE_VARCHAR:
200
187
case DRIZZLE_TYPE_BLOB: /* Blob is here due to TINYTEXT. Feel the hate. */
201
if (charset==&my_charset_bin)
203
default_item= new Item_string(default_bin_value->c_str(),
204
default_bin_value->length(),
209
default_item= new Item_string(default_value->c_str(),
210
default_value->length(),
211
system_charset_info);
188
return &charset== &my_charset_bin
189
? new Item_string(default_bin_value, &my_charset_bin)
190
: new Item_string(default_value, system_charset_info);
214
191
case DRIZZLE_TYPE_DECIMAL:
215
default_item= new Item_decimal(default_value->c_str(),
216
default_value->length(),
217
system_charset_info);
192
return new Item_decimal(default_value.c_str(), default_value.length(), system_charset_info);
975
948
unireg_type= Field::TIMESTAMP_UN_FIELD;
979
if (pfield.has_comment())
951
lex_string_t comment;
952
if (!pfield.has_comment())
954
comment.assign("", 0);
981
958
comment.assign(mem().strdup(pfield.comment()), pfield.comment().size());
1042
1019
pfield.options().default_null() ||
1043
1020
pfield.options().has_default_bin_value())
1045
default_value= default_value_item(field_type,
1047
pfield.options().default_null(),
1048
&pfield.options().default_value(),
1049
&pfield.options().default_bin_value());
1022
default_value= default_value_item(field_type, *charset, pfield.options().default_null(), pfield.options().default_value(), pfield.options().default_bin_value());
1050
1023
if (default_value == NULL)
1052
1025
my_error(ER_INVALID_DEFAULT, MYF(0), pfield.name().c_str());