maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #04656
Re: [Commits] Rev 3488: Fix of LP bug#968720. in file:///home/bell/maria/bzr/work-maria-5.3-lpb968720/
Sanja,
Please correct the comment (see my variant below) and fix the problem in
cut() I discovered.
Sorry, I basically don't understand your code.
Contact me on IRC please.
Regards,
Igor.
On 04/04/2012 04:01 AM, sanja@xxxxxxxxxxxxxxxx wrote:
> At file:///home/bell/maria/bzr/work-maria-5.3-lpb968720/
>
> ------------------------------------------------------------
> revno: 3488
> revision-id: sanja@xxxxxxxxxxxxxxxx-20120404110135-7eca0tt18auum3xo
> parent: monty@xxxxxxxxxxxx-20120402092715-4cwn2rrcdeafir0x
> committer: sanja@xxxxxxxxxxxxxxxx
> branch nick: work-maria-5.3-lpb968720
> timestamp: Wed 2012-04-04 14:01:35 +0300
> message:
> Fix of LP bug#968720.
>
> Problem:
> During converting from merged to materialized all items listed in used_item list changed from real tables to
When a view/derived table is converted from merged to materialized the
items from the used_item lists are substituted for items referring to
the fields of the result of the materialization. The problem appeared
with queries employing natural joins. Since the resolution of a natural
join was performed only once the used_item list formed at the second
execution of the query lacked the references to the fields that were
used only in the equality predicates generated for the natural join.
the temporary table of materialized join. The problem was that natural
join matching made only once and on second
prepare phase (first is prepare opf PREPARE statement, second is prepare
phase of executing the statement) the list
lack fields of natural join because it is not made second time.
>
> Solution:
> Save the used_items list after natural join matching and restore it during re-initialization.
>
>
>
> _______________________________________________
> commits mailing list
> commits@xxxxxxxxxxx
> https://lists.askmonty.org/cgi-bin/mailman/listinfo/commits
+ /*
+ Save the lists made during natural join matching (because
+ the matching done only once but we need the list in case
+ of prepared statements).
+ */
^ remove this comment altogether.
+ table_ref_1->save_used_items= table_ref_1->used_items;
+ table_ref_2->save_used_items= table_ref_2->used_items;
You save here the head of list only. Why?
+
...
+ /**
+ Cut the list with leaving not more then n elements
^to leave
+ */
+ inline uint cut(uint n)
+ {
+ list_node *element= first;
+ uint i= 0;
+ for (;
+ i < n && element != &end_of_list;
+ element= element->next);
+ if (element != &end_of_list)
+ {
+ elements= i + 1;
+ last= &element->next;
+ element->next= &end_of_list;
+ }
+ return i + 1;
+ }
^^^
i is initialized to 0.
i is never changed.
in this context the comparison i<n does not make any sense.
+ /*
+ Following is a bit hack but pointer length is equal everywhere
+ and we need revert pointers after prepared statement execution.
+ */
^We need to restore the pointers after the execution of the
prepared statement
+ thd->change_item_tree((Item **)&ref->ref, (Item*)materialized_items
+ idx);