Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:36702 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7073 invoked from network); 31 Mar 2008 08:19:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Mar 2008 08:19:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@hristov.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@hristov.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain hristov.com from 85.92.73.163 cause and error) X-PHP-List-Original-Sender: php@hristov.com X-Host-Fingerprint: 85.92.73.163 iko.gotobg.net Received: from [85.92.73.163] ([85.92.73.163:51767] helo=iko.gotobg.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B9/50-05022-F9E90F74 for ; Mon, 31 Mar 2008 03:19:43 -0500 Received: from androto.ddns.playtime.bg ([87.120.220.53] helo=[192.168.1.127]) by iko.gotobg.net with esmtpa (Exim 4.68) (envelope-from ) id 1JgFEv-0002K0-TB; Mon, 31 Mar 2008 11:19:38 +0300 Message-ID: <47F09E92.5020101@hristov.com> Date: Mon, 31 Mar 2008 11:19:30 +0300 User-Agent: Thunderbird 2.0.0.12 (X11/20080226) MIME-Version: 1.0 To: Olivier Bonvalet CC: internals@lists.php.net References: <47EF7A6A.2050301@daevel.net> In-Reply-To: <47EF7A6A.2050301@daevel.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - iko.gotobg.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - hristov.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] Add a memory limit in mysql ext From: php@hristov.com (Andrey Hristov) Hi, Olivier Bonvalet wrote: > Hello, > > I often host clients which have "bad" PHP/SQL code ; as for example > a "select *" + mysql_row_nums on a 200Mo table just to count lines... > > So I add a little patch to throw a warning in case the result of > mysql_query > is larger than a specified limit. > I use the setting "mysql.min_stored_data_before_warn" in php.ini, and the > result is : > [30-Mar-2008 04:39:56] PHP Warning: mysql_query() [ href='function.mysql-query'>function.mysql-query]: Your query use > too much memory (202636 o) in /path/to/script.php on line 8 > > This patch seem "usefull" for me as PHP does not report the queries's > memory > consumption. But maybe it should be done in mysqli and PDO extensions to ? > > I'm not a "C developper", and the patch use the mysql internal struct, so > it's not really "clean". Maybe we can do it differently. From 5.3 one can compile ext/mysql and ext/mysqli with mysqlnd (comes with PHP) instead of libmysql. mysqlnd uses the Zend MM and thus obeys to the memory limit. You can even download ext/mysql and ext/mysqlnd from a 5.3 source and replace ext/mysql in your source tree. Rebuild configure with buildconf and then configure with --with-mysql=mysqlnd . You get the functionality with 5.2 then too. Using mysqli with 5.2 needs a small Zend patch (backport of 2 files from 5.3 due toe mysqli's persistent connections). > Thanks > > Olivier > > PS : sorry for my limited english. > Regards, Andrey