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

How to return an array of any dimenion from pl/rust function. #399

Open
thiru-baffle opened this issue Jan 3, 2024 · 0 comments
Open

How to return an array of any dimenion from pl/rust function. #399

thiru-baffle opened this issue Jan 3, 2024 · 0 comments

Comments

@thiru-baffle
Copy link

We are converting the UDFs from PL/PGSQL to PL/Rust.
The following pl/pgsql function accepts an array of bigint and returns an array of bytea.

  1. create function array_encrypt(xs anyarray) returns bytea[].

With this function, it can accept any dimension of an array and can return any dimension array by returning an array[[data::bytea][data2::bytea]].

To do this same thing in pl/rust, I have tried a few things as below:

  1. CREATE FUNCTION echo_array(a INT[]) RETURNS int[] STRICT LANGUAGE pl/rust AS -> it always expects the return type of Vec<Option>
  2. I have noticed that when the function argument is of array type, then pl/rust accepts it as Array<'_, i32>. So I tried

CREATE FUNCTION echo_fn_2(a INT[]) RETURNS Array<', i32> -> But failed to recognize the Array<',i32> type in pl/rust.

Could you help me, is there any options to achieve the above requirement in pl/rust?

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

No branches or pull requests

1 participant