postgres_output

The `postgres_output` directive specifies the output format for data returned from PostgreSQL queries.

Syntaxpostgres_output rds | text | value | binary_value | none;
Defaultrds
Contexthttp, server, location, if in location
Arguments1

Description

The postgres_output directive in the ngx_postgres module configures how the output from the PostgreSQL database is formatted. This directive accepts a single argument that determines the format of the response sent back to the client. The available formats include rds, which is a compatible format with the ngx_rds_json and ngx_drizzle modules, text, providing plaintext responses, value for single scalar return values, binary_value for binary data, and none, which disables output formatting entirely.

When set to rds, the output is structured in a way that facilitates easier integration with JSON-based processing modules in NGINX, making the integration smooth for modern web applications. Users can configure the output to adjust based on their application requirements. For instance, when textual data is required, text can be used, while value can be useful for queries expected to return scalar results only. The none option might be applied in scenarios where the output should not be processed at all, effectively passing through the raw data without transformations.

This directive can be defined in various contexts such as http, server, and location, allowing for granular control over the data output based on different routing or processing needs. It is crucial to ensure the output format aligns with the expectations of the consuming client or application to avoid misinterpretation of the returned data.

Config Example

location /query {
    postgres_pass my_back_end;
    postgres_query SELECT * FROM my_table;
    postgres_output json;
}

Using an unsupported output format may result in unexpected outcomes or errors.

Ensure the output format matches the consuming application's expectations to avoid data misinterpretation.

← Back to all directives