-
-
Notifications
You must be signed in to change notification settings - Fork 308
Closed
Description
#[pg_extern]
fn single_column() -> TableIterator<'static, (name!(foo_col, String) /* name!(bar_col, String) */,)>
{
let mut out = vec![];
let foo = "foo".to_owned();
let bar = "bar".to_owned();
out.push((foo /*bar*/,));
TableIterator::new(out.into_iter())
}
# select * from single_column();
ERROR: return type must be a row type
Uncomment the reference to bar in two places and it works fine.
The workaround is to use SetOfIterator for single-column tables.
Rust also has a weird syntax issue that tripped me up for an hour. TableIterator needs a tuple type, but if you do something like this: out.push((foo)), the parentheses get ignored. You need the trailing comma: out.push((foo,)). This is a Rust thing, not a pgx thing, but a bit of documentation on it in https://github.com/tcdi/pgx/blob/master/pgx-examples/srf/src/lib.rs might save others some time.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels