*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.111 1999/05/26 19:45:53 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.112 1999/05/26 21:51:12 tgl Exp $
*
*
{
PGresult *res;
int ntups;
- char query[MAXQUERYLEN];
+ char query[MAX_QUERY_SIZE];
res = PQexec(g_conn, "begin");
if (!res ||
const TableInfo tblinfo, bool oids)
{
PGresult *res;
- char q[MAXQUERYLEN];
+ char q[MAX_QUERY_SIZE];
int tuple;
int field;
char *expsrc;
- char *expdest;
sprintf(q, "SELECT * FROM %s", fmtId(classname, force_quotes));
res = PQexec(g_conn, q);
strcat(q, ") ");
fprintf(fout, "%s", q);
}
- fprintf(fout, "values (");
+ fprintf(fout, "VALUES (");
for (field = 0; field < PQnfields(res); field++)
{
if (field > 0)
fprintf(fout, ",");
if (PQgetisnull(res, tuple, field))
+ {
fprintf(fout, "NULL");
- else
+ continue;
+ }
+ switch (PQftype(res, field))
{
- switch (PQftype(res, field))
- {
- case INT2OID:
- case INT4OID:
- case OIDOID: /* int types */
- case FLOAT4OID:
- case FLOAT8OID: /* float types */
- /* These types are printed without quotes */
- fprintf(fout, "%s",
- PQgetvalue(res, tuple, field));
- break;
- default:
-
- /*
- * All other types are printed as string literals,
- * with appropriate escaping of special
- * characters. Quote mark ' goes to '' per SQL
- * standard, other stuff goes to \ sequences.
- */
- expsrc = PQgetvalue(res, tuple, field);
- expdest = q;
- for (; *expsrc; expsrc++)
+ case INT2OID:
+ case INT4OID:
+ case OIDOID: /* int types */
+ case FLOAT4OID:
+ case FLOAT8OID: /* float types */
+ /* These types are printed without quotes */
+ fprintf(fout, "%s",
+ PQgetvalue(res, tuple, field));
+ break;
+ default:
+ /*
+ * All other types are printed as string literals,
+ * with appropriate escaping of special
+ * characters. Quote mark ' goes to '' per SQL
+ * standard, other stuff goes to \ sequences.
+ */
+ putc('\'', fout);
+ expsrc = PQgetvalue(res, tuple, field);
+ while (*expsrc)
+ {
+ char ch = *expsrc++;
+
+ if (ch == '\\' || ch == '\'')
{
- char ch = *expsrc;
-
- if (ch == '\\' || ch == '\'')
- {
- *expdest++ = ch; /* double it */
- *expdest++ = ch;
- }
- else if (ch < '\040')
- {
- /* generate octal escape for control chars */
- *expdest++ = '\\';
- *expdest++ = ((ch >> 6) & 3) + '0';
- *expdest++ = ((ch >> 3) & 7) + '0';
- *expdest++ = (ch & 7) + '0';
- }
- else
- *expdest++ = ch;
+ putc(ch, fout); /* double these */
+ putc(ch, fout);
}
- *expdest = '\0';
- fprintf(fout, "'%s'", q);
- break;
- }
+ else if (ch < '\040')
+ {
+ /* generate octal escape for control chars */
+ putc('\\', fout);
+ putc(((ch >> 6) & 3) + '0', fout);
+ putc(((ch >> 3) & 7) + '0', fout);
+ putc((ch & 7) + '0', fout);
+ }
+ else
+ putc(ch, fout);
+ }
+ putc('\'', fout);
+ break;
}
}
fprintf(fout, ");\n");
}
fflush(g_fout);
- fclose(g_fout);
+ if (g_fout != stdout)
+ fclose(g_fout);
+
clearTableInfo(tblinfo, numTables);
PQfinish(g_conn);
exit(0);
PGresult *res;
int ntups;
int i;
- char query[MAXQUERYLEN];
+ char query[MAX_QUERY_SIZE];
TypeInfo *tinfo;
int i_oid;
PGresult *res;
int ntups;
int i;
- char query[MAXQUERYLEN];
+ char query[MAX_QUERY_SIZE];
OprInfo *oprinfo;
PGresult *res;
int ntups;
int i;
- char query[MAXQUERYLEN];
+ char query[MAX_QUERY_SIZE];
AggInfo *agginfo;
int i_oid;
PGresult *res;
int ntups;
int i;
- char query[MAXQUERYLEN];
+ char query[MAX_QUERY_SIZE];
FuncInfo *finfo;
int i_oid;
PGresult *res;
int ntups;
int i;
- char query[MAXQUERYLEN];
+ char query[MAX_QUERY_SIZE];
TableInfo *tblinfo;
int i_oid;
int tgnargs = atoi(PQgetvalue(res2, i2, i_tgnargs));
char *tgargs = PQgetvalue(res2, i2, i_tgargs);
char *p;
- char farg[MAXQUERYLEN];
+ char farg[MAX_QUERY_SIZE];
int findx;
for (findx = 0; findx < numFuncs; findx++)
PGresult *res;
int ntups;
int i;
- char query[MAXQUERYLEN];
+ char query[MAX_QUERY_SIZE];
InhInfo *inhinfo;
int i_inhrel;
{
int i,
j;
- char q[MAXQUERYLEN];
+ char q[MAX_QUERY_SIZE];
int i_attname;
int i_typname;
int i_atttypmod;
getIndices(int *numIndices)
{
int i;
- char query[MAXQUERYLEN];
+ char query[MAX_QUERY_SIZE];
PGresult *res;
int ntups;
IndInfo *indinfo;
TypeInfo *tinfo, int numTypes)
{
int i;
- char q[MAXQUERYLEN];
+ char q[MAX_QUERY_SIZE];
int funcInd;
for (i = 0; i < numTypes; i++)
TypeInfo *tinfo, int numTypes)
{
PGresult *res;
- char query[MAXQUERYLEN];
+ char query[MAX_QUERY_SIZE];
int ntups;
int i_lanname;
int i_lanpltrusted;
dumpOneFunc(FILE *fout, FuncInfo *finfo, int i,
TypeInfo *tinfo, int numTypes)
{
- char q[MAXQUERYLEN];
+ char q[MAX_QUERY_SIZE];
int j;
char *func_def;
char func_lang[NAMEDATALEN + 1];
TypeInfo *tinfo, int numTypes)
{
int i;
- char q[MAXQUERYLEN];
- char leftarg[MAXQUERYLEN];
- char rightarg[MAXQUERYLEN];
- char commutator[MAXQUERYLEN];
- char negator[MAXQUERYLEN];
- char restrictor[MAXQUERYLEN];
- char join[MAXQUERYLEN];
- char sort1[MAXQUERYLEN];
- char sort2[MAXQUERYLEN];
+ char q[MAX_QUERY_SIZE];
+ char leftarg[MAX_QUERY_SIZE/8];
+ char rightarg[MAX_QUERY_SIZE/8];
+ char commutator[MAX_QUERY_SIZE/8];
+ char negator[MAX_QUERY_SIZE/8];
+ char restrictor[MAX_QUERY_SIZE/8];
+ char join[MAX_QUERY_SIZE/8];
+ char sort1[MAX_QUERY_SIZE/8];
+ char sort2[MAX_QUERY_SIZE/8];
for (i = 0; i < numOperators; i++)
{
TypeInfo *tinfo, int numTypes)
{
int i;
- char q[MAXQUERYLEN];
- char sfunc1[MAXQUERYLEN];
- char sfunc2[MAXQUERYLEN];
- char basetype[MAXQUERYLEN];
- char finalfunc[MAXQUERYLEN];
+ char q[MAX_QUERY_SIZE];
+ char sfunc1[MAX_QUERY_SIZE];
+ char sfunc2[MAX_QUERY_SIZE];
+ char basetype[MAX_QUERY_SIZE];
+ char finalfunc[MAX_QUERY_SIZE];
char comma1[2],
comma2[2];
else
{
*eqpos = '\0'; /* it's ok to clobber aclbuf */
- if (strncmp(tok, "group ",strlen("group ")) == 0)
- fprintf(fout, "GROUP %s;\n",
- fmtId(tok + sizeof("group ") - 1, force_quotes));
- else fprintf(fout, "%s;\n", fmtId(tok, force_quotes));
+ if (strncmp(tok, "group ", strlen("group ")) == 0)
+ fprintf(fout, "GROUP %s;\n",
+ fmtId(tok + strlen("group "), force_quotes));
+ else
+ fprintf(fout, "%s;\n", fmtId(tok, force_quotes));
}
}
free(priv);
int i,
j,
k;
- char q[MAXQUERYLEN];
+ char q[MAX_QUERY_SIZE];
char *serialSeq = NULL; /* implicit sequence name created
* by SERIAL datatype */
const char *serialSeqSuffix = "_id_seq"; /* suffix for implicit
indclass;
int nclass;
- char q[MAXQUERYLEN],
- id1[MAXQUERYLEN],
- id2[MAXQUERYLEN];
+ char q[MAX_QUERY_SIZE],
+ id1[MAX_QUERY_SIZE],
+ id2[MAX_QUERY_SIZE];
PGresult *res;
for (i = 0; i < numIndices; i++)
char cycled,
called,
*t;
- char query[MAXQUERYLEN];
+ char query[MAX_QUERY_SIZE];
sprintf(query,
"SELECT sequence_name, last_value, increment_by, max_value, "
int nrules;
int i,
t;
- char query[MAXQUERYLEN];
+ char query[MAX_QUERY_SIZE];
int i_definition;