summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-01-15 22:43:25 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-01-15 22:43:25 +0000
commit584e646ad886ab53d23d268bbf62f56882f0bb4e (patch)
tree666dc7068b4e2d62ddb25bad18cdedb2dcc01b04 /src/backend/utils/adt
parent0f4a58682153844419b3922f6524bc198135491e (diff)
downloadpostgresql-584e646ad886ab53d23d268bbf62f56882f0bb4e.tar.gz
Fix a passel of problems with incorrect calls to typinput and typoutput
functions, which would lead to trouble with datatypes that paid attention to the typelem or typmod parameters to these functions. In particular, incorrect code in pg_aggregate.c explains the platform-specific failures that have been reported in NUMERIC avg().
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r--src/backend/utils/adt/arrayfuncs.c10
-rw-r--r--src/backend/utils/adt/ruleutils.c6
-rw-r--r--src/backend/utils/adt/selfuncs.c10
3 files changed, 14 insertions, 12 deletions
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 9f04ca4822..ebf54e8b62 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.50 1999/12/09 15:56:16 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.51 2000/01/15 22:43:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -669,21 +669,21 @@ array_out(ArrayType *v, Oid element_type)
switch (typlen)
{
case 1:
- values[i] = (*fmgr_faddr(&outputproc)) (*p, typelem);
+ values[i] = (*fmgr_faddr(&outputproc)) (*p, typelem, -1);
break;
case 2:
- values[i] = (*fmgr_faddr(&outputproc)) (*(int16 *) p, typelem);
+ values[i] = (*fmgr_faddr(&outputproc)) (*(int16 *) p, typelem, -1);
break;
case 3:
case 4:
- values[i] = (*fmgr_faddr(&outputproc)) (*(int32 *) p, typelem);
+ values[i] = (*fmgr_faddr(&outputproc)) (*(int32 *) p, typelem, -1);
break;
}
p += typlen;
}
else
{
- values[i] = (*fmgr_faddr(&outputproc)) (p, typelem);
+ values[i] = (*fmgr_faddr(&outputproc)) (p, typelem, -1);
if (typlen > 0)
p += typlen;
else
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 496fb94ddc..c4e3149160 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -3,7 +3,7 @@
* out of its tuple
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.38 2000/01/15 02:59:38 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.39 2000/01/15 22:43:24 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -1604,7 +1604,6 @@ get_const_expr(Const *constval, deparse_context *context)
FmgrInfo finfo_output;
char *extval;
char *valptr;
- bool isnull = FALSE;
typetup = SearchSysCacheTuple(TYPEOID,
ObjectIdGetDatum(constval->consttype),
@@ -1629,7 +1628,8 @@ get_const_expr(Const *constval, deparse_context *context)
fmgr_info(typeStruct->typoutput, &finfo_output);
extval = (char *) (*fmgr_faddr(&finfo_output)) (constval->constvalue,
- &isnull, -1);
+ typeStruct->typelem,
+ -1);
switch (constval->consttype)
{
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index b711d768c0..7ec3e4dc1b 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.47 2000/01/15 02:59:38 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.48 2000/01/15 22:43:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -600,6 +600,7 @@ getattstatistics(Oid relid, AttrNumber attnum, Oid opid, Oid typid,
HeapTuple tuple;
HeapTuple typeTuple;
FmgrInfo inputproc;
+ Oid typelem;
rel = heap_openr(StatisticRelationName, AccessShareLock);
@@ -630,6 +631,7 @@ getattstatistics(Oid relid, AttrNumber attnum, Oid opid, Oid typid,
elog(ERROR, "getattstatistics: Cache lookup failed for type %u",
typid);
fmgr_info(((Form_pg_type) GETSTRUCT(typeTuple))->typinput, &inputproc);
+ typelem = ((Form_pg_type) GETSTRUCT(typeTuple))->typelem;
/* Values are variable-length fields, so cannot access as struct fields.
* Must do it the hard way with heap_getattr.
@@ -649,7 +651,7 @@ getattstatistics(Oid relid, AttrNumber attnum, Oid opid, Oid typid,
{
char *strval = textout(val);
*commonval = (Datum)
- (*fmgr_faddr(&inputproc)) (strval, typid, typmod);
+ (*fmgr_faddr(&inputproc)) (strval, typelem, typmod);
pfree(strval);
}
}
@@ -669,7 +671,7 @@ getattstatistics(Oid relid, AttrNumber attnum, Oid opid, Oid typid,
{
char *strval = textout(val);
*loval = (Datum)
- (*fmgr_faddr(&inputproc)) (strval, typid, typmod);
+ (*fmgr_faddr(&inputproc)) (strval, typelem, typmod);
pfree(strval);
}
}
@@ -689,7 +691,7 @@ getattstatistics(Oid relid, AttrNumber attnum, Oid opid, Oid typid,
{
char *strval = textout(val);
*hival = (Datum)
- (*fmgr_faddr(&inputproc)) (strval, typid, typmod);
+ (*fmgr_faddr(&inputproc)) (strval, typelem, typmod);
pfree(strval);
}
}