]> granicus.if.org Git - postgresql/commitdiff
fmgr interface mopup work. Use new DatumGetBool and BoolGetDatum
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 21 Aug 2000 17:22:36 +0000 (17:22 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 21 Aug 2000 17:22:36 +0000 (17:22 +0000)
macros where appropriate (the code used to have several different ways
of doing that, including Int32, Int8, UInt8, ...).  Remove last few
references to float32 and float64 typedefs --- it's all float4/float8
now.  The typedefs themselves should probably stay in c.h for a release
or two, though, to avoid breaking user-written C functions.

doc/src/sgml/xfunc.sgml
src/backend/catalog/pg_operator.c
src/backend/catalog/pg_proc.c
src/backend/catalog/pg_type.c
src/backend/commands/analyze.c
src/backend/commands/command.c
src/backend/optimizer/util/clauses.c
src/include/c.h

index fe3ef3108bb6bb9b25a5f86d4174141a2258f8f6..23db3819c781768c9a5a32946b6a66fafe943d6c 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.17 2000/05/27 18:18:31 tgl Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.18 2000/08/21 17:22:36 tgl Exp $
 -->
 
  <chapter id="xfunc">
@@ -499,12 +499,12 @@ SELECT clean_EMP();
        </row>
        <row>
         <entry>float4</entry>
-        <entry>float32 or (float4 *)</entry>
+        <entry>(float4 *)</entry>
        <entry>include/c.h or include/postgres.h</entry>
        </row>
        <row>
         <entry>float8</entry>
-        <entry>float64 or (float8 *)</entry>
+        <entry>(float8 *)</entry>
         <entry>include/c.h or include/postgres.h</entry>
        </row>
        <row>
index 5796b11b988ea2068681f5cace2e54f8167a60f1..a0c6dd70a385d0e095c043b7c58f00fdae3c4ac0 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.50 2000/05/28 17:55:54 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.51 2000/08/21 17:22:35 tgl Exp $
  *
  * NOTES
  *       these routines moved here from commands/define.c and somewhat cleaned up.
@@ -262,10 +262,10 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc,
        namestrcpy(&oname, operatorName);
        values[i++] = NameGetDatum(&oname);
        values[i++] = Int32GetDatum(GetUserId());
-       values[i++] = (Datum) (uint16) 0;
-       values[i++] = (Datum) 'b';      /* assume it's binary */
-       values[i++] = (Datum) (bool) 0;
-       values[i++] = (Datum) (bool) 0;
+       values[i++] = UInt16GetDatum(0);
+       values[i++] = CharGetDatum('b'); /* assume it's binary */
+       values[i++] = BoolGetDatum(false);
+       values[i++] = BoolGetDatum(false);
        values[i++] = ObjectIdGetDatum(leftObjectId);           /* <-- left oid */
        values[i++] = ObjectIdGetDatum(rightObjectId);          /* <-- right oid */
        values[i++] = ObjectIdGetDatum(InvalidOid);
@@ -648,9 +648,9 @@ OperatorDef(char *operatorName,
        values[i++] = NameGetDatum(&oname);
        values[i++] = Int32GetDatum(GetUserId());
        values[i++] = UInt16GetDatum(precedence);
-       values[i++] = leftTypeName ? (rightTypeName ? 'b' : 'r') : 'l';
-       values[i++] = Int8GetDatum(isLeftAssociative);
-       values[i++] = Int8GetDatum(canHash);
+       values[i++] = CharGetDatum(leftTypeName ? (rightTypeName ? 'b' : 'r') : 'l');
+       values[i++] = BoolGetDatum(isLeftAssociative);
+       values[i++] = BoolGetDatum(canHash);
        values[i++] = ObjectIdGetDatum(leftTypeId);
        values[i++] = ObjectIdGetDatum(rightTypeId);
 
index 0322d982d16c24e75f759caa1970c811af8cda26..ab6ce91e46d8e15fb034d9ec4ba60d0683b64ca2 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.46 2000/07/05 23:11:07 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.47 2000/08/21 17:22:35 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -295,14 +295,14 @@ ProcedureCreate(char *procedureName,
        values[i++] = Int32GetDatum(GetUserId());
        values[i++] = ObjectIdGetDatum(languageObjectId);
        /* XXX isinherited is always false for now */
-       values[i++] = Int8GetDatum((bool) false);
-       values[i++] = Int8GetDatum(trusted);
-       values[i++] = Int8GetDatum(canCache);
-       values[i++] = Int8GetDatum(isStrict);
+       values[i++] = BoolGetDatum(false);
+       values[i++] = BoolGetDatum(trusted);
+       values[i++] = BoolGetDatum(canCache);
+       values[i++] = BoolGetDatum(isStrict);
        values[i++] = UInt16GetDatum(parameterCount);
-       values[i++] = Int8GetDatum(returnsSet);
+       values[i++] = BoolGetDatum(returnsSet);
        values[i++] = ObjectIdGetDatum(typeObjectId);
-       values[i++] = (Datum) typev;
+       values[i++] = PointerGetDatum(typev);
        values[i++] = Int32GetDatum(byte_pct);          /* probyte_pct */
        values[i++] = Int32GetDatum(perbyte_cpu);       /* properbyte_cpu */
        values[i++] = Int32GetDatum(percall_cpu);       /* propercall_cpu */
index 8356958d325186a008be2f0172f3a0a4b32dc886..2e5970cfcc856d109cbe5943eaa2ced78d0c4da6 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.54 2000/07/05 23:11:07 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.55 2000/08/21 17:22:35 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -177,17 +177,17 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName)
        values[i++] = Int16GetDatum(0);                         /* 3 */
        values[i++] = Int16GetDatum(0);                         /* 4 */
        values[i++] = BoolGetDatum(false);                      /* 5 */
-       values[i++] = BoolGetDatum(false);                      /* 6 */
+       values[i++] = CharGetDatum(0);                          /* 6 */
        values[i++] = BoolGetDatum(false);                      /* 7 */
-       values[i++] = BoolGetDatum(false);                      /* 8 */
+       values[i++] = CharGetDatum(0);                          /* 8 */
        values[i++] = ObjectIdGetDatum(InvalidOid);     /* 9 */
        values[i++] = ObjectIdGetDatum(InvalidOid);     /* 10 */
        values[i++] = ObjectIdGetDatum(InvalidOid);     /* 11 */
        values[i++] = ObjectIdGetDatum(InvalidOid);     /* 12 */
        values[i++] = ObjectIdGetDatum(InvalidOid);     /* 13 */
        values[i++] = ObjectIdGetDatum(InvalidOid);     /* 14 */
-       values[i++] = CharGetDatum('p');                        /* 15 */
-       values[i++] = CharGetDatum('i');                        /* 16 */
+       values[i++] = CharGetDatum('i');                        /* 15 */
+       values[i++] = CharGetDatum('p');                        /* 16 */
        values[i++] = DirectFunctionCall1(textin,
                                                                          CStringGetDatum(typeName));   /* 17 */
 
@@ -370,16 +370,16 @@ TypeCreate(char *typeName,
         */
        i = 0;
        namestrcpy(&name, typeName);
-       values[i++] = NameGetDatum(&name);      /* 1 */
-       values[i++] = (Datum) GetUserId();      /* 2 */
-       values[i++] = (Datum) internalSize; /* 3 */
-       values[i++] = (Datum) externalSize; /* 4 */
-       values[i++] = (Datum) passedByValue;            /* 5 */
-       values[i++] = (Datum) typeType;         /* 6 */
-       values[i++] = (Datum) (bool) 1;         /* 7 */
-       values[i++] = (Datum) typDelim;         /* 8 */
-       values[i++] = (Datum) (typeType == 'c' ? relationOid : InvalidOid); /* 9 */
-       values[i++] = (Datum) elementObjectId;          /* 10 */
+       values[i++] = NameGetDatum(&name);                      /* 1 */
+       values[i++] = Int32GetDatum(GetUserId());       /* 2 */
+       values[i++] = Int16GetDatum(internalSize);      /* 3 */
+       values[i++] = Int16GetDatum(externalSize);      /* 4 */
+       values[i++] = BoolGetDatum(passedByValue);      /* 5 */
+       values[i++] = CharGetDatum(typeType);           /* 6 */
+       values[i++] = BoolGetDatum(true);                       /* 7 */
+       values[i++] = CharGetDatum(typDelim);           /* 8 */
+       values[i++] = ObjectIdGetDatum(typeType == 'c' ? relationOid : InvalidOid); /* 9 */
+       values[i++] = ObjectIdGetDatum(elementObjectId); /* 10 */
 
        procs[0] = inputProcedure;
        procs[1] = outputProcedure;
@@ -438,20 +438,20 @@ TypeCreate(char *typeName,
                                func_error("TypeCreate", procname, 1, argList, NULL);
                }
 
-               values[i++] = (Datum) tup->t_data->t_oid;               /* 11 - 14 */
+               values[i++] = ObjectIdGetDatum(tup->t_data->t_oid);     /* 11 - 14 */
        }
 
        /* ----------------
         * set default alignment
         * ----------------
         */
-       values[i++] = (Datum) alignment;        /* 15 */
+       values[i++] = CharGetDatum(alignment);  /* 15 */
 
        /* ----------------
         *      set default storage for TOAST
         * ----------------
         */
-       values[i++] = (Datum) storage; /* 16 */
+       values[i++] = CharGetDatum(storage);    /* 16 */
 
        /* ----------------
         *      initialize the default value for this type.
index 757003f81129fc5e079cac53e4440c34d4cd328e..1747132f8a7247965f95b7c4873918b91fb824c9 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.4 2000/08/06 04:40:08 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.5 2000/08/21 17:22:32 tgl Exp $
  *
 
  *-------------------------------------------------------------------------
@@ -436,8 +436,8 @@ update_attstats(Oid relid, int natts, VacAttrStats *vacattrstats)
 
                if (VacAttrStatsEqValid(stats))
                {
-                       float32data selratio;   /* average ratio of rows selected
-                                                                        * for a random constant */
+                       float4  selratio;       /* average ratio of rows selected
+                                                                * for a random constant */
 
                        /* Compute disbursion */
                        if (stats->nonnull_cnt == 0 && stats->null_cnt == 0)
index 68487f64ffce08b5e61edfa2629fcaefeb3f75d9..13d0ad56497714cd1c32f3d410041535445bb4fd 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.94 2000/08/04 04:16:06 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.95 2000/08/21 17:22:32 tgl Exp $
  *
  * NOTES
  *       The PerformAddAttribute() code, like most of the relation
@@ -614,7 +614,7 @@ AlterTableAlterColumn(const char *relationName,
                                                           Int16GetDatum(attnum));
                ScanKeyEntryInitialize(&scankeys[2], 0x0,
                                                           Anum_pg_attribute_atthasdef, F_BOOLEQ,
-                                                          Int32GetDatum(TRUE));
+                                                          BoolGetDatum(true));
 
                scan = heap_beginscan(attr_rel, false, SnapshotNow, 3, scankeys);
                AssertState(scan != NULL);
index 65e714563601d83e64d5dc79ccaf04f0a8d4114e..22d93b26e7ba33c0d62f378565f34f1852b66582 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.71 2000/08/13 02:50:10 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.72 2000/08/21 17:22:34 tgl Exp $
  *
  * HISTORY
  *       AUTHOR                        DATE                    MAJOR EVENT
@@ -353,7 +353,7 @@ make_ands_implicit(Expr *clause)
                return clause->args;
        else if (IsA(clause, Const) &&
                         !((Const *) clause)->constisnull &&
-                        DatumGetInt32(((Const *) clause)->constvalue))
+                        DatumGetBool(((Const *) clause)->constvalue))
                return NIL;                             /* constant TRUE input -> NIL list */
        else
                return lcons(clause, NIL);
