Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PGcat detection from code #724

Open
olivierACRI opened this issue Apr 19, 2024 · 1 comment
Open

PGcat detection from code #724

olivierACRI opened this issue Apr 19, 2024 · 1 comment

Comments

@olivierACRI
Copy link

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
Copy link
Contributor

tobyhede commented May 5, 2024

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}"]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants