summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian1997-08-21 02:28:55 +0000
committerBruce Momjian1997-08-21 02:28:55 +0000
commitf1edf02cc162ef8c0eccca5109e036e6f6c75642 (patch)
tree9d9f785d85da69cce0e1db515ef4d0fc1f25696f
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.
-rw-r--r--src/backend/catalog/heap.c6
-rw-r--r--src/backend/commands/vacuum.c4
-rw-r--r--src/backend/executor/nodeSort.c4
-rw-r--r--src/backend/port/aix/dlfcn.c1
-rw-r--r--src/backend/utils/adt/selfuncs.c47
-rw-r--r--src/bin/pg_dump/pg_dump.c13
-rw-r--r--src/bin/pg_dump/pg_dumpall16
-rw-r--r--src/include/catalog/pg_attribute.h10
-rw-r--r--src/include/catalog/pg_database.h4
9 files changed, 52 insertions, 53 deletions
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index f709dec4495..ef6773c0c81 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.18 1997/08/21 01:32:03 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.19 1997/08/21 02:27:53 momjian Exp $
*
* INTERFACE ROUTINES
* heap_creatr() - Create an uncataloged heap relation
@@ -571,7 +571,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
dpp = tupdesc->attrs;
for (i = 0; i < natts; i++) {
(*dpp)->attrelid = new_rel_oid;
- (*dpp)->attnvals = 0l;
+ (*dpp)->attnvals = 0;
tup = heap_addheader(Natts_pg_attribute,
ATTRIBUTE_TUPLE_SIZE,
@@ -592,7 +592,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
dpp = HeapAtt;
for (i = 0; i < -1 - FirstLowInvalidHeapAttributeNumber; i++) {
(*dpp)->attrelid = new_rel_oid;
- /* (*dpp)->attnvals = 0l; unneeded */
+ /* (*dpp)->attnvals = 0; unneeded */
tup = heap_addheader(Natts_pg_attribute,
ATTRIBUTE_TUPLE_SIZE,
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 36fb0948be0..7ecad57cbaf 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.39 1997/08/18 20:52:21 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.40 1997/08/21 02:27:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1814,7 +1814,7 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats *vacrelst
}
if (selratio > 1.0)
selratio = 1.0;
- attp->attnvals = (selratio ? (selratio * ATTNVALS_SCALE) : 0);
+ attp->attnvals = selratio;
WriteNoReleaseBuffer(abuf);
/* DO PG_STATISTIC INSERTS */
diff --git a/src/backend/executor/nodeSort.c b/src/backend/executor/nodeSort.c
index 84c6db71f79..0955108b2fb 100644
--- a/src/backend/executor/nodeSort.c
+++ b/src/backend/executor/nodeSort.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.5 1997/08/06 03:41:31 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.6 1997/08/21 02:28:06 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -170,7 +170,7 @@ ExecSort(Sort *node)
/* *** get_cs_ResultTupleSlot((CommonState) sortstate); */
slot->ttc_tupleDescriptor = ExecGetTupType(outerNode);
-#ifdef 0
+#if 0
slot->ttc_execTupDescriptor = ExecGetExecTupDesc(outerNode);
#endif
/* ----------------
diff --git a/src/backend/port/aix/dlfcn.c b/src/backend/port/aix/dlfcn.c
index b164336d5fd..4e95271e098 100644
--- a/src/backend/port/aix/dlfcn.c
+++ b/src/backend/port/aix/dlfcn.c
@@ -13,6 +13,7 @@
#include <a.out.h>
#include <ldfcn.h>
#include "dlfcn.h"
+#include "c.h"
/*
* We simulate dlopen() et al. through a call to load. Because AIX has
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index b127e4238b2..d8caa5a4776 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.6 1997/04/09 02:20:32 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.7 1997/08/21 02:28:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -33,8 +33,6 @@
#include "utils/lsyscache.h" /* for get_oprrest() */
#include "catalog/pg_statistic.h"
-#include "commands/vacuum.h" /* for ATTNVALS_SCALE */
-
/* N is not a valid var/constant or relation id */
#define NONVALUE(N) ((N) == -1)
@@ -43,7 +41,7 @@
*/
#define FunctionalSelectivity(nIndKeys,attNum) (attNum==InvalidAttrNumber)
-static int32 getattnvals(Oid relid, AttrNumber attnum);
+static float32data getattnvals(Oid relid, AttrNumber attnum);
static void gethilokey(Oid relid, AttrNumber attnum, Oid opid,
char **high, char **low);
@@ -58,19 +56,13 @@ eqsel(Oid opid,
char *value,
int32 flag)
{
- int32 nvals;
float64 result;
result = (float64) palloc(sizeof(float64data));
if (NONVALUE(attno) || NONVALUE(relid))
*result = 0.1;
- else {
- nvals = getattnvals(relid, (int) attno);
- if (nvals == 0)
- *result = 0.0;
- else
- *result = ((float64data)nvals) / ((float64data)ATTNVALS_SCALE);
- }
+ else
+ *result = (float64data)getattnvals(relid, (int) attno);
return(result);
}
@@ -102,7 +94,7 @@ intltsel(Oid opid,
int32 value,
int32 flag)
{
- float64 result;
+ float64 result;
char *highchar, *lowchar;
long val, high, low, top, bottom;
@@ -121,12 +113,15 @@ intltsel(Oid opid,
low = atol(lowchar);
if ((flag & SEL_RIGHT && val < low) ||
(!(flag & SEL_RIGHT) && val > high)) {
- int nvals;
+ float32data nvals;
nvals = getattnvals(relid, (int) attno);
if (nvals == 0)
*result = 1.0 / 3.0;
- else
- *result = 3.0 * ((float64data)nvals) / ((float64data)ATTNVALS_SCALE);
+ else {
+ *result = 3.0 * (float64data)nvals;
+ if (*result > 1.0)
+ *result = 1;
+ }
}else {
bottom = high - low;
if (bottom == 0)
@@ -180,7 +175,7 @@ eqjoinsel(Oid opid,
AttrNumber attno2)
{
float64 result;
- int32 num1, num2, max;
+ float32data num1, num2, max;
result = (float64) palloc(sizeof(float64data));
if (NONVALUE(attno1) || NONVALUE(relid1) ||
@@ -193,7 +188,7 @@ eqjoinsel(Oid opid,
if (max == 0)
*result = 1.0;
else
- *result = ((float64data)max) / ((float64data)ATTNVALS_SCALE);
+ *result = (float64data)max;
}
return(result);
}
@@ -263,11 +258,12 @@ intgtjoinsel(Oid opid,
* more efficient. However, the cast will not work
* for gethilokey which accesses stahikey in struct statistic.
*/
-static int32
+static float32data
getattnvals(Oid relid, AttrNumber attnum)
{
HeapTuple atp;
- int nvals;
+ float32data nvals;
+ int32 ntuples;
atp = SearchSysCacheTuple(ATTNUM,
ObjectIdGetDatum(relid),
@@ -290,15 +286,10 @@ getattnvals(Oid relid, AttrNumber attnum)
elog(WARN, "getattnvals: no relation tuple %d", relid);
return(0);
}
- nvals = ((Form_pg_class) GETSTRUCT(atp))->reltuples;
+ ntuples = ((Form_pg_class) GETSTRUCT(atp))->reltuples;
/* Look above how nvals is used. - vadim 04/09/97 */
- if ( nvals > 0 )
- {
- double selratio = 1.0 / (double)nvals;
-
- selratio *= (double)ATTNVALS_SCALE;
- nvals = (int) ceil (selratio);
- }
+ if ( ntuples > 0 )
+ nvals = 1.0 / ntuples;
return(nvals);
}
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 - [email protected] - 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;"
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index 9fb92243b6f..da28d2b7055 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_attribute.h,v 1.9 1997/08/21 01:37:51 vadim Exp $
+ * $Id: pg_attribute.h,v 1.10 1997/08/21 02:28:52 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@@ -48,7 +48,7 @@ CATALOG(pg_attribute) BOOTSTRAP {
attributes of this instance, so they had better match or Postgres
will fail.
*/
- int4 attnvals;
+ float4 attnvals;
int2 attlen;
/* attlen is a copy of the typlen field from pg_type for this
attribute. See atttypid above. See struct TypeTupleFormData for
@@ -209,7 +209,7 @@ DATA(insert OID = 0 ( 1247 vtype 18 0 1 -11 0 -1 t f c f f));
* ----------------
*/
DATA(insert OID = 0 ( 1262 datname 19 0 NAMEDATALEN 1 0 -1 f f i f f));
-DATA(insert OID = 0 ( 1262 datdba 26 0 4 2 0 -1 t f i f f));
+DATA(insert OID = 0 ( 1262 datdba 23 0 4 2 0 -1 t f s f f));
DATA(insert OID = 0 ( 1262 datpath 25 0 -1 3 0 -1 f f i f f));
DATA(insert OID = 0 ( 1262 ctid 27 0 6 -1 0 -1 f f i f f));
DATA(insert OID = 0 ( 1262 oid 26 0 4 -2 0 -1 t f i f f));
@@ -362,7 +362,7 @@ DATA(insert OID = 0 ( 1261 vtype 18 0 1 -11 0 -1 t f c f f));
{ 1249l, {"attrelid"}, 26l, 0l, 4, 1, 0l, -1l, '\001', '\0', 'i', '\0', '\0' }, \
{ 1249l, {"attname"}, 19l, 0l, NAMEDATALEN, 2, 0l, -1l, '\0', '\0', 'i', '\0', '\0' }, \
{ 1249l, {"atttypid"}, 26l, 0l, 4, 3, 0l, -1l, '\001', '\0', 'i', '\0', '\0' }, \
-{ 1249l, {"attnvals"}, 23l, 0l, 4, 4, 0l, -1l, '\001', '\0', 'i', '\0', '\0' }, \
+{ 1249l, {"attnvals"}, 700l, 0l, 4, 4, 0l, -1l, '\001', '\0', 'i', '\0', '\0' }, \
{ 1249l, {"attlen"}, 21l, 0l, 2, 5, 0l, -1l, '\001', '\0', 's', '\0', '\0' }, \
{ 1249l, {"attnum"}, 21l, 0l, 2, 6, 0l, -1l, '\001', '\0', 's', '\0', '\0' }, \
{ 1249l, {"attnelems"}, 23l, 0l, 4, 7, 0l, -1l, '\001', '\0', 'i', '\0', '\0' }, \
@@ -376,7 +376,7 @@ DATA(insert OID = 0 ( 1261 vtype 18 0 1 -11 0 -1 t f c f f));
DATA(insert OID = 0 ( 1249 attrelid 26 0 4 1 0 -1 t f i f f));
DATA(insert OID = 0 ( 1249 attname 19 0 NAMEDATALEN 2 0 -1 f f i f f));
DATA(insert OID = 0 ( 1249 atttypid 26 0 4 3 0 -1 t f i f f));
-DATA(insert OID = 0 ( 1249 attnvals 23 0 4 4 0 -1 t f i f f));
+DATA(insert OID = 0 ( 1249 attnvals 700 0 4 4 0 -1 t f i f f));
DATA(insert OID = 0 ( 1249 attlen 21 0 2 5 0 -1 t f s f f));
DATA(insert OID = 0 ( 1249 attnum 21 0 2 6 0 -1 t f s f f));
DATA(insert OID = 0 ( 1249 attnelems 23 0 4 7 0 -1 t f i f f));
diff --git a/src/include/catalog/pg_database.h b/src/include/catalog/pg_database.h
index 057d40b19fc..56536f811bd 100644
--- a/src/include/catalog/pg_database.h
+++ b/src/include/catalog/pg_database.h
@@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_database.h,v 1.2 1996/10/31 09:47:23 scrappy Exp $
+ * $Id: pg_database.h,v 1.3 1997/08/21 02:28:55 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@@ -32,7 +32,7 @@
*/
CATALOG(pg_database) BOOTSTRAP {
NameData datname;
- Oid datdba;
+ int4 datdba;
text datpath; /* VARIABLE LENGTH FIELD */
} FormData_pg_database;