Please find attached a patch for pgbench that introduces a new auto-variable 'client_number'. Following in the footsteps of 'scale' auto-variable, this is not declared if the user has specified this variable using -D switch.
Since 'clientid' is a very common name a user can use for their own script's variable, I chose to call this auto-variable client_number; just to avoid conflicts.
This variable can come in handy when you want to use a different expression in a query depending on which client is executing it. An example custom transaction is attached, where the UPDATE statement from any given client always updates the same logical row.
Best regards,
--