АО
json_build_object('property', json_agg(property), 'value', json_agg(value)) AS app_config
возвращает мне "app_config":{
"key":[
"a",
"c"
],
"value":[
"b",
"d"
]
}Size: a a a
АО
json_build_object('property', json_agg(property), 'value', json_agg(value)) AS app_config
возвращает мне "app_config":{
"key":[
"a",
"c"
],
"value":[
"b",
"d"
]
}АО
CREATE OR REPLACE FUNCTION get_user_ext ()
RETURNS json
AS $$
SELECT
row_to_json(t) AS rowToJsont
FROM (
SELECT
users.id,
users.useraddress,
users.accounttype,
users.smartcard,
json_build_object('property', json_agg(property), 'value', json_agg(value)) AS app_config
FROM
users,
app_config
GROUP BY
users.id) t;
$$
LANGUAGE SQL;
И
CREATE OR REPLACE FUNCTION get_user_ext ()
RETURNS json
AS $$
SELECT
row_to_json(t) AS rowToJsont
FROM (
SELECT
users.id,
users.useraddress,
users.accounttype,
users.smartcard,
json_build_object('property', json_agg(property), 'value', json_agg(value)) AS app_config
FROM
users,
app_config
GROUP BY
users.id) t;
$$
LANGUAGE SQL;
s
МШ
ST
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";SELECT pg_reload_conf();uuid_generate_v4()?ERROR: syntax error at or near "uuid_generate_v4"Ð
{
"user_name":"name",
"user_address":"address",
"config": {
"key":"value",
"key":"value"
}
}ГА
YS
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";SELECT pg_reload_conf();uuid_generate_v4()?ERROR: syntax error at or near "uuid_generate_v4"ST
Z
СК
СК
ГА
СК
ЕЮ
AL
MC
create table test_plan_with_multifunction(id int );Я делаю самый информативный эксплэйн:
create function f_test_plan_with_multifunction_1() returns int as $$
insert into mchist.test_plan_with_multifunction(id) values (1) returning id;
$$ language sql;
CREATE OR REPLACE FUNCTION f_test_plan_with_multifunction_2(integer)
RETURNS integer
LANGUAGE plpgsql
AS $function$
begin
if $1 < 10 then
insert into test_plan_with_multifunction(id) select mchist.f_test_plan_with_multifunction_2($1 + 1);
end if;
return $1 * f_test_plan_with_multifunction_1();
end $function$
explain (analyze, costs, buffers, verbose) select f_test_plan_with_multifunction_2(1)Но он мне выдаёт только работу самой первой вызванной функции:
Result (cost=0.00..0.26 rows=1 width=4) (actual time=0.232..0.233 rows=1 loops=1)Что хотелось бы на этом сферическом примере: увидеть вызов всех вложенных f_test_plan_with_multifunction_2, как добавляется запись в таблицу test_plan_with_multifunction_2 в результате их работы.
Output: f_test_plan_with_multifunction_2(1)
Buffers: shared hit=9
Planning Time: 0.032 ms
Execution Time: 0.257 ms
SET auto_explain.log_nested_statements = ON;
SET auto_explain.log_min_duration = 0;
SET auto_explain.log_analyze = true;С
ST
DO
$do$
BEGIN
FOR value IN 'rub', 'usd' LOOP
....
end;
$do$
'rub', 'usd'