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 1vS9I2-003pt6-1x for pgsql-hackers@arkaria.postgresql.org; Sun, 07 Dec 2025 07:34:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vS9Hz-00CxN6-2D for pgsql-hackers@arkaria.postgresql.org; Sun, 07 Dec 2025 07:34:39 +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 1vS9Hz-00CxMx-10 for pgsql-hackers@lists.postgresql.org; Sun, 07 Dec 2025 07:34:39 +0000 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vS9Hx-003dRo-0w for pgsql-hackers@lists.postgresql.org; Sun, 07 Dec 2025 07:34:39 +0000 Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-4ee13dc0c52so29514151cf.2 for ; Sat, 06 Dec 2025 23:34:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765092874; x=1765697674; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=s+h7yK0ClYKPfq51U7FPX3ezCqNMrEwIJhzBb7C62D4=; b=cD+0NAjsE9kIgIYg2g5FMqxyZGfQ04s/jAKwTwkur4Z5JDxCqqmJc2x+uZ7XS6riqB MCFf91r456L887xcOn5CvwbjBds2YlYQ0yYhNxQWcURt2nt8sxSoEOttogAV7zu86A5F bNFpCcvxgXgi9ZKiPQYe8kNsNxUYBGJ19+OxjcjEpz5O+HVXHhXFqxaVJMRlZRzXfMy9 seHW+z6Jy1nxgrG9WSlLRbapibudXjBh6NSsXRzB4i/8+fHX82GpH8gD9CX++FypJdGq 3qHF1Iy5uykNrGzLz+Z8SwInXpNmMr1BDE5RHhymRPdEwruc7e8XYvy5/e5lzS8hrpPd xrYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765092874; x=1765697674; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=s+h7yK0ClYKPfq51U7FPX3ezCqNMrEwIJhzBb7C62D4=; b=SU20TQJ7R/Cf+5N0K07oSInHtAMNEeif35IxVoKbmRaUw69ZmpuRrPMaFIeZ+pQHl9 +12jsxDFXAxBYkwbht5k5185azDZdzpw+uZ0D+X9DzAwmXKHOMb5xlyTok5LfoAZojnz e0qRCiJxXuZxugFF0t5M4/VKdW4D+eP8x5efeC67Aql0R7PAdifmX8U+YnQUw8gfxQ8o o1ITiy78awUA+Kb1RDBayZZJpMY63GPJYQkr4CcKZbkIDQRovWcZPZlXIsodbj2z9u5m RUMqLU6NAhSDoIwYYRQmFHc/i5vTwJVQ4+TgSlvKAP6ueL+suMiwZkyQO3U6+2JLikTz I1dQ== X-Gm-Message-State: AOJu0YysiljZjWbh42DpDJgr1ub1UjCbYLle9fa+7145NIBAJ6AVJQQo eeZDnOI7OzuN+Em21j0BHqbTJKsr9Oh/twmWkxBFHblqOCTWgOWetea0yLI04wjKOeEr46mAzZo 6sG51KywccNVOoxxgIT858t6r0FwIasA= X-Gm-Gg: ASbGncuDmieXnYo9ZiJ2y+FuZJqbIIhSv6hImabXkrR8ctyNQBdAj6N8eFta4nUd8lK MU4IRqBceVI1cAg2nqg1Y98MfGdFdWSU946Ezqh91njbeMWP54a8J4dD7Ftb7OODsKoGceN+HRz ewWYDc5pz/bcQo/kSgDSrLpjbr2PdcvQWKKr5EHVQ1qf4nUvHfKNdOSZHYnGPLegXef+wHoWmSr 9Sli8lVbDAAWgrxYw93fxDqTtnEsROW6kZsOYuXx8dM63sZqiVpxQMDVT2NF9rSVxITreJh1zEQ jX89Daz3XGX4E6Ab X-Google-Smtp-Source: AGHT+IFaFBVXU5WzxcU61A/4YlpCvMteXOKdZFmoHoFP1QUnGU2DYTdTqGe28cFI0B+KxflFebfR46/FGpkh7hZ6d5w= X-Received: by 2002:a05:622a:64c:b0:4ed:e40c:872d with SMTP id d75a77b69052e-4f03ff20b52mr64562671cf.59.1765092873563; Sat, 06 Dec 2025 23:34:33 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Kirill Reshke Date: Sun, 7 Dec 2025 12:34:22 +0500 X-Gm-Features: AQt7F2pqGVPEuJRVvYz8m2fity1Nh-5EcrrPraMRS6u2dEV410aWusgATmKjUz0 Message-ID: Subject: Re: WIP - xmlvalidate implementation from TODO list To: Marcos Magueta Cc: pgsql-hackers@lists.postgresql.org Content-Type: multipart/mixed; boundary="000000000000b98c57064557b5ef" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b98c57064557b5ef Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, 7 Dec 2025 at 04:38, Marcos Magueta wrote= : > > Hello! > > I am likely one of the few people still using XML, but I noticed XSD sche= ma validation is still a TODO on postgresql, which I have some personal use= cases for. > > In this patch I attempt to implement XMLVALIDATE with the already in use = libxml following a version I got my hands on of the SQL/XML standard of 201= 6. > > In short, I had to add the ACCORDING word to comply with it and completel= y ignored the version that was already in the src that fetches arbitrary sc= hemas (it refers to validations of dtds, which is another more troublesome = TODO). > > I had problems running the regression tests on my machine, so I could onl= y test the feature by spawning a modified instance of postgresql and issuin= g queries through psql, therefore I am marking it as WIP. If anyone can ass= ert the tests pass, I would be glad. > > Also, this is my first patch, so I might have not followed standard pract= ices as best as I could, so please pay particular attention to that on revi= ew. > > Cheers, > Marcos Magueta. HI! 1) > + // Default case since nothing got returned > + // out of the normal path for validation calls to libxml PostgreSQL uses /**/ comments style. 2) XML regression test suite fails, see attached. By the way, what are your issues with running `make check` ? 3) By the way, in [0] we have this ` The function in PostgreSQL produces an =E2=80=9Cunimplemented=E2=80=9D erro= r, because PostgreSQL does not have any implementation of the mechanism assumed in the standard for registering schemas in advance, which is necessary to address the security implications of a function that could refer to schemas from arbitrary locations. ` How does your patch resolve this? I did not find any change in this area 4) Also I want to mention that without a doc, the patch is not in a commitable shape. 5) I am a bit surprised by this grammar rule: > XMLVALIDATE '(' document_or_content a_expr ACCORDING TO XMLSCHEMA a_expr= ')' this allow a wide class of expressions accepted by parser, like `SELECT xmlvalidate(DOCUMENT (select oid from pg_class) ACCORDING TO XMLSCHEMA (select 32)) AS is_valid FROM xml_validation_test;` Is this expected? a_expr is way more than string constants and column references.. If yes, the regression test that you added, does not test this.. p.s. I failed to find in google SQL/XML standard of 2016. So, I cannot double-check if this feature is compliant with it... [0] https://wiki.postgresql.org/wiki/PostgreSQL_vs_SQL/XML_Standards --=20 Best regards, Kirill Reshke --000000000000b98c57064557b5ef Content-Type: application/octet-stream; name="xml_diff.diffs" Content-Disposition: attachment; filename="xml_diff.diffs" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_mivddn8n0 ZGlmZiAtVTMgL2hvbWUvcmVzaGtlL3BnL3NyYy90ZXN0L3JlZ3Jlc3MvZXhwZWN0ZWQveG1sLm91 dCAvaG9tZS9yZXNoa2UvcGcvc3JjL3Rlc3QvcmVncmVzcy9yZXN1bHRzL3htbC5vdXQKLS0tIC9o b21lL3Jlc2hrZS9wZy9zcmMvdGVzdC9yZWdyZXNzL2V4cGVjdGVkL3htbC5vdXQJMjAyNS0xMi0w NyAwNjo1MDoyMi40NTgyMTc0NDQgKzAwMDAKKysrIC9ob21lL3Jlc2hrZS9wZy9zcmMvdGVzdC9y ZWdyZXNzL3Jlc3Vsd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