@@ -1111,12 +1111,15 @@ eval_const_expressions_mutator(Node *node, void *context)
                        case OR_EXPR:
                                {
 
-                                       /*
-                                        * OR arguments are handled as follows: non constant:
-                                        * keep FALSE: drop (does not affect result) TRUE:
-                                        * force result to TRUE NULL: keep only one We keep
-                                        * one NULL input because ExecEvalOr returns NULL when
-                                        * no input is TRUE and at least one is NULL.
+                                       /*----------
+                                        * OR arguments are handled as follows:
+                                        *      non constant: keep
+                                        *      FALSE: drop (does not affect result)
+                                        *      TRUE: force result to TRUE
+                                        *      NULL: keep only one
+                                        * We keep one NULL input because ExecEvalOr returns NULL
+                                        * when no input is TRUE and at least one is NULL.
+                                        *----------
                                         */
                                        List       *newargs = NIL;
                                        List       *arg;
@@ -1133,7 +1136,7 @@ eval_const_expressions_mutator(Node *node, void *context)
                                                const_input = (Const *) lfirst(arg);
                                                if (const_input->constisnull)
                                                        haveNull = true;
-                                               else if (DatumGetInt32(const_input->constvalue))
+                                               else if (DatumGetBool(const_input->constvalue))
                                                        forceTrue = true;
                                                /* otherwise, we can drop the constant-false input */
                                        }
