Commit 8d77c1a8 authored by Tom Lane's avatar Tom Lane

Clean up some sloppy casts --- Oid vs. Datum, that sort of thing.

parent e4e6459c
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.43 2000/07/02 22:00:48 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.44 2000/07/23 03:50:26 tgl Exp $
* *
* NOTES * NOTES
* Eventually, the index information should go through here, too. * Eventually, the index information should go through here, too.
...@@ -24,11 +24,10 @@ ...@@ -24,11 +24,10 @@
/* ---------- AMOP CACHES ---------- */ /* ---------- AMOP CACHES ---------- */
/* /*
* op_class - * op_class
* *
* Return t iff operator 'opid' is in operator class 'opclass' for * Return t iff operator 'opid' is in operator class 'opclass' for
* access method 'amopid'. * access method 'amopid'.
*
*/ */
bool bool
op_class(Oid opid, Oid opclass, Oid amopid) op_class(Oid opid, Oid opclass, Oid amopid)
...@@ -46,11 +45,10 @@ op_class(Oid opid, Oid opclass, Oid amopid) ...@@ -46,11 +45,10 @@ op_class(Oid opid, Oid opclass, Oid amopid)
/* ---------- ATTRIBUTE CACHES ---------- */ /* ---------- ATTRIBUTE CACHES ---------- */
/* /*
* get_attname - * get_attname
* *
* Given the relation id and the attribute number, * Given the relation id and the attribute number,
* return the "attname" field from the attribute relation. * return the "attname" field from the attribute relation.
*
*/ */
char * char *
get_attname(Oid relid, AttrNumber attnum) get_attname(Oid relid, AttrNumber attnum)
...@@ -59,7 +57,7 @@ get_attname(Oid relid, AttrNumber attnum) ...@@ -59,7 +57,7 @@ get_attname(Oid relid, AttrNumber attnum)
tp = SearchSysCacheTuple(ATTNUM, tp = SearchSysCacheTuple(ATTNUM,
ObjectIdGetDatum(relid), ObjectIdGetDatum(relid),
UInt16GetDatum(attnum), Int16GetDatum(attnum),
0, 0); 0, 0);
if (HeapTupleIsValid(tp)) if (HeapTupleIsValid(tp))
{ {
...@@ -72,11 +70,10 @@ get_attname(Oid relid, AttrNumber attnum) ...@@ -72,11 +70,10 @@ get_attname(Oid relid, AttrNumber attnum)
} }
/* /*
* get_attnum - * get_attnum
* *
* Given the relation id and the attribute name, * Given the relation id and the attribute name,
* return the "attnum" field from the attribute relation. * return the "attnum" field from the attribute relation.
*
*/ */
AttrNumber AttrNumber
get_attnum(Oid relid, char *attname) get_attnum(Oid relid, char *attname)
...@@ -98,11 +95,10 @@ get_attnum(Oid relid, char *attname) ...@@ -98,11 +95,10 @@ get_attnum(Oid relid, char *attname)
} }
/* /*
* get_atttype - * get_atttype
* *
* Given the relation OID and the attribute number with the relation, * Given the relation OID and the attribute number with the relation,
* return the attribute type OID. * return the attribute type OID.
*
*/ */
Oid Oid
get_atttype(Oid relid, AttrNumber attnum) get_atttype(Oid relid, AttrNumber attnum)
...@@ -111,7 +107,7 @@ get_atttype(Oid relid, AttrNumber attnum) ...@@ -111,7 +107,7 @@ get_atttype(Oid relid, AttrNumber attnum)
tp = SearchSysCacheTuple(ATTNUM, tp = SearchSysCacheTuple(ATTNUM,
ObjectIdGetDatum(relid), ObjectIdGetDatum(relid),
UInt16GetDatum(attnum), Int16GetDatum(attnum),
0, 0); 0, 0);
if (HeapTupleIsValid(tp)) if (HeapTupleIsValid(tp))
{ {
...@@ -147,11 +143,10 @@ get_attisset(Oid relid, char *attname) ...@@ -147,11 +143,10 @@ get_attisset(Oid relid, char *attname)
} }
/* /*
* get_atttypmod - * get_atttypmod
* *
* Given the relation id and the attribute number, * Given the relation id and the attribute number,
* return the "atttypmod" field from the attribute relation. * return the "atttypmod" field from the attribute relation.
*
*/ */
int32 int32
get_atttypmod(Oid relid, AttrNumber attnum) get_atttypmod(Oid relid, AttrNumber attnum)
...@@ -160,7 +155,7 @@ get_atttypmod(Oid relid, AttrNumber attnum) ...@@ -160,7 +155,7 @@ get_atttypmod(Oid relid, AttrNumber attnum)
tp = SearchSysCacheTuple(ATTNUM, tp = SearchSysCacheTuple(ATTNUM,
ObjectIdGetDatum(relid), ObjectIdGetDatum(relid),
UInt16GetDatum(attnum), Int16GetDatum(attnum),
0, 0); 0, 0);
if (HeapTupleIsValid(tp)) if (HeapTupleIsValid(tp))
{ {
...@@ -272,11 +267,10 @@ get_attdisbursion(Oid relid, AttrNumber attnum, double min_estimate) ...@@ -272,11 +267,10 @@ get_attdisbursion(Oid relid, AttrNumber attnum, double min_estimate)
/* ---------- OPERATOR CACHE ---------- */ /* ---------- OPERATOR CACHE ---------- */
/* /*
* get_opcode - * get_opcode
* *
* Returns the regproc id of the routine used to implement an * Returns the regproc id of the routine used to implement an
* operator given the operator oid. * operator given the operator oid.
*
*/ */
RegProcedure RegProcedure
get_opcode(Oid opno) get_opcode(Oid opno)
...@@ -297,7 +291,7 @@ get_opcode(Oid opno) ...@@ -297,7 +291,7 @@ get_opcode(Oid opno)
} }
/* /*
* get_opname - * get_opname
* returns the name of the operator with the given opno * returns the name of the operator with the given opno
* *
* Note: returns a palloc'd copy of the string, or NULL if no such operator. * Note: returns a palloc'd copy of the string, or NULL if no such operator.
...@@ -321,11 +315,10 @@ get_opname(Oid opno) ...@@ -321,11 +315,10 @@ get_opname(Oid opno)
} }
/* /*
* op_mergejoinable - * op_mergejoinable
* *
* Returns the left and right sort operators and types corresponding to a * Returns the left and right sort operators and types corresponding to a
* mergejoinable operator, or nil if the operator is not mergejoinable. * mergejoinable operator, or nil if the operator is not mergejoinable.
*
*/ */
bool bool
op_mergejoinable(Oid opno, Oid ltype, Oid rtype, Oid *leftOp, Oid *rightOp) op_mergejoinable(Oid opno, Oid ltype, Oid rtype, Oid *leftOp, Oid *rightOp)
...@@ -344,8 +337,8 @@ op_mergejoinable(Oid opno, Oid ltype, Oid rtype, Oid *leftOp, Oid *rightOp) ...@@ -344,8 +337,8 @@ op_mergejoinable(Oid opno, Oid ltype, Oid rtype, Oid *leftOp, Oid *rightOp)
optup->oprleft == ltype && optup->oprleft == ltype &&
optup->oprright == rtype) optup->oprright == rtype)
{ {
*leftOp = ObjectIdGetDatum(optup->oprlsortop); *leftOp = optup->oprlsortop;
*rightOp = ObjectIdGetDatum(optup->oprrsortop); *rightOp = optup->oprrsortop;
return true; return true;
} }
} }
...@@ -356,8 +349,7 @@ op_mergejoinable(Oid opno, Oid ltype, Oid rtype, Oid *leftOp, Oid *rightOp) ...@@ -356,8 +349,7 @@ op_mergejoinable(Oid opno, Oid ltype, Oid rtype, Oid *leftOp, Oid *rightOp)
* op_hashjoinable * op_hashjoinable
* *
* Returns the hash operator corresponding to a hashjoinable operator, * Returns the hash operator corresponding to a hashjoinable operator,
* or nil if the operator is not hashjoinable. * or InvalidOid if the operator is not hashjoinable.
*
*/ */
Oid Oid
op_hashjoinable(Oid opno, Oid ltype, Oid rtype) op_hashjoinable(Oid opno, Oid ltype, Oid rtype)
...@@ -393,10 +385,9 @@ get_operator_tuple(Oid opno) ...@@ -393,10 +385,9 @@ get_operator_tuple(Oid opno)
} }
/* /*
* get_commutator - * get_commutator
* *
* Returns the corresponding commutator of an operator. * Returns the corresponding commutator of an operator.
*
*/ */
Oid Oid
get_commutator(Oid opno) get_commutator(Oid opno)
...@@ -417,10 +408,9 @@ get_commutator(Oid opno) ...@@ -417,10 +408,9 @@ get_commutator(Oid opno)
} }
/* /*
* get_negator - * get_negator
* *
* Returns the corresponding negator of an operator. * Returns the corresponding negator of an operator.
*
*/ */
Oid Oid
get_negator(Oid opno) get_negator(Oid opno)
...@@ -441,10 +431,9 @@ get_negator(Oid opno) ...@@ -441,10 +431,9 @@ get_negator(Oid opno)
} }
/* /*
* get_oprrest - * get_oprrest
* *
* Returns procedure id for computing selectivity of an operator. * Returns procedure id for computing selectivity of an operator.
*
*/ */
RegProcedure RegProcedure
get_oprrest(Oid opno) get_oprrest(Oid opno)
...@@ -465,10 +454,9 @@ get_oprrest(Oid opno) ...@@ -465,10 +454,9 @@ get_oprrest(Oid opno)
} }
/* /*
* get_oprjoin - * get_oprjoin
* *
* Returns procedure id for computing selectivity of a join. * Returns procedure id for computing selectivity of a join.
*
*/ */
RegProcedure RegProcedure
get_oprjoin(Oid opno) get_oprjoin(Oid opno)
...@@ -498,29 +486,23 @@ Oid ...@@ -498,29 +486,23 @@ Oid
get_func_rettype(Oid funcid) get_func_rettype(Oid funcid)
{ {
HeapTuple func_tuple; HeapTuple func_tuple;
Oid funcrettype;
func_tuple = SearchSysCacheTuple(PROCOID, func_tuple = SearchSysCacheTuple(PROCOID,
ObjectIdGetDatum(funcid), ObjectIdGetDatum(funcid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(func_tuple)) if (!HeapTupleIsValid(func_tuple))
elog(ERROR, "Function OID %u does not exist", funcid); elog(ERROR, "Function OID %u does not exist", funcid);
funcrettype = (Oid) return ((Form_pg_proc) GETSTRUCT(func_tuple))->prorettype;
((Form_pg_proc) GETSTRUCT(func_tuple))->prorettype;
return funcrettype;
} }
/* ---------- RELATION CACHE ---------- */ /* ---------- RELATION CACHE ---------- */
#ifdef NOT_USED #ifdef NOT_USED
/* /*
* get_relnatts - * get_relnatts
* *
* Returns the number of attributes for a given relation. * Returns the number of attributes for a given relation.
*
*/ */
int int
get_relnatts(Oid relid) get_relnatts(Oid relid)
...@@ -542,10 +524,9 @@ get_relnatts(Oid relid) ...@@ -542,10 +524,9 @@ get_relnatts(Oid relid)
#endif #endif
/* /*
* get_rel_name - * get_rel_name
* *
* Returns the name of a given relation. * Returns the name of a given relation.
*
*/ */
char * char *
get_rel_name(Oid relid) get_rel_name(Oid relid)
...@@ -568,10 +549,9 @@ get_rel_name(Oid relid) ...@@ -568,10 +549,9 @@ get_rel_name(Oid relid)
/* ---------- TYPE CACHE ---------- */ /* ---------- TYPE CACHE ---------- */
/* /*
* get_typlen - * get_typlen
* *
* Given the type OID, return the length of the type. * Given the type OID, return the length of the type.
*
*/ */
int16 int16
get_typlen(Oid typid) get_typlen(Oid typid)
...@@ -592,11 +572,10 @@ get_typlen(Oid typid) ...@@ -592,11 +572,10 @@ get_typlen(Oid typid)
} }
/* /*
* get_typbyval - * get_typbyval
* *
* Given the type OID, determine whether the type is returned by value or * Given the type OID, determine whether the type is returned by value or
* not. Returns 1 if by value, 0 if by reference. * not. Returns true if by value, false if by reference.
*
*/ */
bool bool
get_typbyval(Oid typid) get_typbyval(Oid typid)
...@@ -610,7 +589,7 @@ get_typbyval(Oid typid) ...@@ -610,7 +589,7 @@ get_typbyval(Oid typid)
{ {
Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
return (bool) typtup->typbyval; return typtup->typbyval;
} }
else else
return false; return false;
...@@ -638,7 +617,7 @@ get_typalign(Oid typid) ...@@ -638,7 +617,7 @@ get_typalign(Oid typid)
#endif #endif
/* /*
* get_typdefault - * get_typdefault
* *
* Given a type OID, return the typdefault field associated with that * Given a type OID, return the typdefault field associated with that
* type, or Datum(NULL) if there is no typdefault. (This implies * type, or Datum(NULL) if there is no typdefault. (This implies
...@@ -744,12 +723,11 @@ get_typdefault(Oid typid) ...@@ -744,12 +723,11 @@ get_typdefault(Oid typid)
} }
/* /*
* get_typtype - * get_typtype
* *
* Given the type OID, find if it is a basic type, a named relation * Given the type OID, find if it is a basic type, a named relation
* or the generic type 'relation'. * or the generic type 'relation'.
* It returns the null char if the cache lookup fails... * It returns the null char if the cache lookup fails...
*
*/ */
#ifdef NOT_USED #ifdef NOT_USED
char char
......
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