2121 *
2222 *
2323 * IDENTIFICATION
24- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.51 1997/10/3003:59:46 momjian Exp $
24+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.52 1997/10/3016:47:59 thomas Exp $
2525 *
2626 * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
2727 *
@@ -205,14 +205,14 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids)
205205if (oids )
206206{
207207fprintf (fout ,"COPY %s WITH OIDS FROM stdin;\n" ,
208- classname );
208+ fmtId ( classname ) );
209209sprintf (query ,"COPY %s WITH OIDS TO stdout;\n" ,
210- classname );
210+ fmtId ( classname ) );
211211}
212212else
213213{
214- fprintf (fout ,"COPY %s FROM stdin;\n" ,classname );
215- sprintf (query ,"COPY %s TO stdout;\n" ,classname );
214+ fprintf (fout ,"COPY %s FROM stdin;\n" ,fmtId ( classname ) );
215+ sprintf (query ,"COPY %s TO stdout;\n" ,fmtId ( classname ) );
216216}
217217res = PQexec (g_conn ,query );
218218if (!res )
@@ -309,7 +309,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname,
309309tuple = 0 ;
310310while (tuple < PQntuples (res ))
311311{
312- fprintf (fout ,"insert into %s " ,classname );
312+ fprintf (fout ,"insert into %s " ,fmtId ( classname ) );
313313if (attrNames )
314314{
315315int j ;
@@ -323,7 +323,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname,
323323sprintf (q ,"%s%s%s" ,
324324q ,
325325(actual_atts > 0 ) ?"," :"" ,
326- tblinfo .attnames [j ]);
326+ fmtId ( tblinfo .attnames [j ]) );
327327actual_atts ++ ;
328328}
329329}
@@ -1944,12 +1944,12 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
19441944sprintf (q ,"%s%s%s" ,
19451945q ,
19461946(j > 0 ) ?"," :"" ,
1947- typname );
1947+ fmtId ( typname ) );
19481948}
19491949sprintf (q ,"%s ) RETURNS %s%s AS '%s' LANGUAGE '%s';\n" ,
19501950q ,
19511951(finfo [i ].retset ) ?" SETOF " :"" ,
1952- findTypeByOid (tinfo ,numTypes ,finfo [i ].prorettype ),
1952+ fmtId ( findTypeByOid (tinfo ,numTypes ,finfo [i ].prorettype ) ),
19531953(finfo [i ].lang == INTERNALlanguageId ) ?finfo [i ].prosrc :
19541954(finfo [i ].lang == ClanguageId ) ?finfo [i ].probin :
19551955(finfo [i ].lang == SQLlanguageId ) ?finfo [i ].prosrc :"unknown" ,
@@ -2005,13 +2005,13 @@ dumpOprs(FILE *fout, OprInfo *oprinfo, int numOperators,
20052005strcmp (oprinfo [i ].oprkind ,"b" )== 0 )
20062006{
20072007sprintf (leftarg ,", LEFTARG = %s " ,
2008- findTypeByOid (tinfo ,numTypes ,oprinfo [i ].oprleft ));
2008+ fmtId ( findTypeByOid (tinfo ,numTypes ,oprinfo [i ].oprleft ) ));
20092009}
20102010if (strcmp (oprinfo [i ].oprkind ,"l" )== 0 ||
20112011strcmp (oprinfo [i ].oprkind ,"b" )== 0 )
20122012{
20132013sprintf (rightarg ,", RIGHTARG = %s " ,
2014- findTypeByOid (tinfo ,numTypes ,oprinfo [i ].oprright ));
2014+ fmtId ( findTypeByOid (tinfo ,numTypes ,oprinfo [i ].oprright ) ));
20152015}
20162016if (strcmp (oprinfo [i ].oprcom ,"0" )== 0 )
20172017commutator [0 ]= '\0' ;
@@ -2094,7 +2094,7 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs,
20942094
20952095sprintf (basetype ,
20962096"BASETYPE = %s, " ,
2097- findTypeByOid (tinfo ,numTypes ,agginfo [i ].aggbasetype ));
2097+ fmtId ( findTypeByOid (tinfo ,numTypes ,agginfo [i ].aggbasetype ) ));
20982098
20992099if (strcmp (agginfo [i ].aggtransfn1 ,"-" )== 0 )
21002100sfunc1 [0 ]= '\0' ;
@@ -2103,7 +2103,7 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs,
21032103sprintf (sfunc1 ,
21042104"SFUNC1 = %s, STYPE1 = %s" ,
21052105agginfo [i ].aggtransfn1 ,
2106- findTypeByOid (tinfo ,numTypes ,agginfo [i ].aggtranstype1 ));
2106+ fmtId ( findTypeByOid (tinfo ,numTypes ,agginfo [i ].aggtranstype1 ) ));
21072107if (agginfo [i ].agginitval1 )
21082108sprintf (sfunc1 ,"%s, INITCOND1 = '%s'" ,
21092109sfunc1 ,agginfo [i ].agginitval1 );
@@ -2117,7 +2117,7 @@ dumpAggs(FILE *fout, AggInfo *agginfo, int numAggs,
21172117sprintf (sfunc2 ,
21182118"SFUNC2 = %s, STYPE2 = %s" ,
21192119agginfo [i ].aggtransfn2 ,
2120- findTypeByOid (tinfo ,numTypes ,agginfo [i ].aggtranstype2 ));
2120+ fmtId ( findTypeByOid (tinfo ,numTypes ,agginfo [i ].aggtranstype2 ) ));
21212121if (agginfo [i ].agginitval2 )
21222122sprintf (sfunc2 ,"%s, INITCOND2 = '%s'" ,
21232123sfunc2 ,agginfo [i ].agginitval2 );
@@ -2213,7 +2213,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
22132213
22142214fprintf (fout ,"\\connect - %s\n" ,tblinfo [i ].usename );
22152215
2216- sprintf (q ,"CREATE TABLE %s (" ,tblinfo [i ].relname );
2216+ sprintf (q ,"CREATE TABLE %s (" ,fmtId ( tblinfo [i ].relname ) );
22172217actual_atts = 0 ;
22182218for (j = 0 ;j < tblinfo [i ].numatts ;j ++ )
22192219{
@@ -2226,7 +2226,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
22262226sprintf (q ,"%s%s%s char" ,
22272227q ,
22282228(actual_atts > 0 ) ?", " :"" ,
2229- tblinfo [i ].attnames [j ]);
2229+ fmtId ( tblinfo [i ].attnames [j ]) );
22302230
22312231/* stored length can be -1 (variable) */
22322232if (tblinfo [i ].attlen [j ]> 0 )
@@ -2240,7 +2240,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
22402240sprintf (q ,"%s%s%s %s" ,
22412241q ,
22422242(actual_atts > 0 ) ?", " :"" ,
2243- tblinfo [i ].attnames [j ],
2243+ fmtId ( tblinfo [i ].attnames [j ]) ,
22442244tblinfo [i ].typnames [j ]);
22452245
22462246/* stored length can be -1 (variable) */
@@ -2255,8 +2255,8 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
22552255sprintf (q ,"%s%s%s %s" ,
22562256q ,
22572257(actual_atts > 0 ) ?", " :"" ,
2258- tblinfo [i ].attnames [j ],
2259- tblinfo [i ].typnames [j ]);
2258+ fmtId ( tblinfo [i ].attnames [j ]) ,
2259+ fmtId ( tblinfo [i ].typnames [j ]) );
22602260actual_atts ++ ;
22612261}
22622262if (tblinfo [i ].adef_expr [j ]!= NULL )
@@ -2347,7 +2347,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
23472347for (i = 0 ;i < numIndices ;i ++ )
23482348{
23492349tableInd = findTableByName (tblinfo ,numTables ,
2350- indinfo [i ].indrelname );
2350+ fmtId ( indinfo [i ].indrelname ) );
23512351
23522352if (strcmp (indinfo [i ].indproc ,"0" )== 0 )
23532353{
@@ -2420,7 +2420,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
24202420attname = tblinfo [tableInd ].attnames [indkey ];
24212421if (funcname )
24222422sprintf (attlist + strlen (attlist ),"%s%s" ,
2423- (k == 0 ) ?"" :", " ,attname );
2423+ (k == 0 ) ?"" :", " ,fmtId ( attname ) );
24242424else
24252425{
24262426if (k >=nclass )
@@ -2431,7 +2431,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
24312431exit_nicely (g_conn );
24322432}
24332433sprintf (attlist + strlen (attlist ),"%s%s %s" ,
2434- (k == 0 ) ?"" :", " ,attname , classname [k ]);
2434+ (k == 0 ) ?"" :", " ,fmtId ( attname ), fmtId ( classname [k ]) );
24352435free (classname [k ]);
24362436}
24372437}
@@ -2441,13 +2441,13 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
24412441
24422442sprintf (q ,"CREATE %s INDEX %s on %s using %s (" ,
24432443 (strcmp (indinfo [i ].indisunique ,"t" )== 0 ) ?"UNIQUE" :"" ,
2444- indinfo [i ].indexrelname ,
2445- indinfo [i ].indrelname ,
2444+ fmtId ( indinfo [i ].indexrelname ) ,
2445+ fmtId ( indinfo [i ].indrelname ) ,
24462446indinfo [i ].indamname );
24472447if (funcname )
24482448{
24492449sprintf (q ,"%s %s (%s) %s );\n" ,
2450- q ,funcname ,attlist ,classname [0 ]);
2450+ q ,funcname ,attlist ,fmtId ( classname [0 ]) );
24512451free (funcname );
24522452free (classname [0 ]);
24532453}
@@ -2666,7 +2666,7 @@ dumpSequence(FILE *fout, TableInfo tbinfo)
26662666sprintf (query ,
26672667"SELECT sequence_name, last_value, increment_by, max_value, "
26682668"min_value, cache_value, is_cycled, is_called from %s" ,
2669- tbinfo .relname );
2669+ fmtId ( tbinfo .relname ) );
26702670
26712671res = PQexec (g_conn ,query );
26722672if (!res || PQresultStatus (res )!= PGRES_TUPLES_OK )
@@ -2706,7 +2706,7 @@ dumpSequence(FILE *fout, TableInfo tbinfo)
27062706sprintf (query ,
27072707"CREATE SEQUENCE %s start %d increment %d maxvalue %d "
27082708"minvalue %d cache %d %s;\n" ,
2709- tbinfo .relname ,last ,incby ,maxv ,minv ,cache ,
2709+ fmtId ( tbinfo .relname ) ,last ,incby ,maxv ,minv ,cache ,
27102710(cycled == 't' ) ?"cycle" :"" );
27112711
27122712fputs (query ,fout );