pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: danielb@megasystems.us
To: pgsql-bugs@postgresql.org
Subject: BUG #6128: A boolean variable doesn't evaluate properly in an IF conditional...
Date: Thu, 21 Jul 2011 18:48:28 GMT
Message-ID: <201107211848.p6LImSlt064768@wwwmaster.postgresql.org> (raw)


The following bug has been logged online:

Bug reference:      6128
Logged by:          
Email address:      danielb@megasystems.us
PostgreSQL version: 8.3
Operating system:   Windows XP
Description:        A boolean variable doesn't evaluate properly in an IF
conditional...
Details: 

I wrote some code in a PLPGSQL function to generate a printout string of
some information. Basically, I create a string of printed characters, which
my calling program will then print out...

I wrote an IF conditional to generate different printing based on what input
data I got...

I declared the variable "put_the_in_city_online boolean := false" in my
declaration section. I then had the following IF conditional inside a FOR
LOOP structure with a record variable called "rec"...

-- If the applicant has electric services, 
-- then we display a line indicating such...
IF (rec.has_electric = 'Y') THEN
  IF (put_the_in_city_online = FALSE) THEN
    application_page_01 := application_page_01 || 
      '  SERVICES: ELECTRIC   ' || 
      rec.electric_rate_category || '              ' 
      || rec.in_or_out_of_city || end_of_line;

          put_the_in_city_online := true;
  ELSE
    application_page_01 := application_page_01 || 
      '            ELECTRIC   ' ||
      rec.electric_rate_category || end_of_line;
  END IF;
END IF;

The bug occurs in the execution of these statements. I enter inside the
first IF statement no problem, but the 2nd IF statement executes the
opposite of what it should. The ELSE code is executing when the IF code
should be executing!

For some reason, POSTGRESQL does not evaluate ((put_the_in_city_online =
FALSE) = true) correctly. This statement is true, but corresponding
statements are not executed; the statements for ((put_the_in_city_online =
FALSE) = false) end up being executed!

I don't see any flaw in my logic. Postgresql doesn't seem to work correctly
based on logic!



view thread (3+ messages)  latest in thread

Message-ID: <201107211848.p6LImSlt064768@wwwmaster.postgresql.org>
Permalink:  ../201107211848.p6LImSlt064768@wwwmaster.postgresql.org/
Also on:    postgresql.org/message-id/201107211848.p6LImSlt064768@wwwmaster.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: danielb@megasystems.us
  Subject: Re: BUG #6128: A boolean variable doesn't evaluate properly in an IF conditional...
  In-Reply-To: <201107211848.p6LImSlt064768@wwwmaster.postgresql.org>
  References: <201107211848.p6LImSlt064768@wwwmaster.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox