Re: Sudden increase in n_dead_tup with no corresponding insert/update/delete

2025-06-03 Thread David Rowley
On Wed, 4 Jun 2025 at 07:22, Matthew Tice wrote: > Tue 03 Jun 2025 07:13:11 PM UTC (every 1s) > n_dead_tup | 5038 > autoanalyze_count | 3078 > Tue 03 Jun 2025 07:13:12 PM UTC (every 1s) > n_dead_tup | 1290579 > autoanalyze_count | 3079 > I don't understand where this large

Re: Combining scalar and row types in RETURNING

2025-06-03 Thread Ray O'Donnell
On 03/06/2025 20:01, Adrian Klaver wrote: On 6/3/25 11:18, Ray O'Donnell wrote: On 03/06/2025 17:53, Tom Lane wrote: Thanks a million for the explanation, Tom - that makes sense. I tried what you suggested, with mixed results: (i) Running the MERGE as a stand-alone query, with just RETURNIN

Re: Combining scalar and row types in RETURNING

2025-06-03 Thread Tom Lane
"Ray O'Donnell" writes: > (iii) Running (ii) but with the order of the items in RETURNING reversed - >     ... returning t, merge_action() into m_new, m_action > - gave me a different error: > ERROR:  record variable cannot be part of multiple-item INTO list > LINE 53: m, merge_action() i

Sudden increase in n_dead_tup with no corresponding insert/update/delete

2025-06-03 Thread Matthew Tice
Hi all, While investigating some potential vacuum improvements to make to a table I happened to notice that one table (along with others) will suddenly increase the number of n_dead_tup reported in pg_stat_user_tables without a corresponding increase in the inserts, updates, or deletes. For in

Re: Combining scalar and row types in RETURNING

2025-06-03 Thread Adrian Klaver
On 6/3/25 11:18, Ray O'Donnell wrote: On 03/06/2025 17:53, Tom Lane wrote: Thanks a million for the explanation, Tom - that makes sense. I tried what you suggested, with mixed results: (i) Running the MERGE as a stand-alone query, with just RETURNING... , worked - I got a scalar and a row a

Re: Combining scalar and row types in RETURNING

2025-06-03 Thread Ray O'Donnell
On 03/06/2025 17:53, Tom Lane wrote: "Ray O'Donnell" writes: Can you combine scalar and row types in a RETURNING clause? I think so. declare     m_action text;     m_new_data record; begin     merge into my_table t     using (             ) s     on (t.id = s.id)     whe

Re: Combining scalar and row types in RETURNING

2025-06-03 Thread Tom Lane
"Ray O'Donnell" writes: > Can you combine scalar and row types in a RETURNING clause? I think so. > declare >     m_action text; >     m_new_data record; > begin >     merge into my_table t >     using ( >         >     ) s >     on (t.id = s.id) >     when matched then >         u

Combining scalar and row types in RETURNING

2025-06-03 Thread Ray O'Donnell
Can you combine scalar and row types in a RETURNING clause? My use-case is getting the results of a MERGE - I'd like to be able to capture both the action performed and the modified row, something like this (this is in a plpgsql function): declare     m_action text;     m_new_data record; beg

Re: current_role of caller of a DEFINER function

2025-06-03 Thread Dominique Devienne
On Wed, Jun 26, 2024 at 2:25 PM Dominique Devienne wrote: > On Wed, Jun 26, 2024 at 11:08 AM Laurenz Albe > wrote: > > On Wed, 2024-06-26 at 10:35 +0200, Dominique Devienne wrote: > > > So I have two questions: > > > 1) Is there any way to know the current_role of the caller of a > > > DEFINER f