[PATCH] for oci8 and some improvement proposals

php.internals

Antony Dovgal

22 years ago
Hi, all! I want to propose a patch, that will add functions listed below to OCI8 extension. Similar functions exist in Postgres & Informix extensions, but they are absent in OCI8 module. The patch is being used on 4 my servers (development, test & 2 production servers) about a week and seems to be (almost? =)) bug-free. ocitelllob(); [ OCI_Lob->tell(); ] - ftell(); analogue for Lobs ociwritelob(); [ OCI_Lob->write(); ] - fwrite(); analogue for Lobs ocitruncatelob(); [ OCI_Lob->truncate(); ] - ftruncate(); analogue for Lobs ocieraselob(); [ OCI_Lob->erase(); ] - erases specified part of a Lob (for BLOBs it means zero-filling, for CLOBs - space-filling) ociflushlob(); [ OCI_Lob->flush(); ] - flushes Lob buffer (if buffering was enabled before) ocisetbufferinglob(); [ OCI_Lob->setBuffering(); ] - turns on/off buffering for the current Lob ocigetbufferinglob(); [ OCI_Lob->getBuffering(); ] - gets buffering' current state ocirewindlob(); [ OCI_Lob->rewind(); ] - rewind(); analogue for Lobs ocireadlob(); [ OCI_Lob->read(); ] - fread(); analogue for Lobs ocieoflob(); [ OCI_Lob->eof(); ] - feof(); analogue for Lobs ociseeklob(); [ OCI_Lob->seek(); ] - fseek(); analogue for Lobs ocilobgetlength(); [ OCI_Lob->getLength(); ] - filesize(); analogue for Lobs ociappendlob(); - appends data from a Lob to another Lob ocicopylob(); - copies data from a Lob to another Lob ociisequallob(); - compares 2 Lobs and checks if they are equal All OCI-Lob methods could be rewritten to receive Lob as parameter, when they aren't called as methods, but currently this is not done (should I do it?). As you can see, I've added this check: if (oci_lobgetlen(descr->conn,descr,&len) == 0 && descr->lob_size >= 0) to almost all new functions. I propose to add this check to already existing functions (I mean, to replace calls of CALL_OCI_RETURN()), 'cause at this moment they get Lob's length from Oracle each time they are called and it's not the best decision imho. And there is another one thing I want to ask you about: ALL functions, which wrap database API's in PHP, are called like this: <db>_<action>_<to>_<do>, but only OCI8 wrappers are called in another way: oci<action><to><do> Maybe it's time to declare this style deprecated and to change it to oci_<action>_<to>_<do>? (especially after that endless discussion about studlyCaps =)) --- WBR, Antony Dovgal aka tony2001 tony2001@phpclub.net

Wez Furlong

22 years ago
Would it make sense to expose this stuff as a stream using the streams API, so the user would be able to fread($lob) etc? You could still add functions for those things that aren't covered already by streams (the erase() call). One of the benefits would be avoiding adding more functions to the global namespace, and also side stepping any naming convention wars that might arise. --Wez. ----- Original Message ----- From: "Antony Dovgal" <tony2001@phpclub.net> To: <internals@lists.php.net> Cc: <thies@thiesos.org>; <maxim@php.net>; <ssb@fast.no> Sent: Friday, December 05, 2003 1:30 PM Subject: [PHP-DEV] [PATCH] for oci8 and some improvement proposals
> Hi, all! > > I want to propose a patch, that will add functions listed below to OCI8
extension.
> Similar functions exist in Postgres & Informix extensions, but they are
absent in OCI8 module.
> The patch is being used on 4 my servers (development, test & 2 production
servers) about a week and seems to be (almost? =)) bug-free.
> > ocitelllob(); [ OCI_Lob->tell(); ] - ftell(); analogue
for Lobs
> ociwritelob(); [ OCI_Lob->write(); ] - fwrite(); analogue
for Lobs
> ocitruncatelob(); [ OCI_Lob->truncate(); ] - ftruncate();
analogue for Lobs
> ocieraselob(); [ OCI_Lob->erase(); ] - erases specified
part of a Lob (for BLOBs it means zero-filling, for CLOBs - space-filling)
> ociflushlob(); [ OCI_Lob->flush(); ] - flushes Lob buffer
(if buffering was enabled before)
> ocisetbufferinglob(); [ OCI_Lob->setBuffering(); ] - turns on/off
buffering for the current Lob
> ocigetbufferinglob(); [ OCI_Lob->getBuffering(); ] - gets buffering'
current state
> ocirewindlob(); [ OCI_Lob->rewind(); ] - rewind(); analogue
for Lobs
> ocireadlob(); [ OCI_Lob->read(); ] - fread(); analogue
for Lobs
> ocieoflob(); [ OCI_Lob->eof(); ] - feof(); analogue for
Lobs
> ociseeklob(); [ OCI_Lob->seek(); ] - fseek(); analogue
for Lobs
> ocilobgetlength(); [ OCI_Lob->getLength(); ] - filesize(); analogue
for Lobs
> > ociappendlob(); - appends data from a Lob to another Lob > ocicopylob(); - copies data from a Lob to another Lob > ociisequallob(); - compares 2 Lobs and checks if they are equal > > All OCI-Lob methods could be rewritten to receive Lob as parameter, when
they aren't called as methods, but currently this is not done (should I do it?).
> > As you can see, I've added this check: > if (oci_lobgetlen(descr->conn,descr,&len) == 0 && descr->lob_size >= 0) > to almost all new functions. > I propose to add this check to already existing functions (I mean, to
replace calls of CALL_OCI_RETURN()),
> 'cause at this moment they get Lob's length from Oracle each time they are
called and it's not the best decision imho.
> > And there is another one thing I want to ask you about: > ALL functions, which wrap database API's in PHP, are called like this:
<db>_<action>_<to>_<do>,
> but only OCI8 wrappers are called in another way: oci<action><to><do> > Maybe it's time to declare this style deprecated and to change it to
oci_<action>_<to>_<do>?

