Skip to content

Figure out what people actually use derive(PostgresType) for #1384

@workingjubilee

Description

@workingjubilee

A lot of programmers using pgrx seem to think derive(PostgresType) is required for some things. However, they aren't very clear on what those things are. For instance, they also think derive(Serialize, Deserialize) is required for implementing FromDatum and IntoDatum, but it is not! You can implement those by hand. My PR1 does propose to do away with that ability, leaving a gap for those who do use by-hand implementations that we should close before releasing 0.12.0.

Frankly, I myself am not entirely sure what derive(PostgresType) is actually... for? Not because I can't read the code, but because it does a lot of small things, currently, which are seemingly-needlessly coupled. I don't know which one was the "main point". It would be nice if we could work out a more consistent story for it.

We need

  • to figure out everything PostgresType does
    • it emits DDL for CREATE TYPE
    • it potentially implements JsonInOutFuncs
    • it potentially implements PgVarlenaInOutFuncs
    • it potentially implements FromDatum and IntoDatum
    • it may be overridden by InOutFuncs
    • it emits a bunch of #[pg_extern] functions for each of these cases
  • to figure out what parts of PostgresType do actually need to be coupled
  • to figure out if there's any use-cases we're missing
  • a substitute for derive(PostgresType) + impl {From,Into}Datum (sortof)
  • a substitute for derive(PostgresType) + impl InOutFuncs
  • a substitute for derive(PostgresType) + impl InOutFuncs + impl {From,Into}Datum

Footnotes

  1. https://github.com/pgcentralfoundation/pgrx/pull/1381

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions