mirror of
https://github.com/postgres/postgres.git
synced 2025-06-23 14:01:44 +03:00
I also noticed that pg_dump contains a copy of the same
prompt_for_password code that psql does. We fixed psql a month or two back to permit usernames and passwords longer than 8 characters. I propagated the same fix into pg_dump. Tom Lane
This commit is contained in:
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.24 1998/09/01 04:33:43 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.25 1998/09/20 03:18:42 momjian Exp $
|
||||||
*
|
*
|
||||||
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
|
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
|
||||||
*
|
*
|
||||||
@ -116,7 +116,8 @@ findParentsByOid(TableInfo *tblinfo, int numTables,
|
|||||||
{
|
{
|
||||||
int i,
|
int i,
|
||||||
j;
|
j;
|
||||||
int parentInd;
|
int parentInd,
|
||||||
|
selfInd;
|
||||||
char **result;
|
char **result;
|
||||||
int numParents;
|
int numParents;
|
||||||
|
|
||||||
@ -139,6 +140,16 @@ findParentsByOid(TableInfo *tblinfo, int numTables,
|
|||||||
{
|
{
|
||||||
parentInd = findTableByOid(tblinfo, numTables,
|
parentInd = findTableByOid(tblinfo, numTables,
|
||||||
inhinfo[i].inhparent);
|
inhinfo[i].inhparent);
|
||||||
|
if (parentInd < 0)
|
||||||
|
{
|
||||||
|
selfInd = findTableByOid(tblinfo, numTables, oid);
|
||||||
|
fprintf(stderr,
|
||||||
|
"failed sanity check, parent oid %s of table %s (oid %s) was not found\n",
|
||||||
|
inhinfo[i].inhparent,
|
||||||
|
(selfInd >= 0) ? tblinfo[selfInd].relname : "",
|
||||||
|
oid);
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
result[j++] = tblinfo[parentInd].relname;
|
result[j++] = tblinfo[parentInd].relname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -387,6 +398,13 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
|
|||||||
{
|
{
|
||||||
parentInd = findTableByName(tblinfo, numTables,
|
parentInd = findTableByName(tblinfo, numTables,
|
||||||
tblinfo[i].parentRels[k]);
|
tblinfo[i].parentRels[k]);
|
||||||
|
if (parentInd < 0)
|
||||||
|
{
|
||||||
|
/* shouldn't happen unless findParentsByOid is broken */
|
||||||
|
fprintf(stderr, "failed sanity check, table %s not found by flagInhAttrs\n",
|
||||||
|
tblinfo[i].parentRels[k]);
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
for (j = 0; j < tblinfo[i].numatts; j++)
|
for (j = 0; j < tblinfo[i].numatts; j++)
|
||||||
{
|
{
|
||||||
if (strInArray(tblinfo[i].attnames[j],
|
if (strInArray(tblinfo[i].attnames[j],
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.84 1998/09/03 02:10:36 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.85 1998/09/20 03:18:43 momjian Exp $
|
||||||
*
|
*
|
||||||
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
||||||
*
|
*
|
||||||
@ -472,6 +472,7 @@ dumpClasses(const TableInfo *tblinfo, const int numTables, FILE *fout,
|
|||||||
static void
|
static void
|
||||||
prompt_for_password(char *username, char *password)
|
prompt_for_password(char *username, char *password)
|
||||||
{
|
{
|
||||||
|
char buf[512];
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
#ifdef HAVE_TERMIOS_H
|
#ifdef HAVE_TERMIOS_H
|
||||||
@ -481,13 +482,11 @@ prompt_for_password(char *username, char *password)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf("Username: ");
|
printf("Username: ");
|
||||||
fgets(username, 9, stdin);
|
fgets(username, 100, stdin);
|
||||||
length = strlen(username);
|
length = strlen(username);
|
||||||
/* skip rest of the line */
|
/* skip rest of the line */
|
||||||
if (length > 0 && username[length - 1] != '\n')
|
if (length > 0 && username[length - 1] != '\n')
|
||||||
{
|
{
|
||||||
static char buf[512];
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
fgets(buf, 512, stdin);
|
fgets(buf, 512, stdin);
|
||||||
@ -503,7 +502,7 @@ prompt_for_password(char *username, char *password)
|
|||||||
t.c_lflag &= ~ECHO;
|
t.c_lflag &= ~ECHO;
|
||||||
tcsetattr(0, TCSADRAIN, &t);
|
tcsetattr(0, TCSADRAIN, &t);
|
||||||
#endif
|
#endif
|
||||||
fgets(password, 9, stdin);
|
fgets(password, 100, stdin);
|
||||||
#ifdef HAVE_TERMIOS_H
|
#ifdef HAVE_TERMIOS_H
|
||||||
tcsetattr(0, TCSADRAIN, &t_orig);
|
tcsetattr(0, TCSADRAIN, &t_orig);
|
||||||
#endif
|
#endif
|
||||||
@ -512,8 +511,6 @@ prompt_for_password(char *username, char *password)
|
|||||||
/* skip rest of the line */
|
/* skip rest of the line */
|
||||||
if (length > 0 && password[length - 1] != '\n')
|
if (length > 0 && password[length - 1] != '\n')
|
||||||
{
|
{
|
||||||
static char buf[512];
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
fgets(buf, 512, stdin);
|
fgets(buf, 512, stdin);
|
||||||
@ -541,8 +538,8 @@ main(int argc, char **argv)
|
|||||||
int numTables;
|
int numTables;
|
||||||
char connect_string[512] = "";
|
char connect_string[512] = "";
|
||||||
char tmp_string[128];
|
char tmp_string[128];
|
||||||
char username[64];
|
char username[100];
|
||||||
char password[64];
|
char password[100];
|
||||||
int use_password = 0;
|
int use_password = 0;
|
||||||
|
|
||||||
g_verbose = false;
|
g_verbose = false;
|
||||||
@ -2584,7 +2581,13 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
|
|||||||
for (i = 0; i < numIndices; i++)
|
for (i = 0; i < numIndices; i++)
|
||||||
{
|
{
|
||||||
tableInd = findTableByName(tblinfo, numTables,
|
tableInd = findTableByName(tblinfo, numTables,
|
||||||
(indinfo[i].indrelname));
|
indinfo[i].indrelname);
|
||||||
|
if (tableInd < 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "failed sanity check, table %s was not found\n",
|
||||||
|
indinfo[i].indrelname);
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(indinfo[i].indproc, "0") == 0)
|
if (strcmp(indinfo[i].indproc, "0") == 0)
|
||||||
funcname = NULL;
|
funcname = NULL;
|
||||||
|
Reference in New Issue
Block a user