Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: operator is not unique: utils.ulid = utils.ulid in PG 16 #45

Open
kydemy-fran opened this issue May 22, 2024 · 1 comment
Open
Labels
C: operator Context: Operator D2: medium Difficulty: Medium to implement T: bug Type: Bug fix W: confirm Waiting: Needs confirmation Z: help wanted Z: Need help

Comments

@kydemy-fran
Copy link

We have installed the extension in a schema called utils:

CREATE SCHEMA utils;
CREATE EXTENSION ULID SCHEMA utils;

The function utils.gen_monotonic_ulid() works fine.

If I run the following query in postgresql 16.1:

SELECT CAST('01HTHV582X9B5YBFP7GRBWXRHX' AS utils.ulid) = CAST('01HTHV582X9B5YBFP7GRBWXRHX' AS utils.ulid)

Same result if we do:

SELECT utils.gen_monotonic_ulid() = utils.gen_monotonic_ulid();

I am getting the following error:

[2024-05-22 16:28:51] [42725] ERROR: operator is not unique: utils.ulid = utils.ulid
[2024-05-22 16:28:51] Hint: Could not choose a best candidate operator. You might need to add explicit type casts.

I have checked and I have the = operator defined in the DB for ulid types:

SELECT
    n.nspname,
    o.oprname,
    o.oprleft,
    o.oprright,
    o.oprresult,
    p.proname
FROM
    pg_operator o
        JOIN
    pg_namespace n ON o.oprnamespace = n.oid
        JOIN
    pg_proc p ON o.oprcode = p.oid
WHERE
    n.nspname = 'utils' AND oprname = '=';

Returns:

nspname oprname oprleft oprright oprresult proname
utils = 1403350 1403350 16 ulid_eq
utils = 1403766 1403766 16 geometry_eq
utils = 1404472 1404472 16 geography_eq

We are having that same error I reported when joining tables by ULID ids.

Thank you!

@pksunkara pksunkara added the Z: help wanted Z: Need help label May 22, 2024
@kydemy-fran
Copy link
Author

We have been able to circumvent this issue by casting to TExT, but other views / operators / functions that use operators fail.

For instance:

SELECT NULLIF(utils.gen_monotonic_ulid(),utils.gen_monotonic_ulid());

@pksunkara pksunkara changed the title Problems with joins in PG 16 ERROR: operator is not unique: utils.ulid = utils.ulid in PG 16 Sep 18, 2024
@pksunkara pksunkara added T: bug Type: Bug fix W: confirm Waiting: Needs confirmation D2: medium Difficulty: Medium to implement C: operator Context: Operator and removed D2: medium Difficulty: Medium to implement labels Sep 18, 2024
@pksunkara pksunkara pinned this issue Sep 18, 2024
@pksunkara pksunkara unpinned this issue Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: operator Context: Operator D2: medium Difficulty: Medium to implement T: bug Type: Bug fix W: confirm Waiting: Needs confirmation Z: help wanted Z: Need help
Projects
None yet
Development

No branches or pull requests

2 participants