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 1upNcn-0041ad-3D for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Aug 2025 08:59:54 +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 1upNcm-004IdM-Dp for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Aug 2025 08:59:53 +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 1upNcm-004IdD-3l for pgsql-hackers@lists.postgresql.org; Fri, 22 Aug 2025 08:59:52 +0000 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1upNck-001FGT-1k for pgsql-hackers@lists.postgresql.org; Fri, 22 Aug 2025 08:59:52 +0000 Received: by mail-qt1-x835.google.com with SMTP id d75a77b69052e-4b109c4af9eso15285731cf.3 for ; Fri, 22 Aug 2025 01:59:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755853188; x=1756457988; darn=lists.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=UCL7eVlGsjEIilY+a9qfqk8gU0vQf8vv58IPgQc1ElU=; b=cYWGI0ALUbaX5sZPvpBioo83Wfpqg63kH2Fi/ivv7pdeI7dBKiO7PMLiTX1XxdFRGq 4veaPk8eD2qmoslUrX1627kXW2W1MjFg3tWVyZbMu2BYM5AIK47bxC1m6ztwMBpKJdw1 /zaOzyIZ5/FOdepPldYk3eB8Shxil0xBEwOiWCOlEq2AN1C9k6r4HhcaJVWpgP6Tc+Ta +3cVrOC/j0OjwylJKS5ohVLULQ7cwRnVHZtzjeuz4I2n2WPECKPcgHPuEr+hJPrsn/Mu FYrzaXt8ZawHxpgeU/qgLBU67UsR/+D6k2c2FzG7uwhv/c0zG3ZpHjFYo97bwGGjXygg K9nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755853188; x=1756457988; 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=UCL7eVlGsjEIilY+a9qfqk8gU0vQf8vv58IPgQc1ElU=; b=fB2ZSUOhFhxBFvPtmysN55pp1LXL+EKSAeLpGJMrqeMLXAa8M6JwzEPGF9lRUKb3d8 SuVy2HCDqMIM9XRieJbc8kU3leacwa/6NSEBOxFfRmtQAoaDoLfOrDZ4GazpHgi3g9Pz PcKhaDA0eYLiVZLZekir5nHz9VOUGdZDo3yfOAYRbMwYGo2VyEElwc84EFiswuURLlsT Z1GBkwMN4svSsLQaJwZddS/8CatRvadRFbghRzjdnBD5KeYwdJIcIcBBdycZaEaNSH7Q NnGEnjo255NxSrU7AL60Lfg3j3x6CrpQ3L+A6nnto5NY37Wmo/Hae5hyy2su1Jm81Muz Xk9g== X-Forwarded-Encrypted: i=1; AJvYcCVRFbS/XGauGnYWlmlBKoZDOlQcdrVMY6Z87Y+cjRwuuZF+HqKA2dgZQDVGNpGy3LUI6VoG5Ia2TvEYYkC0@lists.postgresql.org X-Gm-Message-State: AOJu0Yzy4XeFhQGlbI3ss1835Efv7ahkOVPKz1Ixktud6UXGlt0q6iZ+ Pc3A/KN6tVPSmBbt1ly31RFlR2NIcwJNbehNDekyhns/LtBlTaoRFP4OYhti5dty81PYXOrw5Km jNzPMVW3ZVdq4lXHJbSN/aRcSl0s6/8s= X-Gm-Gg: ASbGnctORC0c72F8ugZHWdbnAwyfoaPLtMU1j2TU6AEi+WyMouVy3uLYrCrWcaolsNz m0WoyDxGqPBkbrEaa3EFIvj3hq+xR2dP8in8+OjkT9qg+On9tWEQalzQc6C4AgovxN4y2qTv+wh Mu+Jv9/dYO+gwIdt5OeHLecgNxxIu4ZSFPpotiSkrlsjZNqSXdC2jAqX83o2i+4t1S0HKwIqwGG nvskN85UhDH0TEC51g= X-Google-Smtp-Source: AGHT+IHBUD7wEXX9uBQOAsLXYy48AWsZgS7Rn4Y8TYVYp1CLFNcNrRK9NAA4vSbhaoETKRV1fJ0Scsjf5WNfsYCkj5w= X-Received: by 2002:a05:622a:294:b0:4b2:9bdc:5da2 with SMTP id d75a77b69052e-4b2aab6797amr26651871cf.76.1755853188283; Fri, 22 Aug 2025 01:59:48 -0700 (PDT) MIME-Version: 1.0 References: <1898722.1732732780@sss.pgh.pa.us> <2007224.1732773174@sss.pgh.pa.us> <1075425.1732993688@sss.pgh.pa.us> <345c20e5-a6d7-477a-9598-982661bb5740@eisentraut.org> <1990479.1733256458@sss.pgh.pa.us> <499425.1733936916@sss.pgh.pa.us> In-Reply-To: From: Kirill Reshke Date: Fri, 22 Aug 2025 13:59:37 +0500 X-Gm-Features: Ac12FXxoSQlxwovKHTlSXvylG0F31WJdgqAKcpIUQeopGCYVFPHBeDo3ubOGHj0 Message-ID: Subject: Re: CREATE SCHEMA ... CREATE DOMAIN support To: jian he Cc: Tom Lane , Peter Eisentraut , PostgreSQL Hackers 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 Tue, 19 Aug 2025 at 08:37, jian he wrote: > > On Thu, Dec 12, 2024 at 1:08=E2=80=AFAM Tom Lane wrot= e: > > This cannot possibly work if an object-type-based re-ordering > > is done to it. > > > > So IMV, we have three possibilities: > > > > 1. CREATE SCHEMA's schema-element feature remains forevermore > > a sad joke that (a) doesn't cover nearly enough to be useful and > > (b) doesn't come close to doing what the spec says it should. > > > > 2. We invest an enormous amount of engineering effort on trying > > to extract dependencies from not-yet-analyzed parse trees, after > > which we invest a bunch more effort figuring out heuristics for > > ordering the subcommands in the face of circular dependencies. > > (Some of that could be stolen from pg_dump, but not all: pg_dump > > only has to resolve a limited set of cases.) > > > > 3. We bypass the need for #2 by decreeing that we'll execute > > the subcommands in order. > > > > > > >> PS: if we were really excited about allowing circular FKs to be > > >> made within CREATE SCHEMA, a possible though non-standard answer > > >> would be to allow ALTER TABLE ADD CONSTRAINT as a . > > > > > That's a nice feature to have by itself? > > > > Not unless we abandon the idea of subcommand reordering, because > > where are you going to put the ALTER TABLE subcommands? > > > > hi. Hi! > move this forward with option #3 (executing the subcommands in order). Thank you. I am +1 on option #3. > pg_dump don't use CREATE SCHEMA ...CREATE ... > so if we error out > CREATE SCHEMA regress_schema_2 CREATE VIEW abcd_view AS SELECT a FROM > abcd CREATE TABLE abcd (a int); > it won't be a big compatibility issue? > Also this thread doesn=E2=80=99t show strong support for sorting the subc= ommands. > > the full in 11.1 is: > 11.1 > > ::=3D > > | > | > | > | > | > | > | > | > | > | > | > | > | > | > | > > so I also add support for CREATE SCHEMA CREATE COLLATION. > > v6-0001-Don-t-try-to-re-order-the-subcommands-of-CREATE-SCHEMA.patch > v6-0002-CREATE-SCHEMA-CREATE-DOMAIN.patch > v6-0003-CREATE-SCHEMA-CREATE-COLLATION.patch > > v6-0001-Don-t-try-to-re-order-the-subcommands-of-CREATE-SCHEMA.patch > is refactor/rebase based on > v1-0001-Don-t-try-to-re-order-the-subcommands-of-CREATE-S.patch > > v6-0002-CREATE-SCHEMA-CREATE-DOMAIN.patch > for CREATE SCHEMA ... CREATE-DOMAIN > > v6-0003-CREATE-SCHEMA-CREATE-COLLATION.patch > for CREATE SCHEMA ... CREATE-COLLATION With these patches applied: ``` reshke=3D# create schema sh1 create type tp as (i text); ERROR: unrecognized node type: 226 ``` Without patches it will be a syntax error. Also we need a better error message in this: "CREATE SCHEMA ... CREATE OBJECT currently not support for..." First of all, is it s/support/supported/ ? Also would vote for something like "%s is not yet supported inside schema definition." WDYT? --=20 Best regards, Kirill Reshke