Re: [PATCHES] Patch to pg_dump for NUMERIC. - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [PATCHES] Patch to pg_dump for NUMERIC.
Date
Msg-id 199905130234.WAA27395@candle.pha.pa.us
Whole thread Raw
In response to Patch to pg_dump for NUMERIC.  (Keith Parks <emkxp01@mtcc.demon.co.uk>)
List pgsql-hackers
Applied.


> Here's a small patch to cause pg_dump to emit the
> scale and precision for NUMERIC type column defs.
> 
> Keith.
Content-Description: pg_dump.c.patch

> *** src/bin/pg_dump/pg_dump.c.orig    Mon May 10 22:19:09 1999
> --- src/bin/pg_dump/pg_dump.c    Wed May 12 11:26:35 1999
> ***************
> *** 2671,2676 ****
> --- 2671,2680 ----
>       char            **parentRels;            /* list of names of parent relations */
>       int            numParents;
>       int            actual_atts;            /* number of attrs in this CREATE statment */
> +     int32            tmp_typmod;
> +     int            precision;
> +     int            scale;
> + 
>   
>       /* First - dump SEQUENCEs */
>       if (tablename)
> ***************
> *** 2747,2752 ****
> --- 2751,2768 ----
>                           {
>                               sprintf(q + strlen(q), "(%d)",
>                                       tblinfo[i].atttypmod[j] - VARHDRSZ);
> +                         }
> +                     }
> +                     else if (!strcmp(tblinfo[i].typnames[j], "numeric"))
> +                     {
> +                         sprintf(q + strlen(q), "numeric");
> +                         if (tblinfo[i].atttypmod[j] != -1)
> +                         {
> +                             tmp_typmod = tblinfo[i].atttypmod[j] - VARHDRSZ;
> +                             precision = (tmp_typmod >> 16) & 0xffff;
> +                             scale     = tmp_typmod & 0xffff;
> +                             sprintf(q + strlen(q), "(%d,%d)",
> +                                         precision, scale);
>                           }
>                       }
>                       /* char is an internal single-byte data type;


--  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
 


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] BUG? serials and primary keys (was Re: [INTERFACES] Bug in psql?)
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] backend dies suddenly after a lot of error messages