Bug #842: pgplsql: IF-THEN-ELSIF-ELSE acts different from IF-THEN-ELSE IF

Поиск
Список
Период
Сортировка
От pgsql-bugs@postgresql.org
Тема Bug #842: pgplsql: IF-THEN-ELSIF-ELSE acts different from IF-THEN-ELSE IF
Дата
Msg-id 20021209153456.EC4CC475BEC@postgresql.org
обсуждение исходный текст
Ответы Re: Bug #842: pgplsql: IF-THEN-ELSIF-ELSE acts different from IF-THEN-ELSE IF  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
Jørn Cornelius Olsen (jco@cornelius-olsen.dk) reports a bug with a severity of 4
The lower the number the more severe it is.

Short Description
pgplsql: IF-THEN-ELSIF-ELSE acts different from IF-THEN-ELSE IF

Long Description
1) The 'boolean-expression' after 'ELSIF' always evaluates to FALSE. According to the manual IF-THEN-ELSIF-ELSE should
beformally equivalent to IF-THEN-ELSE-IF-THEN, yet the example code below shows differently. 

2) Also: There is no parse error if one omits 'THEN' after 'ELSIF boolean-expression' which leads me to believe that
ELSIFhas never been implemented. Yet there is not warning or error message nor any notices in the documentation. 

Apart from the above: Thanks for a great SQL!

Sample Code
*** For the record ***
select version();
                           version
-------------------------------------------------------------
 PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by GCC 2.96
(1 row)

*** Demonstration ***
> create function demo1() returns integer as '
begin
  if false then
    return 1;
  elsif true then
    return 2;
  else
    return 3;
  end if;
end;' language 'plpgsql';

> select demo1();

 demo1
-------
     3
(1 row)

create function demo2() returns integer as '
begin
  if false then
    return 1;
  else
    if true then
      return 2;
    else
      return 3;
    end if;
  end if;
end;' language 'plpgsql';

> select demo2();

 demo2
-------
     2
(1 row)


No file was uploaded with this report

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Bug #841: SET search_path in createdb -T ... and pgdump
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Bug #842: pgplsql: IF-THEN-ELSIF-ELSE acts different from IF-THEN-ELSE IF