Thread: pg_dump bug

pg_dump bug

From
jose soares
Date:
Hi,

I think I found a bug in pg_dump:
I created a table like:

CREATE TABLE ut (       Azienda                CHAR(16)    NOT NULL,       ragione_sociale     VARCHAR(45) NOT NULL,
  indirizzo                CHAR(40),       inizio_attivita         DATE DEFAULT CURRENT_DATE,       fine_attivita
   DATE       );
 

and pg_dump modify the structure table as:

\connect - postgres
CREATE TABLE "ut" (       "azienda" character(16) NOT NULL,       "ragione_sociale" character varying(45) NOT NULL,
 "indirizzo" character(40),       "inizio_attivita" date DEFAULT date( 'current'::datetime + '0
 
sec') NOT NULL,       "fine_attivita" date);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If I try to recreate the table I have this:
ERROR:  parser: parse error at or near "'"

Any ideas ?

José




Re: [HACKERS] pg_dump bugu

From
Bruce Momjian
Date:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi,
> 
> I think I found a bug in pg_dump:
> I created a table like:
> 
> CREATE TABLE ut (
>         Azienda                CHAR(16)    NOT NULL,
>         ragione_sociale     VARCHAR(45) NOT NULL,
>         indirizzo                CHAR(40),
>         inizio_attivita         DATE DEFAULT CURRENT_DATE,
>         fine_attivita           DATE
>         );
> 
> and pg_dump modify the structure table as:
> 
> \connect - postgres
> CREATE TABLE "ut" (
>         "azienda" character(16) NOT NULL,
>         "ragione_sociale" character varying(45) NOT NULL,
>         "indirizzo" character(40),
>         "inizio_attivita" date DEFAULT date( 'current'::datetime + '0
> sec') NOT NULL,
>         "fine_attivita" date);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Strange, but the query looks fine, and creates fine here in the current
sources.  We had a quoting bug in defaults at some point.  What version
are you using?

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] pg_dump bug

From
Oleg Bartunov
Date:
I confirm this bug for 6.5.3, Linux
Oleg

On Fri, 19 Nov 1999, jose soares wrote:

> Date: Fri, 19 Nov 1999 12:32:04 +0100
> From: jose soares <jose@sferacarta.com>
> To: hackers <pgsql-hackers@postgreSQL.org>
> Subject: [HACKERS] pg_dump bug
> 
> Hi,
> 
> I think I found a bug in pg_dump:
> I created a table like:
> 
> CREATE TABLE ut (
>         Azienda                CHAR(16)    NOT NULL,
>         ragione_sociale     VARCHAR(45) NOT NULL,
>         indirizzo                CHAR(40),
>         inizio_attivita         DATE DEFAULT CURRENT_DATE,
>         fine_attivita           DATE
>         );
> 
> and pg_dump modify the structure table as:
> 
> \connect - postgres
> CREATE TABLE "ut" (
>         "azienda" character(16) NOT NULL,
>         "ragione_sociale" character varying(45) NOT NULL,
>         "indirizzo" character(40),
>         "inizio_attivita" date DEFAULT date( 'current'::datetime + '0
> sec') NOT NULL,
>         "fine_attivita" date);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> If I try to recreate the table I have this:
> ERROR:  parser: parse error at or near "'"
> 
> Any ideas ?
> 
> JosИ
> 
> 
> 
> ************
> 

_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83



Re: [HACKERS] pg_dump bug

From
Tom Lane
Date:
jose soares <jose@sferacarta.com> writes:
> I think I found a bug in pg_dump:

It's not pg_dump's fault; it's just putting out what's in the system
tables, and "date( 'current'::datetime + '0 sec')" is how the 6.5.*
parser translates DEFAULT CURRENT_DATE.  (Which is inconsistent with
how it translates CURRENT_DATE in other contexts, but nevermind.)

The failure actually comes up because the 6.5.* parser can't cope with
"x::y"-style typecasts in default expressions; it translates them to
a syntactically invalid string.  CAST ... AS doesn't work either, BTW.

I have ripped out and rewritten all of that cruft for 7.0, which is why
it works now (more or less).  I dunno if it's worth trying to patch
around this particular bug in the default-handling code in 6.5.*.
It's got so many others :-(

Current sources still have a problem with this example, which is that
the default expression gets prematurely constant-folded:CREATE TABLE ut (d1 DATE DEFAULT CURRENT_DATE);
pg_dumps asCREATE TABLE "ut" (        "d1" date DEFAULT '11-19-1999'::date);
Drat.  I thought I'd taken care of that class of problems...
        regards, tom lane


Re: [HACKERS] pg_dump bug

From
Thomas Lockhart
Date:
> I confirm this bug for 6.5.3, Linux

Hmm. I'm running a more-or-less current development tree, and don't
see a problem (on Linux also). Does someone want to track it down??

Although Jose may have marked the line causing a problem, perhaps
someone can more explicitly identify the offending syntax?
                 - Thomas

> > I think I found a bug in pg_dump:
> > CREATE TABLE "ut" (
> >         "azienda" character(16) NOT NULL,
> >         "ragione_sociale" character varying(45) NOT NULL,
> >         "indirizzo" character(40),
> >         "inizio_attivita" date DEFAULT date( 'current'::datetime + '0
> > sec') NOT NULL,
> >         "fine_attivita" date);
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > If I try to recreate the table I have this:
> > ERROR:  parser: parse error at or near "'"

-- 
Thomas Lockhart                lockhart@alumni.caltech.edu
South Pasadena, California


Re: [HACKERS] pg_dump bug

From
Bruce Momjian
Date:
[Charset koi8-r unsupported, filtering to ASCII...]
> I confirm this bug for 6.5.3, Linux

OK, seems like it is only 6.5.* tree and not development tree, which
means development has a fix that was too risky for 6.5.*.  Seems user
will have to wait for 7.0.

> 
>     Oleg
> 
> On Fri, 19 Nov 1999, jose soares wrote:
> 
> > Date: Fri, 19 Nov 1999 12:32:04 +0100
> > From: jose soares <jose@sferacarta.com>
> > To: hackers <pgsql-hackers@postgreSQL.org>
> > Subject: [HACKERS] pg_dump bug
> > 
> > Hi,
> > 
> > I think I found a bug in pg_dump:
> > I created a table like:
> > 
> > CREATE TABLE ut (
> >         Azienda                CHAR(16)    NOT NULL,
> >         ragione_sociale     VARCHAR(45) NOT NULL,
> >         indirizzo                CHAR(40),
> >         inizio_attivita         DATE DEFAULT CURRENT_DATE,
> >         fine_attivita           DATE
> >         );
> > 
> > and pg_dump modify the structure table as:
> > 
> > \connect - postgres
> > CREATE TABLE "ut" (
> >         "azienda" character(16) NOT NULL,
> >         "ragione_sociale" character varying(45) NOT NULL,
> >         "indirizzo" character(40),
> >         "inizio_attivita" date DEFAULT date( 'current'::datetime + '0
> > sec') NOT NULL,
> >         "fine_attivita" date);
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > 
> > If I try to recreate the table I have this:
> > ERROR:  parser: parse error at or near "'"
> > 
> > Any ideas ?
> > 
> > Jos_
> > 
> > 
> > 
> > ************
> > 
> 
> _____________________________________________________________
> Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
> Sternberg Astronomical Institute, Moscow University (Russia)
> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
> phone: +007(095)939-16-83, +007(095)939-23-83
> 
> 
> ************
> 


--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: [HACKERS] pg_dump bug

From
Tom Lane
Date:
I wrote:
> Current sources still have a problem with this example, which is that
> the default expression gets prematurely constant-folded:
>     CREATE TABLE ut (d1 DATE DEFAULT CURRENT_DATE);
> pg_dumps as
>     CREATE TABLE "ut" (
>             "d1" date DEFAULT '11-19-1999'::date);
> Drat.  I thought I'd taken care of that class of problems...

Fixed in CVS.
        regards, tom lane