CREATE TYPE pdf; CREATE FUNCTION pdf_in(cstring) RETURNS pdf IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME'; CREATE FUNCTION pdf_out(pdf) RETURNS cstring IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME'; CREATE TYPE pdf ( INTERNALLENGTH = -1, INPUT = pdf_in, OUTPUT = pdf_out, STORAGE = extended ); CREATE CAST (pdf AS text) WITH INOUT AS ASSIGNMENT; CREATE CAST (text AS pdf) WITH INOUT AS ASSIGNMENT; /* API */ CREATE FUNCTION pdf_title(pdf) RETURNS TEXT IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME'; CREATE FUNCTION pdf_author(pdf) RETURNS TEXT IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME'; CREATE FUNCTION pdf_num_pages(pdf) RETURNS INTEGER IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME'; CREATE FUNCTION pdf_page(pdf, integer) RETURNS TEXT IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME'; CREATE FUNCTION pdf_creator(pdf) RETURNS TEXT IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME'; CREATE FUNCTION pdf_keywords(pdf) RETURNS TEXT IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME'; CREATE FUNCTION pdf_metadata(pdf) RETURNS TEXT IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME'; CREATE FUNCTION pdf_version(pdf) RETURNS TEXT IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME'; CREATE FUNCTION pdf_subject(pdf) RETURNS TEXT IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME'; CREATE FUNCTION pdf_creation(pdf) RETURNS TIMESTAMP IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME'; CREATE FUNCTION pdf_modification(pdf) RETURNS TIMESTAMP IMMUTABLE STRICT LANGUAGE C AS 'MODULE_PATHNAME'; CREATE FUNCTION bytea_to_pdf(bytea) RETURNS pdf LANGUAGE C IMMUTABLE STRICT AS 'MODULE_PATHNAME'; CREATE FUNCTION pdf_to_bytea(pdf) RETURNS bytea LANGUAGE C IMMUTABLE STRICT AS 'MODULE_PATHNAME'; CREATE CAST (bytea AS pdf) WITH FUNCTION bytea_to_pdf(bytea) AS ASSIGNMENT; CREATE CAST (pdf AS bytea) WITH FUNCTION pdf_to_bytea(pdf) AS ASSIGNMENT; -------------------- CREATE FUNCTION pdf_read_file(text) RETURNS text LANGUAGE SQL IMMUTABLE STRICT AS 'SELECT $1::pdf::text'; CREATE FUNCTION pdf_read_bytes(bytea) RETURNS text LANGUAGE SQL IMMUTABLE STRICT AS 'SELECT $1::bytea::pdf::text';