Обсуждение: pb when creating user type

Поиск
Список
Период
Сортировка

pb when creating user type

От
"abdelkrim"
Дата:
hello
I try to create a type complex, i generate a complex.so and when to insert
one complex into a table i have some problems
please help me


CREATE FUNCTION complex_out(opaque)  RETURNS opaque  AS '/usr/local/pgsql/complex.so'  LANGUAGE 'c';
CREATE

CREATE TYPE complex (  internallength = 16,  input = complex_in,  output = complex_out
);
CREATE


CREATE TABLE test_complex (       a       complex,       b       complex
);
CREATE

INSERT INTO test_complex VALUES ('(1.0, 2.5)', '(4.2, 3.55 )');
ERROR:  Can't find function complex_in in file /usr/local/pgsql/complex.so
ERROR:  Can't find function complex_in in file /usr/local/pgsql/complex.so
INSERT INTO test_complex VALUES ('(33.0, 51.4)', '(100.42, 93.55)');
ERROR:  Can't find function complex_in in file /usr/local/pgsql/complex.so
ERROR:  Can't find function complex_in in file /usr/local/pgsql/complex.so




RE: [INTERFACES] pb when creating user type

От
Craig Orsinger
Дата:
On 03-May-99 abdelkrim wrote:
> hello
> I try to create a type complex, i generate a complex.so and when to insert
> one complex into a table i have some problems
> please help me
> 
> 
> CREATE FUNCTION complex_out(opaque)
>    RETURNS opaque
>    AS '/usr/local/pgsql/complex.so'
>    LANGUAGE 'c';
> CREATE
> 
> CREATE TYPE complex (
>    internallength = 16,
>    input = complex_in,
>    output = complex_out
> );
> CREATE
> 
> 
> CREATE TABLE test_complex (
>         a       complex,
>         b       complex
> );
> CREATE
> 
> INSERT INTO test_complex VALUES ('(1.0, 2.5)', '(4.2, 3.55 )');
> ERROR:  Can't find function complex_in in file /usr/local/pgsql/complex.so
> ERROR:  Can't find function complex_in in file /usr/local/pgsql/complex.so
> INSERT INTO test_complex VALUES ('(33.0, 51.4)', '(100.42, 93.55)');
> ERROR:  Can't find function complex_in in file /usr/local/pgsql/complex.so
> ERROR:  Can't find function complex_in in file /usr/local/pgsql/complex.so
       The first question that occurs to me is, what version of 
PostgreSQL are you trying this with, and on what operating system?
       Second question: How did you generate the "complex.so"
library? You need to turn it into a shared library, which generally
requires that you first compile using a position independent code
option. With GNU utilities, it would go something like this:
       gcc -c -g -fpic -o complex.o complex.c       ld -Bshareable -o complex.so complex.o 
       Then of course, you'll have to copy it to the /usr/local/pgsql
directory (since your installation script looks for it there), and you
may have to make sure that you have read AND execute permissions set.
HPUX requires this, and other OSs may, as well.
       As near as I can tell, the commands you listed should work,
provided you've installed per my directions. If that's not the problem
then we'll need more information, I suspect.

----------------------------------
Date: 03-May-99  Time: 11:06:27

Craig Orsinger                  (email: <orsingerc@epg.lewis.army.mil>)
Logicon RDA
Bldg. 8B28                      "Just another megalomaniac with ideas above his
6th & F Streets                 station. The Universe is full of them."
Ft. Lewis, WA   98433                   - The Doctor
----------------------------------


RE: [INTERFACES] pb when creating user type

От
Craig Orsinger
Дата:
On 03-May-99 Craig Orsinger wrote:
>> hello
>> I try to create a type complex, i generate a complex.so and when to insert
>> one complex into a table i have some problems
>> please help me
>> 
>> 
>> CREATE FUNCTION complex_out(opaque)
>>    RETURNS opaque
>>    AS '/usr/local/pgsql/complex.so'
>>    LANGUAGE 'c';
>> CREATE
       Is this a test? If so, I failed. I don't see where you create your
'complex_in()' function. Is it in a part of a script you forgot to include
in your original post?
       Anyway, if that's the entire script, add a "CREATE FUNCTION"
statement for 'complex_in()' and it should work a lot better.

----------------------------------
Date: 03-May-99  Time: 11:32:36

Craig Orsinger                  (email: <orsingerc@epg.lewis.army.mil>)
Logicon RDA
Bldg. 8B28                      "Just another megalomaniac with ideas above his
6th & F Streets                 station. The Universe is full of them."
Ft. Lewis, WA   98433                   - The Doctor
----------------------------------