Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26646 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16582 invoked by uid 1010); 16 Nov 2006 16:40:06 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 16564 invoked from network); 16 Nov 2006 16:40:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Nov 2006 16:40:06 -0000 Authentication-Results: pb1.pair.com smtp.mail=kingwez@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kingwez@gmail.com; sender-id=pass; domainkeys=good Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.182.190 as permitted sender) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: kingwez@gmail.com X-Host-Fingerprint: 64.233.182.190 nf-out-0910.google.com Linux 2.4/2.6 Received: from [64.233.182.190] ([64.233.182.190:25871] helo=nf-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/FE-01084-4649C554 for ; Thu, 16 Nov 2006 11:40:05 -0500 Received: by nf-out-0910.google.com with SMTP id l35so1169008nfa for ; Thu, 16 Nov 2006 08:40:01 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=UVSCiv9SWjgwR+eDxqOkA8Ue2Usn+lB5vKrQ9Hubp8QyhgL/wpXlp/oYgs7UUSzZWDJVza1rIIdTJiET46s/7CWvw2WDhrKARohz/8AAPlvOsDKbmrfLKXTLPdqpnbZ0YpV0bPu4Vgtsau8mpxYYCfmjKayYxBXdkFJtJ02ut+4= Received: by 10.82.129.8 with SMTP id b8mr88012bud.1163695200646; Thu, 16 Nov 2006 08:40:00 -0800 (PST) Received: by 10.82.167.13 with HTTP; Thu, 16 Nov 2006 08:40:00 -0800 (PST) Message-ID: <4e89b4260611160840p19ad23acg100d9ce44655bd2c@mail.gmail.com> Date: Thu, 16 Nov 2006 11:40:00 -0500 To: "Mario Wolff" Cc: internals@lists.php.net In-Reply-To: <9bb5e33f0611160752g38cdc4acy92e0f72b9aee9c8b@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <9bb5e33f0611160505u2ac2b1dbt1b04feea4314331c@mail.gmail.com> <4e89b4260611160629o1855ed28pf37139f1576fa99b@mail.gmail.com> <9bb5e33f0611160721l6676cbe5ud0185127fad03402@mail.gmail.com> <9bb5e33f0611160745i4ef015e7i16933d7a4904a6ff@mail.gmail.com> <9bb5e33f0611160752g38cdc4acy92e0f72b9aee9c8b@mail.gmail.com> Subject: Re: [PHP-DEV] Enable authorizer-feature in PDO_SQLITE From: kingwez@gmail.com ("Wez Furlong") I think it would be better to pass in the pdo_dbh_t as the autharg to the C level callback and then use that to determine if any of the expensive work needs to be done in the callback. static int authorizer(....) { pdo_dbh_t *db; /* keep the current safemode / basedir checks "cheap" and fast */ if (existing safe_mode and open_base dir return SQLITE_DENY) { return SQLITE_DENY; } db = (pdo_dbh_t*)autharg; if (db->user_authorizer) { TSRMLS_FETCH(); ... free stuff } } You should take a look at how the pdo_sqlite_fci stuff works and adopt that for the authorizer callback, as it will help improve runtime performance there. It would also be best to register constants for the various SQLITE_XXX codes rather than creating strings and having the PHP code check against strings. This will also improve performance at runtime. --Wez. On 11/16/06, Mario Wolff wrote: > Short test script: > > $data = array( 'one', 'two', 'three', 'four', 'five', 'six'); > $db = new PDO( 'sqlite::memory:'); > echo "register authorizer\n"; > $db->sqliteSetAuthorizer('auth'); > $db->exec( "CREATE TABLE strings( a)"); > $insert = $db->prepare( 'INSERT INTO strings VALUES ( ?)'); > foreach ( $data as $str) { > > $insert->execute( array( $str)); > } > $insert = null; > echo "unregister authorizer\n"; > $db->sqliteSetAuthorizer(); > > function auth($type,$arga,$argb,$argc,$argd ){ > echo "$type\t$arga\t$argb\t$argc\t$argd\n"; > return true; > } > print_r( $db->query( 'SELECT sqlite_version( *);')->fetchAll( )); > > ?> > > gives: > register authorizer > SQLITE_INSERT sqlite_master main > SQLITE_CREATE_TABLE strings main > SQLITE_UPDATE sqlite_master type main > SQLITE_UPDATE sqlite_master name main > SQLITE_UPDATE sqlite_master tbl_name main > SQLITE_UPDATE sqlite_master rootpage main > SQLITE_UPDATE sqlite_master sql main > SQLITE_READ sqlite_master ROWID main > SQLITE_READ sqlite_master name main > SQLITE_READ sqlite_master rootpage main > SQLITE_READ sqlite_master sql main > SQLITE_READ sqlite_master tbl_name main > SQLITE_INSERT strings main > unregister authorizer > Array > ( > [0] => Array > ( > [sqlite_version( *)] => 3.3.7 > [0] => 3.3.7 > ) > > ) >