Skip to content

Commit 5b5ee14

Browse files
committed
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.)
1 parent 2f0d528 commit 5b5ee14

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/backend/catalog/index.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.305 2008/09/30 10:52:12 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/index.c,v 1.306 2008/10/14 21:47:39 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -236,6 +236,17 @@ ConstructTupleDescriptor(Relation heapRelation,
236236
to->attislocal = true;
237237

238238
ReleaseSysCache(tuple);
239+
240+
/*
241+
* Make sure the expression yields a type that's safe to store in
242+
* an index. We need this defense because we have index opclasses
243+
* for pseudo-types such as "record", and the actually stored type
244+
* had better be safe; eg, a named composite type is okay, an
245+
* anonymous record type is not. The test is the same as for
246+
* whether a table column is of a safe type (which is why we
247+
* needn't check for the non-expression case).
248+
*/
249+
CheckAttributeType(NameStr(to->attname), to->atttypid);
239250
}
240251

241252
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy