From: | Jan Behrens <jbe-mlist(at)magnetkern(dot)de> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Allowed to return possibly TOASTed datums? |
Date: | 2024-12-14 13:28:27 |
Message-ID: | 20241214142827.fa730433d412246d424436e3@magnetkern.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I would like to implement a function that simply returns its argument
(for the unary plus operator of a custum data type).
Is it allowed to use the following function, assuming the data type is
TOASTable?
PG_FUNCTION_INFO_V1(mytype_pos);
Datum mytype_pos(PG_FUNCTION_ARGS) {
PG_RETURN_DATUM(GETARG_DATUM(0));
}
CREATE FUNCTION "mytype_pos"("mytype") RETURNS "mytype"
STRICT IMMUTABLE LANGUAGE c AS 'mylib.so', 'mytype_pos';
CREATE OPERATOR + (
rightarg = "mytype",
function = "mytype_pos"
);
Or do I need to always return a DETOASTed value? In addition to the
answer, I would like to know where I can find such information. It
seems to be difficult (for me) to find it in the source. Is there any
other documentation I can use, or any hints on WHERE in the source I
find more information about when to DETOAST and when not?
Also: Is my approach an idiomatic way to implement unary plus? Are there
pre-existing functions for that?
Many thanks in advance for your help and kind regards
Jan Behrens
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-12-14 17:01:49 | Re: Allowed to return possibly TOASTed datums? |
Previous Message | PopeRigby | 2024-12-13 22:00:16 | Re: Errors when restoring backup created by pg_dumpall |