D
D
DDwrt1002021-05-21 13:12:50
PostgreSQL
DDwrt100, 2021-05-21 13:12:50

Is it possible to save a copy of a query from a specific table?

UPD Good afternoon, a bug was found in the system being developed. When using the business logic method, a couple of tables in the database did not change their state correctly. So far, this is an isolated case, but what caused this behavior is not completely clear. At the same time, everything is clean in the system logs. For a better understanding of the picture, I would like to catch requests to the table, and compare with timestamps in the application. The option with the inclusion of general logging, I think, is not very good, since all requests to the database are poured there, plus you need to restart the database in order for them to work.
The question is, is it possible somehow to pull out table changes with the help of a trigger function? Preferably in the frame of the request. Or is there some other mechanism. What I like about trigger functions is that they can be hung on a specific table, and they do not require an instance restart.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2021-05-21
@DDwrt100

plus you need to restart the database to make them work

Why did you decide so?
At the moment the request is executed, nothing remains of the request text, it is parsed.

Right now. Carefully kept, tk. may be required for the same logging.
The currently executing client query can be retrieved from anywhere (including the trigger) by calling current_query() .
It is more convenient to log a specific table, yes, with a trigger.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question