Re: BUG #18774: Not the required output of the query used in the function(delete_from_table1) in postgresql9.4
От | Rajni Bobal |
---|---|
Тема | Re: BUG #18774: Not the required output of the query used in the function(delete_from_table1) in postgresql9.4 |
Дата | |
Msg-id | CA+UiKXa4Gk4r1a-ZD4rrMsigxM=LTdnTmxDZCg8WV7avHGPPKA@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: BUG #18774: Not the required output of the query used in the function(delete_from_table1) in postgresql9.4
|
Список | pgsql-bugs |
Hello Sir/Team,
I have created a new bug report, #18776, with the updated problem statement. Kindly disregard bug #18774. Apologies for any inconvenience caused.
regards,
RAJNI BOBAL
On Thu, Jan 16, 2025 at 12:59 PM PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:
Bug reference: 18774
Logged by: Rajni Bobal
Email address: rajnibobal@gmail.com
PostgreSQL version: Unsupported/Unknown
Operating system: Ubuntu 22
Description:
The output or behavior of the query used in the function(delete_from_table1)
below is not producing the expected results, while
function(delete_from_table2) with its query produces the expected result
when used. ( Means all the data is deleted by the function
delete_from_table1, while data (based on wherecon condition) is deleted by
the function delete_from_table2.)
CREATE OR REPLACE FUNCTION delete_from_table1(tblname text, sel_tblname
text, wherecon text, colname text, batchsize int)
RETURNS void AS
$$
BEGIN
-- Construct dynamic SQL for DELETE
EXECUTE 'DELETE FROM '
|| quote_ident(tblname)
|| ' WHERE '
|| quote_ident(colname)
|| ' IN (SELECT '
|| quote_ident(colname)
|| ' FROM '
|| quote_ident(sel_tblname)
|| ' WHERE '
|| wherecon
|| ' LIMIT '
|| batchsize || ')';
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION delete_from_table2(tblname text, sel_tblname
text, wherecon text, colname text, batchsize int)
RETURNS void AS
$$
BEGIN
EXECUTE 'DELETE from ' || quote_ident(tblname) ||
' where $1 in (select $1 from ' || quote_ident(sel_tblname) ||
' where ' || wherecon || ' limit $2 ) '
USING colname, batchsize;
END;
$$ LANGUAGE plpgsql;
В списке pgsql-bugs по дате отправления: