Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rNTVz-00CQC5-Rv for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jan 2024 08:00:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rNTVz-001Rqx-1n for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jan 2024 08:00:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rNTVy-001Rqn-P6 for pgsql-hackers@lists.postgresql.org; Wed, 10 Jan 2024 08:00:42 +0000 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rNTVs-000nQ3-3n for pgsql-hackers@postgresql.org; Wed, 10 Jan 2024 08:00:42 +0000 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2cd7e348311so1271821fa.2 for ; Wed, 10 Jan 2024 00:00:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704873635; x=1705478435; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lGwTOLVY7N1t9eNyK5jt+W4prNUgjNnVaZYDMK6CTsE=; b=I5QxuJKidbBCAcPclXcm44ggCI2cuDFS7jB4eYzZwrwYLA9YwWYg6f1gURjzwCWUH6 2GNZbQCd39IO0w4tkVOMFSWfm9StfdqNFyfaza99FjfTF6Xqd8m1m717hk0MeIF6Z4Ix xg8ItmWmkoe4AdHX3CulNVQJJT13A+iYVKYFmSAqlXI+qLuSS79EW5ACjZIWS40WkIL9 CYfz/cVp56c4zlEgj0q14Lm+60HKLhzobaDeGJAgUNRrYTr51LawJnpc2jIecM5SrQfQ w+Dv4X1naWhZu1qLhwcnGaYV7j8kzOk5fdj1ugq8SKx3j92y2xlPuu2QzjhYxKEZf1zz MiMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704873635; x=1705478435; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lGwTOLVY7N1t9eNyK5jt+W4prNUgjNnVaZYDMK6CTsE=; b=rFwnj7sgnSMZnCCIoPL8biBWijP160/qt4AOe6C4AJlsSzOrjRqjrMvRbnZGcw8PzR uJ71dG4KAlWU+mTIHGkd/Nmu1lClDJ1QoKJpxv5qYDL1L14QXfgpU2+ECYgTAHW/mkCJ J0HQ0rtI/n2KBrG23yS2KlD7OBptfsPiOM/khY459u6HxRv3TI6IBk8mHGUYLc83RrHy ys2TXXImJAPBcz3JQk6pw88Ne+X5O6TMV7uTwg1uOI18lQUg6Fe/eFuwglrthmCcfQ+6 0bQEy2PooHju4K/EhLtVqp8dvJQ9LRv+wL312LWKRG7iroLHZkoP4U8VSujNwSPzkSLs tBpw== X-Gm-Message-State: AOJu0YwWTmma/cLUr8HQ4hLW9IrBbs15pYDLTdWf0f8ZP0rHH3ZQyKe+ NJ0cg9VhhaK7iX+JpQ+z5deku6F2d9lraBTXrpOYNgqHt8k= X-Google-Smtp-Source: AGHT+IECxijeg0Grtb8MIT7c57RKQLNBcCwVgbtggrtN5BOZGqaBM6v8RmgLEuxJpTFgwhQfRSCfVQ36hGlAgXIp7Ng= X-Received: by 2002:a2e:b0cc:0:b0:2cd:6bf9:a7c7 with SMTP id g12-20020a2eb0cc000000b002cd6bf9a7c7mr315919ljl.61.1704873634724; Wed, 10 Jan 2024 00:00:34 -0800 (PST) MIME-Version: 1.0 References: <75ae5875-3abc-dafc-8aec-73247ed41cde@eisentraut.org> <0375b1fb-c2e7-be24-806e-b3b96bd00c31@eisentraut.org> <9aea7c02-ca6f-4cf0-0e5a-bcc0fd959b7c@eisentraut.org> In-Reply-To: From: John Naylor Date: Wed, 10 Jan 2024 15:00:23 +0700 Message-ID: Subject: Re: generate syscache info automatically To: Peter Eisentraut Cc: pgsql-hackers , John Naylor Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Nov 2, 2023 at 4:13=E2=80=AFAM Peter Eisentraut wrote: > > Here is a rebased patch set, along with a summary of the questions I > have about these patches: This is an excellent summary of the issues, thanks. > v4-0001-Generate-syscache-info-from-catalog-files.patch > > What's a good syntax to declare a syscache? Currently, I have, for examp= le > > -DECLARE_UNIQUE_INDEX_PKEY(pg_type_oid_index, 2703, TypeOidIndexId, > pg_type, btree(oid oid_ops)); > +DECLARE_UNIQUE_INDEX_PKEY(pg_type_oid_index, 2703, TypeOidIndexId, > pg_type, btree(oid oid_ops), TYPEOID, 64); > > I suppose a sensible alternative could be to leave the > DECLARE_..._INDEX... alone and make a separate statement, like > > MAKE_SYSCACHE(pg_type_oid_index, TYPEOID, 64); > > That's at least visually easier, because some of those > DECLARE_... lines are getting pretty long. Probably a good idea, and below I mention a third possible macro. > I would like to keep those MAKE_SYSCACHE lines in the catalog files. > That just makes it easier to reference everything together. That seems fine. If we ever want to do something more invasive with the syscaches, some of that can be copied/moved out into a separate script, but what's there in 0001 is pretty small. > v4-0002-Generate-ObjectProperty-from-catalog-files.patch > > Several questions here: > > * What's a good way to declare the mapping between catalog and object > type? Perhaps this idea: > I suppose a sensible alternative could be to leave the > DECLARE_..._INDEX... alone and make a separate statement, like > > MAKE_SYSCACHE(pg_type_oid_index, TYPEOID, 64); ...could be used, so something like DECLARE_OBJECT_INFO(OBJECT_ACCESS_METHOD); > * How to select which catalogs have ObjectProperty entries generated? Would the above work for that as well? > * Where to declare class descriptions? Or just keep the current hack in > the patch. I don't have an opinion on this. > * How to declare the purpose of a catalog column, like "this is the ACL > column for this catalog". This is currently done by name, but maybe > it should be more explicit. Perhaps we can have additional column macros, like BKI_OBJ_ACL or something, but that doesn't seem like it would result in less code. > * Question about how to pick the correct value for is_nsp_name_unique? How is that known now -- I don't mean in the patch, but in general? Also, I get most of the hard-wired exceptions, but + # XXX? + $name_syscache =3D "SUBSCRIPTIONNAME" if $catname eq 'pg_subscription'; What is not right otherwise? + if ($index->{index_decl} eq 'btree(oid oid_ops)') + { + $oid_index =3D $index->{index_oid_macro}; + $oid_syscache =3D $index->{syscache_name}; + } + if ($index->{index_decl} =3D~ /\(\w+name name_ops(, \w+namespace oid_ops)= ?\)/) + { + $name_syscache =3D $index->{syscache_name}; + $is_nsp_name_unique =3D 1 if $index->{is_unique}; + } The variables name_syscache and syscache_name are unfortunately close to eachother.