Skip site navigation (1) Skip section navigation (2)

Re: HeapTuple->t_tableOid==0 after SPI_exec

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: achill(at)matrix(dot)gatewaynet(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: HeapTuple->t_tableOid==0 after SPI_exec
Date: 2003-10-03 14:43:36
Message-ID: 19369.1065192216@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-sql
achill(at)matrix(dot)gatewaynet(dot)com writes:
> When HeapTuple is populated by 
> SPI_exec("select * from foobar when id=667");
> tuple = SPI_tuptable->tvals[0] (id is PK and row with 667 exists)
> then tuple->t_tableOid is always 0.

The result of a SELECT is never a raw table tuple, not even when it's a
straight "select * from foo".  It's a constructed tuple that belongs to
no particular table --- which makes sense because in general it wouldn't
match any particular table's rowtype.

I think in 7.4 there may be an optimization that skips the tuple
projection step in this particular case, but if you can in fact see
t_tableOid in 7.4, it'd be an implementation artifact rather than
something we will promise to support in future.  The correct way if you
want to see tableoid is to select it:

	select tableoid,* from foobar where ...

and then extract it from the result using the usual field-access
routines.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Oleg BartunovDate: 2003-10-03 14:48:42
Subject: Re: Weird locking situation
Previous:From: Patrick WelcheDate: 2003-10-03 14:00:36
Subject: Re: ecpg doesn't compile (datetime.h/dtime_t)

pgsql-sql by date

Next:From: Tom LaneDate: 2003-10-03 15:03:19
Subject: Re: HeapTuple->t_tableOid==0 after SPI_exec
Previous:From: John B. ScaliaDate: 2003-10-03 13:18:44
Subject: Bug in psql - Postgresql 7.3.1?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group