| 1203 | */ |
| 1204 | |
| 1205 | int |
| 1206 | Event_timed::get_create_event(THD *thd, String *buf) |
| 1207 | { |
| 1208 | char tmp_buf[2 * STRING_BUFFER_USUAL_SIZE]; |
| 1209 | String expr_buf(tmp_buf, sizeof(tmp_buf), system_charset_info); |
| 1210 | expr_buf.length(0); |
| 1211 | |
| 1212 | DBUG_ENTER("get_create_event"); |
| 1213 | DBUG_PRINT("ret_info",("body_len=[%d]body=[%s]", |
| 1214 | (int) body.length, body.str)); |
| 1215 | |
| 1216 | if (expression && Events::reconstruct_interval_expression(&expr_buf, interval, |
| 1217 | expression)) |
| 1218 | DBUG_RETURN(EVEX_MICROSECOND_UNSUP); |
| 1219 | |
| 1220 | buf->append(STRING_WITH_LEN("CREATE ")); |
| 1221 | append_definer(thd, buf, &definer_user, &definer_host); |
| 1222 | buf->append(STRING_WITH_LEN("EVENT ")); |
| 1223 | append_identifier(thd, buf, &name); |
| 1224 | |
| 1225 | if (expression) |
| 1226 | { |
| 1227 | buf->append(STRING_WITH_LEN(" ON SCHEDULE EVERY ")); |
| 1228 | buf->append(expr_buf); |
| 1229 | buf->append(' '); |
| 1230 | LEX_CSTRING *ival= &interval_type_to_name[interval]; |
| 1231 | buf->append(ival->str, ival->length); |
| 1232 | |
| 1233 | if (!starts_null) |
| 1234 | append_datetime(buf, time_zone, starts, STRING_WITH_LEN("STARTS")); |
| 1235 | |
| 1236 | if (!ends_null) |
| 1237 | append_datetime(buf, time_zone, ends, STRING_WITH_LEN("ENDS")); |
| 1238 | } |
| 1239 | else |
| 1240 | { |
| 1241 | append_datetime(buf, time_zone, execute_at, |
| 1242 | STRING_WITH_LEN("ON SCHEDULE AT")); |
| 1243 | } |
| 1244 | |
| 1245 | if (on_completion == Event_parse_data::ON_COMPLETION_DROP) |
| 1246 | buf->append(STRING_WITH_LEN(" ON COMPLETION NOT PRESERVE ")); |
| 1247 | else |
| 1248 | buf->append(STRING_WITH_LEN(" ON COMPLETION PRESERVE ")); |
| 1249 | |
| 1250 | if (status == Event_parse_data::ENABLED) |
| 1251 | buf->append(STRING_WITH_LEN("ENABLE")); |
| 1252 | else if (status == Event_parse_data::SLAVESIDE_DISABLED) |
| 1253 | buf->append(STRING_WITH_LEN("DISABLE ON SLAVE")); |
| 1254 | else |
| 1255 | buf->append(STRING_WITH_LEN("DISABLE")); |
| 1256 | |
| 1257 | if (comment.length) |
| 1258 | { |
| 1259 | buf->append(STRING_WITH_LEN(" COMMENT ")); |
| 1260 | append_unescaped(buf, comment.str, comment.length); |
| 1261 | } |
| 1262 | buf->append(STRING_WITH_LEN(" DO ")); |
no test coverage detected