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.96) (envelope-from ) id 1vjG8R-00C0rB-1P for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Jan 2026 12:19:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vjG8Q-00HR7m-1N for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Jan 2026 12:19:30 +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.96) (envelope-from ) id 1vjG8Q-00HR7d-0D for pgsql-hackers@lists.postgresql.org; Fri, 23 Jan 2026 12:19:30 +0000 Received: from udcm-wwu2.uni-muenster.de ([128.176.118.28]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vjG8N-0000000059l-3X1t for pgsql-hackers@lists.postgresql.org; Fri, 23 Jan 2026 12:19:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=uni-muenster.de; i=@uni-muenster.de; q=dns/txt; s=uniout; t=1769170769; x=1800706769; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=rsHpEHuubYUUwE9N7S8gNQLkCE5FJ52GI0g6sOe7KtQ=; b=HBGobOVQu9VzpiXH9dZ7+whszTbWdvGhDry7wxyQXP1qznDAduimInuJ mtILlIt+d0ksFxQ1OHzXM1nf7d9VabxxBMXIArlcagopw2Lg7aGI8LXHV wajE2w6920x3NIvi+1XJh4eFHvi3QgPv7Wu7CIfebsLWb9bcrsyUc1sWa BrCw6HEc0WVK3H5pkr8FsWu6e04dDg4v1okgy+l0oDMMdKM/KPseOhqIR UeRmD2AMLb3hT2VcZtE621CxEDe4V+SaH4sznI4MApA+h1idFnFz8tPFA llzNGI5xuTNLrwv5EJ45lCOwHdcf9YUKgN6YxyBi7sVKGUukdgsYKXZkQ A==; X-CSE-ConnectionGUID: Ih3UDYzDRM66WZJLDhU+Gw== X-CSE-MsgGUID: i28FEqYkRd2o8uUTsz8PPw== X-IronPort-AV: E=Sophos;i="6.21,248,1763420400"; d="scan'208";a="382253763" Received: from secmail.uni-muenster.de ([128.176.118.4]) by UDCM-RELAY2.UNI-MUENSTER.DE with ESMTP; 23 Jan 2026 13:19:27 +0100 Received: from [192.168.178.27] (dynamic-080-171-062-073.80.171.pool.telefonica.de [80.171.62.73]) by SECMAIL.UNI-MUENSTER.DE (Postfix) with ESMTPSA id 3669120ADF00; Fri, 23 Jan 2026 13:19:26 +0100 (CET) Message-ID: <08052569-9384-41b5-bcb7-33929fcc6c71@uni-muenster.de> Date: Fri, 23 Jan 2026 13:19:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: WIP - xmlvalidate implementation from TODO list To: Marcos Magueta Cc: Andrey Borodin , Kirill Reshke , PostgreSQL Hackers References: <89DE974B-F318-4D0A-A60B-51EDE84054E2@gmail.com> <9A074422-2308-4BD0-9FFA-0B6D70989935@yandex-team.ru> <70c72cb1-a39f-41b3-bfe3-e32ee7fda9c4@uni-muenster.de> <68a012d3-121b-418a-913b-aa0aaf32915d@uni-muenster.de> <2898f090-d9cf-475c-940c-a99da4a308f1@uni-muenster.de> Content-Language: de-DE, en-GB From: Jim Jones In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 21/01/2026 21:44, Marcos Magueta wrote: >> Any particular reason for that? If not, take a look at other options, > e.g. a_expr > No particular reason apart from it being simpler since I didn't need to > invoke an execution at the cmd. Changed it now. > >> Why did you choose text over xml for schemadata? > My original thought was that XML schemas require additional validation > in contrast to normal XML, but it being additive, we would have > redundant checks. But in reconsideration, perhaps keeping the field with > an XML type is more intuitive for anyone introspecting over the catalog. > Also applied the change on the latest version of the patch. Data type for schemadata in pg_xmlschema is now xml. postgres=# \d pg_xmlschema Table "pg_catalog.pg_xmlschema" Column | Type | Collation | Nullable | Default -----------------+-----------+-----------+----------+--------- oid | oid | | not null | schemaname | name | | not null | schemanamespace | oid | | not null | schemaowner | oid | | not null | schemadata | xml | | not null | schemaacl | aclitem[] | | | Indexes: "pg_xmlschema_oid_index" PRIMARY KEY, btree (oid) "pg_xmlschema_name_nsp_index" UNIQUE CONSTRAINT, btree (schemaname, schemanamespace) I agree it's more intuitive this way. It also facilitates function calls that require the parameter to be xml, e.g. xmlserialize postgres=# CREATE XMLSCHEMA x AS ''; CREATE XMLSCHEMA postgres=# SELECT xmlserialize(DOCUMENT schemadata AS text INDENT) FROM pg_xmlschema; xmlserialize --------------------------------------------------------- + + (1 row) > I noticed DefineXmlSchema() calls IsThereXmlSchemaInNamespace() right > after XmlSchemaCreate() returns a valid OID. Since XmlSchemaCreate() > already inserted the tuple into the catalog (via CatalogTupleInsert at > pg_xmlschema.c:166), wouldn't SearchSysCacheExists2() find it and always > throw "already exists"? We all tested the original code and it worked > fine, so I'm missing something about syscache visibility or timing; that > was an early function I did to check for duplicates that ended up in the > wrong place. I removed the call (and function) as I judged it to be > redundant (the duplicate check already happens inside > XmlSchemaCreate()), but is there something subtle about intra-command > visibility I'm not understanding? If anyone knows, please let me know. I couldn't find any IsThereXmlSchemaInNamespace call in DefineXmlSchema in the current version, so I cannot say much here. But I agree that the a further check is not necessary, since XmlSchemaCreate is already doing it. > Also, I added tab completion on psql and fixed pg_dump. Nice. pg_dump now exports CREATE XMLSCHEMA statements. Tab completion for CREATE, ALTER, and DROP XMLSCHEMA now also works. A few other comments == patch version == You forgot to include the version to the patch name. For instance, instead of 0001-Add-CREATE-ALTER-DROP-XMLSCHEMA-DDL-commands.patch the file could be named v3-0001-Add-CREATE-ALTER-DROP-XMLSCHEMA-DDL-commands.patch == IS_XMLVALIDATE dependency == The patches 0001, 0002, and 0003 depend on IS_XMLVALIDATE, which is only introduced in 0004, so they cannot be compiled and tested independently. == permissions == In the tests I see you added a few GRANTs to set the visibility of certain xmlschemas: GRANT USAGE ON XMLSCHEMA permission_test_schema TO regress_xmlschema_user2 I could not find anything regarding this in the docs. If we are to support it, shouldn't we add it to grant.sgml? As I mentioned upthread, I believe that schema registration and usage should be privilege-controlled, for example via dedicated roles GRANT pg_read_xmlschemas TO u; GRANT pg_write_xmlschemas TO u; What do you think? But being able to grant or revoke access to a certain xmlschema also has its appeal :) Best, Jim