MCPcopy Create free account
hub / github.com/MariaDB/server / write_delayed

Function write_delayed

sql/sql_insert.cc:3214–3352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3212/* Put a question in queue */
3213
3214static
3215int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic,
3216 LEX_STRING query, bool ignore, bool log_on)
3217{
3218 delayed_row *row= 0;
3219 Delayed_insert *di=thd->di;
3220 const Discrete_interval *forced_auto_inc;
3221 size_t user_len, host_len, ip_length;
3222 DBUG_ENTER("write_delayed");
3223 DBUG_PRINT("enter", ("query = '%s' length %lu", query.str,
3224 (ulong) query.length));
3225
3226 THD_STAGE_INFO(thd, stage_waiting_for_handler_insert);
3227 mysql_mutex_lock(&di->mutex);
3228 while (di->stacked_inserts >= delayed_queue_size && !thd->killed)
3229 mysql_cond_wait(&di->cond_client, &di->mutex);
3230 THD_STAGE_INFO(thd, stage_storing_row_into_queue);
3231
3232 if (thd->killed)
3233 goto err;
3234
3235 /*
3236 Take a copy of the query string, if there is any. The string will
3237 be free'ed when the row is destroyed. If there is no query string,
3238 we don't do anything special.
3239 */
3240
3241 if (query.str)
3242 {
3243 char *str;
3244 if (!(str= my_strndup(PSI_INSTRUMENT_ME, query.str, query.length,
3245 MYF(MY_WME))))
3246 goto err;
3247 query.str= str;
3248 }
3249 row= new delayed_row(query, duplic, ignore, log_on);
3250 if (row == NULL)
3251 {
3252 my_free(query.str);
3253 goto err;
3254 }
3255
3256 user_len= host_len= ip_length= 0;
3257 row->user= row->host= row->ip= NULL;
3258 if (thd->security_ctx)
3259 {
3260 if (thd->security_ctx->user)
3261 user_len= strlen(thd->security_ctx->user) + 1;
3262 if (thd->security_ctx->host)
3263 host_len= strlen(thd->security_ctx->host) + 1;
3264 if (thd->security_ctx->ip)
3265 ip_length= strlen(thd->security_ctx->ip) + 1;
3266 }
3267 /* This can't be THREAD_SPECIFIC as it's freed in delayed thread */
3268 if (!(row->record= (char*) my_malloc(PSI_INSTRUMENT_ME,
3269 table->s->reclength +
3270 user_len + host_len + ip_length,
3271 MYF(MY_WME))))

Callers 1

mysql_insertFunction · 0.85

Calls 7

my_strndupFunction · 0.85
my_freeFunction · 0.85
my_mallocFunction · 0.85
unlink_blobsFunction · 0.85
get_nextMethod · 0.45
minimumMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected