aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/selfuncs.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>1997-08-21 02:28:55 +0000
committerBruce Momjian <bruce@momjian.us>1997-08-21 02:28:55 +0000
commitf1edf02cc162ef8c0eccca5109e036e6f6c75642 (patch)
tree9d9f785d85da69cce0e1db515ef4d0fc1f25696f /src/backend/utils/adt/selfuncs.c
parentac3d7b3146067ce690c27218832f1830b9f0a1c4 (diff)
downloadpostgresql-f1edf02cc162ef8c0eccca5109e036e6f6c75642.tar.gz
postgresql-f1edf02cc162ef8c0eccca5109e036e6f6c75642.zip
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/backend/utils/adt/selfuncs.c')
-rw-r--r--src/backend/utils/adt/selfuncs.c47
1 files changed, 19 insertions, 28 deletions
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);
}