*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.76 1998/06/20 02:49:38 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.77 1998/07/08 14:33:19 thomas Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
fprintf(stderr,
"\t -d \t\t dump data as proper insert strings\n");
fprintf(stderr,
- "\t -D \t\t dump data as inserts with attribute names\n");
+ "\t -D \t\t dump data as inserts with attribute names\n");
fprintf(stderr,
"\t -f filename \t\t script output filename\n");
fprintf(stderr,
if (oids)
{
- fprintf(fout, "COPY %s WITH OIDS FROM stdin;\n",
+ fprintf(fout, "COPY \"%s\" WITH OIDS FROM stdin;\n",
fmtId(classname));
- sprintf(query, "COPY %s WITH OIDS TO stdout;\n",
+ sprintf(query, "COPY \"%s\" WITH OIDS TO stdout;\n",
fmtId(classname));
}
else
{
- fprintf(fout, "COPY %s FROM stdin;\n", fmtId(classname));
- sprintf(query, "COPY %s TO stdout;\n", fmtId(classname));
+ fprintf(fout, "COPY \"%s\" FROM stdin;\n", fmtId(classname));
+ sprintf(query, "COPY \"%s\" TO stdout;\n", fmtId(classname));
}
res = PQexec(g_conn, query);
if (!res ||
PQresultStatus(res) == PGRES_FATAL_ERROR)
{
- fprintf(stderr, "SQL query to dump the contents of Table %s "
+ fprintf(stderr, "SQL query to dump the contents of Table '%s' "
"did not execute. Explanation from backend: '%s'.\n"
"The query was: '%s'.\n",
classname, PQerrorMessage(g_conn), query);
{
if (PQresultStatus(res) != PGRES_COPY_OUT)
{
- fprintf(stderr, "SQL query to dump the contents of Table %s "
+ fprintf(stderr, "SQL query to dump the contents of Table '%s' "
"executed abnormally.\n"
"PQexec() returned status %d when %d was expected.\n"
"The query was: '%s'.\n",
ret = PQendcopy(res->conn);
if (ret != 0)
{
- fprintf(stderr, "SQL query to dump the contents of Table %s "
+ fprintf(stderr, "SQL query to dump the contents of Table '%s' "
"did not execute correctly. After we read all the "
"table contents from the backend, PQendcopy() failed. "
"Explanation from backend: '%s'.\n"
int tuple;
int field;
- sprintf(query, "select * from %s", classname);
+ sprintf(query, "SELECT * FROM \"%s\"", classname);
res = PQexec(g_conn, query);
if (!res ||
PQresultStatus(res) != PGRES_TUPLES_OK)
tuple = 0;
while (tuple < PQntuples(res))
{
- fprintf(fout, "insert into %s ", fmtId(classname));
+ fprintf(fout, "INSERT INTO \"%s\" ", fmtId(classname));
if (attrNames)
{
int j;
{
if (tblinfo.inhAttrs[j] == 0)
{
- sprintf(q, "%s%s%s",
+ sprintf(q, "%s%s\"%s\"",
q,
(actual_atts > 0) ? "," : "",
fmtId(tblinfo.attnames[j]));
if (!onlytable || (!strcmp(tblinfo[i].relname, onlytable)))
{
if (g_verbose)
- fprintf(stderr, "%s dumping out schema of sequence %s %s\n",
+ fprintf(stderr, "%s dumping out schema of sequence '%s' %s\n",
g_comment_start, tblinfo[i].relname, g_comment_end);
fprintf(fout, "\\connect - %s\n", tblinfo[i].usename);
dumpSequence(fout, tblinfo[i]);
if (!onlytable || (!strcmp(classname, onlytable)))
{
if (g_verbose)
- fprintf(stderr, "%s dumping out the contents of Table %s %s\n",
+ fprintf(stderr, "%s dumping out the contents of Table '%s' %s\n",
g_comment_start, classname, g_comment_end);
if (!dumpData)
int i2;
if (g_verbose)
- fprintf(stderr, "%s finding CHECK constraints for relation: %s %s\n",
+ fprintf(stderr, "%s finding CHECK constraints for relation: '%s' %s\n",
g_comment_start,
tblinfo[i].relname,
g_comment_end);
ntups2 = PQntuples(res2);
if (ntups2 != tblinfo[i].ncheck)
{
- fprintf(stderr, "getTables(): relation %s: %d CHECKs were expected, but got %d\n",
+ fprintf(stderr, "getTables(): relation '%s': %d CHECKs were expected, but got %d\n",
tblinfo[i].relname, tblinfo[i].ncheck, ntups2);
exit_nicely(g_conn);
}
int i2;
if (g_verbose)
- fprintf(stderr, "%s finding Triggers for relation: %s %s\n",
+ fprintf(stderr, "%s finding Triggers for relation: '%s' %s\n",
g_comment_start,
tblinfo[i].relname,
g_comment_end);
ntups2 = PQntuples(res2);
if (ntups2 != tblinfo[i].ntrig)
{
- fprintf(stderr, "getTables(): relation %s: %d Triggers were expected, but got %d\n",
+ fprintf(stderr, "getTables(): relation '%s': %d Triggers were expected, but got %d\n",
tblinfo[i].relname, tblinfo[i].ntrig, ntups2);
exit_nicely(g_conn);
}
}
if (findx == numFuncs)
{
- fprintf(stderr, "getTables(): relation %s: cannot find function with oid %s for trigger %s\n",
+ fprintf(stderr, "getTables(): relation '%s': cannot find function with oid %s for trigger %s\n",
tblinfo[i].relname, tgfunc, PQgetvalue(res2, i2, i_tgname));
exit_nicely(g_conn);
}
tgfunc = finfo[findx].proname;
- sprintf(query, "CREATE TRIGGER %s ", PQgetvalue(res2, i2, i_tgname));
+ sprintf(query, "CREATE TRIGGER \"%s\" ", PQgetvalue(res2, i2, i_tgname));
/* Trigger type */
findx = 0;
if (TRIGGER_FOR_BEFORE(tgtype))
else
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);
for (findx = 0; findx < tgnargs; findx++)
{
p = strchr(p, '\\');
if (p == NULL)
{
- fprintf(stderr, "getTables(): relation %s: bad argument string (%s) for trigger %s\n",
+ fprintf(stderr, "getTables(): relation '%s': bad argument string (%s) for trigger '%s'\n",
tblinfo[i].relname,
PQgetvalue(res2, i2, i_tgargs),
PQgetvalue(res2, i2, i_tgname));
* later
*/
if (g_verbose)
- fprintf(stderr, "%s finding the attrs and types for table: %s %s\n",
+ fprintf(stderr, "%s finding the attrs and types for table: '%s' %s\n",
g_comment_start,
tblinfo[i].relname,
g_comment_end);
PGresult *res2;
if (g_verbose)
- fprintf(stderr, "%s finding DEFAULT expression for attr: %s %s\n",
+ fprintf(stderr, "%s finding DEFAULT expression for attr: '%s' %s\n",
g_comment_start,
tblinfo[i].attnames[j],
g_comment_end);
fprintf(fout, "\\connect - %s\n", tinfo[i].usename);
sprintf(q,
- "CREATE TYPE %s "
+ "CREATE TYPE \"%s\" "
"( internallength = %s, externallength = %s, input = %s, "
"output = %s, send = %s, receive = %s, default = '%s'",
tinfo[i].typname,
fprintf(fout, "\\connect - %s\n", finfo[i].usename);
- sprintf(q, "CREATE FUNCTION %s (", finfo[i].proname);
+ sprintf(q, "CREATE FUNCTION \"%s\" (", finfo[i].proname);
for (j = 0; j < finfo[i].nargs; j++)
{
char *typname;
typname = findTypeByOid(tinfo, numTypes, finfo[i].argtypes[j]);
- sprintf(q, "%s%s%s",
+ sprintf(q, "%s%s\"%s\"",
q,
(j > 0) ? "," : "",
fmtId(typname));
commutator,
negator,
restrictor,
- (strcmp(oprinfo[i].oprcanhash, "t")) ? ", HASHES" : "",
+ (strcmp(oprinfo[i].oprcanhash, "t") == 0) ? ", HASHES" : "",
join,
sortop);
return;
else
{
- fprintf(stderr, "Could not parse ACL list for %s...Exiting!\n",
+ fprintf(stderr, "Could not parse ACL list for '%s'...Exiting!\n",
tbinfo.relname);
exit_nicely(g_conn);
}
/* Revoke Default permissions for PUBLIC */
fprintf(fout,
- "REVOKE ALL on %s from PUBLIC;\n",
+ "REVOKE ALL on '%s' from PUBLIC;\n",
tbinfo.relname);
for (k = 0; k < l; k++)
{
if (ACLlist[k].privledges != (char *) NULL)
fprintf(fout,
- "GRANT %s on %s to %s;\n",
+ "GRANT %s on \"%s\" to \"%s\";\n",
ACLlist[k].privledges, tbinfo.relname,
ACLlist[k].user);
}
fprintf(fout, "\\connect - %s\n", tblinfo[i].usename);
- sprintf(q, "CREATE TABLE %s (", fmtId(tblinfo[i].relname));
+ sprintf(q, "CREATE TABLE \"%s\" (", fmtId(tblinfo[i].relname));
actual_atts = 0;
for (j = 0; j < tblinfo[i].numatts; j++)
{
/* Show lengths on bpchar and varchar */
if (!strcmp(tblinfo[i].typnames[j], "bpchar"))
{
- sprintf(q, "%s%s%s char",
+ sprintf(q, "%s%s\"%s\" char",
q,
(actual_atts > 0) ? ", " : "",
fmtId(tblinfo[i].attnames[j]));
}
else if (!strcmp(tblinfo[i].typnames[j], "varchar"))
{
- sprintf(q, "%s%s%s %s",
+ sprintf(q, "%s%s\"%s\" %s",
q,
(actual_atts > 0) ? ", " : "",
fmtId(tblinfo[i].attnames[j]),
}
else
{
- sprintf(q, "%s%s%s %s",
+ sprintf(q, "%s%s\"%s\" %s",
q,
(actual_atts > 0) ? ", " : "",
fmtId(tblinfo[i].attnames[j]),
else
attname = tblinfo[tableInd].attnames[indkey];
if (funcname)
- sprintf(attlist + strlen(attlist), "%s%s",
+ sprintf(attlist + strlen(attlist), "%s\"%s\"",
(k == 0) ? "" : ", ", fmtId(attname));
else
{
if (k >= nclass)
{
fprintf(stderr, "dumpIndices(): OpClass not found for "
- "attribute %s of index %s\n",
+ "attribute '%s' of index '%s'\n",
attname, indinfo[i].indexrelname);
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]));
free(classname[k]);
}
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" : "",
fmtId(indinfo[i].indexrelname),
fmtId(indinfo[i].indrelname),
indinfo[i].indamname);
if (funcname)
{
- sprintf(q, "%s %s (%s) %s );\n",
+ sprintf(q, "%s %s (%s) \"%s\" );\n",
q, funcname, attlist, fmtId(classname[0]));
free(funcname);
free(classname[0]);
sprintf(query,
"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));
res = PQexec(g_conn, query);
PQclear(res);
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",
fmtId(tbinfo.relname), last, incby, maxv, minv, cache,
(cycled == 't') ? "cycle" : "");