[HACKERS] Function returning tuples.

From: markw(at)mohawksoft(dot)com (mlw)
To: news-list(dot)pgsql(dot)general(at)innominate(dot)de
Subject: [HACKERS] Function returning tuples.
Date: 2000-12-06 11:10:27
Message-ID: 3A2E1E40.A4522ACB@mohawksoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers


For an extension I am writing, I want to be able to write a function
that does this:

select * from table where field = textsearch(field, 'la bla bla', 10)
order by score(10);

I can currently do this:

create temp table search_results (key int, rank int);

select plpgsql_textsearch(....);

select * from table where field = search_results.key order by rank;

drop table search_results;

The plpgsql function calls textsearch and populates the table doing
inserts. As:

for pos in 0 .. count-1 loop
insert into search_result(key, rank)
values (search_key(handle,pos),
search_rank(handle,pos));
end loop;

Obviously, if I return a field type I force a table scan, if I return a
set of tuples postgres should be able to perform a join.

>From what I can see, it looks like I need to create a heap tuple, and
add tuples to it. Is this correct? It is also unclear how I should go
about this. Does anyone have any code that does this already?

If this is the wrong forum in which to ask this question, I apologize,
but I just can't see any clear way to do this.

--
http://www.mohawksoft.com

Browse pgsql-general by date

  From Date Subject
Next Message "Edmar Wiggers" 2000-12-06 11:58:39 RE: [HACKERS] Indexing for geographic objects?
Previous Message Hiroshi Inoue 2000-12-06 11:00:54 Re: [HACKERS] How to reset WAL enveironment

Browse pgsql-hackers by date

  From Date Subject
Next Message "Edmar Wiggers" 2000-12-06 11:58:39 RE: [HACKERS] Indexing for geographic objects?
Previous Message Hiroshi Inoue 2000-12-06 11:00:54 Re: [HACKERS] How to reset WAL enveironment