Skip to content

Package CONSTANT/variable referenced more than once in an expression returns wrong value #1382

Closed

Description

@db-nikhil

Bug Report

A PL/iSQL package-qualified CONSTANT (or variable) can silently return the wrong value — either empty, or the leftover value of a completely unrelated local variable — when it is referenced more than once while a "simple expression" is being evaluated, particularly when the reference is on the right-hand side of an assignment to a variable that was already assigned earlier in the same block.

This is a correctness bug in the core PL/iSQL engine (src/pl/plisql/src/pl_exec.c), not specific to any one package — it reproduces with any freshly-created package that exposes a VARCHAR2 constant.

Reported-by: Yasir Hussain Shah [email protected]

IvorySQL Version

IvorySQL master branch

OS Version (uname -a)

Configuration options ( config.status --config )

Current Behavior

NOTICE: Line 1
Line 2
NOTICE: Line 3Line 1
Line 2Line 4

Expected behavior/code

NOTICE: Line 1
Line 2
NOTICE: Line 3
Line 4

Step to reproduce

SET ivorysql.compatible_mode = oracle;

CREATE OR REPLACE PACKAGE my_test_pkg AS
my_const CONSTANT VARCHAR2(2) := chr(13) || chr(10);
END my_test_pkg;
/

DO $$
DECLARE
l_message VARCHAR2(100);
v_crlf VARCHAR2(2) := my_test_pkg.my_const;
BEGIN
l_message := 'Line 1' || v_crlf || 'Line 2';
RAISE NOTICE '%', l_message;
l_message := 'Line 3' || my_test_pkg.my_const || 'Line 4';
RAISE NOTICE '%', l_message;
END;
$$;

Additional context that can be helpful for identifying the problem

Activity

  1. added
    bug
    on Jul 7, 2026
  2. added 2 commits that reference this issue on Jul 7, 2026
    6fb45e7
    3363aae
  3. bigplaice commented on Jul 7, 2026

    @bigplaice
    Collaborator

    Thanks for reporting this bug! I can reproduce it on my machine.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions