Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] Bug and Patch for dump/restore of varchars

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: cobrien(at)access(dot)digex(dot)net (Cary B(dot) O'Brien)
Cc: pgsql-hackers(at)postgreSQL(dot)org, pgsql-patches(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Bug and Patch for dump/restore of varchars
Date: 1998-10-12 02:06:20
Message-ID: 199810120206.WAA29396@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Applied


> 
> OK, i finally got some time.  I know I should have gotten
> this out long ago
> 
> I had three actual bugs I had to fix with 6.3.1 for our
> production application.  
> 
> 1) can't enter float .001  (FIXED)
> 2) Can't dump/restore varchar fields (See attached bug report/patch)
> 3) Problems with tcl interface, storing/retrieving lists  (under discussion)
> 
> Is this the right fix?  How do I get the patch applied?  
> I haven't supplied patches before.  The patch is against
> the latest snapshot.
> 
> -- cary
> 
> Bug report, can't restore varchar fields
> ---------------------------------------
> 
> Version:  postgresql snapshot dated oct 9 (well, that's when I downloaded it).
> 
> Problem:  Pg dump dumps varchar fields as varchar(-5).
> 
> cary=> create table fred (id int, name varchar, salary float);
> CREATE
> cary=> \q
> [cary(at)jason new]$ pg_dump cary -t fred > /tmp/fred.sql
> [cary(at)jason new]$ cat /tmp/fred.sql
> CREATE TABLE "fred" ("id" "int4", "name" varchar(-5), "salary" "float8");
> COPY "fred" FROM stdin;
> \.
> [cary(at)jason new]$ psql < /tmp/fred.sql
> CREATE TABLE "fred" ("id" "int4", "name" varchar(-5), "salary" "float8");
> ERROR:  parser: parse error at or near "-"
> COPY "fred" FROM stdin;
> EOF
> 
> Solution:  fix pg_dump
> ---------------------------------------- start patch ----------------------
> [cary(at)jason pg_dump]$ rcsdiff -C 5 pg_dump.c
> ===================================================================
> RCS file: RCS/pg_dump.c,v
> retrieving revision 1.1
> diff -C 5 -r1.1 pg_dump.c
> *** pg_dump.c	1998/10/10 11:24:22	1.1
> --- pg_dump.c	1998/10/10 11:34:47
> ***************
> *** 2647,2660 ****
>   						sprintf(q, "%s%s%s %s",
>   								q,
>   								(actual_atts > 0) ? ", " : "",
>   								fmtId(tblinfo[i].attnames[j]),
>   								tblinfo[i].typnames[j]);
> ! 
> ! 						sprintf(q, "%s(%d)",
>   								q,
>   								tblinfo[i].atttypmod[j] - VARHDRSZ);
>   						actual_atts++;
>   					}
>   					else
>   					{
>   						strcpy(id1, fmtId(tblinfo[i].attnames[j]));
> --- 2647,2664 ----
>   						sprintf(q, "%s%s%s %s",
>   								q,
>   								(actual_atts > 0) ? ", " : "",
>   								fmtId(tblinfo[i].attnames[j]),
>   								tblinfo[i].typnames[j]);
> ! 						if(tblinfo[i].atttypmod[j] != -1) {
> ! 						        sprintf(q, "%s(%d)",
>   								q,
>   								tblinfo[i].atttypmod[j] - VARHDRSZ);
> + 						}
> + 						else {
> + 						        sprintf(q, "%s", q);
> + 						}
>   						actual_atts++;
>   					}
>   					else
>   					{
>   						strcpy(id1, fmtId(tblinfo[i].attnames[j]));
> ---------------------- end of patch ------------------------------------------
> 
> 


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


In response to

pgsql-hackers by date

Next:From: TaralDate: 1998-10-12 02:16:17
Subject: RE: [HACKERS] Open 6.4 items
Previous:From: Bruce MomjianDate: 1998-10-12 01:31:06
Subject: Re: [HACKERS] Open 6.4 items

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group