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

Parameters don't line up with the names properly #111

Closed
jim-mlodgenski opened this issue Nov 9, 2022 · 4 comments · Fixed by #112
Closed

Parameters don't line up with the names properly #111

jim-mlodgenski opened this issue Nov 9, 2022 · 4 comments · Fixed by #112

Comments

@jim-mlodgenski
Copy link

When 2 of the same data type are passed in, the names don't match the ordinal number correctly.

CREATE OR REPLACE FUNCTION test(a int, b int) 
  RETURNS int AS 
$$
  Some(a.unwrap())
$$ LANGUAGE plrust;

=# select test(1, 2);
 test 
------
    2
(1 row)

@eeeebbbbrrrr
Copy link
Contributor

Woah.

Thanks for the report.

@workingjubilee
Copy link
Contributor

fwiw this test would be written the same as

CREATE OR REPLACE FUNCTION test(a int, b int) 
  RETURNS int AS 
$$
  a
$$ LANGUAGE plrust;

I have reproduced the error as a test and while my initial hypothesis was a problem in pgx, it seems to be unique to PL/Rust and the equivalent test in pgx passes fine.

@workingjubilee
Copy link
Contributor

...This appears to be a "Heisenbug", which may explain why we have not seen it before. That is, it does not seem to happen consistently, and the ordering that happens somehow can change when the functions are rebuilt and retested. It also seems to be exacerbated by simultaneously submitting multiple PL/Rust functions at once, but is not exclusive to that.

@workingjubilee
Copy link
Contributor

Ah. The lesson here is to never use HashMap (which is, by default, HashMap<K, V, RandomState>... i.e. the data is hashed with a random state seed selected upon creation of the HashMap) and expect a deterministic ordering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants