pgsql: Fix an ancient logic error in plpgsql's exec_stmt_block: it

Поиск
Список
Период
Сортировка
От tgl@postgresql.org (Tom Lane)
Тема pgsql: Fix an ancient logic error in plpgsql's exec_stmt_block: it
Дата
Msg-id 20070208183755.EB4319FB2B2@postgresql.org
обсуждение исходный текст
Список pgsql-committers
Log Message:
-----------
Fix an ancient logic error in plpgsql's exec_stmt_block: it thought it could
get away with not (re)initializing a local variable if the variable is marked
"isconst" and not "isnull".  Unfortunately it makes this decision after having
already freed the old value, meaning that something like

   for i in 1..10 loop
     declare c constant text := 'hi there';

leads to subsequent accesses to freed memory, and hence probably crashes.
(In particular, this is why Asif Ali Rehman's bug leads to crash and not
just an unexpectedly-NULL value for SQLERRM: SQLERRM is marked CONSTANT
and so triggers this error.)

The whole thing seems wrong on its face anyway: CONSTANT means that you can't
change the variable inside the block, not that the initializer expression is
guaranteed not to change value across successive block entries.  Hence,
remove the "optimization" instead of trying to fix it.

Tags:
----
REL8_1_STABLE

Modified Files:
--------------
    pgsql/src/pl/plpgsql/src:
        pl_exec.c (r1.154.2.5 -> r1.154.2.6)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/pl/plpgsql/src/pl_exec.c.diff?r1=1.154.2.5&r2=1.154.2.6)

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

Предыдущее
От: tgl@postgresql.org (Tom Lane)
Дата:
Сообщение: pgsql: Rearrange use of plpgsql_add_initdatums() so that only the
Следующее
От: tgl@postgresql.org (Tom Lane)
Дата:
Сообщение: pgsql: Rearrange use of plpgsql_add_initdatums() so that only the