Here's a small patch to cause pg_dump to emit the
scale and precision for NUMERIC type column defs.

Keith.
Wed, 12 May 1999 20:27:21 +0100 (BST)
Keith Parks <emkxp01@mtcc.demon.co.uk>
Patch to pg_dump for NUMERIC.

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, Pennsylvania 19026

Wed, 12 May 1999 22:34:38 -0400 (EDT)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [PATCHES] Patch to pg_dump for NUMERIC.