From 3e8235ba4f9cc3375b061fb5d3f3575434539b5f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 14 Feb 2024 11:30:39 -0500 Subject: Fix multiranges to behave more like dependent types. For most purposes, multiranges act like dependent objects of the associated range type: you can't create them separately or drop them separately. This is like the way that autogenerated array types behave. However, a couple of points were overlooked: array types automatically track the ownership of their base type, and array types do not have their own permissions but use those of the base type, while multiranges didn't emulate those behaviors. This is fairly broken, mainly because pg_dump doesn't think it needs to worry about multiranges as separate objects, and thus it fails to dump/restore ownership or permissions of multiranges. There's no apparent value in letting a multirange diverge from its parent's ownership or permissions, so let's make them act like arrays in these respects. However, we continue to let multiranges be renamed or moved to a different schema independently of their parent, since that doesn't break anything. Discussion: https://postgr.es/m/1580383.1705343264@sss.pgh.pa.us --- src/bin/pg_dump/pg_dump.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/bin') diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 348748bae53..f40bc759c5c 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -1868,7 +1868,7 @@ selectDumpableType(TypeInfo *tyinfo, Archive *fout) return; } - /* skip auto-generated array types */ + /* skip auto-generated array and multirange types */ if (tyinfo->isArray || tyinfo->isMultirange) { tyinfo->dobj.objType = DO_DUMMY_TYPE; @@ -1876,8 +1876,8 @@ selectDumpableType(TypeInfo *tyinfo, Archive *fout) /* * Fall through to set the dump flag; we assume that the subsequent * rules will do the same thing as they would for the array's base - * type. (We cannot reliably look up the base type here, since - * getTypes may not have processed it yet.) + * type or multirange's range type. (We cannot reliably look up the + * base type here, since getTypes may not have processed it yet.) */ } @@ -5770,7 +5770,7 @@ getTypes(Archive *fout, int *numTypes) else tyinfo[i].isArray = false; - if (tyinfo[i].typtype == 'm') + if (tyinfo[i].typtype == TYPTYPE_MULTIRANGE) tyinfo[i].isMultirange = true; else tyinfo[i].isMultirange = false; -- cgit v1.2.3