I also noticed that pg_dump contains a copy of the same
authorBruce Momjian <bruce@momjian.us>
Sun, 20 Sep 1998 03:18:43 +0000 (03:18 +0000)
committerBruce Momjian <bruce@momjian.us>
Sun, 20 Sep 1998 03:18:43 +0000 (03:18 +0000)
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

src/bin/pg_dump/common.c
src/bin/pg_dump/pg_dump.c

index 62ba98793c19819b428cb0b60c39ff2ac378892b..c9a806f10a6bd9b3f2936eeb5336e61327bd683d 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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
  *
@@ -116,7 +116,8 @@ findParentsByOid(TableInfo *tblinfo, int numTables,
 {
    int         i,
                j;
-   int         parentInd;
+   int         parentInd,
+               selfInd;
    char      **result;
    int         numParents;
 
@@ -139,6 +140,16 @@ findParentsByOid(TableInfo *tblinfo, int numTables,
            {
                parentInd = findTableByOid(tblinfo, numTables,
                                           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;
            }
        }
@@ -387,6 +398,13 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
        {
            parentInd = findTableByName(tblinfo, numTables,
                                        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++)
            {
                if (strInArray(tblinfo[i].attnames[j],
index 746f2af2166dfd04514e25f74a56c029cb23659e..24f8c4e36ed920ea7b4cc7d4be0c18c8f27edb8c 100644 (file)
@@ -21,7 +21,7 @@
  *
  *
  * 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
  *
@@ -472,6 +472,7 @@ dumpClasses(const TableInfo *tblinfo, const int numTables, FILE *fout,
 static void
 prompt_for_password(char *username, char *password)
 {
+   char        buf[512];
    int         length;
 
 #ifdef HAVE_TERMIOS_H
@@ -481,13 +482,11 @@ prompt_for_password(char *username, char *password)
 #endif
 
    printf("Username: ");
-   fgets(username, 9, stdin);
+   fgets(username, 100, stdin);
    length = strlen(username);
    /* skip rest of the line */
    if (length > 0 && username[length - 1] != '\n')
    {
-       static char buf[512];
-
        do
        {
            fgets(buf, 512, stdin);
@@ -503,7 +502,7 @@ prompt_for_password(char *username, char *password)
    t.c_lflag &= ~ECHO;
    tcsetattr(0, TCSADRAIN, &t);
 #endif
-   fgets(password, 9, stdin);
+   fgets(password, 100, stdin);
 #ifdef HAVE_TERMIOS_H
    tcsetattr(0, TCSADRAIN, &t_orig);
 #endif
@@ -512,8 +511,6 @@ prompt_for_password(char *username, char *password)
    /* skip rest of the line */
    if (length > 0 && password[length - 1] != '\n')
    {
-       static char buf[512];
-
        do
        {
            fgets(buf, 512, stdin);
@@ -541,8 +538,8 @@ main(int argc, char **argv)
    int         numTables;
    char        connect_string[512] = "";
    char        tmp_string[128];
-   char        username[64];
-   char        password[64];
+   char        username[100];
+   char        password[100];
    int         use_password = 0;
 
    g_verbose = false;
@@ -2584,7 +2581,13 @@ dumpIndices(FILE *fout, IndInfo *indinfo, int numIndices,
    for (i = 0; i < numIndices; i++)
    {
        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)
            funcname = NULL;