PGcat detection from code
olivierACRI opened this issue · 1 comments
olivierACRI commented
Is there a way to detect that we are connected to pgcat from the code (doing a special request that won't crash on a real database and will answer something different from pgcat)
tobyhede commented
You could use the intercept plugin to intercept your own SQL command and return a value.
From the example config:
[plugins.intercept.queries.0]
query = "select current_database() as a, current_schemas(false) as b"
schema = [["a", "text"], ["b", "text"]]
result = [["${DATABASE}", "{public}"]]
[plugins.intercept.queries.1]
query = "select current_database(), current_schema(), current_user"
schema = [
[
"current_database",
"text",
],
[
"current_schema",
"text",
],
[
"current_user",
"text",
],
]
result = [["${DATABASE}", "public", "${USER}"]]