Thread: UPDATING and DELETING sub-classes

UPDATING and DELETING sub-classes

From
Ami Ganguli
Date:
I've tried posting this to pgsql-bugs with no response, so I thought I'd try
here (in case there's something silly I'm doing wrong).

I'm trying to use the DELETE and UPDATE commands to update both the parent
class (which is specfied in the query) and the sub-classes.  According to the
documentation the default behaviour is to include sub-classes and that's
exactly what I want.  Unfortunately it doesn't work:

If I do this:

create table parent ( a int );
create table child ( b int ) inherits (parent);
insert into child values ( 1, 2 );
update parent set a=3 where a=1;

The update does nothing.  I would expect it to update the record in the child
table.

What am I doing wrong?  If this is a bug, is there a workaround?

Thanks,
Ami.


Re: UPDATING and DELETING sub-classes

From
Tom Lane
Date:
Ami Ganguli <ami@ganguli.com> writes:
> I'm trying to use the DELETE and UPDATE commands to update both the parent
> class (which is specfied in the query) and the sub-classes.  According to the
> documentation the default behaviour is to include sub-classes and that's
> exactly what I want.  Unfortunately it doesn't work:

It sounds like you are reading the documentation on the website.
Unfortunately those pages are a snapshot of docs for current development
sources, not the prior release.  It happens that this is an area Chris
Bitmead has been changing recently --- 7.0.* and prior versions do NOT
behave that way.  AFAIK, delete/update don't work on subclasses at all
in 7.0.*.  The docs used to claim that "DELETE FROM parent*", etc,
was the way to do it, but that never worked.  You'll have to wait for
7.1 (or try current snapshot if you're brave).  Sorry.

            regards, tom lane

Re: UPDATING and DELETING sub-classes

From
ChristophSchmidt
Date:
I think you get only the structure of parent in child, nothing more.
parent :    a      - one column
child   :    a | b  - two column
you have two tables  the only benefit of inheritation in this case
is that you have to write less code.
Something similar to Domains.

(I am right ?)
cs

> I've tried posting this to pgsql-bugs with no response, so I thought I'd try
> here (in case there's something silly I'm doing wrong).
>
> I'm trying to use the DELETE and UPDATE commands to update both the parent
> class (which is specfied in the query) and the sub-classes.  According to the
> documentation the default behaviour is to include sub-classes and that's
> exactly what I want.  Unfortunately it doesn't work:
>
> If I do this:
>
> create table parent ( a int );
> create table child ( b int ) inherits (parent);
> insert into child values ( 1, 2 );
> update parent set a=3 where a=1;
>
> The update does nothing.  I would expect it to update the record in the child
> table.
>
> What am I doing wrong?  If this is a bug, is there a workaround?
>
> Thanks,
> Ami.

...

From
Boszormenyi Laszlo
Date:
Hi.

 I have created a database and a table in it with user 'postgres'. Then I
added a user with creatuser. Question is, how can I access the table with
the freshly created user? I get 'permission denied' now.

Thanks,
    Laszlo Boszormenyi


Re: UPDATING and DELETING sub-classes

From
Ami Ganguli
Date:
Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Ami Ganguli <ami@ganguli.com> writes:
> > Is there an ETA for 7.1?
>
> September or October or thereabouts ... see recent comments on
> other mailing lists.  We're trying to keep this release cycle
> fairly short.

Thanks.  I'll start using 7.1 in that case.  I need something stable by
October 2, but I'll gamble that I'll find a late Beta that's good enough
sometime in September.

Regards,
Ami.


Re: UPDATING and DELETING sub-classes

From
Ami Ganguli
Date:
Ami Ganguli <ami@ganguli.com> wrote:
> Thanks.  I'll start using 7.1 in that case.

Maybe I spoke too soon.  The July 7 build fails with:

    make[4]: *** No rule to make target `ipc/SUBSYS.o'.  Stop.

Is there a somewhat stable & buildable recent snapshot somewhere?

... Ami.