Skip to content

Exception catch seems to fail (Dynamic linking error: cannot resolve symbol setTempRet0) #736

@hugoattal

Description

@hugoattal

Hello, I've stumbled across what seems to be a bug.
I wanted to use a function that safely cast something to something else.

Here's a simple minimal reproduction:

CREATE OR REPLACE FUNCTION safe_cast(text, anyelement) RETURNS anyelement AS $$
BEGIN
    $0 := $1;
    RETURN $0;
    EXCEPTION WHEN OTHERS THEN
        RETURN $2;
END;
$$ LANGUAGE plpgsql;

SELECT safe_cast('abc'::text, 42::numeric);

Here's a debug: 5 log in my app (in a bit more complex usecase):

Image

And the error in the playground: Dynamic linking error: cannot resolve symbol setTempRet0

You can test it here: https://pglite.dev/repl/

Here, it works as intented: https://onecompiler.com/postgresql/

Metadata

Metadata

Assignees

Labels

bug(compiler)emsdk/wasi-sdk compiler bug(s)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions