Re: Proposal for XML Schema Validation - Mailing list pgsql-hackers

From Bisen Vikrantsingh Mohansingh MT2012036
Subject Re: Proposal for XML Schema Validation
Date
Msg-id 6a028c4a09e741a287dcd6af5fe89384@HKXPR01MB055.apcprd01.prod.exchangelabs.com
Whole thread Raw
In response to Re: Proposal for XML Schema Validation  (Craig Ringer <craig@2ndquadrant.com>)
List pgsql-hackers
Hi Craig Ringer,

yeah, you are right indeed. I tried to answer your question in three section as below.

(A) XML Schema update

User may wish to update schema in future. So we will provide them one more function

UPDATE_XML_SCHEMA("<URL OF SCHEMA>","<NAMESPACE>","<NEW CONTENT OF .XSD>")

Here we are assuming URL OF SCHEMA as a primary key. And we will overwrite content of .xsd field no provision
of altering a selective portion xsd in place.

Whenever an update to schema happens
before committing changes we will run small algo as below1. For all table in which this schema is used2.
if(!validatexml document for each row) 3.       abort/exit with error;4. commit   

If user modify schema by adding some extra optional tags then their won't be any error
,error will arise in cases such as adding new compulsory/required tags, datatype in .xsd for
certain tag is modified. This is beyond our control an obvious solution as suggested by you
could be used, user will manually go through rows which are violating schema (for simplicity,
we will mention row number which are violating schema in our error message) and do
modification/deletion as required.


(
similar case happen, suppose you have a table t(a,b,c) with lot of data, later on
you want to add primary key constraints to column 'a', but if data in column 'a' is
not unique then it may fail, and user has to manually handle this situation may be by deleting or
modifying respective rows.
)


(B) Alter Table
  Only sole purpose of making use of keyword USE_SCHEMA is to mimic oracle (somewhere on
oracle site i found this type of syntax), I may not be correct but check constraint is only used tolimit the value
ranges.So it is better to introduce new meaningful keyword or else no problem  
to work embed this feature with CHECK()

(C)

yes , there are memory management related issue with libxml as mentioned on below link
http://wiki.postgresql.org/wiki/XML_Support#Implementation_Issues
It is also mention there that this issue can be resolved(how? don't know!).



Thanks,
Vikrantsingh & Pridhvi
IIIT Bangalore
________________________________________
From: Craig Ringer <craig@2ndquadrant.com>
Sent: Friday, August 09, 2013 8:27 AM
To: Kodamasimham Pridhvi (MT2012066)
Cc: pgsql-hackers@postgresql.org; Bisen Vikrantsingh Mohansingh MT2012036
Subject: Re: [HACKERS] Proposal for XML Schema Validation

On 08/09/2013 12:39 AM, Kodamasimham Pridhvi (MT2012066) wrote:
>
> Objective: To Add XML Schema validation and xmlvalidate functions (SQL:2008)
>
> Description:
> We’ve gone through current support of xml in postgreSQL and found that there is a check for well-formedness of xml
documentwhile inserting and updating. We want to extend this feature by adding xml schema validation. 
>        We will be providing user with DDL commands for creating and deleting XML Schema, also provision of
associatingxml schema with table while creation of new table or while altering table structure, we are planning to use
libxml2library. Proposed syntax is given below. 

The first thing that comes to mind here is "what if the user wants to
update/replace the schema" ? How would you handle re-validating the fields?

Sure, updating XML schemas is not a great idea, but it doesn't stop
people doing it. It might be reasonable to say "if you want to do this
you have to drop the dependent constraints, drop the schema, re-create
the schema and re-create the schema constraints" though.

Why extend the create table / alter table syntax with "USE_SCHEMA"? Is
there a compatibility/standards reason to do this? If not, what
advantage does this provide over using a suitable CHECK constraint?

IIRC there were some memory management issues with libxml2 in Pg. Anyone
remember anything about that?

--Craig Ringer                   http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: confusing error message
Next
From: Josh Berkus
Date:
Subject: Re: Proposal: leave a hint when switching logging away from stderr