提交 f6293c8f 编写于 作者: S serge-rider

#3025 Table truncate config for different databases


Former-commit-id: 04156ded
上级 f71d24a3
...@@ -128,6 +128,7 @@ ...@@ -128,6 +128,7 @@
<property id="supports-multiple-results" label="Driver supports multiple results" description="Driver supports multiple results for a single query." type="boolean" required="false" defaultValue="false"/> <property id="supports-multiple-results" label="Driver supports multiple results" description="Driver supports multiple results for a single query." type="boolean" required="false" defaultValue="false"/>
<property id="supports-limits" label="Driver supports result set limit" description="Driver supports multiple result set limit (max rows)." type="boolean" required="false" defaultValue="true"/> <property id="supports-limits" label="Driver supports result set limit" description="Driver supports multiple result set limit (max rows)." type="boolean" required="false" defaultValue="true"/>
<property id="supports-struct-cache" label="Driver supports structure cache" description="Driver supports structure cache reading. Enables schema columns, keys, etc." type="boolean" required="false" defaultValue="true"/> <property id="supports-struct-cache" label="Driver supports structure cache" description="Driver supports structure cache reading. Enables schema columns, keys, etc." type="boolean" required="false" defaultValue="true"/>
<property id="supports-truncate" label="Driver supports TRUNCATE operation" description="Driver supports TRUNCATE command. It is much faster than DELETE without criteria." type="boolean" required="false" defaultValue="true"/>
</propertyGroup> </propertyGroup>
<propertyGroup label="Queries" description="Custom driver queries"> <propertyGroup label="Queries" description="Custom driver queries">
<property id="query-get-active-db" label="Get active database" description="Query to obtain active database name" type="string" required="false" defaultValue=""/> <property id="query-get-active-db" label="Get active database" description="Query to obtain active database name" type="string" required="false" defaultValue=""/>
...@@ -563,6 +564,7 @@ ...@@ -563,6 +564,7 @@
webURL="http://www.ingres.com/products/ingres-database/" webURL="http://www.ingres.com/products/ingres-database/"
description="Ingres Database"> description="Ingres Database">
<file type="jar" path="maven:/com.ingres.jdbc:iijdbc:RELEASE"/> <file type="jar" path="maven:/com.ingres.jdbc:iijdbc:RELEASE"/>
<parameter name="supports-truncate" value="false"/>
</driver> </driver>
<driver <driver
id="linter" id="linter"
...@@ -594,6 +596,7 @@ ...@@ -594,6 +596,7 @@
<parameter name="supports-scroll" value="true"/> <parameter name="supports-scroll" value="true"/>
<parameter name="ddl-drop-column-short" value="true"/> <parameter name="ddl-drop-column-short" value="true"/>
<parameter name="script-delimiter-redefiner" value="SET TERM"/> <parameter name="script-delimiter-redefiner" value="SET TERM"/>
<parameter name="supports-truncate" value="false"/>
</driver> </driver>
<driver <driver
id="firebird_jaybird3" id="firebird_jaybird3"
...@@ -618,6 +621,7 @@ ...@@ -618,6 +621,7 @@
<parameter name="supports-scroll" value="true"/> <parameter name="supports-scroll" value="true"/>
<parameter name="ddl-drop-column-short" value="true"/> <parameter name="ddl-drop-column-short" value="true"/>
<parameter name="script-delimiter-redefiner" value="SET TERM"/> <parameter name="script-delimiter-redefiner" value="SET TERM"/>
<parameter name="supports-truncate" value="false"/>
</driver> </driver>
<driver <driver
id="sqlite_jdbc" id="sqlite_jdbc"
...@@ -641,6 +645,7 @@ ...@@ -641,6 +645,7 @@
<parameter name="supports-struct-cache" value="false"/> <parameter name="supports-struct-cache" value="false"/>
<parameter name="supports-indexes" value="true"/> <parameter name="supports-indexes" value="true"/>
<parameter name="supports-stored-code" value="false"/> <parameter name="supports-stored-code" value="false"/>
<parameter name="supports-truncate" value="false"/>
</driver> </driver>
<driver <driver
...@@ -659,6 +664,8 @@ ...@@ -659,6 +664,8 @@
<file type="jar" path="drivers/teradata/terajdbc4.jar" bundle="drivers.teradata"/> <file type="jar" path="drivers/teradata/terajdbc4.jar" bundle="drivers.teradata"/>
<file type="jar" path="drivers/teradata/tdgssconfig.jar" bundle="drivers.teradata"/> <file type="jar" path="drivers/teradata/tdgssconfig.jar" bundle="drivers.teradata"/>
<file type="license" path="drivers/teradata/LICENSE.txt" bundle="drivers.teradata"/> <file type="license" path="drivers/teradata/LICENSE.txt" bundle="drivers.teradata"/>
<parameter name="supports-truncate" value="false"/>
</driver> </driver>
<driver <driver
id="mysql3" id="mysql3"
...@@ -703,13 +710,16 @@ ...@@ -703,13 +710,16 @@
webURL="http://csvjdbc.sourceforge.net/" webURL="http://csvjdbc.sourceforge.net/"
embedded="true" embedded="true"
description="CsvJdbc driver for CSV and DBF files"> description="CsvJdbc driver for CSV and DBF files">
<parameter name="supports-select-count" value="false"/>
<property name="separator" value=","/> <property name="separator" value=","/>
<property name="quotechar" value="&quot;"/> <property name="quotechar" value="&quot;"/>
<property name="fileExtension" value=".csv"/> <property name="fileExtension" value=".csv"/>
<property name="suppressHeaders" value="false"/> <property name="suppressHeaders" value="false"/>
<property name="charset" value="UTF-8"/> <property name="charset" value="UTF-8"/>
<parameter name="supports-select-count" value="false"/>
<parameter name="supports-stored-code" value="false"/> <parameter name="supports-stored-code" value="false"/>
<parameter name="supports-truncate" value="false"/>
<file type="jar" path="maven:/net.sourceforge.csvjdbc:csvjdbc:RELEASE" bundle="!drivers.csvjdbc"/> <file type="jar" path="maven:/net.sourceforge.csvjdbc:csvjdbc:RELEASE" bundle="!drivers.csvjdbc"/>
...@@ -847,6 +857,8 @@ ...@@ -847,6 +857,8 @@
category="Hadoop"> category="Hadoop">
<file type="jar" path="maven:/org.spark-project.hive:hive-jdbc:RELEASE"/> <file type="jar" path="maven:/org.spark-project.hive:hive-jdbc:RELEASE"/>
<file type="jar" path="maven:/org.apache.hadoop:hadoop-core:RELEASE"/> <file type="jar" path="maven:/org.apache.hadoop:hadoop-core:RELEASE"/>
<parameter name="supports-truncate" value="false"/>
</driver> </driver>
<driver <driver
id="apache_drill" id="apache_drill"
...@@ -857,6 +869,8 @@ ...@@ -857,6 +869,8 @@
webURL="http://drill.apache.org/docs/using-the-jdbc-driver/" webURL="http://drill.apache.org/docs/using-the-jdbc-driver/"
category="Hadoop"> category="Hadoop">
<file type="jar" path="maven:/org.apache.drill.exec:drill-jdbc-all:RELEASE"/> <file type="jar" path="maven:/org.apache.drill.exec:drill-jdbc-all:RELEASE"/>
<parameter name="supports-truncate" value="false"/>
</driver> </driver>
<!-- Cloudera --> <!-- Cloudera -->
...@@ -909,6 +923,7 @@ ...@@ -909,6 +923,7 @@
description="MACHBASE standard driver" description="MACHBASE standard driver"
webURL="http://www.machbase.com"> webURL="http://www.machbase.com">
<file type="jar" path="http://www.machbase.com/dist/machbase.jar"/> <file type="jar" path="http://www.machbase.com/dist/machbase.jar"/>
<parameter name="supports-truncate" value="false"/>
</driver> </driver>
<!-- Yandex ClickHouse --> <!-- Yandex ClickHouse -->
...@@ -921,6 +936,8 @@ ...@@ -921,6 +936,8 @@
description="Yandex ClickHouse" description="Yandex ClickHouse"
webURL="https://github.com/yandex/clickhouse-jdbc"> webURL="https://github.com/yandex/clickhouse-jdbc">
<file type="jar" path="maven:/ru.yandex.clickhouse:clickhouse-jdbc:RELEASE"/> <file type="jar" path="maven:/ru.yandex.clickhouse:clickhouse-jdbc:RELEASE"/>
<parameter name="supports-truncate" value="false"/>
</driver> </driver>
<!-- OrientDB --> <!-- OrientDB -->
...@@ -934,6 +951,8 @@ ...@@ -934,6 +951,8 @@
description="OrientDB JDBC driver" description="OrientDB JDBC driver"
webURL="https://github.com/orientechnologies/orientdb-jdbc"> webURL="https://github.com/orientechnologies/orientdb-jdbc">
<file type="jar" path="maven:/com.orientechnologies:orientdb-jdbc:RELEASE[1.7]"/> <file type="jar" path="maven:/com.orientechnologies:orientdb-jdbc:RELEASE[1.7]"/>
<parameter name="supports-truncate" value="false"/>
</driver> </driver>
<!-- Neo4j --> <!-- Neo4j -->
...@@ -947,6 +966,7 @@ ...@@ -947,6 +966,7 @@
description="Neo4j JDBC driver" description="Neo4j JDBC driver"
webURL="https://github.com/neo4j-contrib/neo4j-jdbc"> webURL="https://github.com/neo4j-contrib/neo4j-jdbc">
<file type="jar" path="maven:/org.neo4j:neo4j-jdbc-driver:RELEASE"/> <file type="jar" path="maven:/org.neo4j:neo4j-jdbc-driver:RELEASE"/>
<parameter name="supports-truncate" value="false"/>
</driver> </driver>
<!-- PrestoDB --> <!-- PrestoDB -->
...@@ -997,6 +1017,7 @@ ...@@ -997,6 +1017,7 @@
description="Apache SolrJ JDBC driver" description="Apache SolrJ JDBC driver"
webURL="https://lucene.apache.org/solr/"> webURL="https://lucene.apache.org/solr/">
<file type="jar" path="maven:/org.apache.solr:solr-solrj:RELEASE"/> <file type="jar" path="maven:/org.apache.solr:solr-solrj:RELEASE"/>
<parameter name="supports-truncate" value="false"/>
</driver> </driver>
</drivers> </drivers>
......
...@@ -36,6 +36,7 @@ public class GenericConstants { ...@@ -36,6 +36,7 @@ public class GenericConstants {
public static final String PARAM_SUPPORTS_SCROLL = "supports-scroll"; public static final String PARAM_SUPPORTS_SCROLL = "supports-scroll";
public static final String PARAM_SUPPORTS_STRUCT_CACHE = "supports-struct-cache"; public static final String PARAM_SUPPORTS_STRUCT_CACHE = "supports-struct-cache";
public static final String PARAM_SUPPORTS_MULTIPLE_RESULTS = "supports-multiple-results"; public static final String PARAM_SUPPORTS_MULTIPLE_RESULTS = "supports-multiple-results";
public static final String PARAM_SUPPORTS_TRUNCATE = "supports-truncate";
public static final String PARAM_OMIT_TYPE_CACHE = "omit-type-cache"; public static final String PARAM_OMIT_TYPE_CACHE = "omit-type-cache";
public static final String PARAM_OMIT_CATALOG = "omit-catalog"; public static final String PARAM_OMIT_CATALOG = "omit-catalog";
public static final String PARAM_ALL_OBJECTS_PATTERN = "all-objects-pattern"; public static final String PARAM_ALL_OBJECTS_PATTERN = "all-objects-pattern";
......
...@@ -87,6 +87,13 @@ public class GenericTable extends JDBCTable<GenericDataSource, GenericStructCont ...@@ -87,6 +87,13 @@ public class GenericTable extends JDBCTable<GenericDataSource, GenericStructCont
return getContainer().getTableCache(); return getContainer().getTableCache();
} }
@Override
protected boolean isTruncateSupported() {
return CommonUtils.getBoolean(
getDataSource().getContainer().getDriver().getDriverParameter(GenericConstants.PARAM_SUPPORTS_TRUNCATE),
false);
}
@Override @Override
public DBSObject getParentObject() public DBSObject getParentObject()
{ {
......
...@@ -95,4 +95,8 @@ public class SQLServerTable extends GenericTable implements DBPOverloadedObject ...@@ -95,4 +95,8 @@ public class SQLServerTable extends GenericTable implements DBPOverloadedObject
return ((SQLServerMetaModel)getDataSource().getMetaModel()).isSqlServer(); return ((SQLServerMetaModel)getDataSource().getMetaModel()).isSqlServer();
} }
@Override
protected boolean isTruncateSupported() {
return true;
}
} }
...@@ -27,4 +27,9 @@ public class SQLiteTable extends GenericTable implements DBPNamedObject2 { ...@@ -27,4 +27,9 @@ public class SQLiteTable extends GenericTable implements DBPNamedObject2 {
public SQLiteTable(GenericStructContainer container, @Nullable String tableName, @Nullable String tableType, @Nullable JDBCResultSet dbResult) { public SQLiteTable(GenericStructContainer container, @Nullable String tableName, @Nullable String tableType, @Nullable JDBCResultSet dbResult) {
super(container, tableName, tableType, dbResult); super(container, tableName, tableType, dbResult);
} }
@Override
protected boolean isTruncateSupported() {
return false;
}
} }
...@@ -100,7 +100,11 @@ public abstract class JDBCTable<DATASOURCE extends DBPDataSource, CONTAINER exte ...@@ -100,7 +100,11 @@ public abstract class JDBCTable<DATASOURCE extends DBPDataSource, CONTAINER exte
@Override @Override
public int getSupportedFeatures() public int getSupportedFeatures()
{ {
return DATA_COUNT | DATA_FILTER | DATA_SEARCH | DATA_INSERT | DATA_UPDATE | DATA_DELETE; int features = DATA_COUNT | DATA_FILTER | DATA_SEARCH | DATA_INSERT | DATA_UPDATE | DATA_DELETE;
if (isTruncateSupported()) {
features |= DATA_TRUNCATE;
}
return features;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
...@@ -534,7 +538,7 @@ public abstract class JDBCTable<DATASOURCE extends DBPDataSource, CONTAINER exte ...@@ -534,7 +538,7 @@ public abstract class JDBCTable<DATASOURCE extends DBPDataSource, CONTAINER exte
} }
protected boolean isTruncateSupported() { protected boolean isTruncateSupported() {
return false; return true;
} }
protected String getTruncateTableQuery() { protected String getTruncateTableQuery() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册