@@ -1161,12 +1164,15 @@ eval_const_expressions_mutator(Node *node, void *context)
                        case AND_EXPR:
                                {
 
-                                       /*
-                                        * AND arguments are handled as follows: non constant:
-                                        * keep TRUE: drop (does not affect result) FALSE:
-                                        * force result to FALSE NULL: keep only one We keep
-                                        * one NULL input because ExecEvalAnd returns NULL
+                                       /*----------
+                                        * AND arguments are handled as follows:
+                                        *      non constant: keep
+                                        *      TRUE: drop (does not affect result)
+                                        *      FALSE: force result to FALSE
+                                        *      NULL: keep only one
+                                        * We keep one NULL input because ExecEvalAnd returns NULL
                                         * when no input is FALSE and at least one is NULL.
+                                        *----------
                                         */
                                        List       *newargs = NIL;
                                        List       *arg;
@@ -1183,7 +1189,7 @@ eval_const_expressions_mutator(Node *node, void *context)
                                                const_input = (Const *) lfirst(arg);
                                                if (const_input->constisnull)
                                                        haveNull = true;
-                                               else if (!DatumGetInt32(const_input->constvalue))
+                                               else if (!DatumGetBool(const_input->constvalue))
                                                        forceFalse = true;
                                                /* otherwise, we can drop the constant-true input */
                                        }