Antony Dovgal

22 years ago
On Fri, 5 Dec 2003 13:37:29 -0000 "Wez Furlong" <wez@thebrainroom.com> wrote:
> Would it make sense to expose this stuff as a stream using > the streams API, so the user would be able to fread($lob) etc?
yes, I've been thinking about it as an option. I just want to hear a principal answer about this stuff - what do maintainers and others think about it.
> You could still add functions for those things that aren't > covered already by streams (the erase() call). > > One of the benefits would be avoiding adding more functions to > the global namespace, and also side stepping any naming convention > wars that might arise.
--- WBR, Antony Dovgal aka tony2001 tony2001@phpclub.net

Thies C. Arntzen

22 years ago
Am 05.12.2003 um 14:42 schrieb Antony Dovgal:
> On Fri, 5 Dec 2003 13:37:29 -0000 > "Wez Furlong" <wez@thebrainroom.com> wrote: > >> Would it make sense to expose this stuff as a stream using >> the streams API, so the user would be able to fread($lob) etc? > > yes, I've been thinking about it as an option. > I just want to hear a principal answer about this stuff - what do > maintainers and others think about it.
hi, i'm all for it. just go ahead, apply for a cvs-account and start hacking;-) re, tc

Antony Dovgal

22 years ago
On Fri, 5 Dec 2003 15:58:49 +0100 "Thies C.Arntzen" <thies@thiesos.org> wrote:
> i'm all for it. > > just go ahead, apply for a cvs-account and start hacking;-)
I already have one, but there is not enough karma to hack anything, except peardoc/peardoc-ru. --- WBR, Antony Dovgal aka tony2001 tony2001@phpclub.net

Maxim Maletsky

