[#4646] Significant overhead from Scope.data() Map access
This commit is contained in:
parent
b84b488527
commit
ccae6aae34
@ -41,7 +41,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.conf.ParamType.INDEXED;
|
||||
import static org.jooq.impl.Utils.DATA_OMIT_CLAUSE_EVENT_EMISSION;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_OMIT_CLAUSE_EVENT_EMISSION;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.ArrayDeque;
|
||||
|
||||
@ -52,8 +52,8 @@ import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.conf.SettingsTools.executePreparedStatements;
|
||||
import static org.jooq.conf.SettingsTools.getParamType;
|
||||
import static org.jooq.impl.DSL.using;
|
||||
import static org.jooq.impl.Utils.DATA_COUNT_BIND_VALUES;
|
||||
import static org.jooq.impl.Utils.DATA_FORCE_STATIC_STATEMENT;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_COUNT_BIND_VALUES;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_FORCE_STATIC_STATEMENT;
|
||||
import static org.jooq.impl.Utils.consumeExceptions;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
@ -483,13 +483,13 @@ abstract class AbstractQuery extends AbstractQueryPart implements Query, Attacha
|
||||
x
|
||||
x
|
||||
|
||||
xx xxxxxxxxxxxxxxxxxxxxxx x xxxxxxxx x
|
||||
xxxxx xxx xxxxxxxxxxxxxxxxxxxxx xxxx xxxxxxxx x xxxxxxx xxxxxxx xxxx xxx xxxx xxxxx xxxxxxxx xxxxxx xxxxxxxx xxxxxxxxx xx x xxxxxxxxxx xxxxxxx xx xxxxxxx xxxxxxxxxxxxxxxxxxxxxx xx xxx xxxx xx xxx xxxx xxxxxxx xxxx xxxx xxxx xxxxxxxxx
|
||||
x
|
||||
|
||||
xx xxxx x xxxxxxxxxxxxxxxxxxxxxxxxxxx x
|
||||
xxxxx xxx xxxxxxxxxxxxxxxxxxxxxx xx xxx xxxxx xxxxxx xxx xxxxx xxxx xxxx xxxx xxxxxx xxxxxxxx xxxxxxxxx xx x xxxxxxxxxx xxxxxxx xx xxxxxxx xxxxxxxxxxxxxxxxxxxxxx xx xxx xxxx xx xxxxxx xxxx xxxx xxxxxxxxx
|
||||
x
|
||||
xx xx xxxxxxxxxxxxxxxxxxxxxx x xxxxxxxx x
|
||||
xx xxxxx xxx xxxxxxxxxxxxxxxxxxxxx xxxx xxxxxxxx x xxxxxxx xxxxxxx xxxx xxx xxxx xxxxx xxxxxxxx xxxxxx xxxxxxxx xxxxxxxxx xx x xxxxxxxxxx xxxxxxx xx xxxxxxx xxxxxxxxxxxxxxxxxxxxxx xx xxx xxxx xx xxx xxxx xxxxxxx xxxx xxxx xxxx xxxxxxxxx
|
||||
xx x
|
||||
xx
|
||||
xx xx xxxx x xxxxxxxxxxxxxxxxxxxxxxxxxxx x
|
||||
xx xxxxx xxx xxxxxxxxxxxxxxxxxxxxxx xx xxx xxxxx xxxxxx xxx xxxxx xxxx xxxx xxxx xxxxxx xxxxxxxx xxxxxxxxx xx x xxxxxxxxxx xxxxxxx xx xxxxxxx xxxxxxxxxxxxxxxxxxxxxx xx xxx xxxx xx xxxxxx xxxx xxxx xxxxxxxxx
|
||||
xx x
|
||||
|
||||
xx xxxxxxxx xx xx [/pro] */
|
||||
return result;
|
||||
|
||||
@ -48,7 +48,7 @@ import static java.util.concurrent.Executors.newSingleThreadExecutor;
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.impl.Utils.DATA_LOCK_ROWS_FOR_UPDATE;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_LOCK_ROWS_FOR_UPDATE;
|
||||
import static org.jooq.impl.Utils.consumeResultSets;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
@ -40,7 +40,6 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
@ -69,7 +68,7 @@ abstract class AbstractScope implements Scope {
|
||||
}
|
||||
|
||||
if (data == null) {
|
||||
data = new HashMap<Object, Object>();
|
||||
data = new DataMap();
|
||||
}
|
||||
|
||||
this.configuration = configuration;
|
||||
|
||||
@ -68,7 +68,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
import static org.jooq.impl.DSL.falseCondition;
|
||||
import static org.jooq.impl.DSL.field;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.Utils.DATA_UNALIAS_ALIASES_IN_ORDER_BY;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_UNALIAS_ALIASES_IN_ORDER_BY;
|
||||
import static org.jooq.impl.Utils.list;
|
||||
|
||||
import org.jooq.Clause;
|
||||
|
||||
@ -55,7 +55,7 @@ import static org.jooq.impl.DSL.field;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.sql;
|
||||
import static org.jooq.impl.Utils.DATA_DROP_CONSTRAINT;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_DROP_CONSTRAINT;
|
||||
import static org.jooq.impl.Utils.toSQLDDLTypeDeclaration;
|
||||
|
||||
import org.jooq.AlterTableAlterStep;
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.conf.SettingsTools.executeStaticStatements;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_OMIT_RETURNING_CLAUSE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
@ -111,7 +112,7 @@ class BatchCRUD implements Batch {
|
||||
));
|
||||
|
||||
// [#1537] Communicate with UpdatableRecordImpl
|
||||
local.data(Utils.DATA_OMIT_RETURNING_CLAUSE, true);
|
||||
local.data(DATA_OMIT_RETURNING_CLAUSE, true);
|
||||
|
||||
// [#1529] Avoid DEBUG logging of single INSERT / UPDATE statements
|
||||
local.settings().setExecuteLogging(false);
|
||||
|
||||
@ -48,7 +48,7 @@ import static org.jooq.impl.ConstraintImpl.Action.SET_DEFAULT;
|
||||
import static org.jooq.impl.ConstraintImpl.Action.SET_NULL;
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.Utils.DATA_DROP_CONSTRAINT;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_DROP_CONSTRAINT;
|
||||
import static org.jooq.impl.Utils.fieldsByName;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@ -55,7 +55,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.field;
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.Utils.DATA_SELECT_INTO_TABLE;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_SELECT_INTO_TABLE;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import static org.jooq.impl.Utils.DATA_LOCK_ROWS_FOR_UPDATE;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_LOCK_ROWS_FOR_UPDATE;
|
||||
import static org.jooq.impl.Utils.recordFactory;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
167
jOOQ/src/main/java/org/jooq/impl/DataMap.java
Normal file
167
jOOQ/src/main/java/org/jooq/impl/DataMap.java
Normal file
@ -0,0 +1,167 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2015, Data Geekery GmbH (http://www.datageekery.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jooq.Scope;
|
||||
import org.jooq.impl.Utils.DataKey;
|
||||
|
||||
/**
|
||||
* The {@link Map} implementation for use with {@link Scope#data()}.
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
class DataMap extends AbstractMap<Object, Object> {
|
||||
|
||||
final EnumMap<DataKey, Object> internal;
|
||||
Map<Object, Object> external;
|
||||
final Set<Entry<Object, Object>> entrySet;
|
||||
|
||||
DataMap() {
|
||||
internal = new EnumMap<DataKey, Object>(DataKey.class);
|
||||
entrySet = new EntrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int size() {
|
||||
return internal().size() + external(false).size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isEmpty() {
|
||||
return internal().isEmpty() && external(false).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean containsKey(Object key) {
|
||||
return delegate(key, false).containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean containsValue(Object value) {
|
||||
return internal().containsValue(value) || external(false).containsValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Object get(Object key) {
|
||||
return delegate(key, false).get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Object put(Object key, Object value) {
|
||||
return delegate(key, true).put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Object remove(Object key) {
|
||||
return delegate(key, true).remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void clear() {
|
||||
internal().clear();
|
||||
external(true).clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Set<Entry<Object, Object>> entrySet() {
|
||||
return entrySet;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private final Map<Object, Object> internal() {
|
||||
return (Map) internal;
|
||||
}
|
||||
|
||||
private final Map<Object, Object> external(boolean initialise) {
|
||||
if (external == null) {
|
||||
if (initialise)
|
||||
external = new HashMap<Object, Object>();
|
||||
else
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
return external;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private final Map<Object, Object> delegate(Object key, boolean initialise) {
|
||||
return key instanceof DataKey ? (Map) internal() : external(initialise);
|
||||
}
|
||||
|
||||
private class EntrySet extends AbstractSet<Entry<Object, Object>> {
|
||||
@Override
|
||||
public final Iterator<Entry<Object, Object>> iterator() {
|
||||
return new Iterator<Entry<Object, Object>>() {
|
||||
final Iterator<Entry<Object, Object>> internalIterator = internal().entrySet().iterator();
|
||||
final Iterator<Entry<Object, Object>> externalIterator = external(false).entrySet().iterator();
|
||||
|
||||
@Override
|
||||
public final boolean hasNext() {
|
||||
return internalIterator.hasNext() || externalIterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Entry<Object, Object> next() {
|
||||
return internalIterator.hasNext() ? internalIterator.next() : externalIterator.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int size() {
|
||||
return DataMap.this.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -41,7 +41,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.SQLDialect.DEFAULT;
|
||||
import static org.jooq.impl.Utils.DATA_DEFAULT_TRANSACTION_PROVIDER_CONNECTION;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_DEFAULT_TRANSACTION_PROVIDER_CONNECTION;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
@ -51,7 +51,6 @@ import java.sql.SQLOutput;
|
||||
import java.sql.SQLWarning;
|
||||
import java.sql.SQLXML;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -371,7 +370,7 @@ class DefaultExecuteContext implements ExecuteContext {
|
||||
|
||||
private DefaultExecuteContext(Configuration configuration, Query query, Query[] batchQueries, Routine<?> routine) {
|
||||
this.configuration = configuration;
|
||||
this.data = new HashMap<Object, Object>();
|
||||
this.data = new DataMap();
|
||||
this.query = query;
|
||||
this.batchQueries = (batchQueries == null ? new Query[0] : batchQueries);
|
||||
this.routine = routine;
|
||||
|
||||
@ -40,7 +40,6 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
@ -58,16 +57,16 @@ import org.jooq.conf.Settings;
|
||||
*/
|
||||
class DefaultRecordContext implements RecordContext {
|
||||
|
||||
private final Configuration configuration;
|
||||
private final HashMap<Object, Object> data;
|
||||
private final ExecuteType type;
|
||||
private final Record[] records;
|
||||
Exception exception;
|
||||
private final Configuration configuration;
|
||||
private final Map<Object, Object> data;
|
||||
private final ExecuteType type;
|
||||
private final Record[] records;
|
||||
Exception exception;
|
||||
|
||||
DefaultRecordContext(Configuration configuration, ExecuteType type, Record... records) {
|
||||
this.configuration = configuration;
|
||||
this.type = type;
|
||||
this.data = new HashMap<Object, Object>();
|
||||
this.data = new DataMap();
|
||||
this.records = records;
|
||||
}
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ import static org.jooq.impl.Identifiers.QUOTES;
|
||||
import static org.jooq.impl.Identifiers.QUOTE_END_DELIMITER;
|
||||
import static org.jooq.impl.Identifiers.QUOTE_END_DELIMITER_ESCAPED;
|
||||
import static org.jooq.impl.Identifiers.QUOTE_START_DELIMITER;
|
||||
import static org.jooq.impl.Utils.DATA_COUNT_BIND_VALUES;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_COUNT_BIND_VALUES;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -40,9 +40,9 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Utils.DATA_DEFAULT_TRANSACTION_PROVIDER_AUTOCOMMIT;
|
||||
import static org.jooq.impl.Utils.DATA_DEFAULT_TRANSACTION_PROVIDER_CONNECTION;
|
||||
import static org.jooq.impl.Utils.DATA_DEFAULT_TRANSACTION_PROVIDER_SAVEPOINTS;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_DEFAULT_TRANSACTION_PROVIDER_AUTOCOMMIT;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_DEFAULT_TRANSACTION_PROVIDER_CONNECTION;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_DEFAULT_TRANSACTION_PROVIDER_SAVEPOINTS;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@ -59,8 +59,8 @@ import static org.jooq.impl.Term.ARRAY_AGG;
|
||||
import static org.jooq.impl.Term.LIST_AGG;
|
||||
import static org.jooq.impl.Term.MEDIAN;
|
||||
import static org.jooq.impl.Term.ROW_NUMBER;
|
||||
import static org.jooq.impl.Utils.DATA_LOCALLY_SCOPED_DATA_MAP;
|
||||
import static org.jooq.impl.Utils.DATA_WINDOW_DEFINITIONS;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_LOCALLY_SCOPED_DATA_MAP;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_WINDOW_DEFINITIONS;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -43,8 +43,8 @@ package org.jooq.impl;
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import static org.jooq.impl.DSL.field;
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.Utils.DATA_OVERRIDE_ALIASES_IN_ORDER_BY;
|
||||
import static org.jooq.impl.Utils.DATA_UNALIAS_ALIASES_IN_ORDER_BY;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_OVERRIDE_ALIASES_IN_ORDER_BY;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_UNALIAS_ALIASES_IN_ORDER_BY;
|
||||
|
||||
import org.jooq.Field;
|
||||
import org.jooq.QueryPart;
|
||||
|
||||
@ -84,8 +84,8 @@ import static org.jooq.impl.DSL.condition;
|
||||
import static org.jooq.impl.DSL.exists;
|
||||
import static org.jooq.impl.DSL.notExists;
|
||||
import static org.jooq.impl.DSL.selectOne;
|
||||
import static org.jooq.impl.Utils.DATA_COLLECTED_SEMI_ANTI_JOIN;
|
||||
import static org.jooq.impl.Utils.DATA_COLLECT_SEMI_ANTI_JOIN;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_COLLECTED_SEMI_ANTI_JOIN;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_COLLECT_SEMI_ANTI_JOIN;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
@ -57,7 +57,7 @@ import static org.jooq.impl.DSL.exists;
|
||||
import static org.jooq.impl.DSL.insertInto;
|
||||
import static org.jooq.impl.DSL.notExists;
|
||||
import static org.jooq.impl.DSL.nullSafe;
|
||||
import static org.jooq.impl.Utils.DATA_WRAP_DERIVED_TABLES_IN_PARENTHESES;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_WRAP_DERIVED_TABLES_IN_PARENTHESES;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -45,7 +45,7 @@ import static java.util.Arrays.asList;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.DSL.val;
|
||||
import static org.jooq.impl.Utils.DATA_ROW_VALUE_EXPRESSION_PREDICATE_SUBQUERY;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_ROW_VALUE_EXPRESSION_PREDICATE_SUBQUERY;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.jooq.impl.Utils.DATA_LIST_ALREADY_INDENTED;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_LIST_ALREADY_INDENTED;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Utils.DATA_LIST_ALREADY_INDENTED;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_LIST_ALREADY_INDENTED;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Converter;
|
||||
|
||||
@ -60,7 +60,7 @@ import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.notExists;
|
||||
import static org.jooq.impl.DSL.row;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.Utils.DATA_ROW_VALUE_EXPRESSION_PREDICATE_SUBQUERY;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_ROW_VALUE_EXPRESSION_PREDICATE_SUBQUERY;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -98,18 +98,18 @@ import static org.jooq.impl.DSL.orderBy;
|
||||
import static org.jooq.impl.DSL.row;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.Utils.DATA_COLLECTED_SEMI_ANTI_JOIN;
|
||||
import static org.jooq.impl.Utils.DATA_COLLECT_SEMI_ANTI_JOIN;
|
||||
import static org.jooq.impl.Utils.DATA_LOCALLY_SCOPED_DATA_MAP;
|
||||
import static org.jooq.impl.Utils.DATA_OMIT_INTO_CLAUSE;
|
||||
import static org.jooq.impl.Utils.DATA_OVERRIDE_ALIASES_IN_ORDER_BY;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_COLLECTED_SEMI_ANTI_JOIN;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_COLLECT_SEMI_ANTI_JOIN;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_LOCALLY_SCOPED_DATA_MAP;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_OMIT_INTO_CLAUSE;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_OVERRIDE_ALIASES_IN_ORDER_BY;
|
||||
// ...
|
||||
import static org.jooq.impl.Utils.DATA_RENDER_TRAILING_LIMIT_IF_APPLICABLE;
|
||||
import static org.jooq.impl.Utils.DATA_ROW_VALUE_EXPRESSION_PREDICATE_SUBQUERY;
|
||||
import static org.jooq.impl.Utils.DATA_SELECT_INTO_TABLE;
|
||||
import static org.jooq.impl.Utils.DATA_UNALIAS_ALIASES_IN_ORDER_BY;
|
||||
import static org.jooq.impl.Utils.DATA_WINDOW_DEFINITIONS;
|
||||
import static org.jooq.impl.Utils.DATA_WRAP_DERIVED_TABLES_IN_PARENTHESES;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_RENDER_TRAILING_LIMIT_IF_APPLICABLE;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_ROW_VALUE_EXPRESSION_PREDICATE_SUBQUERY;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_SELECT_INTO_TABLE;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_UNALIAS_ALIASES_IN_ORDER_BY;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_WINDOW_DEFINITIONS;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_WRAP_DERIVED_TABLES_IN_PARENTHESES;
|
||||
import static org.jooq.impl.Utils.fieldArray;
|
||||
|
||||
import java.sql.ResultSetMetaData;
|
||||
|
||||
@ -43,7 +43,7 @@ package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Clause.FIELD;
|
||||
import static org.jooq.Clause.FIELD_REFERENCE;
|
||||
import static org.jooq.impl.Utils.DATA_OMIT_CLAUSE_EVENT_EMISSION;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_OMIT_CLAUSE_EVENT_EMISSION;
|
||||
|
||||
import org.jooq.Binding;
|
||||
import org.jooq.Clause;
|
||||
|
||||
@ -44,6 +44,7 @@ import static java.lang.Boolean.TRUE;
|
||||
import static org.jooq.impl.RecordDelegate.delegate;
|
||||
import static org.jooq.impl.RecordDelegate.RecordLifecycleType.INSERT;
|
||||
import static org.jooq.impl.Utils.indexOrFail;
|
||||
import static org.jooq.impl.Utils.DataKey.DATA_OMIT_RETURNING_CLAUSE;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.sql.Timestamp;
|
||||
@ -168,7 +169,7 @@ public class TableRecordImpl<R extends TableRecord<R>> extends AbstractRecord im
|
||||
// [#1002] Consider also identity columns of non-updatable records
|
||||
// [#1537] Avoid refreshing identity columns on batch inserts
|
||||
Collection<Field<?>> key = null;
|
||||
if (!TRUE.equals(create.configuration().data(Utils.DATA_OMIT_RETURNING_CLAUSE))) {
|
||||
if (!TRUE.equals(create.configuration().data(DATA_OMIT_RETURNING_CLAUSE))) {
|
||||
key = getReturning();
|
||||
insert.setReturning(key);
|
||||
}
|
||||
|
||||
@ -150,169 +150,172 @@ final class Utils {
|
||||
// Some constants for use with Context.data()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* [#1537] This constant is used internally by jOOQ to omit the RETURNING
|
||||
* clause in {@link DSLContext#batchStore(UpdatableRecord...)} calls for
|
||||
* {@link SQLDialect#POSTGRES}.
|
||||
*/
|
||||
static final String DATA_OMIT_RETURNING_CLAUSE = "org.jooq.configuration.omit-returning-clause";
|
||||
enum DataKey {
|
||||
|
||||
/**
|
||||
* [#1905] This constant is used internally by jOOQ to indicate to
|
||||
* subqueries that they're being rendered in the context of a row value
|
||||
* expression predicate.
|
||||
* <p>
|
||||
* This is particularly useful for H2, which pretends that ARRAYs and RVEs
|
||||
* are the same
|
||||
*/
|
||||
static final String DATA_ROW_VALUE_EXPRESSION_PREDICATE_SUBQUERY = "org.jooq.configuration.row-value-expression-subquery";
|
||||
/**
|
||||
* [#1537] This constant is used internally by jOOQ to omit the RETURNING
|
||||
* clause in {@link DSLContext#batchStore(UpdatableRecord...)} calls for
|
||||
* {@link SQLDialect#POSTGRES}.
|
||||
*/
|
||||
DATA_OMIT_RETURNING_CLAUSE,
|
||||
|
||||
/**
|
||||
* [#1296] This constant is used internally by jOOQ to indicate that
|
||||
* {@link ResultSet} rows must be locked to emulate a
|
||||
* <code>FOR UPDATE</code> clause.
|
||||
*/
|
||||
static final String DATA_LOCK_ROWS_FOR_UPDATE = "org.jooq.configuration.lock-rows-for-update";
|
||||
/**
|
||||
* [#1905] This constant is used internally by jOOQ to indicate to
|
||||
* subqueries that they're being rendered in the context of a row value
|
||||
* expression predicate.
|
||||
* <p>
|
||||
* This is particularly useful for H2, which pretends that ARRAYs and RVEs
|
||||
* are the same
|
||||
*/
|
||||
DATA_ROW_VALUE_EXPRESSION_PREDICATE_SUBQUERY,
|
||||
|
||||
/**
|
||||
* [#1520] Count the number of bind values, and potentially enforce a static
|
||||
* statement.
|
||||
*/
|
||||
static final String DATA_COUNT_BIND_VALUES = "org.jooq.configuration.count-bind-values";
|
||||
/**
|
||||
* [#1296] This constant is used internally by jOOQ to indicate that
|
||||
* {@link ResultSet} rows must be locked to emulate a
|
||||
* <code>FOR UPDATE</code> clause.
|
||||
*/
|
||||
DATA_LOCK_ROWS_FOR_UPDATE,
|
||||
|
||||
/**
|
||||
* [#1520] Enforce executing static statements.
|
||||
* <p>
|
||||
* Some SQL dialects support only a limited amount of bind variables. This
|
||||
* flag is set when static statements have too many bind variables. Known
|
||||
* values are:
|
||||
* <ul>
|
||||
* <li>{@link SQLDialect#ASE} : 2000</li>
|
||||
* <li>{@link SQLDialect#INGRES} : 1024</li>
|
||||
* <li>{@link SQLDialect#SQLITE} : 999</li>
|
||||
* <li>{@link SQLDialect#SQLSERVER} : 2100</li>
|
||||
* </ul>
|
||||
*/
|
||||
static final String DATA_FORCE_STATIC_STATEMENT = "org.jooq.configuration.force-static-statement";
|
||||
/**
|
||||
* [#1520] Count the number of bind values, and potentially enforce a static
|
||||
* statement.
|
||||
*/
|
||||
DATA_COUNT_BIND_VALUES,
|
||||
|
||||
/**
|
||||
* [#2665] Omit the emission of clause events by {@link QueryPart}s.
|
||||
* <p>
|
||||
* Some {@link QueryPart}s may contain further {@link QueryPart}s for whom
|
||||
* {@link Clause} emission should be avoided. For example
|
||||
* {@link Clause#FIELD_REFERENCE} may contain a
|
||||
* {@link Clause#TABLE_REFERENCE}.
|
||||
*/
|
||||
static final String DATA_OMIT_CLAUSE_EVENT_EMISSION = "org.jooq.configuration.omit-clause-event-emission";
|
||||
/**
|
||||
* [#1520] Enforce executing static statements.
|
||||
* <p>
|
||||
* Some SQL dialects support only a limited amount of bind variables. This
|
||||
* flag is set when static statements have too many bind variables. Known
|
||||
* values are:
|
||||
* <ul>
|
||||
* <li>{@link SQLDialect#ASE} : 2000</li>
|
||||
* <li>{@link SQLDialect#INGRES} : 1024</li>
|
||||
* <li>{@link SQLDialect#SQLITE} : 999</li>
|
||||
* <li>{@link SQLDialect#SQLSERVER} : 2100</li>
|
||||
* </ul>
|
||||
*/
|
||||
DATA_FORCE_STATIC_STATEMENT,
|
||||
|
||||
/**
|
||||
* [#2665] Wrap derived tables in parentheses.
|
||||
* <p>
|
||||
* Before allowing for hooking into the SQL transformation SPI, new
|
||||
* {@link RenderContext} instances could be created to "try" to render a
|
||||
* given SQL subclause before inserting it into the real SQL string. This
|
||||
* practice should no longer be pursued, as such "sub-renderers" will emit /
|
||||
* divert {@link Clause} events.
|
||||
*/
|
||||
static final String DATA_WRAP_DERIVED_TABLES_IN_PARENTHESES = "org.jooq.configuration.wrap-derived-tables-in-parentheses";
|
||||
/**
|
||||
* [#2665] Omit the emission of clause events by {@link QueryPart}s.
|
||||
* <p>
|
||||
* Some {@link QueryPart}s may contain further {@link QueryPart}s for whom
|
||||
* {@link Clause} emission should be avoided. For example
|
||||
* {@link Clause#FIELD_REFERENCE} may contain a
|
||||
* {@link Clause#TABLE_REFERENCE}.
|
||||
*/
|
||||
DATA_OMIT_CLAUSE_EVENT_EMISSION,
|
||||
|
||||
/**
|
||||
* [#2790] A locally scoped data map.
|
||||
* <p>
|
||||
* Sometimes, it is useful to have some information only available while
|
||||
* visiting QueryParts in the same context of the current subquery, e.g.
|
||||
* when communicating between SELECT and WINDOW clauses, as is required to
|
||||
* emulate #531.
|
||||
*/
|
||||
static final String DATA_LOCALLY_SCOPED_DATA_MAP = "org.jooq.configuration.locally-scoped-data-map";
|
||||
/**
|
||||
* [#2665] Wrap derived tables in parentheses.
|
||||
* <p>
|
||||
* Before allowing for hooking into the SQL transformation SPI, new
|
||||
* {@link RenderContext} instances could be created to "try" to render a
|
||||
* given SQL subclause before inserting it into the real SQL string. This
|
||||
* practice should no longer be pursued, as such "sub-renderers" will emit /
|
||||
* divert {@link Clause} events.
|
||||
*/
|
||||
DATA_WRAP_DERIVED_TABLES_IN_PARENTHESES,
|
||||
|
||||
/**
|
||||
* [#531] The local window definitions.
|
||||
* <p>
|
||||
* The window definitions declared in the <code>WINDOW</code> clause are
|
||||
* needed in the <code>SELECT</code> clause when emulating them by inlining
|
||||
* window specifications.
|
||||
*/
|
||||
static final String DATA_WINDOW_DEFINITIONS = "org.jooq.configuration.local-window-definitions";
|
||||
/**
|
||||
* [#2790] A locally scoped data map.
|
||||
* <p>
|
||||
* Sometimes, it is useful to have some information only available while
|
||||
* visiting QueryParts in the same context of the current subquery, e.g.
|
||||
* when communicating between SELECT and WINDOW clauses, as is required to
|
||||
* emulate #531.
|
||||
*/
|
||||
DATA_LOCALLY_SCOPED_DATA_MAP,
|
||||
|
||||
/* [pro] xx
|
||||
xxx
|
||||
x xxxxxxx xxxxxxxxx xxxxxxxxx xxx xxx xxxxx xxxxx xxxxxxx
|
||||
x xxx
|
||||
x xx xxxx x xxxxxxxxxxx xxxxx xxxxxxx xxxxxxxxxxx xxxxxx xxxxxxx xxxxx
|
||||
x xxxxxxxxxxx xx xxx xxxxxxxxxx xxxxxxxxxxxx xx xxxxxxxxxxxxxxxx xxxxxxx
|
||||
xx
|
||||
xxxxxx xxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xx [/pro] */
|
||||
/**
|
||||
* [#531] The local window definitions.
|
||||
* <p>
|
||||
* The window definitions declared in the <code>WINDOW</code> clause are
|
||||
* needed in the <code>SELECT</code> clause when emulating them by inlining
|
||||
* window specifications.
|
||||
*/
|
||||
DATA_WINDOW_DEFINITIONS,
|
||||
|
||||
/**
|
||||
* [#1629] The {@link Connection#getAutoCommit()} flag value before starting
|
||||
* a new transaction.
|
||||
*/
|
||||
static final String DATA_DEFAULT_TRANSACTION_PROVIDER_AUTOCOMMIT = "org.jooq.configuration.default-transaction-provider-autocommit";
|
||||
/* [pro] xx
|
||||
xxx
|
||||
x xxxxxxx xxxxxxxxx xxxxxxxxx xxx xxx xxxxx xxxxx xxxxxxx
|
||||
x xxx
|
||||
x xx xxxx x xxxxxxxxxxx xxxxx xxxxxxx xxxxxxxxxxx xxxxxx xxxxxxx xxxxx
|
||||
x xxxxxxxxxxx xx xxx xxxxxxxxxx xxxxxxxxxxxx xx xxxxxxxxxxxxxxxx xxxxxxx
|
||||
xx
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
xx [/pro] */
|
||||
|
||||
/**
|
||||
* [#1629] The {@link Connection#getAutoCommit()} flag value before starting
|
||||
* a new transaction.
|
||||
*/
|
||||
static final String DATA_DEFAULT_TRANSACTION_PROVIDER_SAVEPOINTS = "org.jooq.configuration.default-transaction-provider-savepoints";
|
||||
/**
|
||||
* [#1629] The {@link Connection#getAutoCommit()} flag value before starting
|
||||
* a new transaction.
|
||||
*/
|
||||
DATA_DEFAULT_TRANSACTION_PROVIDER_AUTOCOMMIT,
|
||||
|
||||
/**
|
||||
* [#1629] The {@link DefaultConnectionProvider} instance to be used during
|
||||
* the transaction.
|
||||
*/
|
||||
static final String DATA_DEFAULT_TRANSACTION_PROVIDER_CONNECTION = "org.jooq.configuration.default-transaction-provider-connection-provider";
|
||||
/**
|
||||
* [#1629] The {@link Connection#getAutoCommit()} flag value before starting
|
||||
* a new transaction.
|
||||
*/
|
||||
DATA_DEFAULT_TRANSACTION_PROVIDER_SAVEPOINTS,
|
||||
|
||||
/**
|
||||
* [#2080] When emulating OFFSET pagination in certain databases, synthetic
|
||||
* aliases are generated that must be referenced also in
|
||||
* <code>ORDER BY</code> clauses, in lieu of their corresponding original
|
||||
* aliases.
|
||||
*/
|
||||
static final String DATA_OVERRIDE_ALIASES_IN_ORDER_BY = "org.jooq.configuration.override-aliases-in-order-by";
|
||||
/**
|
||||
* [#1629] The {@link DefaultConnectionProvider} instance to be used during
|
||||
* the transaction.
|
||||
*/
|
||||
DATA_DEFAULT_TRANSACTION_PROVIDER_CONNECTION,
|
||||
|
||||
/**
|
||||
* [#2080] When emulating OFFSET pagination in certain databases, synthetic
|
||||
* aliases are generated that must be referenced also in
|
||||
* <code>ORDER BY</code> clauses, in lieu of their corresponding original
|
||||
* aliases.
|
||||
*/
|
||||
static final String DATA_UNALIAS_ALIASES_IN_ORDER_BY = "org.jooq.configuration.unalias-aliases-in-order-by";
|
||||
/**
|
||||
* [#2080] When emulating OFFSET pagination in certain databases, synthetic
|
||||
* aliases are generated that must be referenced also in
|
||||
* <code>ORDER BY</code> clauses, in lieu of their corresponding original
|
||||
* aliases.
|
||||
*/
|
||||
DATA_OVERRIDE_ALIASES_IN_ORDER_BY,
|
||||
|
||||
/**
|
||||
* [#3381] The table to be used for the {@link Clause#SELECT_INTO} clause.
|
||||
*/
|
||||
static final String DATA_SELECT_INTO_TABLE = "org.jooq.configuration.select-into-table";
|
||||
/**
|
||||
* [#2080] When emulating OFFSET pagination in certain databases, synthetic
|
||||
* aliases are generated that must be referenced also in
|
||||
* <code>ORDER BY</code> clauses, in lieu of their corresponding original
|
||||
* aliases.
|
||||
*/
|
||||
DATA_UNALIAS_ALIASES_IN_ORDER_BY,
|
||||
|
||||
/**
|
||||
* [#3381] Omit the {@link Clause#SELECT_INTO}, as it is being emulated.
|
||||
*/
|
||||
static final String DATA_OMIT_INTO_CLAUSE = "org.jooq.configuration.omit-into-clause";
|
||||
/**
|
||||
* [#3381] The table to be used for the {@link Clause#SELECT_INTO} clause.
|
||||
*/
|
||||
DATA_SELECT_INTO_TABLE,
|
||||
|
||||
/**
|
||||
* [#1658] Specify whether the trailing LIMIT clause needs to be rendered.
|
||||
*/
|
||||
static final String DATA_RENDER_TRAILING_LIMIT_IF_APPLICABLE = "org.jooq.configuration.render-trailing-limit-if-applicable";
|
||||
/**
|
||||
* [#3381] Omit the {@link Clause#SELECT_INTO}, as it is being emulated.
|
||||
*/
|
||||
DATA_OMIT_INTO_CLAUSE,
|
||||
|
||||
/**
|
||||
* [#3886] Whether a list has already been indented.
|
||||
*/
|
||||
static final String DATA_LIST_ALREADY_INDENTED = "org.jooq.configuration.list-already-indented";
|
||||
/**
|
||||
* [#1658] Specify whether the trailing LIMIT clause needs to be rendered.
|
||||
*/
|
||||
DATA_RENDER_TRAILING_LIMIT_IF_APPLICABLE,
|
||||
|
||||
/**
|
||||
* [#3338] Whether a constraint is being dropped.
|
||||
*/
|
||||
static final String DATA_DROP_CONSTRAINT = "org.jooq.configuration.drop-constraint";
|
||||
/**
|
||||
* [#3886] Whether a list has already been indented.
|
||||
*/
|
||||
DATA_LIST_ALREADY_INDENTED,
|
||||
|
||||
/**
|
||||
* [#1206] Whether to collect Semi / Anti JOIN.
|
||||
*/
|
||||
static final String DATA_COLLECT_SEMI_ANTI_JOIN = "org.jooq.configuration.collect-semi-anti-join";
|
||||
/**
|
||||
* [#3338] Whether a constraint is being dropped.
|
||||
*/
|
||||
DATA_DROP_CONSTRAINT,
|
||||
|
||||
/**
|
||||
* [#1206] The collected Semi / Anti JOIN predicates.
|
||||
*/
|
||||
static final String DATA_COLLECTED_SEMI_ANTI_JOIN = "org.jooq.configuration.collected-semi-anti-join";
|
||||
/**
|
||||
* [#1206] Whether to collect Semi / Anti JOIN.
|
||||
*/
|
||||
DATA_COLLECT_SEMI_ANTI_JOIN,
|
||||
|
||||
/**
|
||||
* [#1206] The collected Semi / Anti JOIN predicates.
|
||||
*/
|
||||
DATA_COLLECTED_SEMI_ANTI_JOIN,
|
||||
}
|
||||
|
||||
/**
|
||||
* [#2965] These are {@link ConcurrentHashMap}s containing caches for
|
||||
|
||||
Loading…
Reference in New Issue
Block a user