You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Chris Darroch <ch...@apache.org> on 2016/02/25 23:51:44 UTC
[PATCH 59070, 59072] apr_dbd_oracle clob read bug
Hi --
I've added these as PRs 59070 and 59072 ... thanks in advance
to anyone who can take a quick look. Cheers,
Chris.
> It's been a very long time since I looked at the Oracle DB support
> in APR ... my apologies!
>
> I bumped into a bug recently (actually, in APR-util 1.5.x but it's
> also in APR trunk) where CLOBs are not readable due to a failed
> check on the val->type in dbd_oracle_get_entry() in dbd/apr_dbd_oracle.c.
>
> In the surrounding switch statement, val->type has been determined to
> be one of the Oracle SQLT_BLOB or SQLT_CLOB values. Then, to handle
> the CLOB case specifically, val->type is tested again but now it is
> incorrectly checked against APR_DBD_TYPE_CLOB instead of SQLT_CLOB.
>
> That always fails, so CLOBs are treated as BLOBs, insufficient
> space may be allocated, and then trouble ensues.
>
> The patch below has been running in production for a long time;
> I just never realized I hadn't reported it to the APR list. Again,
> my apologies!
>
>
> I also added a patch for the test/dbd.c which enables it to
> succeed on Oracle (at least, on our versions of Oracle). The trailing
> semicolons in the individual SQL INSERTs otherwise cause Oracle to
> issue an ORA-00911 "invalid character" error.
>
>
> I hope these are both relatively uncontroversial! Thanks very much,
>
> Chris.
>
> ===========================================================================
> --- dbd/apr_dbd_oracle.c.orig 2016-01-19 17:22:12.878414056 -0800
> +++ dbd/apr_dbd_oracle.c 2016-01-19 17:22:45.692414935 -0800
> @@ -1853,7 +1853,7 @@
> break;
> }
>
> - if (val->type == APR_DBD_TYPE_CLOB) {
> + if (val->type == SQLT_CLOB) {
> #if 1
> /* Is this necessary, or can it be defaulted? */
> sql->status = OCILobCharSetForm(dbd_oracle_env, sql->err,
> ===========================================================================
> --- test/dbd.c.orig 2016-01-19 17:21:45.370413319 -0800
> +++ test/dbd.c 2016-01-19 17:21:57.510413644 -0800
> @@ -69,11 +69,11 @@
> rv = apr_dbd_query(driver, handle, &nrows, statement);
> if (rv) {
> const char* stmt[] = {
> - "INSERT into apr_dbd_test (col1) values ('foo');",
> - "INSERT into apr_dbd_test values ('wibble', 'other', 5);",
> - "INSERT into apr_dbd_test values ('wibble', 'nothing', 5);",
> - "INSERT into apr_dbd_test values ('qwerty', 'foo', 0);",
> - "INSERT into apr_dbd_test values ('asdfgh', 'bar', 1);",
> + "INSERT into apr_dbd_test (col1) values ('foo')",
> + "INSERT into apr_dbd_test values ('wibble', 'other', 5)",
> + "INSERT into apr_dbd_test values ('wibble', 'nothing', 5)",
> + "INSERT into apr_dbd_test values ('qwerty', 'foo', 0)",
> + "INSERT into apr_dbd_test values ('asdfgh', 'bar', 1)",
> NULL
> };
> printf("Compound insert failed; trying statements one-by-one\n") ;
> ===========================================================================
>
>
--
GPG Key ID: 088335A9
GPG Key Fingerprint: 86CD 3297 7493 75BC F820 6715 F54F E648 0883 35A9