1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

New multi-table-update code

New (simpler) internal timestamp handling.
More debuging to heap tables.
Small cleanups to multi-table-delete
false -> 0 and true -> 1  (We should use TRUE and FALSE)
This commit is contained in:
monty@mashka.mysql.fi
2002-11-29 16:40:18 +02:00
parent fa7798596d
commit 6603d75213
29 changed files with 776 additions and 636 deletions

View File

@ -422,7 +422,7 @@ end:
}
static void reset_mqh(THD *thd, LEX_USER *lu, bool get_them=false)
static void reset_mqh(THD *thd, LEX_USER *lu, bool get_them= 0)
{
(void) pthread_mutex_lock(&LOCK_user_conn);
@ -1826,61 +1826,29 @@ mysql_execute_command(void)
select_lex->select_limit,
lex->duplicates);
}
else
else
{
multi_update *result;
uint table_count;
TABLE_LIST *auxi;
const char *msg=0;
lex->sql_command=SQLCOM_MULTI_UPDATE;
for (auxi=(TABLE_LIST*) tables, table_count=0 ; auxi ; auxi=auxi->next)
table_count++;
const char *msg= 0;
lex->sql_command= SQLCOM_MULTI_UPDATE;
if (select_lex->order_list.elements)
msg="ORDER BY";
else if (select_lex->select_limit && select_lex->select_limit !=
HA_POS_ERROR)
msg="LIMIT";
if (msg)
{
net_printf(&thd->net, ER_WRONG_USAGE, "UPDATE", msg);
res= 1;
break;
}
tables->grant.want_privilege=(SELECT_ACL & ~tables->grant.privilege);
if ((res=open_and_lock_tables(thd,tables)))
break;
thd->select_limit=HA_POS_ERROR;
if (!setup_fields(thd,tables,select_lex->item_list,1,0,0) &&
!setup_fields(thd,tables,lex->value_list,0,0,0) &&
! thd->fatal_error &&
(result=new multi_update(thd,tables,select_lex->item_list,
lex->duplicates, table_count)))
{
List <Item> total_list;
List_iterator <Item> field_list(select_lex->item_list);
List_iterator <Item> value_list(lex->value_list);
Item *item;
while ((item=field_list++))
total_list.push_back(item);
while ((item=value_list++))
total_list.push_back(item);
res=mysql_select(thd,tables,total_list,
select_lex->where,
(ORDER *)NULL,(ORDER *)NULL,(Item *)NULL,
(ORDER *)NULL,
select_lex->options | thd->options |
SELECT_NO_JOIN_CACHE,
result);
delete result;
}
else
res= -1; // Error is not sent
close_thread_tables(thd);
res= mysql_multi_update(thd,tables,
&select_lex->item_list,
&lex->value_list,
select_lex->where,
select_lex->options,
lex->duplicates);
}
break;
break;
case SQLCOM_INSERT:
if (check_access(thd,INSERT_ACL,tables->db,&tables->grant.privilege))
goto error; /* purecov: inspected */
@ -2741,11 +2709,8 @@ mysql_init_select(LEX *lex)
select_lex->olap= UNSPECIFIED_OLAP_TYPE;
lex->exchange = 0;
lex->proc_list.first=0;
select_lex->order_list.elements=select_lex->group_list.elements=0;
select_lex->order_list.first=0;
select_lex->order_list.next= (byte**) &select_lex->order_list.first;
select_lex->group_list.first=0;
select_lex->group_list.next= (byte**) &select_lex->group_list.first;
select_lex->order_list.empty();
select_lex->group_list.empty();
select_lex->next = (SELECT_LEX *)NULL;
}
@ -2818,16 +2783,6 @@ mysql_parse(THD *thd,char *inBuf,uint length)
}
inline static void
link_in_list(SQL_LIST *list,byte *element,byte **next)
{
list->elements++;
(*list->next)=element;
list->next=next;
*next=0;
}
/*****************************************************************************
** Store field definition for create
** Return 0 if ok
@ -3102,7 +3057,7 @@ void store_position_for_column(const char *name)
}
bool
add_proc_to_list(Item *item)
add_proc_to_list(THD* thd, Item *item)
{
ORDER *order;
Item **item_ptr;
@ -3113,7 +3068,7 @@ add_proc_to_list(Item *item)
*item_ptr= item;
order->item=item_ptr;
order->free_me=0;
link_in_list(&current_lex->proc_list,(byte*) order,(byte**) &order->next);
thd->lex.proc_list.link_in_list((byte*) order,(byte**) &order->next);
return 0;
}
@ -3167,7 +3122,7 @@ bool add_to_list(SQL_LIST &list,Item *item,bool asc)
order->asc = asc;
order->free_me=0;
order->used=0;
link_in_list(&list,(byte*) order,(byte**) &order->next);
list.link_in_list((byte*) order,(byte**) &order->next);
DBUG_RETURN(0);
}
@ -3248,7 +3203,7 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias,
}
}
}
link_in_list(&thd->lex.select->table_list,(byte*) ptr,(byte**) &ptr->next);
thd->lex.select->table_list.link_in_list((byte*) ptr,(byte**) &ptr->next);
DBUG_RETURN(ptr);
}