see attachment

-- 
Christian Zagrodnick

gocept gmbh & co. kg - schalaunische strasse 6 - 06366 koethen/anhalt
fon. +49 3496 3099114
fax. +49 3496 3099118
mob. +49 173  9078826
mail [EMAIL PROTECTED]

If PostgreSQL failed to compile on your computer or you found a bug that
is likely to be specific to one platform then please fill out this form
and e-mail it to [EMAIL PROTECTED]

To report any other bug, fill out the form below and e-mail it to
[EMAIL PROTECTED]

If you not only found the problem but solved it and generated a patch
then e-mail it to [EMAIL PROTECTED] instead.  Please use the
command "diff -c" to generate the patch.

You may also enter a bug report at http://www.postgresql.org/ instead of
e-mail-ing this form.

============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name               :Christian Zagrodnick   
Your email address      :[EMAIL PROTECTED]


System Configuration
---------------------
  Architecture (example: Intel Pentium)         :Intel Pentium

  Operating System (example: Linux 2.0.26 ELF)  :Linux 2.4.18-686-smp

  PostgreSQL version (example: PostgreSQL-7.2.1):   PostgreSQL-7.2.1

  Compiler used (example:  gcc 2.95.2)          :gcc 2.95.4 (i think; i used the 
debian package)


Please enter a FULL description of your problem:
------------------------------------------------
I built a plpgsql function that behaves strange. Starting a new session it
works one time. Dumping the function in the same session again let it work as
it is supposed to.


Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible: 
----------------------------------------------------------------------

create table mystifier (
        rd int8 check (1::bool and 0::bool) -- table has to be empty
);

create or replace function mystify(int8) returns varchar as '
        DECLARE
                id ALIAS for $1;
                random int8;
                rec RECORD;
                newid varchar;
                qry varchar;
        BEGIN
        
        SELECT INTO rec * FROM mystifier;
        IF NOT FOUND THEN
                qry:=''SELECT (random()*500000000)::int8 as rd''; 
                FOR rec IN EXECUTE qry LOOP
                        random:=rec.rd;
                END LOOP;
                CREATE TEMP TABLE mystifier (rd int8);
                INSERT INTO mystifier VALUES (rec.rd);
                SELECT INTO rec * FROM mystifier;
        END IF; 
        
        random:=rec.rd;
                
        newid:=to_char(id#random,''0000000000000000000'');
        RETURN newid;
        END;
' language 'plpgsql';


chzeamt=> select * from mystifier ;
 rd 
----
(0 rows)

chzeamt=> select mystify(3);
       mystify        
----------------------
  0000000000147097331
(1 row)

chzeamt=> select mystify(3);
NOTICE:  Error occurred while executing PL/pgSQL function mystify
NOTICE:  line 15 at SQL statement
ERROR:  Relation 'mystifier' already exists

chzeamt=> create or replace function mystify(int8) returns varchar as '
.....

chzeamt=> select mystify(3);
       mystify        
----------------------
  0000000000147097331
(1 row)

chzeamt=> select mystify(3);
       mystify        
----------------------
  0000000000147097331
(1 row)

chzeamt=> select mystify(8);
       mystify        
----------------------
  0000000000147097336
(1 row)

chzeamt=> select mystify(8);
       mystify        
----------------------
  0000000000147097336
(1 row)

chzeamt=> \q
zagy@lisa:~> psql -U chzeamt chzeamt
chzeamt=> select mystify(46578);
       mystify        
----------------------
  0000000000287181363
(1 row)

chzeamt=> select mystify(46578);
NOTICE:  Error occurred while executing PL/pgSQL function mystify
NOTICE:  line 15 at SQL statement
ERROR:  Relation 'mystifier' already exists

chzeamt=> create or replace function mystify(int8) returns varchar as '
.....

chzeamt=> select mystify(46570);
       mystify        
----------------------
  0000000000287181355
(1 row)

chzeamt=> select mystify(46570);
       mystify        
----------------------
  0000000000287181355
(1 row)

... and so on. The function might be stupid, but well... ;-)


If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------




---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Reply via email to