Denzo
01/21/2022, 9:50 AMexecute 3: with recursive pks_fks as ( -- pk + fk referencing col select conrelid as resorigtbl, unnest(conkey) as resorigcol from pg_constraint where contype IN ('p', 'f') union -- fk referenced col select confrelid, unnest(confkey) from pg_constraint where contype='f' ), views as ( select c.oid as view_id, n.nspname as view_schema, c.relname as view_name, r.ev_action as view_definition from pg_class c join pg_namespace n on n.oid = c.relnamespace join pg_rewrite r on r.ev_class = c.oid where c.relkind in ('v', 'm') and n.nspname = ANY($1 || $2) ), ...........
ziad
01/21/2022, 5:46 PMget_cosmos_userid
@DenzoDenzo
01/21/2022, 7:53 PMget_cosmos_userid()
is this:
sql
create or replace function public.get_cosmos_userid(email text, region text default 'us', lang text default 'en', currency text default 'usd')
returns jsonb
language sql
as $$
select content::json->'user'->'userId' as userId
from
http_post(
'https://example.tld',
'{
"email": "' || get_cosmos_userid.email || '",
"region": "' || coalesce(get_cosmos_userid.region, 'us') || '",
"language": "' || coalesce(get_cosmos_userid.lang, 'en') || '",
"currency": "' || coalesce(get_cosmos_userid.currency, 'usd') || '",
"domain": "example.tld"
}',
'application/json'
);
$$
ziad
01/21/2022, 8:11 PMziad
01/21/2022, 8:35 PMziad
01/21/2022, 8:36 PMziad
01/21/2022, 8:37 PMDenzo
01/21/2022, 9:53 PMhttp_post()
call directly within the trigger function to see whether the issue is simply something with regards to permissions and/or scope.Denzo
01/21/2022, 9:54 PMDenzo
01/21/2022, 9:54 PMziad
01/22/2022, 1:53 AMziad
01/22/2022, 1:53 AMgaryaustin
01/23/2022, 3:40 PMset search_path to public, extensions
to your function calling http_post as it is in the extensions schema and the session user might not have that path from a trigger depending on your settings.
I'm not sure just doing extensions.http_post is enough as it is a shell for http() and not sure it sets it's own search path or not.
But your error is not what I would expect for this versus a not found error.jason-lynx
01/24/2022, 6:39 AMget_cosmos_userid
, instead of referencing the parameters with e.g. get_cosmos_userid.email
, could you try using just the parameter name (e.g. just email
instead of get_cosmos_userid.email
) or positional value (e.g. $1
to reference the first parameter aka email
, $2
for region
...)?
not certain that this will help, but just in caseDenzo
01/24/2022, 8:42 AMDenzo
01/24/2022, 11:49 AMDenzo
01/24/2022, 11:52 AMsecurity definer set search_path to public, extensions
did the trick, although the latter might not have been necessaryDenzo
01/24/2022, 11:53 AMgaryaustin
01/24/2022, 2:28 PMDenzo
01/24/2022, 2:37 PMSteve
01/25/2022, 10:30 PMSteve
01/25/2022, 10:32 PMSteve
01/25/2022, 10:32 PMDenzo
01/25/2022, 10:47 PMget_cosmos_userid
method directly works fine from RPC, I haven't tried that with the trigger function itself though (is that even possible?)Denzo
01/25/2022, 10:48 PMgaryaustin
01/25/2022, 11:06 PMDenzo
01/26/2022, 9:57 AMhttp_post
call to some endpoint to fetch a user id from our old database to link new users to our old APIDenzo
01/26/2022, 9:59 AMSteve
01/26/2022, 10:17 PMgaryaustin
01/26/2022, 11:20 PM