Skip to main content

Module section

Module section 

Source
Expand description

Wire format support for the embedded pgrx schema linker section.

This module owns the bytes we embed into the extension shared object and later decode from cargo-pgrx schema. That format is intentionally compact and const-friendly because the producer side runs through macro expansion into static linker-section entries, not through a normal runtime serializer.

Why this is a bespoke binary format instead of JSON:

  • the producer must be able to size each entry at compile time
  • the producer must emit raw bytes into a static item placed in a custom linker section
  • the metadata we serialize is exposed to macro expansion through associated consts such as SqlTranslatable::{ARGUMENT_SQL, RETURN_SQL}

JSON would make the decode side simpler, but it would not remove the hard part. We would still need a handwritten const-time encoder, plus escaping logic for strings, SQL snippets, paths, and error payloads. That is not a clear win over the current length-prefixed binary layout.

So the current design choice is:

  • keep the section format binary while the producer is const-time linker-section emission
  • keep the wire format logic centralized in this module instead of spreading it across macro emitters

If we ever move away from linker-section bytes and toward a normal build-time manifest artifact, that would be the right time to re-evaluate a serde-based format such as JSON.

Structs§

EntryReader
EntryWriter

Constants§

AGGREGATE_FINALIZE_READ_ONLY
AGGREGATE_FINALIZE_READ_WRITE
AGGREGATE_FINALIZE_SHAREABLE
AGGREGATE_PARALLEL_RESTRICTED
AGGREGATE_PARALLEL_SAFE
AGGREGATE_PARALLEL_UNSAFE
ARG_ERROR_BARE_U8
ARG_ERROR_DATUM
ARG_ERROR_NESTED_ARRAY
ARG_ERROR_NOT_VALID
ARG_ERROR_SET_OF
ARG_ERROR_SKIP_IN_ARRAY
ARG_ERROR_TABLE
ELF_SECTION_NAME
ENTITY_AGGREGATE
ENTITY_CUSTOM_SQL
ENTITY_ENUM
ENTITY_FUNCTION
ENTITY_HASH
ENTITY_ORD
ENTITY_SCHEMA
ENTITY_SENTINEL
ENTITY_TRIGGER
ENTITY_TYPE
EXTERN_ARG_COST
EXTERN_ARG_CREATE_OR_REPLACE
EXTERN_ARG_IMMUTABLE
EXTERN_ARG_NAME
EXTERN_ARG_NO_GUARD
EXTERN_ARG_PARALLEL_RESTRICTED
EXTERN_ARG_PARALLEL_SAFE
EXTERN_ARG_PARALLEL_UNSAFE
EXTERN_ARG_RAW
EXTERN_ARG_REQUIRES
EXTERN_ARG_SCHEMA
EXTERN_ARG_SECURITY_DEFINER
EXTERN_ARG_SECURITY_INVOKER
EXTERN_ARG_SHOULD_PANIC
EXTERN_ARG_STABLE
EXTERN_ARG_STRICT
EXTERN_ARG_SUPPORT
EXTERN_ARG_VOLATILE
EXTERN_RET_ITERATED
EXTERN_RET_NONE
EXTERN_RET_SET_OF
EXTERN_RET_TRIGGER
EXTERN_RET_TYPE
MACHO_SECTION_NAME
MACHO_SECTION_PATH
MACHO_SEGMENT_NAME
OPERATOR_CAST_ASSIGNMENT
OPERATOR_CAST_DEFAULT
OPERATOR_CAST_IMPLICIT
POSITIONING_REF_FULL_PATH
POSITIONING_REF_NAME
RESULT_ERR
RESULT_OK
RETURNS_ERROR_BARE_U8
RETURNS_ERROR_DATUM
RETURNS_ERROR_NESTED_ARRAY
RETURNS_ERROR_NESTED_SET_OF
RETURNS_ERROR_NESTED_TABLE
RETURNS_ERROR_SET_OF_CONTAINING_TABLE
RETURNS_ERROR_SET_OF_IN_ARRAY
RETURNS_ERROR_SKIP_IN_ARRAY
RETURNS_ERROR_TABLE_CONTAINING_SET_OF
RETURNS_ERROR_TABLE_IN_ARRAY
RETURNS_ONE
RETURNS_SET_OF
RETURNS_TABLE
SECTION_SENTINEL_ENTRY_LEN
SECTION_SENTINEL_MAGIC
SECTION_SENTINEL_PAYLOAD
SECTION_SENTINEL_PAYLOAD_LEN
SQL_DECLARED_ENUM
SQL_DECLARED_FUNCTION
SQL_DECLARED_TYPE
SQL_MAPPING_ARRAY
SQL_MAPPING_AS
SQL_MAPPING_COMPOSITE
SQL_MAPPING_NUMERIC
SQL_MAPPING_SKIP
TYPE_ORIGIN_EXTERNAL
TYPE_ORIGIN_THIS_EXTENSION

Functions§

argument_error_len
argument_sql_len
bool_len
bytes_len
decode_entities
decode_entity
entry_payloads
function_metadata_type_len
is_schema_section_name
list_len
opt_len
return_sql_len
returns_error_len
returns_len
schema_section_sentinel_entry
sql_array_mapping_len
sql_mapping_len
str_len
u8_len
u32_len