summaryrefslogtreecommitdiff
path: root/sql/sql_udf.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2018-04-04 12:16:12 +0300
committerMonty <monty@mariadb.org>2018-05-07 00:07:32 +0300
commit30ebc3ee9efcab635b1f3e14b9198a58ae93c233 (patch)
tree81e3ad66cd4ec8693964317cbf23515d0e9ecf35 /sql/sql_udf.cc
parenta22a339f8e044a1e8df011beb0b4c8f43792ac96 (diff)
downloadmariadb-git-30ebc3ee9efcab635b1f3e14b9198a58ae93c233.tar.gz
Add likely/unlikely to speed up execution
Added to: - if (error) - Lex - sql_yacc.yy and sql_yacc_ora.yy - In header files to alloc() calls - Added thd argument to thd_net_is_killed()
Diffstat (limited to 'sql/sql_udf.cc')
-rw-r--r--sql/sql_udf.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 3eb50d45b42..9a036156de6 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -252,7 +252,7 @@ void udf_init()
}
}
}
- if (error > 0)
+ if (unlikely(error > 0))
sql_print_error("Got unknown error: %d", my_errno);
end_read_record(&read_record_info);
table->m_needs_reopen= TRUE; // Force close to free memory
@@ -453,7 +453,7 @@ static int mysql_drop_function_internal(THD *thd, udf_func *udf, TABLE *table)
HA_READ_KEY_EXACT))
{
int error;
- if ((error= table->file->ha_delete_row(table->record[0])))
+ if (unlikely((error= table->file->ha_delete_row(table->record[0]))))
table->file->print_error(error, MYF(0));
}
DBUG_RETURN(0);
@@ -513,7 +513,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
{
if (thd->lex->create_info.or_replace())
{
- if ((error= mysql_drop_function_internal(thd, u_d, table)))
+ if (unlikely((error= mysql_drop_function_internal(thd, u_d, table))))
goto err;
}
else if (thd->lex->create_info.if_not_exists())
@@ -569,7 +569,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
/* create entry in mysql.func table */
/* Allow creation of functions even if we can't open func table */
- if (!table)
+ if (unlikely(!table))
goto err;
table->use_all_columns();
restore_record(table, s->default_values); // Default values for fields
@@ -578,9 +578,9 @@ int mysql_create_function(THD *thd,udf_func *udf)
table->field[2]->store(u_d->dl,(uint) strlen(u_d->dl), system_charset_info);
if (table->s->fields >= 4) // If not old func format
table->field[3]->store((longlong) u_d->type, TRUE);
- error = table->file->ha_write_row(table->record[0]);
+ error= table->file->ha_write_row(table->record[0]);
- if (error)
+ if (unlikely(error))
{
my_error(ER_ERROR_ON_WRITE, MYF(0), "mysql.func", error);
del_udf(u_d);
@@ -591,7 +591,7 @@ done:
mysql_rwlock_unlock(&THR_LOCK_udf);
/* Binlog the create function. */
- if (write_bin_log(thd, TRUE, thd->query(), thd->query_length()))
+ if (unlikely(write_bin_log(thd, TRUE, thd->query(), thd->query_length())))
DBUG_RETURN(1);
DBUG_RETURN(0);