RefLib

Reference library for AI

Back

postgresql_16:7.1.90.4 Examples

PostgreSQL 16 > Reference > SQL Commands > CREATE TRANSFORM > Examples

To create a transform for type hstore and language plpython3u, first set up the type and the language: CREATE TYPE hstore ...; CREATE EXTENSION plpython3u; Then create the necessary functions: CREATE FUNCTION hstore_to_plpython(val internal) RETURNS internal LANGUAGE C STRICT IMMUTABLE AS ...; CREATE FUNCTION plpython_to_hstore(val internal) RETURNS hstore LANGUAGE C STRICT IMMUTABLE AS ...; And finally create the transform to connect them all together: CREATE TRANSFORM FOR hstore LANGUAGE plpython3u ( FROM SQL WITH FUNCTION hstore_to_plpython(internal), TO SQL WITH FUNCTION plpython_to_hstore(internal) ); In practice, these commands would be wrapped up in an extension.

The contrib section contains a number of extensions that provide transforms, which can serve as real-world examples.

Back