Invalidate vacuum relation cache to use new row counts from vacuum.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.14 1997/01/13 03:43:59 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.15 1997/01/22 01:42:16 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include <catalog/pg_index.h>
#include <catalog/index.h>
#include <catalog/catname.h>
+#include <catalog/catalog.h>
#include <catalog/pg_class.h>
#include <catalog/pg_proc.h>
#include <storage/smgr.h>
#include <storage/lmgr.h>
+#include <utils/inval.h>
#include <utils/mcxt.h>
#include <utils/syscache.h>
#include <commands/vacuum.h>
/* XXX -- after write, should invalidate relcache in other backends */
WriteNoReleaseBuffer(buf); /* heap_endscan release scan' buffers ? */
+ /* invalidating system relations confuses the function cache
+ of pg_operator and pg_opclass */
+ if ( !IsSystemRelationName(pgcform->relname.data))
+ RelationInvalidateHeapTuple(rd, tup);
+
/* that's all, folks */
heap_endscan(sdesc);
heap_close(rd);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.1.1.1 1996/07/09 06:21:32 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.2 1997/01/22 01:42:26 momjian Exp $
*
* NOTES
* Creator functions in POSTGRES 4.2 are generated automatically. Most of
Datum constvalue,
bool constisnull,
bool constbyval,
- bool constisset)
+ bool constisset,
+ bool constiscast)
{
Const *cnst = makeNode(Const);
cnst->constisnull = constisnull;
cnst->constbyval = constbyval;
cnst->constisset = constisset;
+ cnst->constiscast = constiscast;
return cnst;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.1.1.1 1996/07/09 06:21:38 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.2 1997/01/22 01:42:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
(typedefault == (struct varlena *)NULL),
/* XXX this is bullshit */
false,
- false /* not a set */);
+ false, /* not a set */
+ false);
temp3 = MakeTLE (makeResdom(attno,
atttype,
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.19 1996/12/17 01:53:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.20 1997/01/22 01:42:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
val,
false,
true,
- true /* is set */);
+ true, /* is set */
+ false);
} else {
lnext(expr) =
makeConst(attrtype,
val,get_typelem(attrtype),-1),
false,
true /* Maybe correct-- 80% chance */,
- false /* is not a set */);
+ false, /* is not a set */
+ false);
}
} else if((Typecast_ok) && (attrtype != type_id)){
lnext(expr) =
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.14 1996/12/26 17:47:41 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.15 1997/01/22 01:43:08 momjian Exp $
*
*-------------------------------------------------------------------------
*/
return(infunc);
}
+/* Given a type id, returns the out-conversion function of the type */
+Oid
+typeid_get_retoutfunc(Oid type_id)
+{
+ HeapTuple typeTuple;
+ TypeTupleForm type;
+ Oid outfunc;
+ typeTuple = SearchSysCacheTuple(TYPOID,
+ ObjectIdGetDatum(type_id),
+ 0,0,0);
+ if ( !HeapTupleIsValid ( typeTuple ))
+ elog(WARN,
+ "typeid_get_retoutfunc: Invalid type - oid = %u",
+ type_id);
+
+ type = (TypeTupleForm) GETSTRUCT(typeTuple);
+ outfunc = type->typoutput;
+ return(outfunc);
+}
+
Oid
typeid_get_relid(Oid type_id)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/Attic/parse_query.c,v 1.11 1996/12/07 04:38:10 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/Attic/parse_query.c,v 1.12 1997/01/22 01:43:19 momjian Exp $
*
*-------------------------------------------------------------------------
*/
left = NULL;
}else {
-
+ char *outstr;
+ Oid infunc, outfunc;
+ Type newtype;
+
+#define CONVERTABLE_TYPE(t) ( (t) == INT2OID || \
+ (t) == INT4OID || \
+ (t) == OIDOID || \
+ (t) == FLOAT4OID || \
+ (t) == FLOAT8OID)
+
/* binary operator */
ltypeId = (ltree==NULL) ? UNKNOWNOID : exprType(ltree);
rtypeId = (rtree==NULL) ? UNKNOWNOID : exprType(rtree);
+
+ /* convert constant when using a const of a numeric type
+ and a non-const of another numeric type */
+ if (CONVERTABLE_TYPE(ltypeId) && nodeTag(ltree) != T_Const &&
+ CONVERTABLE_TYPE(rtypeId) && nodeTag(rtree) == T_Const &&
+ !((Const *)rtree)->constiscast) {
+ outfunc = typeid_get_retoutfunc(rtypeId);
+ infunc = typeid_get_retinfunc(ltypeId);
+ outstr = (char *)fmgr(outfunc, ((Const *)rtree)->constvalue);
+ ((Const *)rtree)->constvalue = (Datum)fmgr(infunc, outstr);
+ pfree(outstr);
+ ((Const *)rtree)->consttype = rtypeId = ltypeId;
+ newtype = get_id_type(rtypeId);
+ ((Const *)rtree)->constlen = tlen(newtype);
+ ((Const *)rtree)->constbyval = tbyval(newtype);
+ }
+
+ if (CONVERTABLE_TYPE(rtypeId) && nodeTag(rtree) != T_Const &&
+ CONVERTABLE_TYPE(ltypeId) && nodeTag(ltree) == T_Const &&
+ !((Const *)ltree)->constiscast) {
+ outfunc = typeid_get_retoutfunc(ltypeId);
+ infunc = typeid_get_retinfunc(rtypeId);
+ outstr = (char *)fmgr(outfunc, ((Const *)ltree)->constvalue);
+ ((Const *)ltree)->constvalue = (Datum)fmgr(infunc, outstr);
+ pfree(outstr);
+ ((Const *)ltree)->consttype = ltypeId = rtypeId;
+ newtype = get_id_type(ltypeId);
+ ((Const *)ltree)->constlen = tlen(newtype);
+ ((Const *)ltree)->constbyval = tbyval(newtype);
+ }
+
temp = oper(opname, ltypeId, rtypeId);
opform = (OperatorTupleForm) GETSTRUCT(temp);
left = make_operand(opname, ltree, ltypeId, opform->oprleft);
elog(NOTICE,"unknown type : %d\n", nodeTag(value));
/* null const */
- con = makeConst(0, 0, (Datum)NULL, TRUE, 0, FALSE);
+ con = makeConst(0, 0, (Datum)NULL, true, false, false, false);
return con;
}
}
con = makeConst(typeid(tp),
tlen(tp),
val,
- FALSE,
+ false,
tbyval(tp),
- FALSE); /* not a set */
+ false, /* not a set */
+ false);
return (con);
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.16 1996/12/26 17:47:42 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.17 1997/01/22 01:43:26 momjian Exp $
*
*-------------------------------------------------------------------------
*/
adt = makeConst(typeid(tp),
len,
(Datum)lcp ,
- 0,
+ false,
tbyvalue(tp),
- 0 /* not a set */);
+ false, /* not a set */
+ true /* is cast */);
if (string_palloced)
pfree(const_string);
(Size) 0,
(Datum) NULL,
true, /* isnull */
- 0 /* was omitted */,
- 0 /* not a set */);
+ false, /* was omitted */
+ false, /* not a set */
+ true /* is cast */);
return ((Node*) adt);
}
adt = makeConst(typeid(tp),
(Size)len,
(Datum)lcp,
- 0,
- 0 /*was omitted*/,
- 0 /* not a set */);
+ false,
+ false, /*was omitted*/
+ false, /* not a set */
+ true /* is cast */);
/*
printf("adt %s : %u %d %d\n",CString(expr),typeid(tp) ,
len,cp);
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: makefuncs.h,v 1.2 1996/11/06 09:21:42 scrappy Exp $
+ * $Id: makefuncs.h,v 1.3 1997/01/22 01:43:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
Datum constvalue,
bool constisnull,
bool constbyval,
- bool constisset);
+ bool constisset,
+ bool constiscast);
#endif /* MAKEFUNC_H */
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: primnodes.h,v 1.6 1996/11/04 07:18:21 scrappy Exp $
+ * $Id: primnodes.h,v 1.7 1997/01/22 01:43:44 momjian Exp $
*
*-------------------------------------------------------------------------
*/
bool constisnull;
bool constbyval;
bool constisset;
+ bool constiscast;
} Const;
/* ----------------
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: catalog_utils.h,v 1.6 1996/12/11 03:18:12 bryanh Exp $
+ * $Id: catalog_utils.h,v 1.7 1997/01/22 01:44:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool func_get_detail(char *funcname, int nargs, Oid *oid_array,
Oid *funcid, Oid *rettype, bool *retset, Oid **true_typeids);
extern Oid typeid_get_retinfunc(Oid type_id);
+extern Oid typeid_get_retoutfunc(Oid type_id);
extern Oid typeid_get_relid(Oid type_id);
extern Oid get_typrelid(Type typ);
extern Oid get_typelem(Oid type_id);