Commit e67ff6b6 authored by Tom Lane's avatar Tom Lane

fmgr interface mopup work. Use new DatumGetBool and BoolGetDatum

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.
parent b503cbe3
<!--
$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>
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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 */
......@@ -371,15 +371,15 @@ 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++] = 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.
......
......@@ -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,7 +436,7 @@ update_attstats(Oid relid, int natts, VacAttrStats *vacattrstats)
if (VacAttrStatsEqValid(stats))
{
float32data selratio; /* average ratio of rows selected
float4 selratio; /* average ratio of rows selected
* for a random constant */
/* Compute disbursion */
......
......@@ -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);
......
......@@ -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 */
/*
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment