User defined function weirdness

From: Rodney McDuff <ccmcduff(at)its(dot)uq(dot)edu(dot)au>
To: pgsql-general(at)postgreSQL(dot)org
Subject: User defined function weirdness
Date: 1999-03-26 06:11:49
Message-ID: 199903260611.QAA24083@its.uq.edu.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi
On postgresql 6.4.2 running on digital unix 4.0d. This bit of code

--------- pfunc.c-----------
/*
cc -c -I/usr/local/pgsql/include pfunc.c
ld -shared -expect_unresolved '*' -o pfunc.so pfunc.o
cc -o pfunc -I/usr/local/pgsql/include pfunc.c

create function int10() returns int4 as '/path/pfunc.so' LANGUAGE 'c';
create function float10() returns float4 as '/path/pfunc.so' LANGUAGE 'c';

select int10(),10::int4,float10(),10::float4;

*/
#include <stdio.h>
#include "postgres.h" /* for char16, etc. */

int4 int10() {
return (int4) 10;
}

float4 float10() {
return (float4) 10.0;
}
----------------------------

does

dbase=> select int10(),10,float10(),10.0;
int10|?column?|float10|?column?
-----+--------+-------+--------
10| 10|2.27828| 10
(1 row)

dbase=> select int10(),10,float10(),10.0;
int10|?column?|float10|?column?
-----+--------+-------+--------
10| 10|2.27812| 10
(1 row)

Note that float10() gives different answers at different times.

--

+-----------------+------------------------------------------+
| _ ^ _ | Dr. Rodney McDuff |
| |\ /|\ /| | Network Development, ITS |
| \ | / | The University of Queensland |
| \ | / | St. Lucia, Brisbane |
| \|/ | Queensland, Australia. 4072. |
|<-------+------->| TELEPHONE: +61 7 3365 8220 |
| /|\ | FACSIMILE: +61 7 3365 4477 |
| / | \ | EMAIL: mcduff(at)its(dot)uq(dot)edu(dot)au |
| / | \ | |
| |/ \|/ \| | Ex ignorantia ad sapientiam |
| - v - | Ex luce ad tenebras |
+-----------------+------------------------------------------+

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Guenter 1999-03-26 06:16:56 Unique indices and inheritance
Previous Message The Hermit Hacker 1999-03-26 03:40:52 Re: [GENERAL] Postgres logo, copyrights, etc...