Attribute Macro pgx_macros::pgx

source ·
#[pgx]
Expand description

A helper attribute for various contexts.

Usage with #[pg_aggregate].

It can be decorated on functions inside a #[pg_aggregate] implementation. In this position, it takes the same args as #[pg_extern], and those args have the same effect.

Usage for configuring SQL generation

This attribute can be used to control the behavior of the SQL generator on a decorated item, e.g. #[pgx(sql = false)]

Currently sql can be provided one of the following:

  • Disable SQL generation with #[pgx(sql = false)]
  • Call custom SQL generator function with #[pgx(sql = path::to_function)]
  • Render a specific fragment of SQL with a string #[pgx(sql = "CREATE FUNCTION ...")]