Fix possible corruption of AfterTriggerEventLists in subtransaction rollback.
Fix possible corruption of AfterTriggerEventLists in subtransaction rollback.

afterTriggerInvokeEvents failed to adjust events->tailfree when truncating
the last chunk of an event list.  This could result in the data being
"de-truncated" by afterTriggerRestoreEventList during a subsequent
subtransaction abort.  Even that wouldn't kill us, because the re-added data
would just be events marked DONE --- unless the data had been partially
overwritten by new events.  Then we might crash, or in any case misbehave
(perhaps fire triggers twice, or fire triggers with the wrong event data).
Per bug #5622 from Thue Janus Kristensen.

Back-patch to 8.4 where the current trigger list representation was introduced.

ashwinstar/gpdb,ovr/postgres-xl,adam8157/gpdb,oberstet/postgres-xl,snaga/postgres-xl,kmjungersen/PostgresXL,xinzweb/gpdb,greenplum-db/gpdb,arcivanov/postgres-xl,postmind-net/postgres-xl,zeroae/postgres-xl,oberstet/postgres-xl,50wu/gpdb,snaga/postgres-xl,jmcatamney/gpdb,xinzweb/gpdb,arcivanov/postgres-xl,ashwinstar/gpdb,tpostgres-projects/tPostgres,greenplum-db/gpdb,Postgres-XL/Postgres-XL,50wu/gpdb,zeroae/postgres-xl,jmcatamney/gpdb,techdragon/Postgres-XL,ovr/postgres-xl,ovr/postgres-xl,ashwinstar/gpdb,adam8157/gpdb,oberstet/postgres-xl,lisakowen/gpdb,pavanvd/postgres-xl,Postgres-XL/Postgres-XL,lisakowen/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,xinzweb/gpdb,kmjungersen/PostgresXL,greenplum-db/gpdb,arcivanov/postgres-xl,ovr/postgres-xl,oberstet/postgres-xl,adam8157/gpdb,techdragon/Postgres-XL,yazun/postgres-xl,ovr/postgres-xl,50wu/gpdb,greenplum-db/gpdb,snaga/postgres-xl,ashwinstar/gpdb,lisakowen/gpdb,techdragon/Postgres-XL,50wu/gpdb,snaga/postgres-xl,adam8157/gpdb,50wu/gpdb,yazun/postgres-xl,50wu/gpdb,lisakowen/gpdb,ashwinstar/gpdb,zeroae/postgres-xl,pavanvd/postgres-xl,pavanvd/postgres-xl,greenplum-db/gpdb,arcivanov/postgres-xl,postmind-net/postgres-xl,pavanvd/postgres-xl,xinzweb/gpdb,lisakowen/gpdb,snaga/postgres-xl,tpostgres-projects/tPostgres,greenplum-db/gpdb,tpostgres-projects/tPostgres,jmcatamney/gpdb,ashwinstar/gpdb,zeroae/postgres-xl,lisakowen/gpdb,jmcatamney/gpdb,50wu/gpdb,jmcatamney/gpdb,adam8157/gpdb,kmjungersen/PostgresXL,techdragon/Postgres-XL,xinzweb/gpdb,tpostgres-projects/tPostgres,lisakowen/gpdb,postmind-net/postgres-xl,xinzweb/gpdb,arcivanov/postgres-xl,kmjungersen/PostgresXL,postmind-net/postgres-xl,yazun/postgres-xl,jmcatamney/gpdb,adam8157/gpdb,adam8157/gpdb,kmjungersen/PostgresXL,xinzweb/gpdb,Postgres-XL/Postgres-XL,oberstet/postgres-xl,xinzweb/gpdb,tpostgres-projects/tPostgres,yazun/postgres-xl,zeroae/postgres-xl,greenplum-db/gpdb,greenplum-db/gpdb,50wu/gpdb,ashwinstar/gpdb,postmind-net/postgres-xl,Postgres-XL/Postgres-XL,yazun/postgres-xl,Postgres-XL/Postgres-XL,lisakowen/gpdb,arcivanov/postgres-xl,adam8157/gpdb,techdragon/Postgres-XL,pavanvd/postgres-xl,jmcatamney/gpdb