Properly detoast access to bytea field pg_trigger.tgargs. Old code
authorBruce Momjian <bruce@momjian.us>
Thu, 25 Jan 2007 04:17:56 +0000 (04:17 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 25 Jan 2007 04:17:56 +0000 (04:17 +0000)
might cause server crash.

Backpatch to 8.2.X.

src/backend/commands/tablecmds.c
src/backend/commands/trigger.c
src/backend/utils/adt/ruleutils.c

index 2b09094d27a8f69dda1278f8da09c95fea83f7e4..cc6d155e00ffd8a0e27498068ca3007dce34e4a5 100644 (file)
@@ -1790,8 +1790,7 @@ update_ri_trigger_args(Oid relid,
                 * line; so does trigger.c ...
                 */
                tgnargs = pg_trigger->tgnargs;
-               val = (bytea *)
-                       DatumGetPointer(fastgetattr(tuple,
+               val = DatumGetByteaP(fastgetattr(tuple,
                                                                                Anum_pg_trigger_tgargs,
                                                                                tgrel->rd_att, &isnull));
                if (isnull || tgnargs < RI_FIRST_ATTNAME_ARGNO ||
index accc5750e47789bb55984f9978bf011e1104c0e0..21570fb8859eace8404bc7654498bd9a72df339c 100644 (file)
@@ -906,8 +906,7 @@ RelationBuildTriggers(Relation relation)
                        char       *p;
                        int                     i;
 
-                       val = (bytea *)
-                               DatumGetPointer(fastgetattr(htup,
+                       val = DatumGetByteaP(fastgetattr(htup,
                                                                                        Anum_pg_trigger_tgargs,
                                                                                        tgrel->rd_att, &isnull));
                        if (isnull)
index b31e5f8db2569f9ec93c39adad72fc17db0b3981..b714d111b10c93dd7fa62c8ddb05598273ed6b20 100644 (file)
@@ -519,8 +519,7 @@ pg_get_triggerdef(PG_FUNCTION_ARGS)
                char       *p;
                int                     i;
 
-               val = (bytea *)
-                       DatumGetPointer(fastgetattr(ht_trig,
+               val = DatumGetByteaP(fastgetattr(ht_trig,
                                                                                Anum_pg_trigger_tgargs,
                                                                                tgrel->rd_att, &isnull));
                if (isnull)