Re: My Object able solution.....?? - Mailing list pgsql-hackers

From Dave Cramer
Subject Re: My Object able solution.....??
Date
Msg-id 010701c1c9dc$6141b9d0$807ba8c0@inspiron
Whole thread Raw
In response to My Object able solution.....??  (alex@AvengerGear.com (Debian User))
List pgsql-hackers
Alex,

There are quite a few object-relation api's available for java that work
with postgres. The most popular being castor, but another lesser known
is sourceforg.net/projects/player

I'm still not sure how you intend to solve one to many object mapping
with this?

Dave

-----Original Message-----
From: pgsql-hackers-owner@postgresql.org
[mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Debian User
Sent: Tuesday, March 12, 2002 9:57 AM
To: pgsql-hackers@postgresql.org
Subject: [HACKERS] My Object able solution.....??


Here is my short hack for the object reference ( tuple ) return 
as int4 function. 


Datum   spycastoid(PG_FUNCTION_ARGS);
Datum   spycastoidbyname(PG_FUNCTION_ARGS);

/* Composite types */

PG_FUNCTION_INFO_V1(spycastoid);

Datum
spycastoid(PG_FUNCTION_ARGS)
{ TupleTableSlot *t = (TupleTableSlot *) PG_GETARG_POINTER(0); int32   slot = PG_GETARG_INT32(1); int32   myid;
 bool    isnull; myid = DatumGetInt32(GetAttributeByNum(t, slot, &isnull)); if (isnull)   PG_RETURN_INT32(0);
 PG_RETURN_INT32(myid);
}

PG_FUNCTION_INFO_V1(spycastoidbyname);

Datum
spycastoidbyname(PG_FUNCTION_ARGS)
{ TupleTableSlot *t = (TupleTableSlot *) PG_GETARG_POINTER(0); text *slot = PG_GETARG_TEXT_P(1); int32   myid; bool
isnull;
 /*printf( "cast -->%s<----", slot+VARHDRSZ );*/
 myid = DatumGetInt32(GetAttributeByName(t, slot->vl_dat, &isnull)); if (isnull)   PG_RETURN_INT32(0);
 PG_RETURN_INT32(myid);
}

***************FUNCTION A******************************
CREATE FUNCTION spycastoid( table_has_other_object, int4) RETURNS int4 AS '/usr/lib/postgresql/lib/castfunc.so'
LANGUAGE'c';
 

***************FUNCTION A2******************************
CREATE FUNCTION castoid(table_has_other_object) RETURNS int4 AS 'select spycastoid($1, 1);'   <---colnum LANGUAGE
'sql';

***************FUNCTION B******************************
CREATE FUNCTION spycastoidbyname( table_has_other_object , text) RETURNS
int4 AS '/usr/lib/postgresql/lib/castfunc.so' LANGUAGE 'c';

***************FUNCTION B2*****************************
CREATE FUNCTION spycastoidbyname( table_has_other_object ) RETURNS int4 AS 'select spycastoidbyname( $1, \'colname\')'
LANGUAGE'sql';
 

so now at lease you can do 

select * from child where spycastoid(child, 1)=178120 or preset A2
select * from child where spycastoid(child)=178120 select * from child
where spycastoidbyname(child, 'myfather')=178120 or preset B2 select *
from child where spycastoidbyname( child )=178120

There may be some bug in between. I'm not sure. When the tuple get by
name, 
something the string compare is not correct. Let me know if that work. I
really want to see some real object action in PostgreSQL I'm currently
building a Java API for all database to enable object-relation mapping
for rapid application development. Let me know if you want to talk about
this also. 

Alex 



---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster




pgsql-hackers by date:

Previous
From: mlw
Date:
Subject: pgbench consistency
Next
From: Lamar Owen
Date:
Subject: Zlib vulnerability heads-up.