File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\constant\DbSettings.java.html

1 /*
2 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
3 * Version 1.0, and under the Eclipse Public License, Version 1.0
4 * (http://h2database.com/html/license.html).
5 * Initial Developer: H2 Group
6 */
7 package org.h2.constant;
8
9 import java.util.HashMap;
10 import org.h2.engine.SettingsBase;
11
12 /**
13 * This class contains various database-level settings. To override the
14 * documented default value for a database, append the setting in the database
15 * URL: "jdbc:h2:test;ALIAS_COLUMN_NAME=TRUE" when opening the first connection
16 * to the database. The settings can not be changed once the database is open.
17 * <p>
18 * Some settings are a last resort and temporary solution to work around a
19 * problem in the application or database engine. Also, there are system
20 * properties to enable features that are not yet fully tested or that are not
21 * backward compatible.
22 * </p>
23 */
24 public class DbSettings extends SettingsBase {
25
26 private static DbSettings defaultSettings;
27
28 /**
29 * Database setting <code>ALIAS_COLUMN_NAME</code> (default: false).<br />
30 * When enabled, aliased columns (as in SELECT ID AS I FROM TEST) return the
31 * alias (I in this case) in ResultSetMetaData.getColumnName() and 'null' in
32 * getTableName(). If disabled, the real column name (ID in this case) and
33 * table name is returned.
34 * <br />
35 * This setting only affects the default and the MySQL mode. When using
36 * any other mode, this feature is enabled for compatibility, even if this
37 * database setting is not enabled explicitly.
38 */
39 public final boolean aliasColumnName = get("ALIAS_COLUMN_NAME", false);
40
41 /**
42 * Database setting <code>ANALYZE_AUTO</code> (default: 2000).<br />
43 * After changing this many rows, ANALYZE is automatically run for a table.
44 * Automatically running ANALYZE is disabled if set to 0. If set to 1000,
45 * then ANALYZE will run against each user table after about 1000 changes to
46 * that table. The time between running ANALYZE doubles each time since
47 * starting the database. It is not run on local temporary tables, and
48 * tables that have a trigger on SELECT.
49 */
50 public final int analyzeAuto = get("ANALYZE_AUTO", 2000);
51
52 /**
53 * Database setting <code>ANALYZE_SAMPLE</code> (default: 10000).<br />
54 * The default sample size when analyzing a table.
55 */
56 public final int analyzeSample = get("ANALYZE_SAMPLE", 10000);
57
58 /**
59 * Database setting <code>DATABASE_TO_UPPER</code> (default: true).<br />
60 * Database short names are converted to uppercase for the DATABASE()
61 * function, and in the CATALOG column of all database meta data methods.
62 * Setting this to "false" is experimental. When set to false, all
63 * identifier names (table names, column names) are case sensitive (except
64 * aggregate, built-in functions, data types, and keywords).
65 */
66 public final boolean databaseToUpper = get("DATABASE_TO_UPPER", true);
67
68 /**
69 * Database setting <code>DB_CLOSE_ON_EXIT</code> (default: true).<br />
70 * Close the database when the virtual machine exits normally, using a
71 * shutdown hook.
72 */
73 public final boolean dbCloseOnExit = get("DB_CLOSE_ON_EXIT", true);
74
75 /**
76 * Database setting <code>DEFAULT_CONNECTION</code> (default: false).<br />
77 * Whether Java functions can use
78 * <code>DriverManager.getConnection("jdbc:default:connection")</code> to
79 * get a database connection. This feature is disabled by default for
80 * performance reasons. Please note the Oracle JDBC driver will try to
81 * resolve this database URL if it is loaded before the H2 driver.
82 */
83 public boolean defaultConnection = get("DEFAULT_CONNECTION", false);
84
85 /**
86 * Database setting <code>DEFAULT_ESCAPE</code> (default: \).<br />
87 * The default escape character for LIKE comparisons. To select no escape
88 * character, use an empty string.
89 */
90 public final String defaultEscape = get("DEFAULT_ESCAPE", "\\");
91
92 /**
93 * Database setting <code>DEFRAG_ALWAYS</code> (default: false).<br />
94 * Each time the database is closed, it is fully defragmented (SHUTDOWN DEFRAG).
95 */
96 public final boolean defragAlways = get("DEFRAG_ALWAYS", false);
97
98 /**
99 * Database setting <code>DROP_RESTRICT</code> (default: true).<br />
100 * Whether the default action for DROP TABLE and DROP VIEW is RESTRICT.
101 */
102 public final boolean dropRestrict = get("DROP_RESTRICT", true);
103
104 /**
105 * Database setting <code>EARLY_FILTER</code> (default: false).<br />
106 * This setting allows table implementations to apply filter conditions
107 * early on.
108 */
109 public final boolean earlyFilter = get("EARLY_FILTER", false);
110
111 /**
112 * Database setting <code>ESTIMATED_FUNCTION_TABLE_ROWS</code> (default:
113 * 1000).<br />
114 * The estimated number of rows in a function table (for example, CSVREAD or
115 * FTL_SEARCH). This value is used by the optimizer.
116 */
117 public final int estimatedFunctionTableRows = get("ESTIMATED_FUNCTION_TABLE_ROWS", 1000);
118
119 /**
120 * Database setting <code>FUNCTIONS_IN_SCHEMA</code> (default:
121 * true).<br />
122 * If set, all functions are stored in a schema. Specially, the SCRIPT statement
123 * will always include the schema name in the CREATE ALIAS statement.
124 * This is not backward compatible with H2 versions 1.2.134 and older.
125 */
126 public final boolean functionsInSchema = get("FUNCTIONS_IN_SCHEMA", true);
127
128 /**
129 * Database setting <code>LARGE_RESULT_BUFFER_SIZE</code> (default: 4096).<br />
130 * Buffer size for large result sets. Set this value to 0 to disable the
131 * buffer.
132 */
133 public final int largeResultBufferSize = get("LARGE_RESULT_BUFFER_SIZE", 4 * 1024);
134
135 /**
136 * Database setting <code>LARGE_TRANSACTIONS</code> (default: true).<br />
137 * Support very large transactions
138 */
139 public final boolean largeTransactions = get("LARGE_TRANSACTIONS", true);
140
141 /**
142 * Database setting <code>MAX_COMPACT_COUNT</code>
143 * (default: Integer.MAX_VALUE).<br />
144 * The maximum number of pages to move when closing a database.
145 */
146 public final int maxCompactCount = get("MAX_COMPACT_COUNT", Integer.MAX_VALUE);
147
148 /**
149 * Database setting <code>MAX_COMPACT_TIME</code> (default: 200).<br />
150 * The maximum time in milliseconds used to compact a database when closing.
151 */
152 public final int maxCompactTime = get("MAX_COMPACT_TIME", 200);
153
154 /**
155 * Database setting <code>MAX_MEMORY_ROWS_DISTINCT</code> (default:
156 * 10000).<br />
157 * The maximum number of rows kept in-memory for SELECT DISTINCT queries. If
158 * more than this number of rows are in a result set, a temporary table is
159 * used.
160 */
161 public final int maxMemoryRowsDistinct = get("MAX_MEMORY_ROWS_DISTINCT", 10000);
162
163 /**
164 * Database setting <code>MAX_QUERY_TIMEOUT</code> (default: 0).<br />
165 * The maximum timeout of a query in milliseconds. The default is 0, meaning
166 * no limit. Please note the actual query timeout may be set to a lower
167 * value.
168 */
169 public int maxQueryTimeout = get("MAX_QUERY_TIMEOUT", 0);
170
171 /**
172 * Database setting <code>NESTED_JOINS</code> (default: true).<br />
173 * Whether nested joins should be supported.
174 */
175 public final boolean nestedJoins = get("NESTED_JOINS", true);
176
177 /**
178 * Database setting <code>OPTIMIZE_DISTINCT</code> (default: true).<br />
179 * Improve the performance of simple DISTINCT queries if an index is
180 * available for the given column. The optimization is used if:
181 * <ul>
182 * <li>The select is a single column query without condition </li>
183 * <li>The query contains only one table, and no group by </li>
184 * <li>There is only one table involved </li>
185 * <li>There is an ascending index on the column </li>
186 * <li>The selectivity of the column is below 20 </li>
187 * </ul>
188 */
189 public final boolean optimizeDistinct = get("OPTIMIZE_DISTINCT", true);
190
191 /**
192 * Database setting <code>OPTIMIZE_EVALUATABLE_SUBQUERIES</code> (default:
193 * true).<br />
194 * Optimize subqueries that are not dependent on the outer query.
195 */
196 public final boolean optimizeEvaluatableSubqueries = get("OPTIMIZE_EVALUATABLE_SUBQUERIES", true);
197
198 /**
199 * Database setting <code>OPTIMIZE_INSERT_FROM_SELECT</code>
200 * (default: true).<br />
201 * Insert into table from query directly bypassing temporary disk storage.
202 * This also applies to create table as select.
203 */
204 public final boolean optimizeInsertFromSelect = get("OPTIMIZE_INSERT_FROM_SELECT", true);
205
206 /**
207 * Database setting <code>OPTIMIZE_IN_LIST</code> (default: true).<br />
208 * Optimize IN(...) and IN(SELECT ...) comparisons. This includes
209 * optimization for SELECT, DELETE, and UPDATE.
210 */
211 public final boolean optimizeInList = get("OPTIMIZE_IN_LIST", true);
212
213 /**
214 * Database setting <code>OPTIMIZE_IN_SELECT</code> (default: true).<br />
215 * Optimize IN(SELECT ...) comparisons. This includes
216 * optimization for SELECT, DELETE, and UPDATE.
217 */
218 public final boolean optimizeInSelect = get("OPTIMIZE_IN_SELECT", true);
219
220 /**
221 * Database setting <code>OPTIMIZE_IS_NULL</code> (default: false).<br />
222 * Use an index for condition of the form columnName IS NULL.
223 */
224 public final boolean optimizeIsNull = get("OPTIMIZE_IS_NULL", true);
225
226 /**
227 * Database setting <code>OPTIMIZE_OR</code> (default: true).<br />
228 * Convert (C=? OR C=?) to (C IN(?, ?)).
229 */
230 public final boolean optimizeOr = get("OPTIMIZE_OR", true);
231
232 /**
233 * Database setting <code>OPTIMIZE_TWO_EQUALS</code> (default: true).<br />
234 * Optimize expressions of the form A=B AND B=1. In this case, AND A=1 is
235 * added so an index on A can be used.
236 */
237 public final boolean optimizeTwoEquals = get("OPTIMIZE_TWO_EQUALS", true);
238
239 /**
240 * Database setting <code>OPTIMIZE_UPDATE</code> (default: true).<br />
241 * Speed up inserts, updates, and deletes by not reading all rows from a
242 * page unless necessary.
243 */
244 public final boolean optimizeUpdate = get("OPTIMIZE_UPDATE", true);
245
246 /**
247 * Database setting <code>PAGE_STORE_MAX_GROWTH</code>
248 * (default: 128 * 1024).<br />
249 * The maximum number of pages the file grows at any time.
250 */
251 public final int pageStoreMaxGrowth = get("PAGE_STORE_MAX_GROWTH", 128 * 1024);
252
253 /**
254 * Database setting <code>PAGE_STORE_INTERNAL_COUNT</code>
255 * (default: false).<br />
256 * Update the row counts on a node level.
257 */
258 public final boolean pageStoreInternalCount = get("PAGE_STORE_INTERNAL_COUNT", false);
259
260 /**
261 * Database setting <code>PAGE_STORE_TRIM</code> (default: true).<br />
262 * Trim the database size when closing.
263 */
264 public final boolean pageStoreTrim = get("PAGE_STORE_TRIM", true);
265
266 /**
267 * Database setting <code>QUERY_CACHE_SIZE</code> (default: 8).<br />
268 * The size of the query cache, in number of cached statements. Each session
269 * has it's own cache with the given size. The cache is only used if the SQL
270 * statement and all parameters match. Only the last returned result per
271 * query is cached. Only SELECT statements are cached (excluding UNION and
272 * FOR UPDATE statements). This works for both statements and prepared
273 * statement.
274 */
275 public final int queryCacheSize = get("QUERY_CACHE_SIZE", 8);
276
277 /**
278 * Database setting <code>RECOMPILE_ALWAYS</code> (default: false).<br />
279 * Always recompile prepared statements.
280 */
281 public final boolean recompileAlways = get("RECOMPILE_ALWAYS", false);
282
283 /**
284 * Database setting <code>RECONNECT_CHECK_DELAY</code> (default: 200).<br />
285 * Check the .lock.db file every this many milliseconds to detect that the
286 * database was changed. The process writing to the database must first
287 * notify a change in the .lock.db file, then wait twice this many
288 * milliseconds before updating the database.
289 */
290 public final int reconnectCheckDelay = get("RECONNECT_CHECK_DELAY", 200);
291
292 /**
293 * Database setting <code>ROWID</code> (default: true).<br />
294 * If set, each table has a pseudo-column _ROWID_.
295 */
296 public final boolean rowId = get("ROWID", true);
297
298 /**
299 * Database setting <code>SELECT_FOR_UPDATE_MVCC</code>
300 * (default: true).<br />
301 * If set, SELECT .. FOR UPDATE queries lock only the selected rows when
302 * using MVCC.
303 */
304 public final boolean selectForUpdateMvcc = get("SELECT_FOR_UPDATE_MVCC", true);
305
306 /**
307 * Database setting <code>SHARE_LINKED_CONNECTIONS</code>
308 * (default: true).<br />
309 * Linked connections should be shared, that means connections to the same
310 * database should be used for all linked tables that connect to the same
311 * database.
312 */
313 public final boolean shareLinkedConnections = get("SHARE_LINKED_CONNECTIONS", true);
314
315 private DbSettings(HashMap<String, String> s) {
316 super(s);
317 }
318
319 /**
320 * INTERNAL.
321 * Get the settings for the given properties (may be null).
322 *
323 * @param s the settings
324 * @return the settings
325 */
326 public static DbSettings getInstance(HashMap<String, String> s) {
327 if (s == null || s.isEmpty()) {
328 if (defaultSettings == null) {
329 defaultSettings = new DbSettings(new HashMap<String, String>());
330 }
331 return defaultSettings;
332 }
333 return new DbSettings(s);
334 }
335
336 }
337