Re: pg_dump && aggregate bug

Lists: Postg토토 핫SQL : Postg토토 핫SQL 메일 링리스트 : 2002-05-27 이후 PGSQL-BUGS 12:36
From: Mathieu Arnold <mat(at)mat(dot)cc>
To: pgsql-bugs(at)postgresql(dot)org
Subject: pg_dump && aggregate bug
Date: 2002-05-21 12:13:55
Message-ID: 2320161025.1021990435@andromede.reaumur.absolight.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Hi

I have :

CREATE FUNCTION "first_cat" (text,text) RETURNS text AS 'SELECT CASE WHEN
$1 IS NULL THEN $2 ELSE $1 END' LANGUAGE 'sql';

and :

CREATE AGGREGATE first ( BASETYPE = text, SFUNC = first_cat, STYPE = text);

when I dump my database, in the dump file, the aggregate becomes :

CREATE AGGREGATE first ( BASETYPE = text, SFUNC = first_cat, STYPE = text,
INITCOND = '' );

which is *not* the same as you may imagine...

To dump my database, I use :
pg_dump -c

and I use :
PostgreSQL 7.2.1 on i386-portbld-freebsd4.5, compiled by GCC 2.95.3

I believe it lies around lines 3860 - 3864 of src/bin/pg_dump/pg_dump.c,
but I don't find what's wrong with it.

--
Mathieu Arnold


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mathieu Arnold <mat(at)mat(dot)cc>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: pg_dump && aggregate bug
Date: 2002-05-21 14:19:35
Message-ID: 20451.1021990775@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Mathieu Arnold <mat(at)mat(dot)cc> writes:
> when I dump my database, in the dump file, the aggregate becomes :

> CREATE AGGREGATE first ( BASETYPE = text, SFUNC = first_cat, STYPE = text,
> INITCOND = '' );

Ooops. This seems to be fixed already in current sources, but I think
a back-patch to 7.2 may be warranted. Try this around line 1912:

agginfo[i].aggbasetype = strdup(PQgetvalue(res, i, i_aggbasetype));
- agginfo[i].agginitval = strdup(PQgetvalue(res, i, i_agginitval));
+ if (PQgetisnull(res, i, i_agginitval))
+ agginfo[i].agginitval = NULL;
+ else
+ agginfo[i].agginitval = strdup(PQgetvalue(res, i, i_agginitval));
agginfo[i].usename = strdup(PQgetvalue(res, i, i_usename));

regards, tom lane


From: Mathieu Arnold <mat(at)mat(dot)cc>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: pg_dump && aggregate bug
Date: 2002-05-27 12:36:08
Message-ID: 2839635289.1022510168@andromede.reaumur.absolight.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: Postg토토 핫SQL : Postg토토 핫SQL 메일 링리스트 : 2002-05-27 이후 PGSQL-BUGS 12:36

--On mardi 21 mai 2002 10:19 -0400 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Mathieu Arnold <mat(at)mat(dot)cc> writes:
>> when I dump my database, in the dump file, the aggregate becomes :
>
>> CREATE AGGREGATE first ( BASETYPE = text, SFUNC = first_cat, STYPE =
>> text, INITCOND = '' );
>
> Ooops. This seems to be fixed already in current sources, but I think
> a back-patch to 7.2 may be warranted. Try this around line 1912:
>
> agginfo[i].aggbasetype = strdup(PQgetvalue(res, i,
> i_aggbasetype)); - agginfo[i].agginitval = strdup(PQgetvalue(res,
> i, i_agginitval)); + if (PQgetisnull(res, i, i_agginitval))
> + agginfo[i].agginitval = NULL;
> + else
> + agginfo[i].agginitval = strdup(PQgetvalue(res, i,
> i_agginitval)); agginfo[i].usename = strdup(PQgetvalue(res, i,
> i_usename));
>
> regards, tom lane

worked, thanks.
I wonder if it could go into a possible 7.1.2 if there is one ? :)

--
Mathieu Arnold