質問

The main issue is that I want to audit user behavior (with triggers), but we are currently using connection pooling with our database, so don't have their username/id directly inside the db.

  1. I understand that there is an EXECUTE AS LOGIN function in MSSQL Server. Is there something similar in MySQL or Postgres?

  2. Do I have other options, other than auditing from the ORM and not the database?

Thanks!

役に立ちましたか?

解決

In PostgreSQL you can use SET ROLE or SET SESSION AUTHORIZATION but you must have the role already defined in the database.

You can choose which of them fits better your needs.

他のヒント

In addition to SET ROLE there is another possibly useful option SET APPLICATION_NAME. This doesn't have to be the application - as long as your app's usernames fit in 64 characters it's very useful for that.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top