Re: BUG #18774: Not the required output of the query used in the function(delete_from_table1) in postgresql9.4

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: BUG #18774: Not the required output of the query used in the function(delete_from_table1) in postgresql9.4
Дата
Msg-id CAKFQuwa+sb1aK+64rBHxqt6R2twi8CTned5_FzBTDu3z4oMk9Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #18774: Not the required output of the query used in the function(delete_from_table1) in postgresql9.4  (Rajni Bobal <rajnibobal@gmail.com>)
Список pgsql-bugs
On Thu, Jan 23, 2025 at 7:54 AM Rajni Bobal <rajnibobal@gmail.com> wrote:
Colname is variable here, it value should be replaced in param string ($1). 

Regardless of the specific characters it is replaced with the important point is that your first query introduces an identifier and the second a string literal.  This is why they behave differently.

There is no bug here - the queries are doing what they are supposed to.  The use of string literals makes the second filter always evaluate to true so long as at least one row is returned and the value of $1 is not null (in this case your where clause is "cmdid' IN ('cmdid', 'cmdid', ...)".  Thus it deletes all rows in the table.

David J.

В списке pgsql-bugs по дате отправления: