I believe you could do CREATE TABLE from inside a pltcl or plperl
function today. plpgsql won't work because it tries to cache query
plans for repeated execution --- which essentially means that you
can only substitute parameters for data values, not for table names
or field names or other structural aspects of a query. But the other
two just treat queries as dynamically-generated strings, so you can
do anything you want in those languages. (At a performance price,
of course: no caching. There ain't no such thing as a free lunch.)
regards, tom lane