aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-06-05 01:55:05 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-06-05 01:55:05 +0000
commitae93e5fd6e8a7e2321e87d23165d9d7660cde598 (patch)
treea8e22c4835283c61e137285ba2dabfe3feead1a9 /src/backend/optimizer/path
parent8f2ea8b7b53a02078ba0393e6892ac5356a3631e (diff)
downloadpostgresql-ae93e5fd6e8a7e2321e87d23165d9d7660cde598.tar.gz
postgresql-ae93e5fd6e8a7e2321e87d23165d9d7660cde598.zip
Make the world very nearly safe for composite-type columns in tables.
1. Solve the problem of not having TOAST references hiding inside composite values by establishing the rule that toasting only goes one level deep: a tuple can contain toasted fields, but a composite-type datum that is to be inserted into a tuple cannot. Enforcing this in heap_formtuple is relatively cheap and it avoids a large increase in the cost of running the tuptoaster during final storage of a row. 2. Fix some interesting problems in expansion of inherited queries that reference whole-row variables. We never really did this correctly before, but it's now relatively painless to solve by expanding the parent's whole-row Var into a RowExpr() selecting the proper columns from the child. If you dike out the preventive check in CheckAttributeType(), composite-type columns now seem to actually work. However, we surely cannot ship them like this --- without I/O for composite types, you can't get pg_dump to dump tables containing them. So a little more work still to do.
Diffstat (limited to 'src/backend/optimizer/path')
-rw-r--r--src/backend/optimizer/path/allpaths.c14
-rw-r--r--src/backend/optimizer/path/costsize.c13
-rw-r--r--src/backend/optimizer/path/pathkeys.c5
3 files changed, 22 insertions, 10 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index dc428abdab9..24a51149e45 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.117 2004/06/01 03:02:51 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.118 2004/06/05 01:55:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -302,11 +302,15 @@ set_inherited_rel_pathlist(Query *root, RelOptInfo *rel,
{
Var *parentvar = (Var *) lfirst(parentvars);
Var *childvar = (Var *) lfirst(childvars);
- int parentndx = parentvar->varattno - rel->min_attr;
- int childndx = childvar->varattno - childrel->min_attr;
- if (childrel->attr_widths[childndx] > rel->attr_widths[parentndx])
- rel->attr_widths[parentndx] = childrel->attr_widths[childndx];
+ if (IsA(parentvar, Var) && IsA(childvar, Var))
+ {
+ int pndx = parentvar->varattno - rel->min_attr;
+ int cndx = childvar->varattno - childrel->min_attr;
+
+ if (childrel->attr_widths[cndx] > rel->attr_widths[pndx])
+ rel->attr_widths[pndx] = childrel->attr_widths[cndx];
+ }
}
}
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
index 46a323fade4..53bd8bdf5c5 100644
--- a/src/backend/optimizer/path/costsize.c
+++ b/src/backend/optimizer/path/costsize.c
@@ -49,7 +49,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.129 2004/06/01 03:02:52 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.130 2004/06/05 01:55:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1704,11 +1704,18 @@ set_rel_width(Query *root, RelOptInfo *rel)
foreach(tllist, rel->reltargetlist)
{
Var *var = (Var *) lfirst(tllist);
- int ndx = var->varattno - rel->min_attr;
+ int ndx;
Oid relid;
int32 item_width;
- Assert(IsA(var, Var));
+ /* For now, punt on whole-row child Vars */
+ if (!IsA(var, Var))
+ {
+ tuple_width += 32; /* arbitrary */
+ continue;
+ }
+
+ ndx = var->varattno - rel->min_attr;
/*
* The width probably hasn't been cached yet, but may as well
diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c
index 363fe54450d..71f96c164e5 100644
--- a/src/backend/optimizer/path/pathkeys.c
+++ b/src/backend/optimizer/path/pathkeys.c
@@ -11,7 +11,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.59 2004/06/01 03:02:52 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.60 2004/06/05 01:55:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -725,7 +725,8 @@ find_indexkey_var(Query *root, RelOptInfo *rel, AttrNumber varattno)
{
Var *var = (Var *) lfirst(temp);
- if (var->varattno == varattno)
+ if (IsA(var, Var) &&
+ var->varattno == varattno)
return var;
}