Fix some bugs introduced by the 8.2-era conversion of cube functions to V1 calling convention.  cube_inter and cube_distance could attempt to pfree their input arguments, and cube_dim returned a value from a struct it might have just pfree'd (which would only really cause a problem in a debug build, but it's still wrong).  Per bug #4208 and additional code reading.
Fix some bugs introduced by the 8.2-era conversion of cube functions to V1
calling convention.  cube_inter and cube_distance could attempt to pfree
their input arguments, and cube_dim returned a value from a struct it
might have just pfree'd (which would only really cause a problem in a
debug build, but it's still wrong).  Per bug #4208 and additional code
reading.

In HEAD and 8.3, I also made a batch of cosmetic changes to bring these
functions into line with the preferred coding style for V1 functions,
ie declare and fetch all the arguments at the top so readers can easily
see what they are.

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