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"> <chapter id="xfunc">
...@@ -499,12 +499,12 @@ SELECT clean_EMP(); ...@@ -499,12 +499,12 @@ SELECT clean_EMP();
</row> </row>
<row> <row>
<entry>float4</entry> <entry>float4</entry>
<entry>float32 or (float4 *)</entry> <entry>(float4 *)</entry>
<entry>include/c.h or include/postgres.h</entry> <entry>include/c.h or include/postgres.h</entry>
</row> </row>
<row> <row>
<entry>float8</entry> <entry>float8</entry>
<entry>float64 or (float8 *)</entry> <entry>(float8 *)</entry>
<entry>include/c.h or include/postgres.h</entry> <entry>include/c.h or include/postgres.h</entry>
</row> </row>
<row> <row>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* these routines moved here from commands/define.c and somewhat cleaned up. * these routines moved here from commands/define.c and somewhat cleaned up.
...@@ -262,10 +262,10 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc, ...@@ -262,10 +262,10 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc,
namestrcpy(&oname, operatorName); namestrcpy(&oname, operatorName);
values[i++] = NameGetDatum(&oname); values[i++] = NameGetDatum(&oname);
values[i++] = Int32GetDatum(GetUserId()); values[i++] = Int32GetDatum(GetUserId());
values[i++] = (Datum) (uint16) 0; values[i++] = UInt16GetDatum(0);
values[i++] = (Datum) 'b'; /* assume it's binary */ values[i++] = CharGetDatum('b'); /* assume it's binary */
values[i++] = (Datum) (bool) 0; values[i++] = BoolGetDatum(false);
values[i++] = (Datum) (bool) 0; values[i++] = BoolGetDatum(false);
values[i++] = ObjectIdGetDatum(leftObjectId); /* <-- left oid */ values[i++] = ObjectIdGetDatum(leftObjectId); /* <-- left oid */
values[i++] = ObjectIdGetDatum(rightObjectId); /* <-- right oid */ values[i++] = ObjectIdGetDatum(rightObjectId); /* <-- right oid */
values[i++] = ObjectIdGetDatum(InvalidOid); values[i++] = ObjectIdGetDatum(InvalidOid);
...@@ -648,9 +648,9 @@ OperatorDef(char *operatorName, ...@@ -648,9 +648,9 @@ OperatorDef(char *operatorName,
values[i++] = NameGetDatum(&oname); values[i++] = NameGetDatum(&oname);
values[i++] = Int32GetDatum(GetUserId()); values[i++] = Int32GetDatum(GetUserId());
values[i++] = UInt16GetDatum(precedence); values[i++] = UInt16GetDatum(precedence);
values[i++] = leftTypeName ? (rightTypeName ? 'b' : 'r') : 'l'; values[i++] = CharGetDatum(leftTypeName ? (rightTypeName ? 'b' : 'r') : 'l');
values[i++] = Int8GetDatum(isLeftAssociative); values[i++] = BoolGetDatum(isLeftAssociative);
values[i++] = Int8GetDatum(canHash); values[i++] = BoolGetDatum(canHash);
values[i++] = ObjectIdGetDatum(leftTypeId); values[i++] = ObjectIdGetDatum(leftTypeId);
values[i++] = ObjectIdGetDatum(rightTypeId); values[i++] = ObjectIdGetDatum(rightTypeId);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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, ...@@ -295,14 +295,14 @@ ProcedureCreate(char *procedureName,
values[i++] = Int32GetDatum(GetUserId()); values[i++] = Int32GetDatum(GetUserId());
values[i++] = ObjectIdGetDatum(languageObjectId); values[i++] = ObjectIdGetDatum(languageObjectId);
/* XXX isinherited is always false for now */ /* XXX isinherited is always false for now */
values[i++] = Int8GetDatum((bool) false); values[i++] = BoolGetDatum(false);
values[i++] = Int8GetDatum(trusted); values[i++] = BoolGetDatum(trusted);
values[i++] = Int8GetDatum(canCache); values[i++] = BoolGetDatum(canCache);
values[i++] = Int8GetDatum(isStrict); values[i++] = BoolGetDatum(isStrict);
values[i++] = UInt16GetDatum(parameterCount); values[i++] = UInt16GetDatum(parameterCount);
values[i++] = Int8GetDatum(returnsSet); values[i++] = BoolGetDatum(returnsSet);
values[i++] = ObjectIdGetDatum(typeObjectId); values[i++] = ObjectIdGetDatum(typeObjectId);
values[i++] = (Datum) typev; values[i++] = PointerGetDatum(typev);
values[i++] = Int32GetDatum(byte_pct); /* probyte_pct */ values[i++] = Int32GetDatum(byte_pct); /* probyte_pct */
values[i++] = Int32GetDatum(perbyte_cpu); /* properbyte_cpu */ values[i++] = Int32GetDatum(perbyte_cpu); /* properbyte_cpu */
values[i++] = Int32GetDatum(percall_cpu); /* propercall_cpu */ values[i++] = Int32GetDatum(percall_cpu); /* propercall_cpu */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -177,17 +177,17 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName)
values[i++] = Int16GetDatum(0); /* 3 */ values[i++] = Int16GetDatum(0); /* 3 */
values[i++] = Int16GetDatum(0); /* 4 */ values[i++] = Int16GetDatum(0); /* 4 */
values[i++] = BoolGetDatum(false); /* 5 */ values[i++] = BoolGetDatum(false); /* 5 */
values[i++] = BoolGetDatum(false); /* 6 */ values[i++] = CharGetDatum(0); /* 6 */
values[i++] = BoolGetDatum(false); /* 7 */ values[i++] = BoolGetDatum(false); /* 7 */
values[i++] = BoolGetDatum(false); /* 8 */ values[i++] = CharGetDatum(0); /* 8 */
values[i++] = ObjectIdGetDatum(InvalidOid); /* 9 */ values[i++] = ObjectIdGetDatum(InvalidOid); /* 9 */
values[i++] = ObjectIdGetDatum(InvalidOid); /* 10 */ values[i++] = ObjectIdGetDatum(InvalidOid); /* 10 */
values[i++] = ObjectIdGetDatum(InvalidOid); /* 11 */ values[i++] = ObjectIdGetDatum(InvalidOid); /* 11 */
values[i++] = ObjectIdGetDatum(InvalidOid); /* 12 */ values[i++] = ObjectIdGetDatum(InvalidOid); /* 12 */
values[i++] = ObjectIdGetDatum(InvalidOid); /* 13 */ values[i++] = ObjectIdGetDatum(InvalidOid); /* 13 */
values[i++] = ObjectIdGetDatum(InvalidOid); /* 14 */ values[i++] = ObjectIdGetDatum(InvalidOid); /* 14 */
values[i++] = CharGetDatum('p'); /* 15 */ values[i++] = CharGetDatum('i'); /* 15 */
values[i++] = CharGetDatum('i'); /* 16 */ values[i++] = CharGetDatum('p'); /* 16 */
values[i++] = DirectFunctionCall1(textin, values[i++] = DirectFunctionCall1(textin,
CStringGetDatum(typeName)); /* 17 */ CStringGetDatum(typeName)); /* 17 */
...@@ -370,16 +370,16 @@ TypeCreate(char *typeName, ...@@ -370,16 +370,16 @@ TypeCreate(char *typeName,
*/ */
i = 0; i = 0;
namestrcpy(&name, typeName); namestrcpy(&name, typeName);
values[i++] = NameGetDatum(&name); /* 1 */ values[i++] = NameGetDatum(&name); /* 1 */
values[i++] = (Datum) GetUserId(); /* 2 */ values[i++] = Int32GetDatum(GetUserId()); /* 2 */
values[i++] = (Datum) internalSize; /* 3 */ values[i++] = Int16GetDatum(internalSize); /* 3 */
values[i++] = (Datum) externalSize; /* 4 */ values[i++] = Int16GetDatum(externalSize); /* 4 */
values[i++] = (Datum) passedByValue; /* 5 */ values[i++] = BoolGetDatum(passedByValue); /* 5 */
values[i++] = (Datum) typeType; /* 6 */ values[i++] = CharGetDatum(typeType); /* 6 */
values[i++] = (Datum) (bool) 1; /* 7 */ values[i++] = BoolGetDatum(true); /* 7 */
values[i++] = (Datum) typDelim; /* 8 */ values[i++] = CharGetDatum(typDelim); /* 8 */
values[i++] = (Datum) (typeType == 'c' ? relationOid : InvalidOid); /* 9 */ values[i++] = ObjectIdGetDatum(typeType == 'c' ? relationOid : InvalidOid); /* 9 */
values[i++] = (Datum) elementObjectId; /* 10 */ values[i++] = ObjectIdGetDatum(elementObjectId); /* 10 */
procs[0] = inputProcedure; procs[0] = inputProcedure;
procs[1] = outputProcedure; procs[1] = outputProcedure;
...@@ -438,20 +438,20 @@ TypeCreate(char *typeName, ...@@ -438,20 +438,20 @@ TypeCreate(char *typeName,
func_error("TypeCreate", procname, 1, argList, NULL); 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 * set default alignment
* ---------------- * ----------------
*/ */
values[i++] = (Datum) alignment; /* 15 */ values[i++] = CharGetDatum(alignment); /* 15 */
/* ---------------- /* ----------------
* set default storage for TOAST * set default storage for TOAST
* ---------------- * ----------------
*/ */
values[i++] = (Datum) storage; /* 16 */ values[i++] = CharGetDatum(storage); /* 16 */
/* ---------------- /* ----------------
* initialize the default value for this type. * initialize the default value for this type.
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -436,8 +436,8 @@ update_attstats(Oid relid, int natts, VacAttrStats *vacattrstats)
if (VacAttrStatsEqValid(stats)) if (VacAttrStatsEqValid(stats))
{ {
float32data selratio; /* average ratio of rows selected float4 selratio; /* average ratio of rows selected
* for a random constant */ * for a random constant */
/* Compute disbursion */ /* Compute disbursion */
if (stats->nonnull_cnt == 0 && stats->null_cnt == 0) if (stats->nonnull_cnt == 0 && stats->null_cnt == 0)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* The PerformAddAttribute() code, like most of the relation * The PerformAddAttribute() code, like most of the relation
...@@ -614,7 +614,7 @@ AlterTableAlterColumn(const char *relationName, ...@@ -614,7 +614,7 @@ AlterTableAlterColumn(const char *relationName,
Int16GetDatum(attnum)); Int16GetDatum(attnum));
ScanKeyEntryInitialize(&scankeys[2], 0x0, ScanKeyEntryInitialize(&scankeys[2], 0x0,
Anum_pg_attribute_atthasdef, F_BOOLEQ, Anum_pg_attribute_atthasdef, F_BOOLEQ,
Int32GetDatum(TRUE)); BoolGetDatum(true));
scan = heap_beginscan(attr_rel, false, SnapshotNow, 3, scankeys); scan = heap_beginscan(attr_rel, false, SnapshotNow, 3, scankeys);
AssertState(scan != NULL); AssertState(scan != NULL);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -353,7 +353,7 @@ make_ands_implicit(Expr *clause) ...@@ -353,7 +353,7 @@ make_ands_implicit(Expr *clause)
return clause->args; return clause->args;
else if (IsA(clause, Const) && else if (IsA(clause, Const) &&
!((Const *) clause)->constisnull && !((Const *) clause)->constisnull &&
DatumGetInt32(((Const *) clause)->constvalue)) DatumGetBool(((Const *) clause)->constvalue))
return NIL; /* constant TRUE input -> NIL list */ return NIL; /* constant TRUE input -> NIL list */
else else
return lcons(clause, NIL); return lcons(clause, NIL);
...@@ -1111,12 +1111,15 @@ eval_const_expressions_mutator(Node *node, void *context) ...@@ -1111,12 +1111,15 @@ eval_const_expressions_mutator(Node *node, void *context)
case OR_EXPR: case OR_EXPR:
{ {
/* /*----------
* OR arguments are handled as follows: non constant: * OR arguments are handled as follows:
* keep FALSE: drop (does not affect result) TRUE: * non constant: keep
* force result to TRUE NULL: keep only one We keep * FALSE: drop (does not affect result)
* one NULL input because ExecEvalOr returns NULL when * TRUE: force result to TRUE
* no input is TRUE and at least one is NULL. * 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 *newargs = NIL;
List *arg; List *arg;
...@@ -1133,7 +1136,7 @@ eval_const_expressions_mutator(Node *node, void *context) ...@@ -1133,7 +1136,7 @@ eval_const_expressions_mutator(Node *node, void *context)
const_input = (Const *) lfirst(arg); const_input = (Const *) lfirst(arg);
if (const_input->constisnull) if (const_input->constisnull)
haveNull = true; haveNull = true;
else if (DatumGetInt32(const_input->constvalue)) else if (DatumGetBool(const_input->constvalue))
forceTrue = true; forceTrue = true;
/* otherwise, we can drop the constant-false input */ /* otherwise, we can drop the constant-false input */
} }
...@@ -1161,12 +1164,15 @@ eval_const_expressions_mutator(Node *node, void *context) ...@@ -1161,12 +1164,15 @@ eval_const_expressions_mutator(Node *node, void *context)
case AND_EXPR: case AND_EXPR:
{ {
/* /*----------
* AND arguments are handled as follows: non constant: * AND arguments are handled as follows:
* keep TRUE: drop (does not affect result) FALSE: * non constant: keep
* force result to FALSE NULL: keep only one We keep * TRUE: drop (does not affect result)
* one NULL input because ExecEvalAnd returns NULL * 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. * when no input is FALSE and at least one is NULL.
*----------
*/ */
List *newargs = NIL; List *newargs = NIL;
List *arg; List *arg;
...@@ -1183,7 +1189,7 @@ eval_const_expressions_mutator(Node *node, void *context) ...@@ -1183,7 +1189,7 @@ eval_const_expressions_mutator(Node *node, void *context)
const_input = (Const *) lfirst(arg); const_input = (Const *) lfirst(arg);
if (const_input->constisnull) if (const_input->constisnull)
haveNull = true; haveNull = true;
else if (!DatumGetInt32(const_input->constvalue)) else if (!DatumGetBool(const_input->constvalue))
forceFalse = true; forceFalse = true;
/* otherwise, we can drop the constant-true input */ /* otherwise, we can drop the constant-true input */
} }
...@@ -1217,7 +1223,7 @@ eval_const_expressions_mutator(Node *node, void *context) ...@@ -1217,7 +1223,7 @@ eval_const_expressions_mutator(Node *node, void *context)
if (const_input->constisnull) if (const_input->constisnull)
return MAKEBOOLCONST(false, true); return MAKEBOOLCONST(false, true);
/* otherwise pretty easy */ /* otherwise pretty easy */
return MAKEBOOLCONST(!DatumGetInt32(const_input->constvalue), return MAKEBOOLCONST(!DatumGetBool(const_input->constvalue),
false); false);
case SUBPLAN_EXPR: case SUBPLAN_EXPR:
...@@ -1330,7 +1336,7 @@ eval_const_expressions_mutator(Node *node, void *context) ...@@ -1330,7 +1336,7 @@ eval_const_expressions_mutator(Node *node, void *context)
} }
const_input = (Const *) casewhen->expr; const_input = (Const *) casewhen->expr;
if (const_input->constisnull || if (const_input->constisnull ||
!DatumGetInt32(const_input->constvalue)) !DatumGetBool(const_input->constvalue))
continue; /* drop alternative with FALSE condition */ continue; /* drop alternative with FALSE condition */
/* /*
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * 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 */ ...@@ -186,6 +186,9 @@ typedef unsigned int uint32; /* == 32 bits */
* *
* Since sizeof(floatN) may be > sizeof(char *), always pass * Since sizeof(floatN) may be > sizeof(char *), always pass
* floatN by reference. * floatN by reference.
*
* XXX: these typedefs are now deprecated in favor of float4 and float8.
* They will eventually go away.
*/ */
typedef float float32data; typedef float float32data;
typedef double float64data; 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