November 29th, 2012, 04:56 PM
Display Last Login
I haven't been able to find any info on how to do something like this with Postgres.
I am looking for a way to configure Postgres such that when a user logs in (interactively, on the command line), the date/time of the last successful login (or number of unsuccessful logins since) gets printed to the screen.
I'm not sure if this is already a feature of Postgres, or if there is some sort of "welcome message" configuration, or if I need to create a trigger (can you make a login trigger?).
Is this sort of thing feasible with Postgres? I am using Postgres 9.1.6 in a Windows environment.
November 29th, 2012, 05:28 PM
I don't think this is possible.
PostgreSQL does not store the last login. You could enable logging the connections, but that would go into the logfile.
Additionally there is no way to e.g. have a trigger that is executed when someone logs in. So even if you had the information available (e.g. by parsing the logfile) there is no place where you could run that code.
I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
Tips on how to ask better questions: