Re: PQftable insufficient for primary key determination

From: mmc(at)maruska(dot)dyndns(dot)org (Michal =?iso-8859-2?q?Maru=B9ka?=)
To: pgsql-general(at)postgresql(dot)org
Subject: Re: PQftable insufficient for primary key determination
Date: 2004-07-20 06:38:11
Message-ID: m2fz7n6v58.fsf@linux11.maruska.tin.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> mmc(at)maruska(dot)dyndns(dot)org (Michal =?iso-8859-2?q?Maru=B9ka?=) writes:
>> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>>> The problem is you haven't said what it is you want to distinguish.
>
>> SELECT * from A, A ....
>
>> gives a result table like:
>
>> p | data | p |data |....
>> --------------------
>> 1 | xxx | 2 | yyy | ...
>
>
>> Now you edit the value 'yyy' and want to commit this change to the DB:
>
>> update A set data = 'zzz' where p = primary-key-value;
>
>> How to determine what to use for 'primary-key-value'? The value from the 1st
>> column (PQftable gives A) or from the 3rd column (PQftable gives A again)?
>
> I don't think this is a well-defined problem. What does the user think
> he's doing when he edits yyy of the join output? There may be multiple
> copies of that value in the output table, if the row that it came from
> joined to multiple rows in the other tables. In that case it would be
> impossible to alter a single field value without changing other rows of
> the displayed result. So at least in the general case, I don't think
> it makes sense to allow editing of fields of join results.
>
> If you have knowledge about the form of the query that's sufficient to
> guarantee that this problem won't occur, then I'd suggest taking another
> look at that knowledge and seeing if it doesn't offer a solution. But
> in the perfectly general form that you've stated the issue, I don't see
> a solution.

i have looked a bit at the comments in header files. I seem to understand, that
what i want is:

in SendRowDescriptionMessage() src/backend/access/common/printtup.c

when it does
pq_sendint(&buf, res->resorigtbl, 4);

i would like to add

Var *source = (Var*) ( ((TargetEntry *) lfirst(targetlist))->expr );

pq_sendint(&buf, source->varnoold, 4);

i should probably test if the ->expr is of type Var by looking at the NodeTag
type; But i don't have an idea what condition to test.

And of course i don't have an idea how to extend the protocol, to send this
value w/o breaking other things.

> regards, tom lane

hints, please ?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Anton Nikiforov 2004-07-20 08:19:55 PL/Ruby timestamp problem
Previous Message Chuck Bearden 2004-07-20 02:30:19 Re: Horology & stats tests fail in 7.4.3/RH 9