Hacker,
some time before I proposed patches implementing CREATE ACCESS METHOD.
As I get from comments to my patches and also from Tom's comment about AM interface in tablesampling thread – AM interface needs reworking. And AFAICS AM interface rework is essential to have CREATE ACCESS METHOD command.
This is why I'd like to show a WIP patch implementing AM interface rework. Patch is quite dirty yet, but I think it illustrated the idea quite clear. AM now have single parameter – handler function. This handler returns pointer to AmRoutine which have the same data as pg_am had before. Thus, API is organized very like FDW.
However, this patch appears to take more work than I expected. It have to do many changes spread among many files. Also, it appears not so easy to hide amsupport into AmRoutine, because it's needed for relcache. As a temporary solution it's duplicated in RelationData.
What do you think about this approach of AM interface rework?