User defined type with text* field

Started by Ken Kalmost 25 years ago5 messagesgeneral
Jump to latest
#1Ken K
kenmail@telocity.com

Hi,

I am trying to create a user defined type with 2 fields
in it, a text* and an Oid. I am not sure what size to
use in the create type command. When I try variable
the back end core dumps. Are there any examples for
doing this sort of thing? Is it even doable?

Thanks,

Ken

#2Alex Pilosov
alex@pilosoft.com
In reply to: Ken K (#1)
Re: User defined type with text* field

Not yet. :)

The best way to do it currently is to create a table with these fields,
it'll create a type (with the same name as table) automatically.

Why'd you want to do that anyway?

On 30 Jun 2001, Ken K wrote:

Show quoted text

Hi,

I am trying to create a user defined type with 2 fields
in it, a text* and an Oid. I am not sure what size to
use in the create type command. When I try variable
the back end core dumps. Are there any examples for
doing this sort of thing? Is it even doable?

Thanks,

Ken

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Ken K (#1)
Re: User defined type with text* field

Ken K <kenmail@telocity.com> writes:

I am trying to create a user defined type with 2 fields
in it, a text* and an Oid. I am not sure what size to
use in the create type command. When I try variable
the back end core dumps. Are there any examples for
doing this sort of thing? Is it even doable?

You can't use any kind of pointer in a datatype --- what is it going to
point to? There's nothing it could point at that might live as long as
the datavalue on disk will.

You could embed a TEXT value into a larger varlena value, say

<total length word>
Oid
<text value here, beginning with its own length word>

regards, tom lane

#4Ken Kachnowich
khkachn@telocity.com
In reply to: Tom Lane (#3)
Re: User defined type with text* field

What I want to do is create a Serialize type for storing Java objects.
The text would be the class name and the Oid would point to the record
where the object is stored. I need the class name and not the Oid of the
table because of a problem I have with long class names (> 32
characters).

If I figure out how to make this a "varlena" value would variable then
work
for the length specification in the create type command?

Are there any examples of varlena user types I could look at?

Thanks,

Ken

Show quoted text

Ken K <kenmail@telocity.com> writes:

I am trying to create a user defined type with 2 fields
in it, a text* and an Oid. I am not sure what size to
use in the create type command. When I try variable
the back end core dumps. Are there any examples for
doing this sort of thing? Is it even doable?

You can't use any kind of pointer in a datatype --- what is it going to
point to? There's nothing it could point at that might live as long as
the datavalue on disk will.

You could embed a TEXT value into a larger varlena value, say

<total length word>
Oid
<text value here, beginning with its own length word>

regards, tom lane

#5Alex Pilosov
alex@pilosoft.com
In reply to: Ken Kachnowich (#4)
Re: Re: User defined type with text* field

On Sun, 1 Jul 2001, Ken Kachnowich wrote:

What I want to do is create a Serialize type for storing Java objects.
The text would be the class name and the Oid would point to the record
where the object is stored. I need the class name and not the Oid of the
table because of a problem I have with long class names (> 32
characters).

If I figure out how to make this a "varlena" value would variable then
work for the length specification in the create type command?

Bytea/varlena types do not have a length, they are unlimited-length (like
text).

Show quoted text

Are there any examples of varlena user types I could look at?

Thanks,

Ken

Ken K <kenmail@telocity.com> writes:

I am trying to create a user defined type with 2 fields
in it, a text* and an Oid. I am not sure what size to
use in the create type command. When I try variable
the back end core dumps. Are there any examples for
doing this sort of thing? Is it even doable?

You can't use any kind of pointer in a datatype --- what is it going to
point to? There's nothing it could point at that might live as long as
the datavalue on disk will.

You could embed a TEXT value into a larger varlena value, say

<total length word>
Oid
<text value here, beginning with its own length word>

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly