Commit 6962f86e authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Clean up double-quotes around column and table names.

 Had too many in some cases because there was already a routine
 taking care of it.
parent 7540af49
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.79 1998/08/06 05:12:51 momjian Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.80 1998/08/25 15:02:04 thomas Exp $
* *
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
* *
...@@ -221,15 +221,15 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids) ...@@ -221,15 +221,15 @@ dumpClasses_nodumpData(FILE *fout, const char *classname, const bool oids)
if (oids) if (oids)
{ {
fprintf(fout, "COPY \"%s\" WITH OIDS FROM stdin;\n", fprintf(fout, "COPY %s WITH OIDS FROM stdin;\n",
fmtId(classname)); fmtId(classname));
sprintf(query, "COPY \"%s\" WITH OIDS TO stdout;\n", sprintf(query, "COPY %s WITH OIDS TO stdout;\n",
fmtId(classname)); fmtId(classname));
} }
else else
{ {
fprintf(fout, "COPY \"%s\" FROM stdin;\n", fmtId(classname)); fprintf(fout, "COPY %s FROM stdin;\n", fmtId(classname));
sprintf(query, "COPY \"%s\" TO stdout;\n", fmtId(classname)); sprintf(query, "COPY %s TO stdout;\n", fmtId(classname));
} }
res = PQexec(g_conn, query); res = PQexec(g_conn, query);
if (!res || if (!res ||
...@@ -316,7 +316,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname, ...@@ -316,7 +316,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname,
int tuple; int tuple;
int field; int field;
sprintf(query, "SELECT * FROM \"%s\"", classname); sprintf(query, "SELECT * FROM %s", fmtId(classname));
res = PQexec(g_conn, query); res = PQexec(g_conn, query);
if (!res || if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK) PQresultStatus(res) != PGRES_TUPLES_OK)
...@@ -327,7 +327,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname, ...@@ -327,7 +327,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname,
tuple = 0; tuple = 0;
while (tuple < PQntuples(res)) while (tuple < PQntuples(res))
{ {
fprintf(fout, "INSERT INTO \"%s\" ", fmtId(classname)); fprintf(fout, "INSERT INTO %s ", fmtId(classname));
if (attrNames) if (attrNames)
{ {
int j; int j;
...@@ -338,7 +338,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname, ...@@ -338,7 +338,7 @@ dumpClasses_dumpData(FILE *fout, const char *classname,
{ {
if (tblinfo.inhAttrs[j] == 0) if (tblinfo.inhAttrs[j] == 0)
{ {
sprintf(q, "%s%s\"%s\"", sprintf(q, "%s%s%s",
q, q,
(actual_atts > 0) ? "," : "", (actual_atts > 0) ? "," : "",
fmtId(tblinfo.attnames[j])); fmtId(tblinfo.attnames[j]));
...@@ -1570,7 +1570,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -1570,7 +1570,7 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
exit_nicely(g_conn); exit_nicely(g_conn);
} }
tgfunc = finfo[findx].proname; tgfunc = finfo[findx].proname;
sprintf(query, "CREATE TRIGGER \"%s\" ", PQgetvalue(res2, i2, i_tgname)); sprintf(query, "CREATE TRIGGER %s ", fmtId(PQgetvalue(res2, i2, i_tgname)));
/* Trigger type */ /* Trigger type */
findx = 0; findx = 0;
if (TRIGGER_FOR_BEFORE(tgtype)) if (TRIGGER_FOR_BEFORE(tgtype))
...@@ -1597,8 +1597,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs) ...@@ -1597,8 +1597,8 @@ getTables(int *numTables, FuncInfo *finfo, int numFuncs)
else else
strcat(query, " UPDATE"); strcat(query, " UPDATE");
} }
sprintf(query, "%s ON \"%s\" FOR EACH ROW EXECUTE PROCEDURE %s (", sprintf(query, "%s ON %s FOR EACH ROW EXECUTE PROCEDURE %s (",
query, tblinfo[i].relname, tgfunc); query, fmtId(tblinfo[i].relname), tgfunc);
for (findx = 0; findx < tgnargs; findx++) for (findx = 0; findx < tgnargs; findx++)
{ {
char *s, char *s,
...@@ -1967,10 +1967,10 @@ dumpTypes(FILE *fout, FuncInfo *finfo, int numFuncs, ...@@ -1967,10 +1967,10 @@ dumpTypes(FILE *fout, FuncInfo *finfo, int numFuncs,
becomeUser(fout, tinfo[i].usename); becomeUser(fout, tinfo[i].usename);
sprintf(q, sprintf(q,
"CREATE TYPE \"%s\" " "CREATE TYPE %s "
"( internallength = %s, externallength = %s, input = %s, " "( internallength = %s, externallength = %s, input = %s, "
"output = %s, send = %s, receive = %s, default = '%s'", "output = %s, send = %s, receive = %s, default = '%s'",
tinfo[i].typname, fmtId(tinfo[i].typname),
tinfo[i].typlen, tinfo[i].typlen,
tinfo[i].typprtlen, tinfo[i].typprtlen,
tinfo[i].typinput, tinfo[i].typinput,
...@@ -2033,13 +2033,13 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i, ...@@ -2033,13 +2033,13 @@ dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
becomeUser(fout, finfo[i].usename); becomeUser(fout, finfo[i].usename);
sprintf(q, "CREATE FUNCTION \"%s\" (", finfo[i].proname); sprintf(q, "CREATE FUNCTION %s (", fmtId(finfo[i].proname));
for (j = 0; j < finfo[i].nargs; j++) for (j = 0; j < finfo[i].nargs; j++)
{ {
char *typname; char *typname;
typname = findTypeByOid(tinfo, numTypes, finfo[i].argtypes[j]); typname = findTypeByOid(tinfo, numTypes, finfo[i].argtypes[j]);
sprintf(q, "%s%s\"%s\"", sprintf(q, "%s%s%s",
q, q,
(j > 0) ? "," : "", (j > 0) ? "," : "",
fmtId(typname)); fmtId(typname));
...@@ -2400,8 +2400,8 @@ dumpACL(FILE *fout, TableInfo tbinfo) ...@@ -2400,8 +2400,8 @@ dumpACL(FILE *fout, TableInfo tbinfo)
/* Revoke Default permissions for PUBLIC */ /* Revoke Default permissions for PUBLIC */
fprintf(fout, fprintf(fout,
"REVOKE ALL on \"%s\" from PUBLIC;\n", "REVOKE ALL on %s from PUBLIC;\n",
tbinfo.relname); fmtId(tbinfo.relname));
for (k = 0; k < l; k++) for (k = 0; k < l; k++)
{ {
...@@ -2409,13 +2409,13 @@ dumpACL(FILE *fout, TableInfo tbinfo) ...@@ -2409,13 +2409,13 @@ dumpACL(FILE *fout, TableInfo tbinfo)
{ {
if (ACLlist[k].user == (char *) NULL) if (ACLlist[k].user == (char *) NULL)
fprintf(fout, fprintf(fout,
"GRANT %s on \"%s\" to PUBLIC;\n", "GRANT %s on %s to PUBLIC;\n",
ACLlist[k].privledges, tbinfo.relname); ACLlist[k].privledges, fmtId(tbinfo.relname));
else else
fprintf(fout, fprintf(fout,
"GRANT %s on \"%s\" to \"%s\";\n", "GRANT %s on %s to %s;\n",
ACLlist[k].privledges, tbinfo.relname, ACLlist[k].privledges, fmtId(tbinfo.relname),
ACLlist[k].user); fmtId(ACLlist[k].user));
} }
} }
} }
...@@ -2471,7 +2471,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables, ...@@ -2471,7 +2471,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
becomeUser(fout, tblinfo[i].usename); becomeUser(fout, tblinfo[i].usename);
sprintf(q, "CREATE TABLE \"%s\" (", fmtId(tblinfo[i].relname)); sprintf(q, "CREATE TABLE %s (", fmtId(tblinfo[i].relname));
actual_atts = 0; actual_atts = 0;
for (j = 0; j < tblinfo[i].numatts; j++) for (j = 0; j < tblinfo[i].numatts; j++)
{ {
...@@ -2481,7 +2481,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables, ...@@ -2481,7 +2481,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
/* Show lengths on bpchar and varchar */ /* Show lengths on bpchar and varchar */
if (!strcmp(tblinfo[i].typnames[j], "bpchar")) if (!strcmp(tblinfo[i].typnames[j], "bpchar"))
{ {
sprintf(q, "%s%s\"%s\" char", sprintf(q, "%s%s%s char",
q, q,
(actual_atts > 0) ? ", " : "", (actual_atts > 0) ? ", " : "",
fmtId(tblinfo[i].attnames[j])); fmtId(tblinfo[i].attnames[j]));
...@@ -2493,7 +2493,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables, ...@@ -2493,7 +2493,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
} }
else if (!strcmp(tblinfo[i].typnames[j], "varchar")) else if (!strcmp(tblinfo[i].typnames[j], "varchar"))
{ {
sprintf(q, "%s%s\"%s\" %s", sprintf(q, "%s%s%s %s",
q, q,
(actual_atts > 0) ? ", " : "", (actual_atts > 0) ? ", " : "",
fmtId(tblinfo[i].attnames[j]), fmtId(tblinfo[i].attnames[j]),
...@@ -2506,7 +2506,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables, ...@@ -2506,7 +2506,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
} }
else else
{ {
sprintf(q, "%s%s\"%s\" %s", sprintf(q, "%s%s%s %s",
q, q,
(actual_atts > 0) ? ", " : "", (actual_atts > 0) ? ", " : "",
fmtId(tblinfo[i].attnames[j]), fmtId(tblinfo[i].attnames[j]),
...@@ -2539,7 +2539,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables, ...@@ -2539,7 +2539,7 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
sprintf(q, "%s%s%s", sprintf(q, "%s%s%s",
q, q,
(k > 0) ? ", " : "", (k > 0) ? ", " : "",
parentRels[k]); fmtId(parentRels[k]));
} }
strcat(q, ")"); strcat(q, ")");
} }
...@@ -2648,7 +2648,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices, ...@@ -2648,7 +2648,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
else else
attname = tblinfo[tableInd].attnames[indkey]; attname = tblinfo[tableInd].attnames[indkey];
if (funcname) if (funcname)
sprintf(attlist + strlen(attlist), "%s\"%s\"", sprintf(attlist + strlen(attlist), "%s%s",
(k == 0) ? "" : ", ", fmtId(attname)); (k == 0) ? "" : ", ", fmtId(attname));
else else
{ {
...@@ -2659,7 +2659,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices, ...@@ -2659,7 +2659,7 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
attname, indinfo[i].indexrelname); attname, indinfo[i].indexrelname);
exit_nicely(g_conn); exit_nicely(g_conn);
} }
sprintf(attlist + strlen(attlist), "%s\"%s\" \"%s\"", sprintf(attlist + strlen(attlist), "%s%s %s",
(k == 0) ? "" : ", ", fmtId(attname), fmtId(classname[k])); (k == 0) ? "" : ", ", fmtId(attname), fmtId(classname[k]));
free(classname[k]); free(classname[k]);
} }
...@@ -2668,14 +2668,14 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices, ...@@ -2668,14 +2668,14 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
if (!tablename || (!strcmp(indinfo[i].indrelname, tablename))) if (!tablename || (!strcmp(indinfo[i].indrelname, tablename)))
{ {
sprintf(q, "CREATE %s INDEX \"%s\" on \"%s\" using %s (", sprintf(q, "CREATE %s INDEX %s on %s using %s (",
(strcmp(indinfo[i].indisunique, "t") == 0) ? "UNIQUE" : "", (strcmp(indinfo[i].indisunique, "t") == 0) ? "UNIQUE" : "",
fmtId(indinfo[i].indexrelname), fmtId(indinfo[i].indexrelname),
fmtId(indinfo[i].indrelname), fmtId(indinfo[i].indrelname),
indinfo[i].indamname); indinfo[i].indamname);
if (funcname) if (funcname)
{ {
sprintf(q, "%s %s (%s) \"%s\" );\n", sprintf(q, "%s %s (%s) %s );\n",
q, funcname, attlist, fmtId(classname[0])); q, funcname, attlist, fmtId(classname[0]));
free(funcname); free(funcname);
free(classname[0]); free(classname[0]);
...@@ -2892,7 +2892,7 @@ dumpSequence(FILE *fout, TableInfo tbinfo) ...@@ -2892,7 +2892,7 @@ dumpSequence(FILE *fout, TableInfo tbinfo)
sprintf(query, sprintf(query,
"SELECT sequence_name, last_value, increment_by, max_value, " "SELECT sequence_name, last_value, increment_by, max_value, "
"min_value, cache_value, is_cycled, is_called from \"%s\"", "min_value, cache_value, is_cycled, is_called from %s",
fmtId(tbinfo.relname)); fmtId(tbinfo.relname));
res = PQexec(g_conn, query); res = PQexec(g_conn, query);
...@@ -2931,7 +2931,7 @@ dumpSequence(FILE *fout, TableInfo tbinfo) ...@@ -2931,7 +2931,7 @@ dumpSequence(FILE *fout, TableInfo tbinfo)
PQclear(res); PQclear(res);
sprintf(query, sprintf(query,
"CREATE SEQUENCE \"%s\" start %d increment %d maxvalue %d " "CREATE SEQUENCE %s start %d increment %d maxvalue %d "
"minvalue %d cache %d %s;\n", "minvalue %d cache %d %s;\n",
fmtId(tbinfo.relname), last, incby, maxv, minv, cache, fmtId(tbinfo.relname), last, incby, maxv, minv, cache,
(cycled == 't') ? "cycle" : ""); (cycled == 't') ? "cycle" : "");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment