mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-05 05:47:01 +02:00
Ok. BTW Mr. Kataoka who is maintaing Japanese version of PostgreSQL
ODBC driver have found a bug in 6.3.2 pg_dump and have made patches. I confirmed that the same bug still exists in the current source tree. So I made up patches based on Kataoka's. Here are some explanations. o fmtId() returns pointer to a static memory in it. In the meantime there is a line where is fmtId() called twice without saving the first value returned by fmtId(). So second call to fmtId() will break the first one. o findTableByName() looks up a table by its name. if a table name contanins upper letters or non ascii chars, fmtId() will returns a name quoted in double quotes, which will not what findTableByName() wants. The result is SEG fault. -- Tatsuo Ishii t-ishii@sra.co.jp
This commit is contained in:
parent
2618fcdf0d
commit
88800aac14
@ -21,7 +21,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.80 1998/08/25 15:02:04 thomas Exp $
|
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.81 1998/08/29 18:06:57 momjian Exp $
|
||||||
*
|
*
|
||||||
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
||||||
*
|
*
|
||||||
@ -2435,7 +2435,9 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
|
|||||||
int i,
|
int i,
|
||||||
j,
|
j,
|
||||||
k;
|
k;
|
||||||
char q[MAXQUERYLEN];
|
char q[MAXQUERYLEN],
|
||||||
|
id1[MAXQUERYLEN],
|
||||||
|
id2[MAXQUERYLEN];
|
||||||
char **parentRels; /* list of names of parent relations */
|
char **parentRels; /* list of names of parent relations */
|
||||||
int numParents;
|
int numParents;
|
||||||
int actual_atts; /* number of attrs in this CREATE statment */
|
int actual_atts; /* number of attrs in this CREATE statment */
|
||||||
@ -2506,11 +2508,13 @@ dumpTables(FILE *fout, TableInfo *tblinfo, int numTables,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
strcpy(id1, fmtId(tblinfo[i].attnames[j]));
|
||||||
|
strcpy(id2, fmtId(tblinfo[i].typnames[j]));
|
||||||
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]),
|
id1,
|
||||||
fmtId(tblinfo[i].typnames[j]));
|
id2);
|
||||||
actual_atts++;
|
actual_atts++;
|
||||||
}
|
}
|
||||||
if (tblinfo[i].adef_expr[j] != NULL)
|
if (tblinfo[i].adef_expr[j] != NULL)
|
||||||
@ -2572,13 +2576,15 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
|
|||||||
indclass;
|
indclass;
|
||||||
int nclass;
|
int nclass;
|
||||||
|
|
||||||
char q[MAXQUERYLEN];
|
char q[MAXQUERYLEN],
|
||||||
|
id1[MAXQUERYLEN],
|
||||||
|
id2[MAXQUERYLEN];
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
|
|
||||||
for (i = 0; i < numIndices; i++)
|
for (i = 0; i < numIndices; i++)
|
||||||
{
|
{
|
||||||
tableInd = findTableByName(tblinfo, numTables,
|
tableInd = findTableByName(tblinfo, numTables,
|
||||||
fmtId(indinfo[i].indrelname));
|
(indinfo[i].indrelname));
|
||||||
|
|
||||||
if (strcmp(indinfo[i].indproc, "0") == 0)
|
if (strcmp(indinfo[i].indproc, "0") == 0)
|
||||||
funcname = NULL;
|
funcname = NULL;
|
||||||
@ -2659,8 +2665,10 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
|
|||||||
attname, indinfo[i].indexrelname);
|
attname, indinfo[i].indexrelname);
|
||||||
exit_nicely(g_conn);
|
exit_nicely(g_conn);
|
||||||
}
|
}
|
||||||
|
strcpy(id1, fmtId(attname));
|
||||||
|
strcpy(id2, fmtId(classname[k]));
|
||||||
sprintf(attlist + strlen(attlist), "%s%s %s",
|
sprintf(attlist + strlen(attlist), "%s%s %s",
|
||||||
(k == 0) ? "" : ", ", fmtId(attname), fmtId(classname[k]));
|
(k == 0) ? "" : ", ", id1, id2);
|
||||||
free(classname[k]);
|
free(classname[k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2668,10 +2676,12 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
|
|||||||
if (!tablename || (!strcmp(indinfo[i].indrelname, tablename)))
|
if (!tablename || (!strcmp(indinfo[i].indrelname, tablename)))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
strcpy(id1, fmtId(indinfo[i].indexrelname));
|
||||||
|
strcpy(id2, fmtId(indinfo[i].indrelname));
|
||||||
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),
|
id1,
|
||||||
fmtId(indinfo[i].indrelname),
|
id2,
|
||||||
indinfo[i].indamname);
|
indinfo[i].indamname);
|
||||||
if (funcname)
|
if (funcname)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user