Patch to pg_dump for NUMERIC.
Started by Keith Parksover 26 years ago2 messages
Here's a small patch to cause pg_dump to emit the
scale and precision for NUMERIC type column defs.
Keith.
Attachments:
pg_dump.c.patchtext/plain; charset=us-ascii; name=pg_dump.c.patch; x-unix-mode=0644Download
*** 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;
Re: [PATCHES] 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