few MySQL Optimizations to char-server
git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15125 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
9b24d39fc7
commit
a0a89380bf
@ -242,7 +242,7 @@ void set_char_online(int map_id, int char_id, int account_id)
|
||||
struct mmo_charstatus *cp;
|
||||
|
||||
//Update DB
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d'", char_db, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='1' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
//Check to see for online conflicts
|
||||
@ -297,7 +297,7 @@ void set_char_offline(int char_id, int account_id)
|
||||
if (cp)
|
||||
idb_remove(char_db_,char_id);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `char_id`='%d'", char_db, char_id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `online`='0' WHERE `char_id`='%d' LIMIT 1", char_db, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
|
||||
@ -814,7 +814,7 @@ int memitemdata_to_sql(const struct item items[], int max, int id, int tableswit
|
||||
}
|
||||
if( !found )
|
||||
{// Item not present in inventory, remove it.
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE from `%s` where `id`='%d'", tablename, item.id) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE from `%s` where `id`='%d' LIMIT 1", tablename, item.id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
errors++;
|
||||
@ -1255,7 +1255,7 @@ int rename_char_sql(struct char_session_data *sd, int char_id)
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, sd->new_name, strnlen(sd->new_name, NAME_LENGTH));
|
||||
|
||||
// check if the char exist
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` LIKE '%s'", char_db, esc_name) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` LIKE '%s' LIMIT 1", char_db, esc_name) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 4;
|
||||
@ -1317,7 +1317,7 @@ int check_char_name(char * name, char * esc_name)
|
||||
}
|
||||
|
||||
// check name (already in use?)
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s'", char_db, esc_name) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `name` = '%s' LIMIT 1", char_db, esc_name) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return -2;
|
||||
@ -1361,7 +1361,7 @@ int make_new_char_sql(struct char_session_data* sd, char* name_, int str, int ag
|
||||
}
|
||||
|
||||
// check char slot
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `account_id` = '%d' AND `char_num` = '%d'", char_db, sd->account_id, slot) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT 1 FROM `%s` WHERE `account_id` = '%d' AND `char_num` = '%d' LIMIT 1", char_db, sd->account_id, slot) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
if( Sql_NumRows(sql_handle) > 0 )
|
||||
return -2; // slot already in use
|
||||
@ -1408,9 +1408,9 @@ int divorce_char_sql(int partner_id1, int partner_id2)
|
||||
{
|
||||
unsigned char buf[64];
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `partner_id`='0' WHERE `char_id`='%d' OR `char_id`='%d'", char_db, partner_id1, partner_id2) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `partner_id`='0' WHERE `char_id`='%d' OR `char_id`='%d' LIMIT 2", char_db, partner_id1, partner_id2) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE (`nameid`='%d' OR `nameid`='%d') AND (`char_id`='%d' OR `char_id`='%d')", inventory_db, WEDDING_RING_M, WEDDING_RING_F, partner_id1, partner_id2) )
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE (`nameid`='%d' OR `nameid`='%d') AND (`char_id`='%d' OR `char_id`='%d') LIMIT 2", inventory_db, WEDDING_RING_M, WEDDING_RING_F, partner_id1, partner_id2) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
WBUFW(buf,0) = 0x2b12;
|
||||
|
Loading…
x
Reference in New Issue
Block a user