pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
HeapTuple->t_tableOid==0 after SPI_exec
4+ messages / 2 participants
[nested] [flat]

* HeapTuple->t_tableOid==0 after SPI_exec
@ 2003-10-03 12:56 achill@matrix.gatewaynet.com
  2003-10-03 14:43 ` Re: HeapTuple->t_tableOid==0 after SPI_exec Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: achill@matrix.gatewaynet.com @ 2003-10-03 12:56 UTC (permalink / raw)
  To: pgsql-sql


Hi,

i notice that when HeapTuple data are populated by a trigger
then the table oid can be retrieved from HeapTuple->t_tableOid.

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.

Is it a known issue??
Am i missing something?

-Achilleus




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: HeapTuple->t_tableOid==0 after SPI_exec
  2003-10-03 12:56 HeapTuple->t_tableOid==0 after SPI_exec achill@matrix.gatewaynet.com
@ 2003-10-03 14:43 ` Tom Lane <tgl@sss.pgh.pa.us>
  2003-10-03 15:04   ` Re: HeapTuple->t_tableOid==0 after SPI_exec achill@matrix.gatewaynet.com
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2003-10-03 14:43 UTC (permalink / raw)
  To: achill@matrix.gatewaynet.com; +Cc: pgsql-hackers@postgresql.org; pgsql-sql

achill@matrix.gatewaynet.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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: HeapTuple->t_tableOid==0 after SPI_exec
  2003-10-03 12:56 HeapTuple->t_tableOid==0 after SPI_exec achill@matrix.gatewaynet.com
  2003-10-03 14:43 ` Re: HeapTuple->t_tableOid==0 after SPI_exec Tom Lane <tgl@sss.pgh.pa.us>
@ 2003-10-03 15:04   ` achill@matrix.gatewaynet.com
  2003-10-03 15:03     ` Re: HeapTuple->t_tableOid==0 after SPI_exec Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: achill@matrix.gatewaynet.com @ 2003-10-03 15:04 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql

On Fri, 3 Oct 2003, Tom Lane wrote:

> 
> 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.

Thanx.

P.S.

are there gonna be changes in SPI or internal structs in 7.4?

> 
> 			regards, tom lane
> 

-- 
-Achilleus




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: HeapTuple->t_tableOid==0 after SPI_exec
  2003-10-03 12:56 HeapTuple->t_tableOid==0 after SPI_exec achill@matrix.gatewaynet.com
  2003-10-03 14:43 ` Re: HeapTuple->t_tableOid==0 after SPI_exec Tom Lane <tgl@sss.pgh.pa.us>
  2003-10-03 15:04   ` Re: HeapTuple->t_tableOid==0 after SPI_exec achill@matrix.gatewaynet.com
@ 2003-10-03 15:03     ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2003-10-03 15:03 UTC (permalink / raw)
  To: achill@matrix.gatewaynet.com; +Cc: pgsql-hackers@postgresql.org; pgsql-sql

achill@matrix.gatewaynet.com writes:
> are there gonna be changes in SPI or internal structs in 7.4?

No more than usual ;-).  You will need to recompile shared libraries,
but (in theory) source code changes shouldn't be needed.  You might want
to think about upgrading elog() calls to ereport() though.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2003-10-03 15:04 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-10-03 12:56 HeapTuple->t_tableOid==0 after SPI_exec achill@matrix.gatewaynet.com
2003-10-03 14:43 ` Tom Lane <tgl@sss.pgh.pa.us>
2003-10-03 15:04   ` achill@matrix.gatewaynet.com
2003-10-03 15:03     ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox