attisdropped, * expansion and tg_trigtuple

Started by Nigel J. Andrewsalmost 23 years ago3 messagesgeneral
Jump to latest
#1Nigel J. Andrews
nandrews@investsystems.co.uk

In light of the recent discussion on * expansion and how dropped columns impact
on record and rowtype variables in plpgsql I thought I'd see if anyone knows of
hand the answer to:

If in a trigger one does a select * from the table the trigger is on is it safe
to assume that tg_trigtuple (and so tg_newtuple) will use the same TupleDesc as
that returned from the select *, i.e. the tg_relation->rd_att TupleDesc?

As I say, just thought I'd ask before I add code to my trigger to map one to
the other via attribute name not number.

--
Nigel J. Andrews

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Nigel J. Andrews (#1)
Re: attisdropped, * expansion and tg_trigtuple

"Nigel J. Andrews" <nandrews@investsystems.co.uk> writes:

If in a trigger one does a select * from the table the trigger is on
is it safe to assume that tg_trigtuple (and so tg_newtuple) will use
the same TupleDesc as that returned from the select *, i.e. the
tg_relation->rd_att TupleDesc?

Given recent discussions about decoupling logical and physical column
order, I'd think that assumption might blow up in your face in a version
or two. It's unsafe even today if the relation has dropped columns.

regards, tom lane

#3Nigel J. Andrews
nandrews@investsystems.co.uk
In reply to: Tom Lane (#2)
Re: attisdropped, * expansion and tg_trigtuple

On Thu, 19 Jun 2003, Tom Lane wrote:

"Nigel J. Andrews" <nandrews@investsystems.co.uk> writes:

If in a trigger one does a select * from the table the trigger is on
is it safe to assume that tg_trigtuple (and so tg_newtuple) will use
the same TupleDesc as that returned from the select *, i.e. the
tg_relation->rd_att TupleDesc?

Given recent discussions about decoupling logical and physical column
order, I'd think that assumption might blow up in your face in a version
or two. It's unsafe even today if the relation has dropped columns.

Thanks, that's what started me thinking about what I was doing and although I
added a check for attisdropped in my loop it still relies on the trigtuple and
the one returned from select * being the same.

Plus of course I wasn't thinking that at some stage that the logical order
might be changed since I'm not likely to do that, but then one never knows and
someone else might change it.

--
Nigel J. Andrews