Don't use custom OID symbols in pg_proc.dat.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 28 Oct 2020 16:18:45 +0000 (12:18 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 28 Oct 2020 16:18:45 +0000 (12:18 -0400)
We have a perfectly good convention for OID macros for built-in functions
already, so making custom symbols is just introducing unnecessary
deviation from the convention.  Remove the one case that had snuck in,
and add an error check in genbki.pl to discourage future instances.

Although this touches pg_proc.dat, there's no need for a catversion
bump since the actual catalog data isn't changed.

John Naylor

Discussion: https://postgr.es/m/CAFBsxsHpCbjfoddNGpnnnY5pHwckWfiYkMYSF74PmP1su0+ZOw@mail.gmail.com

src/backend/catalog/genbki.pl
src/backend/utils/cache/relcache.c
src/include/catalog/pg_proc.dat

index ef3105af44bbebed6773b3257ed4af3fa38b0348..47b1a5d79083c5024a980c17b462fbdac81a8578 100644 (file)
@@ -602,6 +602,13 @@ EOM
        # Emit OID symbol
        if (defined $bki_values{oid_symbol})
        {
+           # OID symbols for builtin functions are handled automatically
+           # by utils/Gen_fmgrtab.pl
+           die sprintf
+             "custom OID symbols are not allowed for pg_proc entries: '%s'",
+             $bki_values{oid_symbol}
+             if $catname eq 'pg_proc';
+
            printf $def "#define %s %s\n",
              $bki_values{oid_symbol}, $bki_values{oid};
        }
index 9061af81a3e3abb1ab9ae227178375d85cf2a80e..9224e2ffeda593dafb39e1d6dfcfca7f0c652781 100644 (file)
@@ -1761,7 +1761,7 @@ RelationInitTableAccessMethod(Relation relation)
         * seem prudent to show that in the catalog. So just overwrite it
         * here.
         */
-       relation->rd_amhandler = HEAP_TABLE_AM_HANDLER_OID;
+       relation->rd_amhandler = F_HEAP_TABLEAM_HANDLER;
    }
    else if (IsCatalogRelation(relation))
    {
@@ -1769,7 +1769,7 @@ RelationInitTableAccessMethod(Relation relation)
         * Avoid doing a syscache lookup for catalog tables.
         */
        Assert(relation->rd_rel->relam == HEAP_TABLE_AM_OID);
-       relation->rd_amhandler = HEAP_TABLE_AM_HANDLER_OID;
+       relation->rd_amhandler = F_HEAP_TABLEAM_HANDLER;
    }
    else
    {
index a66870bcc0808dc5a0ba82445478be584e0fd8f9..24ec2cfed6a390d3ba576e4ac956ecd20f47f065 100644 (file)
   prosrc => 'ftoi4' },
 
 # Table access method handlers
-{ oid => '3', oid_symbol => 'HEAP_TABLE_AM_HANDLER_OID',
-  descr => 'row-oriented heap table access method handler',
+{ oid => '3', descr => 'row-oriented heap table access method handler',
   proname => 'heap_tableam_handler', provolatile => 'v',
   prorettype => 'table_am_handler', proargtypes => 'internal',
   prosrc => 'heap_tableam_handler' },