提交 75b826c4 编写于 作者: A Andrew Khitrin

MSSQL Plan parser first approach

上级 e40d0a42

要显示的变更太多。

To preserve performance only 1000 of 1000+ files are displayed.
<jxb:bindings
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
schemaLocation="../schemas/sql2005/showplanxml.xsd"
jxb:version="2.0">
<jxb:bindings node="//xsd:complexType[@name='ConvertType']/xsd:sequence/xsd:element[@name='Style']">
<jxb:property name="ConvertStyle"/>
</jxb:bindings>
<jxb:schemaBindings>
<jxb:nameXmlTransform>
<jxb:typeName suffix="_sql2005"/>
<jxb:anonymousTypeName suffix="_sql2005"/>
</jxb:nameXmlTransform>
</jxb:schemaBindings>
</jxb:bindings>
\ No newline at end of file
<jxb:bindings
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
schemaLocation="../schemas/sql2005sp2/showplanxml.xsd"
jxb:version="2.0">
<jxb:bindings node="//xsd:complexType[@name='ConvertType']/xsd:sequence/xsd:element[@name='Style']">
<jxb:property name="ConvertStyle"/>
</jxb:bindings>
<jxb:schemaBindings>
<jxb:nameXmlTransform>
<jxb:typeName suffix="_sql2005sp2"/>
<jxb:anonymousTypeName suffix="_sql2005sp2"/>
</jxb:nameXmlTransform>
</jxb:schemaBindings>
</jxb:bindings>
\ No newline at end of file
<jxb:bindings
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
schemaLocation="../schemas/sql2008/showplanxml.xsd"
jxb:version="2.0">
<jxb:bindings node="//xsd:complexType[@name='ConvertType']/xsd:sequence/xsd:element[@name='Style']">
<jxb:property name="ConvertStyle"/>
</jxb:bindings>
<jxb:schemaBindings>
<jxb:nameXmlTransform>
<jxb:typeName suffix="_sql2008"/>
<jxb:anonymousTypeName suffix="_sql2008"/>
</jxb:nameXmlTransform>
</jxb:schemaBindings>
</jxb:bindings>
\ No newline at end of file
<jxb:bindings
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
schemaLocation="../schemas/sql2012/showplanxml.xsd"
jxb:version="2.0">
<jxb:bindings node="//xsd:complexType[@name='ConvertType']/xsd:sequence/xsd:element[@name='Style']">
<jxb:property name="ConvertStyle"/>
</jxb:bindings>
<jxb:schemaBindings>
<jxb:nameXmlTransform>
<jxb:typeName suffix="_sql2012"/>
<jxb:anonymousTypeName suffix="_sql2012"/>
</jxb:nameXmlTransform>
</jxb:schemaBindings>
</jxb:bindings>
\ No newline at end of file
<jxb:bindings
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
schemaLocation="../schemas/sql2014/showplanxml.xsd"
jxb:version="2.0">
<jxb:bindings node="//xsd:complexType[@name='ConvertType']/xsd:sequence/xsd:element[@name='Style']">
<jxb:property name="ConvertStyle"/>
</jxb:bindings>
<jxb:schemaBindings>
<jxb:nameXmlTransform>
<jxb:typeName suffix="_sql2014"/>
<jxb:anonymousTypeName suffix="_sql2014"/>
</jxb:nameXmlTransform>
</jxb:schemaBindings>
</jxb:bindings>
\ No newline at end of file
<jxb:bindings
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
schemaLocation="../schemas/sql2014sp2/showplanxml.xsd"
jxb:version="2.0">
<jxb:bindings node="//xsd:complexType[@name='ConvertType']/xsd:sequence/xsd:element[@name='Style']">
<jxb:property name="ConvertStyle"/>
</jxb:bindings>
<jxb:schemaBindings>
<jxb:nameXmlTransform>
<jxb:typeName suffix="_sql2014sp2"/>
<jxb:anonymousTypeName suffix="_sql2014sp2"/>
</jxb:nameXmlTransform>
</jxb:schemaBindings>
</jxb:bindings>
\ No newline at end of file
<jxb:bindings
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
schemaLocation="../schemas/sql2016/showplanxml.xsd"
jxb:version="2.0">
<jxb:bindings node="//xsd:complexType[@name='ConvertType']/xsd:sequence/xsd:element[@name='Style']">
<jxb:property name="ConvertStyle"/>
</jxb:bindings>
<jxb:schemaBindings>
<jxb:nameXmlTransform>
<jxb:typeName suffix="_sql2016"/>
<jxb:anonymousTypeName suffix="_sql2016"/>
</jxb:nameXmlTransform>
</jxb:schemaBindings>
</jxb:bindings>
\ No newline at end of file
<jxb:bindings
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
schemaLocation="../schemas/sql2016sp1/showplanxml.xsd"
jxb:version="2.0">
<jxb:bindings node="//xsd:complexType[@name='ConvertType']/xsd:sequence/xsd:element[@name='Style']">
<jxb:property name="ConvertStyle"/>
</jxb:bindings>
<jxb:schemaBindings>
<jxb:nameXmlTransform>
<jxb:typeName suffix="_sql2016sp1"/>
<jxb:anonymousTypeName suffix="_sql2016sp1"/>
</jxb:nameXmlTransform>
</jxb:schemaBindings>
</jxb:bindings>
\ No newline at end of file
<jxb:bindings
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
schemaLocation="../schemas/sql2017/showplanxml.xsd"
jxb:version="2.0">
<jxb:bindings node="//xsd:complexType[@name='ConvertType']/xsd:sequence/xsd:element[@name='Style']">
<jxb:property name="ConvertStyle"/>
</jxb:bindings>
<jxb:schemaBindings>
<jxb:nameXmlTransform>
<jxb:typeName suffix="_sql2017"/>
<jxb:anonymousTypeName suffix="_sql2017"/>
</jxb:nameXmlTransform>
</jxb:schemaBindings>
</jxb:bindings>
\ No newline at end of file
set xjc="C:\Program Files\Java\jdk1.8.0_181\bin\xjc"
rmdir ./classes/* /s /q
%xjc% -verbose -d ./classes/ -p org.jkiss.dbeaver.ext.mssql.model.plan.schemas.sql2017 -npa -no-header -encoding UTF8 -enableIntrospection -disableXmlSecurity -b ./bindings/sql2017.xjb ./schemas/sql2017/showplanxml.xsd
%xjc% -verbose -d ./classes/ -p org.jkiss.dbeaver.ext.mssql.model.plan.schemas.sql2016sp1 -npa -no-header -encoding UTF8 -enableIntrospection -disableXmlSecurity -b ./bindings/sql2016sp1.xjb ./schemas/sql2016sp1/showplanxml.xsd
%xjc% -verbose -d ./classes/ -p org.jkiss.dbeaver.ext.mssql.model.plan.schemas.sql2016 -npa -no-header -encoding UTF8 -enableIntrospection -disableXmlSecurity -b ./bindings/sql2016.xjb ./schemas/sql2016/showplanxml.xsd
%xjc% -verbose -d ./classes/ -p org.jkiss.dbeaver.ext.mssql.model.plan.schemas.sql2014sp2 -npa -no-header -encoding UTF8 -enableIntrospection -disableXmlSecurity -b ./bindings/sql2014sp2.xjb ./schemas/sql2014sp2/showplanxml.xsd
%xjc% -verbose -d ./classes/ -p org.jkiss.dbeaver.ext.mssql.model.plan.schemas.sql2014 -npa -no-header -encoding UTF8 -enableIntrospection -disableXmlSecurity -b ./bindings/sql2014.xjb ./schemas/sql2014/showplanxml.xsd
%xjc% -verbose -d ./classes/ -p org.jkiss.dbeaver.ext.mssql.model.plan.schemas.sql2012 -npa -no-header -encoding UTF8 -enableIntrospection -disableXmlSecurity -b ./bindings/sql2012.xjb ./schemas/sql2012/showplanxml.xsd
%xjc% -verbose -d ./classes/ -p org.jkiss.dbeaver.ext.mssql.model.plan.schemas.sql2008 -npa -no-header -encoding UTF8 -enableIntrospection -disableXmlSecurity -b ./bindings/sql2008.xjb ./schemas/sql2008/showplanxml.xsd
%xjc% -verbose -d ./classes/ -p org.jkiss.dbeaver.ext.mssql.model.plan.schemas.sql2005sp2 -npa -no-header -encoding UTF8 -enableIntrospection -disableXmlSecurity -b ./bindings/sql2005sp2.xjb ./schemas/sql2005sp2/showplanxml.xsd
%xjc% -verbose -d ./classes/ -p org.jkiss.dbeaver.ext.mssql.model.plan.schemas.sql2005 -npa -no-header -encoding UTF8 -enableIntrospection -disableXmlSecurity -b ./bindings/sql2005.xjb ./schemas/sql2005/showplanxml.xsd
\ No newline at end of file
......@@ -24,12 +24,14 @@ import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.ModelPreferences;
import org.jkiss.dbeaver.ext.mssql.SQLServerConstants;
import org.jkiss.dbeaver.ext.mssql.SQLServerUtils;
import org.jkiss.dbeaver.ext.mssql.model.plan.SQLServerQueryPlanner;
import org.jkiss.dbeaver.ext.mssql.model.session.SQLServerSessionManager;
import org.jkiss.dbeaver.model.*;
import org.jkiss.dbeaver.model.admin.sessions.DBAServerSessionManager;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.exec.*;
import org.jkiss.dbeaver.model.exec.jdbc.*;
import org.jkiss.dbeaver.model.exec.plan.DBCQueryPlanner;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils;
......@@ -320,8 +322,10 @@ public class SQLServerDataSource extends JDBCDataSource implements DBSObjectSele
public <T> T getAdapter(Class<T> adapter) {
if (adapter == DBSStructureAssistant.class) {
return adapter.cast(new SQLServerStructureAssistant(this));
} else if (adapter == DBAServerSessionManager .class) {
} else if (adapter == DBAServerSessionManager.class) {
return adapter.cast(new SQLServerSessionManager(this));
} else if (adapter == DBCQueryPlanner.class) {
return adapter.cast(new SQLServerQueryPlanner(this));
}
return super.getAdapter(adapter);
}
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2019 Andrew Khitrin (ahitrin@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ext.mssql.model.plan;
import java.io.StringReader;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import org.jkiss.dbeaver.model.exec.plan.DBCPlanNode;
import org.jkiss.utils.xml.XMLException;
import org.xml.sax.InputSource;
public abstract class SQLServerPlanAdapter<PLANTYPE> {
private static JAXBContext jaxbContext = null;
Unmarshaller jaxbUnmarshaller = null;
public abstract List<DBCPlanNode> getNodes(String planString) throws XMLException;
protected abstract Class<PLANTYPE> getPlanClass();
@SuppressWarnings("unchecked")
protected PLANTYPE parseXML(String planString) throws JAXBException {
if (jaxbContext == null) {
jaxbContext = JAXBContext.newInstance(getPlanClass());
}
if (jaxbUnmarshaller == null) {
jaxbUnmarshaller = jaxbContext.createUnmarshaller();
}
return (PLANTYPE) jaxbUnmarshaller.unmarshal(new InputSource(new StringReader(planString)));
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2019 Andrew Khitrin (ahitrin@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ext.mssql.model.plan;
import java.io.FileWriter;
import java.sql.SQLException;
import java.sql.SQLXML;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.exec.DBCSession;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement;
import org.jkiss.dbeaver.model.exec.plan.DBCPlanNode;
import org.jkiss.dbeaver.model.impl.plan.AbstractExecutionPlan;
import org.jkiss.utils.CommonUtils;
import org.jkiss.utils.xml.XMLException;
public class SQLServerPlanAnalyzer extends AbstractExecutionPlan {
private static final String TURN_PLAN_ON = "SET STATISTICS XML ON";
private String query;
private List<DBCPlanNode> nodes;
private static final Log log = Log.getLog(SQLServerPlanAnalyzer.class);
public SQLServerPlanAnalyzer(String query) {
this.query = query;
}
@Override
public String getQueryString() {
return query;
}
@Override
public String getPlanQueryString() throws DBException {
return query;
}
@Override
public List<? extends DBCPlanNode> getPlanNodes(Map<String, Object> options) {
// TODO Auto-generated method stub
return null;
}
public void explain(DBCSession session) throws DBCException
{
JDBCSession connection = (JDBCSession) session;
boolean oldAutoCommit = false;
try {
oldAutoCommit = connection.getAutoCommit();
if (oldAutoCommit) {
connection.setAutoCommit(false);
}
try (JDBCStatement dbStat = connection.createStatement()) {
dbStat.execute(TURN_PLAN_ON);
try (JDBCResultSet dbResult = dbStat.executeQuery(query)) {
if (dbStat.getMoreResults()) {
try (JDBCResultSet planResult = dbStat.getResultSet()) {
if (planResult.next()) {
nodes = SQLServerPlanParser.getInstance().parse(planResult.getString(1));
} else {
throw new DBCException("Query plan not available");
}
}
} else {
throw new DBCException("Query plan not supported");
}
} catch (Exception e) {
throw new DBCException("Can't parse plan XML", e);
}
}
} catch (SQLException e) {
throw new DBCException(e, session.getDataSource());
} finally {
// Rollback changes because EXPLAIN actually executes query and it could be INSERT/UPDATE
try {
connection.rollback();
if (oldAutoCommit) {
connection.setAutoCommit(true);
}
} catch (SQLException e) {
log.error("Error closing plan analyser", e);
}
}
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2019 Andrew Khitrin (ahitrin@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ext.mssql.model.plan;
import java.io.IOException;
import java.io.StringReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.jkiss.dbeaver.ext.mssql.model.plan.adapters.SQLServerPlanAdapter_v_1_0;
import org.jkiss.dbeaver.ext.mssql.model.plan.adapters.SQLServerPlanAdapter_v_1_0_2;
import org.jkiss.dbeaver.ext.mssql.model.plan.adapters.SQLServerPlanAdapter_v_1_1;
import org.jkiss.dbeaver.ext.mssql.model.plan.adapters.SQLServerPlanAdapter_v_1_2;
import org.jkiss.dbeaver.ext.mssql.model.plan.adapters.SQLServerPlanAdapter_v_1_3;
import org.jkiss.dbeaver.ext.mssql.model.plan.adapters.SQLServerPlanAdapter_v_1_3_1;
import org.jkiss.dbeaver.ext.mssql.model.plan.adapters.SQLServerPlanAdapter_v_1_4;
import org.jkiss.dbeaver.ext.mssql.model.plan.adapters.SQLServerPlanAdapter_v_1_5;
import org.jkiss.dbeaver.ext.mssql.model.plan.adapters.SQLServerPlanAdapter_v_1_6;
import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.exec.plan.DBCPlanNode;
import org.jkiss.utils.xml.XMLException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
public class SQLServerPlanParser {
public static final String rootNodeXPath = "/*[local-name() = 'ShowPlanXML']";
public static final String VERSION_ATTR = "Version";
public static SQLServerPlanParser instance = new SQLServerPlanParser();
private final Map<String, SQLServerPlanAdapter<?>> adapterRegistry = new HashMap<String, SQLServerPlanAdapter<?>>() {
{
put("1.6", (SQLServerPlanAdapter<?>) new SQLServerPlanAdapter_v_1_6());
put("1.5", (SQLServerPlanAdapter<?>) new SQLServerPlanAdapter_v_1_5());
put("1.4", (SQLServerPlanAdapter<?>) new SQLServerPlanAdapter_v_1_4());
put("1.3.1", (SQLServerPlanAdapter<?>) new SQLServerPlanAdapter_v_1_3_1());
put("1.3", (SQLServerPlanAdapter<?>) new SQLServerPlanAdapter_v_1_3());
put("1.2", (SQLServerPlanAdapter<?>) new SQLServerPlanAdapter_v_1_2());
put("1.1", (SQLServerPlanAdapter<?>) new SQLServerPlanAdapter_v_1_1());
put("1.02", (SQLServerPlanAdapter<?>) new SQLServerPlanAdapter_v_1_0_2());
put("1.0", (SQLServerPlanAdapter<?>) new SQLServerPlanAdapter_v_1_0());
}
};
private SQLServerPlanParser() {
}
public static SQLServerPlanParser getInstance() {
return instance;
}
public List<DBCPlanNode> parse(String planString) throws DBCException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
Node root;
try {
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(new InputSource(new StringReader(planString)));
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
root = (Element) xpath.evaluate(rootNodeXPath, document, XPathConstants.NODE);
if (root == null) {
throw new DBCException("Unsupported plan format");
}
Node version = root.getAttributes().getNamedItem(VERSION_ATTR);
if (version == null) {
throw new DBCException("Undefined plan version");
}
String ver = version.getNodeValue();
if (ver == null || ver.length() == 0) {
throw new DBCException("Undefined plan version");
}
if (!adapterRegistry.containsKey(ver)) {
throw new DBCException("Unsupported plan version");
}
return adapterRegistry.get(ver).getNodes(planString);
} catch (ParserConfigurationException | SAXException | IOException | XPathExpressionException | XMLException e) {
throw new DBCException("Error parsing plan", e);
}
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2019 Andrew Khitrin (ahitrin@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ext.mssql.model.plan;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.ext.mssql.model.SQLServerDataSource;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.exec.DBCSession;
import org.jkiss.dbeaver.model.exec.plan.DBCPlan;
import org.jkiss.dbeaver.model.exec.plan.DBCPlanStyle;
import org.jkiss.dbeaver.model.exec.plan.DBCQueryPlanner;
public class SQLServerQueryPlanner implements DBCQueryPlanner {
private final SQLServerDataSource dataSource;
public SQLServerQueryPlanner(SQLServerDataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public DBPDataSource getDataSource() {
return dataSource;
}
@Override
public DBCPlan planQueryExecution(DBCSession session, String query) throws DBException {
SQLServerPlanAnalyzer plan = new SQLServerPlanAnalyzer(query);
plan.explain(session);
return plan;
}
@Override
public DBCPlanStyle getPlanStyle() {
return DBCPlanStyle.PLAN;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2019 Andrew Khitrin (ahitrin@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ext.mssql.model.plan.adapters;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.JAXBException;
import org.jkiss.dbeaver.ext.mssql.model.plan.SQLServerPlanAdapter;
import org.jkiss.dbeaver.ext.mssql.model.plan.schemas.sql2005.ShowPlanXML;
import org.jkiss.dbeaver.model.exec.plan.DBCPlanNode;
import org.jkiss.utils.xml.XMLException;
public class SQLServerPlanAdapter_v_1_0 extends SQLServerPlanAdapter<ShowPlanXML>{
@Override
public List<DBCPlanNode> getNodes(String planString) throws XMLException {
List<DBCPlanNode> nodes = Collections.emptyList();
try {
ShowPlanXML plan = parseXML(planString);
System.out.println(plan);
} catch (JAXBException e) {
throw new XMLException("Unable to parse plan",e);
}
return nodes;
}
@Override
protected Class<ShowPlanXML> getPlanClass() {
return ShowPlanXML.class;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2019 Andrew Khitrin (ahitrin@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ext.mssql.model.plan.adapters;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.JAXBException;
import org.jkiss.dbeaver.ext.mssql.model.plan.SQLServerPlanAdapter;
import org.jkiss.dbeaver.ext.mssql.model.plan.schemas.sql2005.ShowPlanXML;
import org.jkiss.dbeaver.model.exec.plan.DBCPlanNode;
import org.jkiss.utils.xml.XMLException;
public class SQLServerPlanAdapter_v_1_0_2 extends SQLServerPlanAdapter<ShowPlanXML>{
@Override
public List<DBCPlanNode> getNodes(String planString) throws XMLException {
List<DBCPlanNode> nodes = Collections.emptyList();
try {
ShowPlanXML plan = parseXML(planString);
System.out.println(plan);
} catch (JAXBException e) {
throw new XMLException("Unable to parse plan",e);
}
return nodes;
}
@Override
protected Class<ShowPlanXML> getPlanClass() {
return ShowPlanXML.class;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
* Copyright (C) 2019 Andrew Khitrin (ahitrin@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ext.mssql.model.plan.adapters;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.JAXBException;
import org.jkiss.dbeaver.ext.mssql.model.plan.SQLServerPlanAdapter;
import org.jkiss.dbeaver.ext.mssql.model.plan.schemas.sql2008.ShowPlanXML;
import org.jkiss.dbeaver.model.exec.plan.DBCPlanNode;
import org.jkiss.utils.xml.XMLException;
public class SQLServerPlanAdapter_v_1_1 extends SQLServerPlanAdapter<ShowPlanXML>{
@Override
public List<DBCPlanNode> getNodes(String planString) throws XMLException {
List<DBCPlanNode> nodes = Collections.emptyList();
try {
ShowPlanXML plan = parseXML(planString);
System.out.println(plan);
} catch (JAXBException e) {
throw new XMLException("Unable to parse plan",e);
}
return nodes;
}
@Override
protected Class<ShowPlanXML> getPlanClass() {
return ShowPlanXML.class;
}
}
package org.jkiss.dbeaver.ext.mssql.model.plan.schemas.sql2005;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for OrderType.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* &lt;simpleType name="OrderType">
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
* &lt;enumeration value="BACKWARD"/>
* &lt;enumeration value="FORWARD"/>
* &lt;/restriction>
* &lt;/simpleType>
* </pre>
*
*/
@XmlType(name = "OrderType", namespace = "http://schemas.microsoft.com/sqlserver/2004/07/showplan")
@XmlEnum
public enum OrderType_sql2005 {
BACKWARD,
FORWARD;
public String value() {
return name();
}
public static OrderType_sql2005 fromValue(String v) {
return valueOf(v);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册