Skip to content

callfunc and callproc always send False for boolean IN #568

@jonesito

Description

@jonesito
  1. What versions are you using?

Oracle Database version: 19.14.0.0.0
platform.platform: macOS-15.7.3-arm64-arm-64bit
sys.maxsize > 2**32: True
platform.python_version: 3.12.11
oracledb.version: 3.4.2

  1. Is it an error or a hang or a crash?

Silent data corruption. No error is raised.

  1. What error(s) or behavior you are seeing?

In thin mode (async), both callfunc and callproc silently send False for boolean IN parameters regardless of the actual value. OUT parameters set by plsql directly decode correctly. Related, but for OUT: https://github.com/oracle/python-oracledb/issues/565

# callfunc
callfunc(bool_echo, bool, [True])  => False  (expected True)   # wrong
callfunc(bool_echo, bool, [False]) => False  (expected False)
callfunc(bool_always_true, bool)   => True   (expected True)    # hardcoded return works

# callproc
callproc(bool_echo_proc, in=True)  => out=False  (expected True)   # wrong
callproc(bool_echo_proc, in=False) => out=False  (expected False)
callproc(bool_always_true_proc)    => out=True    (expected True)   # hardcoded OUT works
  1. Does your application call init_oracle_client()?

No. Thin mode only (async).

  1. Include a runnable Python script that shows the problem.
import asyncio
import oracledb

async def main():
    pool = oracledb.create_pool_async(
        user="YOUR_USER", password="YOUR_PASS", dsn="YOUR_DSN",
        min=1, max=2,
    )
    async with pool.acquire() as conn:
        with conn.cursor() as cur:
            # -- callfunc bug --
            await cur.execute("""
                create or replace function bool_echo(v_flag boolean) return boolean as
                begin
                    return v_flag;
                end;
            """)
            result = await cur.callfunc("bool_echo", bool, [True])
            print(f"callfunc bool_echo(True) => {result}")  # False -- BUG
            assert result is True, f"Expected True, got {result}"

            # -- callproc bug --
            await cur.execute("""
                create or replace procedure bool_echo_proc(v_in boolean, v_out out boolean) as
                begin
                    v_out := v_in;
                end;
            """)
            in_var = cur.var(bool)
            in_var.setvalue(0, True)
            out_var = cur.var(bool)
            await cur.callproc("bool_echo_proc", [in_var, out_var])
            print(f"callproc bool_echo_proc(True) => {out_var.getvalue(0)}")  # False -- BUG
            assert out_var.getvalue(0) is True, f"Expected True, got {out_var.getvalue(0)}"

    await pool.close()

asyncio.run(main())

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions