BUG #5757: PL/PGSQL composite variable field error reporting
The following bug has been logged online:
Bug reference: 5757
Logged by: Andrey Galkin
Email address: andvgal@gmail.com
PostgreSQL version: 9.0.1
Operating system: Debian unstable
Description: PL/PGSQL composite variable field error reporting
Details:
1. Create a variable of composite type in PL/PGSQL function
2. Try to reference not existing field of the variable in some statement,
like IF
3. Get "missing FROM-clause entry for table" error at runtime
The error is not very helpful. If it's possible please detect the
incorrectly referenced field at parsing/statement preparing time.
"Andrey Galkin" <andvgal@gmail.com> writes:
The following bug has been logged online:
Bug reference: 5757
Logged by: Andrey Galkin
Email address: andvgal@gmail.com
PostgreSQL version: 9.0.1
Operating system: Debian unstable
Description: PL/PGSQL composite variable field error reporting
Details:
1. Create a variable of composite type in PL/PGSQL function
2. Try to reference not existing field of the variable in some statement,
like IF
3. Get "missing FROM-clause entry for table" error at runtime
Please provide a complete test-case, not a vague description.
regards, tom lane
No problem, please find a simple test case with its execution result below:
-- ============================================================================
START TRANSACTION;
CREATE TYPE CompositeType AS (
existing_field TEXT
);
--
CREATE FUNCTION Bug_5757_test()
RETURNS VOID
AS $$
DECLARE
v_comp CompositeType;
BEGIN
IF v_comp.non_existing_field THEN
NULL;
END IF;
END;
$$
LANGUAGE plpgsql;
--
SELECT Bug_5757_test();
ROLLBACK;
-- ============================================================================
$ psql -q < pgbug5757.sql
ERROR: missing FROM-clause entry for table "v_comp"
LINE 1: SELECT v_comp.non_existing_field
^
QUERY: SELECT v_comp.non_existing_field
CONTEXT: PL/pgSQL function "bug_5757_test" line 4 at IF
-- ============================================================================
Andrey
2010/11/18 Tom Lane <tgl@sss.pgh.pa.us>
Show quoted text
"Andrey Galkin" <andvgal@gmail.com> writes:
The following bug has been logged online:
Bug reference: 5757
Logged by: Andrey Galkin
Email address: andvgal@gmail.com
PostgreSQL version: 9.0.1
Operating system: Debian unstable
Description: PL/PGSQL composite variable field error reporting
Details:1. Create a variable of composite type in PL/PGSQL function
2. Try to reference not existing field of the variable in some statement,
like IF
3. Get "missing FROM-clause entry for table" error at runtimePlease provide a complete test-case, not a vague description.
regards, tom lane
"Andrey G." <andvgal@gmail.com> writes:
CREATE FUNCTION Bug_5757_test()
RETURNS VOID
AS $$
DECLARE
v_comp CompositeType;
BEGIN
IF v_comp.non_existing_field THEN
NULL;
END IF;
END;
$$
LANGUAGE plpgsql;
OK, I did something about that. Thanks for the report!
regards, tom lane