# US 2013/0159278 A1 · Techniques for efficiently supporting xquery update facility in sql/xml

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2013/0159278 A1
- Document ID: US20130159278A1
- Status: Published application
- Kind: A1
- Application number: 13/330,622
- Filed: 2011-12-19
- Published: 2013-06-20
- Earliest claimed: 2011-12-19
- Assignees: Oracle International Corporation
- Inventors: Zhen Hua Liu; Hui Joe Chang; Balasubramanyam Sthanikam
- Web page: https://patentgrep.com/patent/US20130159278A1

## CPC

- G06F 16/80: of semi-structured data, e.g. markup language structured data such as SGML, XML or HTML (content-based retrieval of web data G06F16/95)
- G06F 16/2452: Query translation
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

The approaches described herein provide an efficient way to process certain kinds of queries that update XML data stored in an object-relational database. A query may include an XML query expression that conforms to a language for querying XML documents. A technique first determines whether the query contains an XML updating expression, and in response rewrites the query to comprise one or more path-based query operators that specify operations for updating XML data. The query may then be further rewritten to comprise one or more storage format specific query operators based on the particular database storage format associated with the XML data specified in the query. The rewritten query operators are used to generate a query execution plan that provides for several query execution optimizations.

## Claims

### Claim 1

A method comprising:
receiving a query expression against a collection of XML documents stored in one or more tables of a database, wherein the collection of XML documents are stored based on a particular data storage format;
determining that the query expression contains an updating expression that conforms to a language for querying XML documents;
in response to determining that the query expression contains an updating expression, rewriting the query expression to form a first rewritten query expression comprising one or more path-based query operators that specify operations for updating XML data;
based on the particular database storage format storing the collection of XML documents, rewriting the first rewritten query expression to form a second rewritten query expression comprising one or more storage format specific query operators configured to update particular XML data of the collection of XML documents; and
wherein the method is performed by one or more computing devices.

### Claim 2 (depends on 1)

The method of claim 1, wherein the particular database storage format is binary-encoded XML, and wherein at least one of the one or more storage format specific query operators is configured to perform streaming evaluation of binary-encoded XML.

### Claim 3 (depends on 1)

The method of claim 1, wherein the particular database storage format is relational storage of the XML documents in one or more database tables, and wherein at least one of the one or more storage format specific query operators is configured to perform a SQL update against the one or more tables of a database containing XML data updated by the query expression.

### Claim 4 (depends on 1)

The method of claim 1, further comprising:
determining that the updating expression identifies two or more target update nodes;
in response to determining that the updating expression identifies two or more target update nodes, at least one of the one or more path-based query operators of the first rewritten query comprising a path expression that identifies the two or more target update nodes and a parameter that determines whether an error is returned.

### Claim 5 (depends on 1)

The method of claim 1, further comprising:
determining that the query expression includes a sequence expression;
in response to determining that the query expression includes a sequence expression, at least one of the one or more path-based query operators of the first rewritten query expression comprising two or more path expressions based on the sequence expression.

### Claim 6 (depends on 1)

The method of claim 1, further comprising:
wherein the query expression includes a conditional expression;
determining that the execution of the updating expression is based on evaluation of the conditional expression;
in response to determining that the execution of the updating expression is based on evaluation of the conditional expression, the first rewritten query expression further comprising a SQL conditional statement.

### Claim 7 (depends on 1)

The method of claim 1, further comprising:
an XML index that indexes one or more XML documents of the collection of XML documents, wherein the XML index comprises one or more path expressions, and wherein each of the one or more path expressions identifies one or more nodes;
determining that the updating expression does not update a node of the one or more nodes identified by a path expression of the XML index;
in response to determining that the updating expression does not update a node of the one or more nodes identified by a path expression of the XML index, setting a flag indicating that the XML index should not be updated.

### Claim 8 (depends on 1)

The method of claim 1, further comprising:
wherein the query expression comprises a collection function;
determining that an XML index exists that indexes XML data identified by the collection function;
in response to determining that an XML index exists that indexes XML data identified by the collection function, the first rewritten query expression further comprising one or more index-based query operators, wherein the index-based query operators identify the XML index.

### Claim 9

A non-transitory computer-readable medium storing instructions which, when executed by one or more processors, cause the one or more processors to perform a method, comprising:
receiving a query expression against a collection of XML documents stored in one or more tables of a database, wherein the collection of XML documents are stored based on a particular data storage format;
determining that the query expression contains an updating expression that conforms to a language for querying XML documents;
in response to determining that the query expression contains an updating expression, rewriting the query expression to form a first rewritten query expression comprising one or more path-based query operators that specify operations for updating XML data;
based on the particular database storage format storing the collection of XML documents, rewriting the first rewritten query expression to form a second rewritten query expression comprising one or more storage format specific query operators configured to update particular XML data of the collection of XML documents.

### Claim 10 (depends on 9)

The non-transitory computer-readable medium of claim 9, wherein the particular database storage format is binary-encoded XML, and wherein at least one of the one or more storage format specific query operators is configured to perform streaming evaluation of binary-encoded XML.

### Claim 11 (depends on 9)

The non-transitory computer-readable medium of claim 9, wherein the particular database storage format is relational storage of the XML documents in one or more database tables, and wherein at least one of the one or more storage format specific query operators is configured to perform a SQL update against the one or more tables of a database containing XML data updated by the query expression.

### Claim 12 (depends on 9)

The non-transitory computer-readable medium of claim 9, further comprising:
determining that the updating expression identifies two or more target update nodes;
in response to determining that the updating expression identifies two or more target update nodes, at least one of the one or more path-based query operators of the first rewritten query comprising a path expression that identifies the two or more target update nodes and a parameter that determines whether an error is returned.

### Claim 13 (depends on 9)

The non-transitory computer-readable medium of claim 9, further comprising:
determining that the query expression includes a sequence expression;
in response to determining that the query expression includes a sequence expression, at least one of the one or more path-based query operators of the first rewritten query expression comprising two or more path expressions based on the sequence expression.

### Claim 14 (depends on 9)

The non-transitory computer-readable medium of claim 9, further comprising:
wherein the query expression includes a conditional expression;
determining that the execution of the updating expression is based on evaluation of the conditional expression;
in response to determining that the execution of the updating expression is based on the evaluation of the conditional expression, the first rewritten query expression further comprising a SQL conditional statement.

### Claim 15 (depends on 9)

The non-transitory computer-readable medium of claim 9, further comprising:
an XML index that indexes one or more XML documents of the collection of XML documents, wherein the XML index comprises one or more path expressions, and wherein each of the one or more path expressions identifies one or more nodes;
determining that the updating expression does not update a node of the one or more nodes identified by a path expression of the XML index;
in response to determining that the updating expression does not update a node of the one or more nodes identified by a path expression of the XML index, setting a flag indicating that the XML index should not be updated.

### Claim 16 (depends on 9)

The non-transitory computer-readable medium of claim 9, further comprising:
wherein the query expression comprises a collection function;
determining that an XML index exists that indexes XML data identified by the collection function;
in response to determining that an XML index exists that indexes XML data identified by the collection function, the first rewritten query expression further comprising one or more index-based query operators, wherein the index-based query operators identify the XML index.
