Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 46194 invoked from network); 15 Jan 2007 22:37:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Jan 2007 22:37:49 -0000 Received: (qmail 93056 invoked by uid 500); 15 Jan 2007 22:37:55 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 93020 invoked by uid 500); 15 Jan 2007 22:37:55 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 93008 invoked by uid 99); 15 Jan 2007 22:37:55 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jan 2007 14:37:55 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [24.71.223.10] (HELO pd3mo3so.prod.shaw.ca) (24.71.223.10) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jan 2007 14:37:44 -0800 Received: from pd2mr1so.prod.shaw.ca (pd2mr1so-qfe3.prod.shaw.ca [10.0.141.110]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0JBX0084ZLIDHG20@l-daemon> for dev@apr.apache.org; Mon, 15 Jan 2007 15:37:25 -0700 (MST) Received: from pn2ml9so.prod.shaw.ca ([10.0.121.7]) by pd2mr1so.prod.shaw.ca (Sun Java System Messaging Server 6.2-7.05 (built Sep 5 2006)) with ESMTP id <0JBX00NN4LID0CI0@pd2mr1so.prod.shaw.ca> for dev@apr.apache.org; Mon, 15 Jan 2007 15:37:25 -0700 (MST) Received: from [192.168.0.103] ([24.69.76.33]) by l-daemon (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0JBX003WALIC5D50@l-daemon> for dev@apr.apache.org; Mon, 15 Jan 2007 15:37:25 -0700 (MST) Date: Mon, 15 Jan 2007 14:37:55 -0800 From: Chris Darroch Subject: Re: DBD: Prepared statements, BLOBs etc. In-reply-to: <20070115130619.1mmlk8lc00gk808c@www.rexursive.com> To: dev@apr.apache.org Message-id: <45AC0243.5070706@pearsoncmg.com> Organization: Pearson CTG/CMG MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Accept-Language: en-ca, en-us X-Enigmail-Version: 0.93.0.0 References: <1155589108.3289.26.camel@shrek.rexursive.com> <44EF3BEF.7060901@pearsoncmg.com> <1156537930.2596.1.camel@shrek.rexursive.com> <20060831092218.nh0wn8ls00cg0c88@www.rexursive.com> <20060904084356.7prsyaa30g4kok08@www.rexursive.com> <44FE6D0B.90004@pearsoncmg.com> <20070115130619.1mmlk8lc00gk808c@www.rexursive.com> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.13) Gecko/20060423 X-Virus-Checked: Checked by ClamAV on apache.org Bojan Smojver wrote: > OCIBindByPos(stmthp, &bindhp[0], errhp, 1, (dvoid *)buffer, 8000, > SQLT_LNG, 0, 0, 0, 0, 0, (ub4) OCI_DEFAULT); > So, one doesn't even need the LOB descriptor or anything, let alone > the name of the table or column. Did I miss something important here? Well, for anything to do with OCI, I always have to go back to basics and try to refresh my memory about all the complexities, so my apologies if this turns out to be incorrect. On a quick glance, I think what they're showing here is essentially what we do now to handle LOBs, and that's treat them like LONGs (SQLT_LNG means SQL Type LONG) when the '%L' placeholder is used. The current apr_dbd_oracle.c then uses strlen() to determine the length of the input argument (in the example above that's the 8000 value). Here's a relevant bit of apr_dbd_oracle.c: case APR_DBD_ORACLE_LOB: /* requires strlen() over large data, which may fail for binary */ statement->args[i].value.raw = va_arg(args, char*); statement->args[i].len = strlen(statement->args[i].value.stringval); sql->status = OCIBindByPos(statement->stmt, &statement->args[i].bind, sql->err, i+1, (void*)statement->args[i].value.raw, statement->args[i].len, SQLT_LNG, &statement->args[i].ind, NULL, (ub2) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT); For binary BLOB data, that strlen() is going to be a problem. At the very least, a way of knowing the length of binary data is required. Beyond that, it looks like Oracle documents a number of limitations on this approach: http://www.stanford.edu/dept/itss/docs/oracle/10g/appdev.101/b10779/oci05bnd.htm#428395 Although it's not mentioned, my own guess is that there are performance reasons for using LOB locators as well, but that's just a guess. The issues I suspect would trip users up would be the ones that sometimes impose a 4 KB limit on the data, depending on the particulars of the SQL statement. The implicit use of temporary tables might be a surprise too, I suppose. Like I said, that's a quick response based on a skim of the docs; apologies in advance for any errors or misinformation. Chris. -- GPG Key ID: 366A375B GPG Key Fingerprint: 485E 5041 17E1 E2BB C263 E4DE C8E3 FA36 366A 375B