diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-10-14 21:47:39 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-10-14 21:47:39 +0000 |
commit | 5b5ee14a4be3a981681df78a8874dd55405009a3 (patch) | |
tree | db81235b29af860da58e25bf055396ce061dc877 /src | |
parent | 2f0d528291fae0b7a859d5d7cdb89c62803d1c71 (diff) | |
download | postgresql-5b5ee14a4be3a981681df78a8874dd55405009a3.tar.gz postgresql-5b5ee14a4be3a981681df78a8874dd55405009a3.zip |
Add a defense to prevent storing pseudo-type data into index columns.
Formerly, the lack of any opclasses that could accept such data was enough
of a defense, but now with a "record" opclass we need to check more carefully.
(You can still use that opclass for an index, but you have to store a named
composite type not an anonymous one.)
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/catalog/index.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index e8063476add..8172918252e 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.305 2008/09/30 10:52:12 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.306 2008/10/14 21:47:39 tgl Exp $ * * * INTERFACE ROUTINES @@ -236,6 +236,17 @@ ConstructTupleDescriptor(Relation heapRelation, to->attislocal = true; ReleaseSysCache(tuple); + + /* + * Make sure the expression yields a type that's safe to store in + * an index. We need this defense because we have index opclasses + * for pseudo-types such as "record", and the actually stored type + * had better be safe; eg, a named composite type is okay, an + * anonymous record type is not. The test is the same as for + * whether a table column is of a safe type (which is why we + * needn't check for the non-expression case). + */ + CheckAttributeType(NameStr(to->attname), to->atttypid); } /* |