# [PATCH] for oci8 and some improvement proposals

- Thread: https://externals.io/message/6228
- Original archive: https://news-web.php.net/php.internals/6228
- Started by Antony Dovgal on 2003-12-05T13:30:44+00:00
- Messages: 17
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #6228 — Antony Dovgal — 2003-12-05T13:30:44+00:00

URL: https://externals.io/message/6228#6228

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

---

## #6229 — Wez Furlong — 2003-12-05T13:37:29+00:00

URL: https://externals.io/message/6228#6229 · In reply to: #6228

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 =))

---

## #6230 — Antony Dovgal — 2003-12-05T13:42:04+00:00

URL: https://externals.io/message/6228#6230 · In reply to: #6229

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

---

## #6231 — Thies C.Arntzen — 2003-12-05T14:58:49+00:00

URL: https://externals.io/message/6228#6231 · In reply to: #6230

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:
>
> > […]
>
> 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

---

## #6232 — Antony Dovgal — 2003-12-05T15:05:52+00:00

URL: https://externals.io/message/6228#6232 · In reply to: #6231

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

---

## #6235 — Antony Dovgal — 2003-12-05T16:02:23+00:00

URL: https://externals.io/message/6228#6235 · In reply to: #6234

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

---

## #6234 — Maxim Maletsky — 2003-12-05T16:08:49+00:00

URL: https://externals.io/message/6228#6234 · In reply to: #6229

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
> 
> 
> > […]
> extension.
> > […]
> absent in OCI8 module.
> > […]
> servers) about a week and seems to be (almost? =)) bug-free.
> > […]
> for Lobs
> > […]
> for Lobs
> > […]
> analogue for Lobs
> > […]
> part of a Lob (for BLOBs it means zero-filling, for CLOBs - space-filling)
> > […]
> (if buffering was enabled before)
> > […]
> buffering for the current Lob
> > […]
> current state
> > […]
> for Lobs
> > […]
> for Lobs
> > […]
> Lobs
> > […]
> for Lobs
> > […]
> for Lobs
> > […]
> they aren't called as methods, but currently this is not done (should I do
> it?).
> > […]
> replace calls of CALL_OCI_RETURN()),
> > […]
> called and it's not the best decision imho.
> > […]
> <db>_<action>_<to>_<do>,
> > […]
> oci_<action>_<to>_<do>?
> > […]


-- 
Maxim Maletsky
maxim@php.net

---

## #6239 — Marcus Boerger — 2003-12-05T20:34:48+00:00

URL: https://externals.io/message/6228#6239 · In reply to: #6235

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:

> > […]

> imho oci8_* is quite good choice.

> > […]

> 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

---

## #6242 — Jani Taskinen — 2003-12-05T23:41:23+00:00

URL: https://externals.io/message/6228#6242 · In reply to: #6234

I had the impression that the 'other' oracle extension
    is somewhat deprecated and unsupported already?
    
    (next one to be moved to sibe..PECL ? :)
    
    --Jani
    



>
>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:
>
> > […]

---

## #6246 — Thies C.Arntzen — 2003-12-06T07:43:53+00:00

URL: https://externals.io/message/6228#6246 · In reply to: #6242

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)

---

## #6247 — Thies C.Arntzen — 2003-12-06T07:46:33+00:00

URL: https://externals.io/message/6228#6247 · In reply to: #6235

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:
>
> > […]
>
> imho oci8_* is quite good choice.
>
> > […]
>
> 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

---

## #6250 — Jani Taskinen — 2003-12-06T11:00:09+00:00

URL: https://externals.io/message/6228#6250 · In reply to: #6247

>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

---

## #6281 — Antony Dovgal — 2003-12-08T09:12:06+00:00

URL: https://externals.io/message/6228#6281 · In reply to: #6247

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

---

## #6282 — Thies C.Arntzen — 2003-12-08T10:46:02+00:00

URL: https://externals.io/message/6228#6282 · In reply to: #6281

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

---

## #6283 — Antony Dovgal — 2003-12-08T11:11:07+00:00

URL: https://externals.io/message/6228#6283 · In reply to: #6282

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:
> > […]
> 
> 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

---

## #6284 — Thies C.Arntzen — 2003-12-08T11:23:32+00:00

URL: https://externals.io/message/6228#6284 · In reply to: #6283

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.

---

## #6286 — Antony Dovgal — 2003-12-08T14:53:04+00:00

URL: https://externals.io/message/6228#6286 · In reply to: #6284

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
