Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oci8 returns OCI-Lob objects #5707

Open
tomaluca95 opened this issue Mar 1, 2019 · 6 comments
Open

oci8 returns OCI-Lob objects #5707

tomaluca95 opened this issue Mar 1, 2019 · 6 comments

Comments

@tomaluca95
Copy link

I'm using CI 3.1.10 and when I run a get against a database with the oci8 driver I have to manualy run ->load() against OCI-Lob objects.

I think this is a bug because DB_result must be driver-agnostic and this exposes how oci8 works.

Maybe can be an option to expose this beauvoir.

@tomaluca95
Copy link
Author

Also breaks the database session driver

@narfbg
Copy link
Contributor

narfbg commented Mar 5, 2019

I'm sorry, I haven't had access to an Oracle database in years and I can't test this. However, patches to the oci8 driver were my first contributions to CI and I would definitely remember a problem like this, so I must assume you're talking of something way more isolated than what it sounds like by your description - please provide an example.

Also, the session driver doesn't support oci8 and this is documented.

@tomaluca95
Copy link
Author

If there is a CLOB column is not returned as a string but as a OCI

I'm using an helper to workaround the issue

if (!function_exists('oci8_fix_result_array')) {

    function oci8_fix_result_array($data) {
        if (!is_null($data)) {
            foreach ($data as $ext_key => $item) {
                foreach ($item as $key => $value) {
                    if (is_object($value) && get_class($value) == "OCI-Lob") {
                        $data[$ext_key][$key] = $value->load();
                    }
                }
            }
        }
        return $data;
    }

}

Isn't good code but it works.

The session on oracle works with "data" varchar2(4000 BYTE) NULL in the schema

@narfbg
Copy link
Contributor

narfbg commented Mar 11, 2019

I see ... We've not paid any attention to LOBs indeed. This isn't exactly a bug, more like an unsupported feature due to our aim to support as many DB platoforms as possible - we don't implement features that only exist in one or two of them, because you're otherwise screwed in case you try to migrate to a database that doesn't have the feature in question.

In this case I think we can implement it regardless of that concern, but it also has to work in PDO_OCI. I found this link suggesting that we'd use stream_get_contents() (relying on an is_resource() check) or PDO::STRINGIFY_FETCHES there. Have you tried that or can you test it?

As for the sessions, again - Oracle is not supported; we only support MySQL and PostgreSQL there, due to advisory locks availability. It may appear to work, but it's not locking current state, which means concurrency problems and possible data corruption.
In hindsight, I should've made it to throw an exception in case someone tries to use another database. Maybe I'll change that for 3.2.0.

@tomaluca95
Copy link
Author

Unfortunately I can only test oci8 driver and not the PDO one, seems to me that they PDO OCI8 driver is no longer maintained and I can't get it to work on my setup.

@narfbg
Copy link
Contributor

narfbg commented Mar 13, 2019

OK, I guess we'll have to rely purely on its documentation then. However, this will also have to target 3.2.0 due to BC concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants