Sergey Could you please review my fix for bug lp:802979. I need you specifically because I needed to touch the range optimzizer to disable evaluation of single-row subqueries. Please consider if I chose the best place in the range optimizer to disable this evaluation of single-row subqueries. I will be back from vacation on Tuesday, so if there is need for discussion, we can talk on Tuesday evening or Wednesday any time. Timour -------- Original Message -------- Return-Path: <commits-bounces@mariadb.org> X-Original-To: timour@askmonty.org Delivered-To: timour@askmonty.org Received: from localhost (localhost.localdomain [127.0.0.1]) by hasky.askmonty.org (Postfix) with ESMTP id 2FB01D0A86; Mon, 4 Jul 2011 14:51:35 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at mail.askmonty.org Received: from hasky.askmonty.org ([127.0.0.1]) by localhost (mail.askmonty.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VhBdpL-sj25D; Mon, 4 Jul 2011 14:51:34 +0300 (EEST) Received: from hasky.askmonty.org (localhost.localdomain [127.0.0.1]) by hasky.askmonty.org (Postfix) with ESMTP id D6837D0A72; Mon, 4 Jul 2011 14:51:34 +0300 (EEST) Received: by hasky.askmonty.org (Postfix) id 13265D0A72; Mon, 4 Jul 2011 14:51:33 +0300 (EEST) Delivered-To: commits@mariadb.org Received: from localhost (localhost.localdomain [127.0.0.1]) by hasky.askmonty.org (Postfix) with ESMTP id 02961D0A84 for <commits@mariadb.org>; Mon, 4 Jul 2011 14:51:33 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at mail.askmonty.org Received: from hasky.askmonty.org ([127.0.0.1]) by localhost (mail.askmonty.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xbI1dw-8fTxt for <commits@mariadb.org>; Mon, 4 Jul 2011 14:51:29 +0300 (EEST) Received: from localhost6.localdomain6 (unknown [213.226.63.169]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by hasky.askmonty.org (Postfix) with ESMTPSA id DC670D0A72 for <commits@mariadb.org>; Mon, 4 Jul 2011 14:51:28 +0300 (EEST) Content-Type: multipart/mixed; boundary="===============4096211003537732309==" MIME-Version: 1.0 From: <timour@askmonty.org> User-Agent: bzr/2.3.1 To: <commits@mariadb.org> Message-Id: <20110704115128.DC670D0A72@hasky.askmonty.org> Date: Mon, 4 Jul 2011 14:51:28 +0300 (EEST) Subject: [Commits] Rev 3071: Fix LP bug lp:802979 in file:///home/tsk/mprog/src/5.3-mwl89/ X-BeenThere: commits@mariadb.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: maria-developers@lists.launchpad.net List-Id: MariaDB Commits List <commits.mariadb.org> List-Unsubscribe: <https://lists.askmonty.org/cgi-bin/mailman/listinfo/commits>, <mailto:commits-request@mariadb.org?subject=unsubscribe> List-Archive: <http://lists.askmonty.org/pipermail/commits> List-Post: <mailto:commits@mariadb.org> List-Help: <mailto:commits-request@mariadb.org?subject=help> List-Subscribe: <https://lists.askmonty.org/cgi-bin/mailman/listinfo/commits>, <mailto:commits-request@mariadb.org?subject=subscribe> Sender: commits-bounces@mariadb.org Errors-To: commits-bounces@mariadb.org At file:///home/tsk/mprog/src/5.3-mwl89/ ------------------------------------------------------------ revno: 3071 revision-id: timour@askmonty.org-20110704115116-cx7ibyty8uiwrpg7 parent: igor@askmonty.org-20110630030724-l43c25gdezawuum3 fixes bug(s): https://launchpad.net/bugs/802979 committer: timour@askmonty.org branch nick: 5.3-mwl89 timestamp: Mon 2011-07-04 14:51:16 +0300 message: Fix LP bug lp:802979 Analysis: This bug consists of two related problems that are result of too early evaluation of single-row subqueries during the optimization phase of the outer query. Several optimizer code paths try to evaluate single-row subqueries in order to produce a constant and use that constant for further optimzation. When the execution of the subquery peforms destructive changes to the representation of the subquery, and these changes are not anticipated by the subsequent optimization phases of the outer query, we tipically get a crash or failed assert. Specifically, in this bug the inner-most suqbuery with DISTINCT triggers a substitution of the original JOIN object by a single-table JOIN object with a temp table needed to perform the DISTINCT operation (created by JOIN::make_simple_join). This substitution breaks EXPLAIN because: a) in the first example JOIN::cleanup no longer can reach the original table of the innermost subquery, and close all indexes, and b) in this second test query, EXPLAIN attempts to print the name of the internal temp table, and crashes because the temp table has no name (NULL pointer instead). Solution: a) fully disable subquery evaluation during optimization in all cases - both for constant propagation and range optimization, and b) change JOIN::join_free() to perform cleanup irrespective of EXPLAIN or not.