22 years ago
it's been a while as I was mentioning that the naming convention for OCI8* functions should change into something like oracle_*. Problem is that there is also an old ora_* set of functions. I think this is something like rewriting the whole thingie ;) if notbody else minds we could think of applying the patch. m On Fri, 5 Dec 2003 13:37:29 -0000 "Wez Furlong" <wez@thebrainroom.com> wrote:
> Would it make sense to expose this stuff as a stream using > the streams API, so the user would be able to fread($lob) etc? > > You could still add functions for those things that aren't > covered already by streams (the erase() call). > > One of the benefits would be avoiding adding more functions to > the global namespace, and also side stepping any naming convention > wars that might arise. > > --Wez. > > ----- Original Message ----- > From: "Antony Dovgal" <tony2001@phpclub.net> > To: <internals@lists.php.net> > Cc: <thies@thiesos.org>; <maxim@php.net>; <ssb@fast.no> > Sent: Friday, December 05, 2003 1:30 PM > Subject: [PHP-DEV] [PATCH] for oci8 and some improvement proposals > > > > Hi, all! > > > > I want to propose a patch, that will add functions listed below to OCI8 > extension. > > Similar functions exist in Postgres & Informix extensions, but they are > absent in OCI8 module. > > The patch is being used on 4 my servers (development, test & 2 production > servers) about a week and seems to be (almost? =)) bug-free. > > > > ocitelllob(); [ OCI_Lob->tell(); ] - ftell(); analogue > for Lobs > > ociwritelob(); [ OCI_Lob->write(); ] - fwrite(); analogue > for Lobs > > ocitruncatelob(); [ OCI_Lob->truncate(); ] - ftruncate(); > analogue for Lobs > > ocieraselob(); [ OCI_Lob->erase(); ] - erases specified > part of a Lob (for BLOBs it means zero-filling, for CLOBs - space-filling) > > ociflushlob(); [ OCI_Lob->flush(); ] - flushes Lob buffer > (if buffering was enabled before) > > ocisetbufferinglob(); [ OCI_Lob->setBuffering(); ] - turns on/off > buffering for the current Lob > > ocigetbufferinglob(); [ OCI_Lob->getBuffering(); ] - gets buffering' > current state > > ocirewindlob(); [ OCI_Lob->rewind(); ] - rewind(); analogue > for Lobs > > ocireadlob(); [ OCI_Lob->read(); ] - fread(); analogue > for Lobs > > ocieoflob(); [ OCI_Lob->eof(); ] - feof(); analogue for > Lobs > > ociseeklob(); [ OCI_Lob->seek(); ] - fseek(); analogue > for Lobs > > ocilobgetlength(); [ OCI_Lob->getLength(); ] - filesize(); analogue > for Lobs > > > > ociappendlob(); - appends data from a Lob to another Lob > > ocicopylob(); - copies data from a Lob to another Lob > > ociisequallob(); - compares 2 Lobs and checks if they are equal > > > > All OCI-Lob methods could be rewritten to receive Lob as parameter, when > they aren't called as methods, but currently this is not done (should I do > it?). > > > > As you can see, I've added this check: > > if (oci_lobgetlen(descr->conn,descr,&len) == 0 && descr->lob_size >= 0) > > to almost all new functions. > > I propose to add this check to already existing functions (I mean, to > replace calls of CALL_OCI_RETURN()), > > 'cause at this moment they get Lob's length from Oracle each time they are > called and it's not the best decision imho. > > > > And there is another one thing I want to ask you about: > > ALL functions, which wrap database API's in PHP, are called like this: > <db>_<action>_<to>_<do>, > > but only OCI8 wrappers are called in another way: oci<action><to><do> > > Maybe it's time to declare this style deprecated and to change it to > oci_<action>_<to>_<do>? > > (especially after that endless discussion about studlyCaps =))
-- Maxim Maletsky maxim@php.net

Antony Dovgal

