Re: [bug] Table not have typarray when created by single user mode

Alvaro Herrera <alvherre@2ndquadrant.com>

From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: shawn wang <shawn.wang.pg@gmail.com>
Cc: wenjing <wjzeng2012@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, pgsql-bugs@lists.postgresql.org, tushar <tushar.ahuja@enterprisedb.com>
Date: 2020-05-19T15:32:39Z
Lists: pgsql-bugs, pgsql-hackers
On 2020-May-19, shawn wang wrote:

> Although single-user mode is used for bootstrapping by initdb. Sometimes it
> is used for debugging or disaster recovery.
> However, it is still possible for users to process data in this mode. If
> only the table is deleted,
> I worry that it will cause inconvenience to the user.
> I don't understand why we must be IsUnderPostmaster to create an array type
> too.
> If we could create an array type in single-user mode, there is not this
> issue.

Looking at the code again, there is one other possible solution: remove
the ereport(ERROR) from AssignTypeArrayOid.  This means that we'll
return InvalidOid and the array type will be marked as 0 in the upgraded
cluster ... which is exactly the case in the original server.  (Of
course, when array_oid is returned as invalid, the creation of the array
should be skipped, in callers of AssignTypeArrayOid.)

I think the argument to have that error check there, is that it's a
cross-check to avoid pg_upgrade bugs for cases where
binary_upgrade_next_array_type_oid is not set when it should have been
set.  But I think we've hammered the pg_upgrade code sufficiently now,
that we don't need that check anymore.  Any bugs that result in that
behavior will be very evident by lack of consistency on some upgrade
anyway.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



Commits

  1. Don't create pg_type entries for sequences or toast tables.

  2. Create composite array types for initdb-created relations.