Postgres C extension parallel aggregate, how to get worker id and row number?

162 views Asked by At

I am writing a Postgres C extension for a Parallel Aggregate function. Normally, in C or C++ I get my thread id and indexing of the work to be done, and then I can make sure the work can be done with no dependency and that the final result is always correct.

Absent getting an index (the row number on the table, not a postgres index) on the row I am operating on along with the worker id I cannot process anything with my aggregate function and guarantee correctness.

  1. Is there a way to get worker_id on postgres for parallel C aggregate extensions?
  2. Is there a way to get the row index/id/number from inside a C aggregate function without having to calculate it in SQL and pass it as a column to my function?

At least I know the worker ID exists, just don't know how to get it.

0

There are 0 answers