> This sounds fine, but begs the question: if there is TOASTed data in the
> table and the column is set to 'not TOASTed', will TOAST cope? And vice verca?
Yes; the detoasting mechanism doesn't pay any attention to attstorage,
only to what's actually in the stored tuple. attstorage is only
examined while storing a tuple, and it's really only advisory anyway
(see tuptoaster.c). The only "must" involved here is that you must not
set attstorage to anything but 'p' for a non-toastable data type; which
you determine by checking the type's pg_type entry (typstorage != 'p'
means toastable).
>> All told it might be a couple
>> hundred lines of new or changed code. Pretty much all of this could
>> be done by cribbing from existing code (ie. programming-by-example)
>> which is a good thing because there's not much documentation.
> So it might be worh documenting, too...
Yes, if you wanted to keep notes and work them up into documentation
for future hackers, that'd be a nice side benefit.
regards, tom lane