summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorBruce Momjian1997-08-21 02:28:55 +0000
committerBruce Momjian1997-08-21 02:28:55 +0000
commitf1edf02cc162ef8c0eccca5109e036e6f6c75642 (patch)
tree9d9f785d85da69cce0e1db515ef4d0fc1f25696f /src/bin
parentac3d7b3146067ce690c27218832f1830b9f0a1c4 (diff)
Change pg_attribute.attnvals to float4, change #ifdef 0 to #if 0, fix aix call to strNcpy, fix pg_super_user_id in pg_dumpall, change pg_database.dtadba from oid to int4.
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_dump/pg_dump.c13
-rw-r--r--src/bin/pg_dump/pg_dumpall16
2 files changed, 18 insertions, 11 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 6c32da2e717..8eae85911a6 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -21,7 +21,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.38 1997/08/19 21:36:40 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.39 1997/08/21 02:28:41 momjian Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
@@ -805,8 +805,6 @@ clearTableInfo(TableInfo *tblinfo, int numTables)
if ( tblinfo[i].sequence )
continue;
- if (tblinfo[i].notnull) free (tblinfo[i].notnull);
-
/* Process Attributes */
for(j=0;j<tblinfo[i].numatts;j++) {
if(tblinfo[i].attnames[j]) free (tblinfo[i].attnames[j]);
@@ -816,6 +814,8 @@ clearTableInfo(TableInfo *tblinfo, int numTables)
if(tblinfo[i].inhAttrs) free((int *)tblinfo[i].inhAttrs);
if(tblinfo[i].attnames) free (tblinfo[i].attnames);
if(tblinfo[i].typnames) free (tblinfo[i].typnames);
+ if(tblinfo[i].notnull) free (tblinfo[i].notnull);
+
}
free(tblinfo);
}
@@ -1299,7 +1299,7 @@ getTableAttrs(TableInfo* tblinfo, int numTables)
if (tblinfo[i].attlen[j] > 0)
tblinfo[i].attlen[j] = tblinfo[i].attlen[j] - 4;
tblinfo[i].inhAttrs[j] = 0; /* this flag is set in flagInhAttrs()*/
- tblinfo[i].notnull[j] = PQgetvalue(res,j,i_attnotnull)[0]=='t'?true:false;
+ tblinfo[i].notnull[j] = (PQgetvalue(res,j,i_attnotnull)[0]=='t')?true:false;
}
PQclear(res);
}
@@ -1514,7 +1514,7 @@ dumpOneFunc(FILE* fout, FuncInfo* finfo, int i,
}
sprintf(q,"%s ) RETURNS %s%s AS '%s' LANGUAGE '%s';\n",
q,
- finfo[i].retset ? " SETOF " : "",
+ (finfo[i].retset) ? " SETOF " : "",
findTypeByOid(tinfo, numTypes, finfo[i].prorettype),
(finfo[i].lang) ? finfo[i].probin : finfo[i].prosrc,
(finfo[i].lang) ? "C" : "SQL");
@@ -1779,7 +1779,8 @@ void dumpTables(FILE* fout, TableInfo *tblinfo, int numTables,
tblinfo[i].typnames[j]);
actual_atts++;
}
- sprintf(q, "%s%s NULL", q, tblinfo[i].notnull[j]?" NOT":"");
+ sprintf(q, "%s%s NULL", q,
+ (tblinfo[i].notnull[j]) ? " NOT" : "");
}
}
diff --git a/src/bin/pg_dump/pg_dumpall b/src/bin/pg_dump/pg_dumpall
index 0e3a1ef0ab2..0a456ad101a 100644
--- a/src/bin/pg_dump/pg_dumpall
+++ b/src/bin/pg_dump/pg_dumpall
@@ -27,14 +27,20 @@ echo "${BS}connect template1"
#
# delete all users in case they run this twice
#
-echo "delete from pg_user"
-echo "where usesysid <> $POSTGRES_SUPER_USER_ID;"
+# we don't use POSTGRES_SUPER_USER_ID because the postgres super user id
+# could be different on the two installations
+#
+echo "select datdba into tmp_pguser \
+ from pg_database where datname = 'template1';"
+echo "delete from pg_user where usesysid <> tmp_pguser.datdba;"
+echo "drop table tmp_pguser;"
#
# load all the non-postgres users
#
echo "copy pg_user from stdin;"
psql -q template1 <<END
-select pg_user.* into table tmp_pg_user
+select pg_user.*
+into table tmp_pg_user
from pg_user
where usesysid <> $POSTGRES_SUPER_USER_ID;
copy tmp_pg_user to stdout;
@@ -42,12 +48,12 @@ drop table tmp_pg_user;
END
echo "${BS}."
psql -l -A -q -t| tr '|' ' ' | grep -v '^template1 ' | \
-while read DATABASE PGUSERID DATAPATH
+while read DATABASE DBUSERID DATAPATH
do
POSTGRES_USER="`echo \" \
select usename \
from pg_user \
- where usesysid = $PGUSERID; \" | \
+ where usesysid = $DBUSERID; \" | \
psql -A -q -t template1`"
echo "${BS}connect template1 $POSTGRES_USER"
echo "create database $DATABASE;"