Skip to content

Mixed positional and named parameters with variable fails: 'failed to find conversion function from unknown to varchar2' #1006

Closed

Description

@rophy

Bug Report

IvorySQL Version

PostgreSQL 18.0 (IvorySQL 5.0) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14+deb12u1) 12.2.0, 64-bit

Docker image: ivorysql/ivorysql:5.0-bookworm

OS Version (uname -a)

Linux 6.8.0-87-generic #88-Ubuntu SMP PREEMPT_DYNAMIC x86_64 GNU/Linux

Configuration options (config.status --config)

'--prefix=/var/local/ivorysql/ivorysql-5' '--enable-cassert' '--enable-debug' '--enable-rpath' '--with-tcl' '--with-python' '--with-gssapi' '--with-pam' '--with-ldap' '--with-openssl' '--with-libedit-preferred' '--with-uuid=e2fs' '--with-ossp-uuid' '--with-libxml' '--with-libxslt' '--with-perl' '--without-icu'

Current Behavior

When calling a package procedure using mixed positional and named parameters, if a named parameter value is a variable (not a literal), the call fails with:

ERROR:  failed to find conversion function from unknown to varchar2

Expected behavior/code

The procedure call should succeed. This is valid PL/SQL syntax and works correctly on Oracle Database.

Steps to reproduce

  1. Connect to IvorySQL on the Oracle-compatible port (1521)

  2. Create the following package:

CREATE OR REPLACE PACKAGE test_named_param IS
  PROCEDURE proc_with_defaults(
    p1 IN VARCHAR2,
    p2 IN VARCHAR2 DEFAULT NULL,
    p3 IN VARCHAR2 DEFAULT NULL
  );
END;
/

CREATE OR REPLACE PACKAGE BODY test_named_param IS
  PROCEDURE proc_with_defaults(
    p1 IN VARCHAR2,
    p2 IN VARCHAR2 DEFAULT NULL,
    p3 IN VARCHAR2 DEFAULT NULL
  ) IS
  BEGIN
    DBMS_OUTPUT.PUT_LINE('p1=' || p1 || ', p2=' || p2 || ', p3=' || p3);
  END;
END;
/
  1. Try to call the procedure with mixed positional and named parameters using a variable:
DO $$
DECLARE
  v_val VARCHAR2(64) := 'hello';
BEGIN
  test_named_param.proc_with_defaults('a', p3=>v_val);
END;
$$ LANGUAGE plisql;
  1. Error occurs:
ERROR:  failed to find conversion function from unknown to varchar2
CONTEXT:  SQL statement "CALL test_named_param.proc_with_defaults('a', p3=>v_val)"
PL/iSQL function inline_code_block line 5 at CALL

What works vs what fails

Call Pattern IvorySQL Oracle
proc('a', 'b', 'c') ✅ Works ✅ Works
proc('a', p3=>'literal') ✅ Works ✅ Works
proc(p1=>'a', p2=>'b', p3=>v_val) ✅ Works ✅ Works
proc('a', p3=>v_val) ❌ FAILS ✅ Works

Workaround: Use all named parameters instead of mixing positional and named:

DO $$
DECLARE
  v_val VARCHAR2(64) := 'hello';
BEGIN
  -- This works:
  test_named_param.proc_with_defaults(p1=>'a', p2=>NULL, p3=>v_val);
END;
$$ LANGUAGE plisql;

Additional context that can be helpful for identifying the problem

  • The issue only occurs when mixing positional and named parameters AND the named parameter is a variable
  • Using all positional parameters works
  • Using all named parameters works
  • Using mixed parameters with literals works
  • The bug appears to be in how PL/iSQL resolves variable types when reordering/filling default parameters
  • Tested on Docker image ivorysql/ivorysql:5.0-bookworm
  • The same SQL executes correctly on Oracle Database 23c Free (container-registry.oracle.com/database/free:23.26.0.0-lite), confirming this is valid PL/SQL syntax

Activity

  1. jiaoshuntian commented on Dec 5, 2025

    @jiaoshuntian
    Collaborator

    Thank you for reporting this bug

  2. added theissue type on Dec 5, 2025
  3. added 17 commits that reference this issue on Dec 11, 2025
    6bb80c3
    3f7f70a
    b9976d0
    a985acc
    d16dd11
    f0bdd57
    003eb19
    8b63987
    eb65b27
    f91b5cc
    ef2fa06
    cb657bf
    539b622
    03106a4
    e4eda31
    ca64a75
    21bdd5f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions