Getting relation/attribute names from inside UDT input/output function

Started by Humberto Luiz Razentealmost 20 years ago5 messagesgeneral
Jump to latest

Hello,

I wrote the UDT input/output functions for my complex type
and everything is working well.
But now, in the input function, I need to get the relation/attribute
names where a new object is being inserted.

PG_FUNCTION_INFO_V1(complex_in);
Datum complex_in(PG_FUNCTION_ARGS) {
char *arg1 = PG_GETARG_CSTRING(0);
char *relname = ???
char *attribname = ???
...
PG_RETURN_POINTER(result);
}

Does anybody have an idea of how I get that?

Thanks in advance

Humberto Razente
hlr@icmc.usp.br

#2Michael Fuhr
mike@fuhr.org
In reply to: Humberto Luiz Razente (#1)
Re: Getting relation/attribute names from inside UDT input/output function

On Wed, May 10, 2006 at 09:58:04AM -0300, Humberto Luiz Razente wrote:

I wrote the UDT input/output functions for my complex type
and everything is working well.
But now, in the input function, I need to get the relation/attribute
names where a new object is being inserted.

Why would the type's input function need to know that? What are
you trying to do?

--
Michael Fuhr

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Humberto Luiz Razente (#1)
Re: Getting relation/attribute names from inside UDT input/output function

"Humberto Luiz Razente" <hlr@icmc.usp.br> writes:

I wrote the UDT input/output functions for my complex type
and everything is working well.
But now, in the input function, I need to get the relation/attribute
names where a new object is being inserted.

Since, in general, there *is* no such place where the value would be
inserted, this is impossible. Consider

SELECT 'foo'::yourtype

Better rethink what you're trying to accomplish.

regards, tom lane

#4Michael Fuhr
mike@fuhr.org
In reply to: Humberto Luiz Razente (#1)
Re: Getting relation/attribute names from inside UDT input/output function

[Please copy the mailing list on replies so others can contribute
to and learn from the discussion.]

On Wed, May 10, 2006 at 02:50:26PM -0300, Humberto Luiz Razente wrote:

I'm trying to index data characteristics extracted from multimedia
files (like a color distribution histogram from an image), in
order to make k-nearest neighbor queries (similarity-based queries).
The problem is that I can have a variable number of characteristics (its
called adimensional features), so I cannot index with R-tree
like GIST. I already have the tree implemented in C, so I would
like to build a tree for each complex type in each
attribute/relation. Am I going in the wrong direction?

I'm not familiar with the problem domain but maybe somebody else
on the mailing list is. Could you explain a bit more, perhaps with
an example showing how you're currently using the type and what
you'd like to be able to do with it (e.g., a hypothetical table,
data set, query, and query result)?

--
Michael Fuhr

#5Martijn van Oosterhout
kleptog@svana.org
In reply to: Michael Fuhr (#4)
Re: Getting relation/attribute names from inside UDT input/output function

On Wed, May 10, 2006 at 09:12:33PM -0600, Michael Fuhr wrote:

On Wed, May 10, 2006 at 02:50:26PM -0300, Humberto Luiz Razente wrote:

I'm trying to index data characteristics extracted from multimedia
files (like a color distribution histogram from an image), in
order to make k-nearest neighbor queries (similarity-based queries).
The problem is that I can have a variable number of characteristics (its
called adimensional features), so I cannot index with R-tree
like GIST. I already have the tree implemented in C, so I would
like to build a tree for each complex type in each
attribute/relation. Am I going in the wrong direction?

I'm not familiar with the problem domain but maybe somebody else
on the mailing list is. Could you explain a bit more, perhaps with
an example showing how you're currently using the type and what
you'd like to be able to do with it (e.g., a hypothetical table,
data set, query, and query result)?

I'm not entirely sure, but this seems a similar issue to what tsearch
had (indexing documents). CVS HEAD has a new index type called GIN
(Generalised Inverted Index) which may be closer to your needs.

Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

From each according to his ability. To each according to his ability to litigate.