@@ -1217,7 +1223,7 @@ eval_const_expressions_mutator(Node *node, void *context)
                                if (const_input->constisnull)
                                        return MAKEBOOLCONST(false, true);
                                /* otherwise pretty easy */
-                               return MAKEBOOLCONST(!DatumGetInt32(const_input->constvalue),
+                               return MAKEBOOLCONST(!DatumGetBool(const_input->constvalue),
                                                                         false);
                        case SUBPLAN_EXPR:
 
@@ -1330,7 +1336,7 @@ eval_const_expressions_mutator(Node *node, void *context)
                        }
                        const_input = (Const *) casewhen->expr;
                        if (const_input->constisnull ||
-                               !DatumGetInt32(const_input->constvalue))
+                               !DatumGetBool(const_input->constvalue))
                                continue;               /* drop alternative with FALSE condition */
 
                        /*
index 2cd807d98c54c42478f53f9a0e3c20717f0a57c5..8bdb40a58a799feefae732778272701b03723b0d 100644 (file)
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: c.h,v 1.80 2000/07/17 04:35:55 tgl Exp $
+ * $Id: c.h,v 1.81 2000/08/21 17:22:32 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -186,6 +186,9 @@ typedef unsigned int uint32;        /* == 32 bits */
  *
  *             Since sizeof(floatN) may be > sizeof(char *), always pass
  *             floatN by reference.
+ *
+ * XXX: these typedefs are now deprecated in favor of float4 and float8.
+ * They will eventually go away.
  */
 typedef float float32data;
 typedef double float64data;