22 years ago
On Fri, 05 Dec 2003 17:08:49 +0100 Maxim Maletsky <maxim@maxim.cx> wrote:
> > it's been a while as I was mentioning that the naming convention for > OCI8* functions should change into something like oracle_*. Problem is > that there is also an old ora_* set of functions.
imho oci8_* is quite good choice.
> I think this is something like rewriting the whole thingie ;)
yep =( but I should mention, that some parts of oci8 look not very good ATM, so some work should be done anyway.. --- WBR, Antony Dovgal aka tony2001 tony2001@phpclub.net

Marcus Börger

22 years ago
Hello Antony, Friday, December 5, 2003, 5:02:23 PM, you wrote:
> On Fri, 05 Dec 2003 17:08:49 +0100 > Maxim Maletsky <maxim@maxim.cx> wrote:
>> >> it's been a while as I was mentioning that the naming convention for >> OCI8* functions should change into something like oracle_*. Problem is >> that there is also an old ora_* set of functions.
> imho oci8_* is quite good choice.
>> I think this is something like rewriting the whole thingie ;)
> yep =( > but I should mention, that some parts of oci8 look not very good ATM, > so some work should be done anyway..
yeah there are some open bug reports...
-- Best regards, Marcus mailto:helly@php.net

Thies C. Arntzen

22 years ago
Am 05.12.2003 um 17:02 schrieb Antony Dovgal:
> On Fri, 05 Dec 2003 17:08:49 +0100 > Maxim Maletsky <maxim@maxim.cx> wrote: > >> >> it's been a while as I was mentioning that the naming convention for >> OCI8* functions should change into something like oracle_*. Problem is >> that there is also an old ora_* set of functions. > > imho oci8_* is quite good choice. > >> I think this is something like rewriting the whole thingie ;) > > yep =( > but I should mention, that some parts of oci8 look not very good ATM, > so some work should be done anyway..
feel free to improve it, remember open source is not about moaning about the quality of other ppls code, but to contribute. BTW: i have no idea what you are talking about, sure i would do things different now - but it works today and another quote starts with "never change..." thies

Jani Taskinen

22 years ago
On Sat, 6 Dec 2003, Thies C.Arntzen wrote:
>BTW: i have no idea what you are talking about, sure i would do things >different now - but it works today and another quote starts with "never >change..."
..code that works? See this: http://bugs.php.net/search.php?cmd=display&status=Open&bug_type%5B%5D=OCI8+related (there have been even more, but those people propably got tired waiting for fixes and moved using other DB / language :) --Jani

Antony Dovgal

22 years ago
On Sat, 6 Dec 2003 08:46:33 +0100 "Thies C.Arntzen" <thies@thiesos.org> wrote:
> > Am 05.12.2003 um 17:02 schrieb Antony Dovgal: > > feel free to improve it, remember open source is not about moaning > about the quality of other ppls code, but to contribute.
I'm just arguing for and not moaning =)
> BTW: i have no idea what you are talking about, sure i would do things > different now - but it works today and another quote starts with "never > change..."
so should I add oci_lobgetlen() instead of OCILobGetLength calls after this statement? or this code is considered to be working and should not be changed anymore? and what about deprecating old syntax, that doesn't meet naming conventions? --- WBR, Antony Dovgal aka tony2001 tony2001@phpclub.net

Thies C. Arntzen

22 years ago
Am 08.12.2003 um 10:12 schrieb Antony Dovgal:
> > so should I add oci_lobgetlen() instead of OCILobGetLength calls after > this statement? > or this code is considered to be working and should not be changed > anymore? > > and what about deprecating old syntax, that doesn't meet naming > conventions? >
i don't think we should break the current style. so just use "OCILobGetLength" and - if you feel like it - then change all the function names to match the std naming-conventions but keep the old names as aliases for bc. as jani has taken me out of the MAINTAINER file (without asking me) you're welcome to take over maintainership for this piece of code. i'd be willing to assist you if you have any questions. quick note about deprecating "old" syntax: we have a long history of keeping deprecated things in forever. would you change functions names in a big php-site you have created just for the sake of it? i certainly woudn't. don't get me wrong, if you want to create new names for the functions that's fine by me, but make _very_ sure you don't screw people. tc

Antony Dovgal

22 years ago
On Mon, 8 Dec 2003 11:46:02 +0100 "Thies C.Arntzen" <thies@thiesos.org> wrote:
> Am 08.12.2003 um 10:12 schrieb Antony Dovgal: > > > > so should I add oci_lobgetlen() instead of OCILobGetLength calls after > > this statement? > > or this code is considered to be working and should not be changed > > anymore? > > > > and what about deprecating old syntax, that doesn't meet naming > > conventions? > > > > i don't think we should break the current style. so just use > "OCILobGetLength" and
It seems, that you misunderstood me. I meant this: Almost every function, that deals with Lobs, calls OciLobGetLength every time it's being called. And I propose to use oci_lobgetlen(), which will decide - is it necessary to call OciLobGetLength or we can get length from Lob's descriptor.
> - if you feel like it - then change all the > function names to match the std naming-conventions but keep the old > names as aliases for bc.
ok, it's obvious.
> as jani has taken me out of the MAINTAINER file (without asking me) > you're welcome to take over maintainership for this piece of code. i'd > be willing to assist you if you have any questions.
indeed, oci8 extension is marked as orphaned ATM.. but for some reasons I thought, that you and Maxim are current maintainers of it. and I don't think I'm currently able to maintain it (especially without your and Maxim active help).
> quick note about deprecating "old" syntax: we have a long history of > keeping deprecated things in forever. would you change functions names > in a big php-site you have created just for the sake of it? i > certainly woudn't. don't get me wrong, if you want to create new names > for the functions that's fine by me, but make _very_ sure you don't > screw people.
I suppose, it's a kind of deprecation, that will last till PHP6 =) --- WBR, Antony Dovgal aka tony2001 tony2001@phpclub.net

Thies C. Arntzen

22 years ago
Am 08.12.2003 um 12:11 schrieb Antony Dovgal:
> It seems, that you misunderstood me. > I meant this: > Almost every function, that deals with Lobs, calls OciLobGetLength > every time it's being called. > And I propose to use oci_lobgetlen(), which will decide - is it > necessary to call OciLobGetLength or we can get length from Lob's > descriptor.
ok, got you, sorry... tc PS: if you want to take over start working on it. i'll help whenever i can.

Antony Dovgal

22 years ago
On Mon, 8 Dec 2003 12:23:32 +0100 "Thies C.Arntzen" <thies@thiesos.org> wrote:
> > Am 08.12.2003 um 12:11 schrieb Antony Dovgal: > PS: if you want to take over start working on it. i'll help whenever i > can.
Ok. After careful thought, I've decided to take it over, if nobody objects. --- WBR, Antony Dovgal aka tony2001 tony2001@phpclub.net

Jani Taskinen

22 years ago
I had the impression that the 'other' oracle extension is somewhat deprecated and unsupported already? (next one to be moved to sibe..PECL ? :) --Jani On Fri, 5 Dec 2003, Maxim Maletsky wrote:

Thies C. Arntzen

22 years ago
Am 06.12.2003 um 00:41 schrieb Jani Taskinen:
> > I had the impression that the 'other' oracle extension > is somewhat deprecated and unsupported already? > > (next one to be moved to sibe..PECL ? :) >
feel free to move bothe oracle and oci to PECL. re, tc (a _strong_ believer that all extensions shoule be in PECL)