pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
calling a function within a view causes problems doing a pg_dumpall
2+ messages / 2 participants
[nested] [flat]

* calling a function within a view causes problems doing a pg_dumpall
@ 2001-05-07 08:28  juerg.rietmann@pup.ch
  0 siblings, 1 reply; 2+ messages in thread

From: juerg.rietmann@pup.ch @ 2001-05-07 08:28 UTC (permalink / raw)
  To: pgsql-sql

Hello

I need to transfer a db form one to another server. I wanted to do this
with pg_dumpall and psql -e ....

I isolated the problem in a view. When I call a self defined function
(buildstring) the problem occurs and when I remove this call pg_dumpall
works. Calling the view with select * from viewrzumfang works with and
without the function call.

I use postgresql 7.0 on SUSE Linux

Function :

CREATE FUNCTION buildString(bpchar) RETURNS text AS '
        DECLARE
                list           text;
                rec          record;
        BEGIN
        list := '''';
          FOR rec IN SELECT z_u_umfang FROM zylinder_umfang WHERE z_u_typ
= $1;
             list := list || text(rec.z_u_umfang) || '','';
          END LOOP;
          RETURN list;
        END;
' LANGUAGE 'plpgsql';

View that is not working :

SELECT rotation.r_code, rotation.r_name, rotation.r_z_typ,
(SELECT zylinder_typen.z_laenge FROM zylinder_typen WHERE
(zylinder_typen.z_typ = rotation.r_z_typ)) AS r_z_laenge,
(SELECT zylinder_typen.z_blaenge FROM zylinder_typen WHERE
(zylinder_typen.z_typ = rotation.r_z_typ)) AS r_z_blaenge,
(SELECT zylinder_typen.z_alaenge_l FROM zylinder_typen WHERE
(zylinder_typen.z_typ = rotation.r_z_typ)) AS r_z_alaenge_l,
(SELECT zylinder_typen.z_alaenge_r FROM zylinder_typen WHERE
(zylinder_typen.z_typ = rotation.r_z_typ)) AS r_z_alaenge_r,
(SELECT rtrim(buildstring(rotation.r_z_typ), ','::text) AS rtrim) AS
r_z_umfang FROM rotation;

View that is working :

SELECT rotation.r_code, rotation.r_name, rotation.r_z_typ,
(SELECT zylinder_typen.z_laenge FROM zylinder_typen WHERE
(zylinder_typen.z_typ = rotation.r_z_typ)) AS r_z_laenge,
(SELECT zylinder_typen.z_blaenge FROM zylinder_typen WHERE
(zylinder_typen.z_typ = rotation.r_z_typ)) AS r_z_blaenge,
(SELECT zylinder_typen.z_alaenge_l FROM zylinder_typen WHERE
(zylinder_typen.z_typ = rotation.r_z_typ)) AS r_z_alaenge_l,
(SELECT zylinder_typen.z_alaenge_r FROM zylinder_typen WHERE
(zylinder_typen.z_typ = rotation.r_z_typ)) AS r_z_alaenge_r,
FROM rotation;

Thanks for any help ... jr

============================================
PFISTER + PARTNER, SYSTEM - ENGINEERING AG
Juerg Rietmann
Grundstrasse 22a
6343 Rotkreuz
Switzerland

phone: +4141 790 4040
fax: +4141 790 2545
mobile: +4179 211 0315
============================================




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

* Re: calling a function within a view causes problems doing a pg_dumpall
@ 2001-05-07 14:53  Josh Berkus <josh@agliodbs.com>
  parent: juerg.rietmann@pup.ch
  0 siblings, 0 replies; 2+ messages in thread

From: Josh Berkus @ 2001-05-07 14:53 UTC (permalink / raw)
  To: juerg.rietmann@pup.ch; pgsql-sql

Juerg,

> I need to transfer a db form one to another server. I wanted to do
> this
> with pg_dumpall and psql -e ....

Have you tried just using pg_dump instead of pg_dumpall?  I understand
that there were a few bugs in pg_dumpall, and pg_dump will mean less
data to transfer.
 

> CREATE FUNCTION buildString(bpchar) RETURNS text AS '
>         DECLARE
>                 list           text;
>                 rec          record;
>         BEGIN
>         list := '''';
>           FOR rec IN SELECT z_u_umfang FROM zylinder_umfang WHERE
> z_u_typ
> = $1;
>              list := list || text(rec.z_u_umfang) || '','';
>           END LOOP;
>           RETURN list;
>         END;
> ' LANGUAGE 'plpgsql';

It would be nice to see the errors you're getting when you try to
restore.  Could it be as simple as the dump file trying to create the
view before the function?  Or plpgsql not being defined as a language on
the target server?

BTW, there is a better-performance way to do the same thing you're doing
with that function.  Please browse the list archives with a search for
'catenate' -- you'll find a discussion of custom aggregates which
concatinate strings.

-Josh



______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco



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


end of thread, other threads:[~2001-05-07 14:53 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-05-07 08:28 calling a function within a view causes problems doing a pg_dumpall juerg.rietmann@pup.ch
2001-05-07 14:53 ` Josh Berkus <josh@agliodbs.com>

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