Say I have a table with an id BIGSERIAL column. I just started a new session. I want to know what the id of the next row I insert will be. How can I tell this?
I can't simply SELECT MAX(id) FROM my_table (and return 1 if none found) because if I previously deleted things, the next id will not be 1 but will be higher.
I've already looked at other answers that use currval() and nextval(). They don't work unless I inserted within the current session... And I don't want to insert a row and see what ID I got, haha.
I'm about to lock the table and insert a lot of rows from a Python script on a client that is also keeping track of row IDs in a dictionary. The row IDs must match up, so I need to know what the first one will be. I'm surprised nobody else is dealing with this scenario.
Edit: I was wrong about the functions not working unless I inserted within the current session, but see the comments below.