File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\engine\Constants.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.engine;
8
9 import java.sql.ResultSet;
10
11 /**
12 * Constants are fixed values that are used in the whole database code.
13 */
14 public class Constants {
15
16 /**
17 * The build date is updated for each public release.
18 */
19 public static final String BUILD_DATE = "2012-11-30";
20
21 /**
22 * The build date is updated for each public release.
23 */
24 public static final String BUILD_DATE_STABLE = "2012-09-09";
25
26 /**
27 * The build id is incremented for each public release.
28 */
29 public static final int BUILD_ID = 170;
30
31 /**
32 * The build id of the last stable release.
33 */
34 public static final int BUILD_ID_STABLE = 169;
35
36 /**
37 * If H2 is compiled to be included in a product, this should be set to
38 * a unique vendor id (to distinguish from official releases).
39 * Additionally, a version number should be set to distinguish releases.
40 * Example: ACME_SVN1651_BUILD3
41 */
42 public static final String BUILD_VENDOR_AND_VERSION = null;
43
44 /**
45 * The TCP protocol version number 6.
46 */
47 public static final int TCP_PROTOCOL_VERSION_6 = 6;
48
49 /**
50 * The TCP protocol version number 7.
51 */
52 public static final int TCP_PROTOCOL_VERSION_7 = 7;
53
54 /**
55 * The TCP protocol version number 8.
56 */
57 public static final int TCP_PROTOCOL_VERSION_8 = 8;
58
59 /**
60 * The TCP protocol version number 9.
61 */
62 public static final int TCP_PROTOCOL_VERSION_9 = 9;
63
64 /**
65 * The TCP protocol version number 10.
66 */
67 public static final int TCP_PROTOCOL_VERSION_10 = 10;
68
69 /**
70 * The TCP protocol version number 11.
71 */
72 public static final int TCP_PROTOCOL_VERSION_11 = 11;
73
74 /**
75 * The TCP protocol version number 11.
76 */
77 public static final int TCP_PROTOCOL_VERSION_12 = 12;
78
79 /**
80 * The major version of this database.
81 */
82 public static final int VERSION_MAJOR = 1;
83
84 /**
85 * The minor version of this database.
86 */
87 public static final int VERSION_MINOR = 3;
88 // Build.getLuceneVersion() uses an ugly hack to read this value
89
90 /**
91 * The lock mode that means no locking is used at all.
92 */
93 public static final int LOCK_MODE_OFF = 0;
94
95 /**
96 * The lock mode that means read locks are acquired, but they are released
97 * immediately after the statement is executed.
98 */
99 public static final int LOCK_MODE_READ_COMMITTED = 3;
100
101 /**
102 * The lock mode that means table level locking is used for reads and
103 * writes.
104 */
105 public static final int LOCK_MODE_TABLE = 1;
106
107 /**
108 * The lock mode that means table level locking is used for reads and
109 * writes. If a table is locked, System.gc is called to close forgotten
110 * connections.
111 */
112 public static final int LOCK_MODE_TABLE_GC = 2;
113
114 /**
115 * Constant meaning both numbers and text is allowed in SQL statements.
116 */
117 public static final int ALLOW_LITERALS_ALL = 2;
118
119 /**
120 * Constant meaning no literals are allowed in SQL statements.
121 */
122 public static final int ALLOW_LITERALS_NONE = 0;
123
124 /**
125 * Constant meaning only numbers are allowed in SQL statements (but no
126 * texts).
127 */
128 public static final int ALLOW_LITERALS_NUMBERS = 1;
129
130 /**
131 * Whether searching in Blob values should be supported.
132 */
133 public static final boolean BLOB_SEARCH = false;
134
135 /**
136 * The minimum number of entries to keep in the cache.
137 */
138 public static final int CACHE_MIN_RECORDS = 16;
139
140 /**
141 * The default cache size in KB.
142 */
143 public static final int CACHE_SIZE_DEFAULT = 16 * 1024;
144
145 /**
146 * The default cache type.
147 */
148 public static final String CACHE_TYPE_DEFAULT = "LRU";
149
150 /**
151 * The value of the cluster setting if clustering is disabled.
152 */
153 public static final String CLUSTERING_DISABLED = "''";
154
155 /**
156 * The value of the cluster setting if clustering is enabled (the actual
157 * value is checked later).
158 */
159 public static final String CLUSTERING_ENABLED = "TRUE";
160
161 /**
162 * The database URL used when calling a function if only the column list
163 * should be returned.
164 */
165 public static final String CONN_URL_COLUMNLIST = "jdbc:columnlist:connection";
166
167 /**
168 * The database URL used when calling a function if the data should be
169 * returned.
170 */
171 public static final String CONN_URL_INTERNAL = "jdbc:default:connection";
172
173 /**
174 * The cost is calculated on rowcount + this offset,
175 * to avoid using the wrong or no index if the table
176 * contains no rows _currently_ (when preparing the statement)
177 */
178 public static final int COST_ROW_OFFSET = 1000;
179
180 /**
181 * The number of milliseconds after which to check for a deadlock if locking
182 * is not successful.
183 */
184 public static final int DEADLOCK_CHECK = 100;
185
186 /**
187 * The default port number of the HTTP server (for the H2 Console).
188 * This value is also in the documentation and in the Server javadoc.
189 */
190 public static final int DEFAULT_HTTP_PORT = 8082;
191
192 /**
193 * The default value for the LOCK_MODE setting.
194 */
195 public static final int DEFAULT_LOCK_MODE = LOCK_MODE_READ_COMMITTED;
196
197 /**
198 * The default maximum length of an LOB that is stored in the database file.
199 */
200 public static final int DEFAULT_MAX_LENGTH_INPLACE_LOB = 4096;
201
202 /**
203 * The default maximum length of an LOB that is stored with the record itself.
204 * Only used if h2.lobInDatabase is enabled.
205 */
206 public static final int DEFAULT_MAX_LENGTH_INPLACE_LOB2 = 128;
207
208 /**
209 * The default value for the maximum transaction log size.
210 */
211 public static final long DEFAULT_MAX_LOG_SIZE = 16 * 1024 * 1024;
212
213 /**
214 * The default maximum number of rows to be kept in memory in a result set.
215 */
216 public static final int DEFAULT_MAX_MEMORY_ROWS = 10000;
217
218 /**
219 * The default value for the MAX_MEMORY_UNDO setting.
220 */
221 public static final int DEFAULT_MAX_MEMORY_UNDO = 50000;
222
223 /**
224 * The default for the setting MAX_OPERATION_MEMORY.
225 */
226 public static final int DEFAULT_MAX_OPERATION_MEMORY = 100000;
227
228 /**
229 * The default page size to use for new databases.
230 */
231 public static final int DEFAULT_PAGE_SIZE = 2048;
232
233 /**
234 * The default result set concurrency for statements created with
235 * Connection.createStatement() or prepareStatement(String sql).
236 */
237 public static final int DEFAULT_RESULT_SET_CONCURRENCY = ResultSet.CONCUR_READ_ONLY;
238
239 /**
240 * The default port of the TCP server.
241 * This port is also used in the documentation and in the Server javadoc.
242 */
243 public static final int DEFAULT_TCP_PORT = 9092;
244
245 /**
246 * The default delay in milliseconds before the transaction log is written.
247 */
248 public static final int DEFAULT_WRITE_DELAY = 500;
249
250 /**
251 * The password is hashed this many times
252 * to slow down dictionary attacks.
253 */
254 public static final int ENCRYPTION_KEY_HASH_ITERATIONS = 1024;
255
256 /**
257 * The block of a file. It is also the encryption block size.
258 */
259 public static final int FILE_BLOCK_SIZE = 16;
260
261 /**
262 * For testing, the lock timeout is smaller than for interactive use cases.
263 * This value could be increased to about 5 or 10 seconds.
264 */
265 public static final int INITIAL_LOCK_TIMEOUT = 2000;
266
267 /**
268 * The block size for I/O operations.
269 */
270 public static final int IO_BUFFER_SIZE = 4 * 1024;
271
272 /**
273 * The block size used to compress data in the LZFOutputStream.
274 */
275 public static final int IO_BUFFER_SIZE_COMPRESS = 128 * 1024;
276
277 /**
278 * The number of milliseconds to wait between checking the .lock.db file
279 * still exists once a database is locked.
280 */
281 public static final int LOCK_SLEEP = 1000;
282
283 /**
284 * The highest possible parameter index.
285 */
286 public static final int MAX_PARAMETER_INDEX = 100000;
287
288 /**
289 * The memory needed by a object of class Data
290 */
291 public static final int MEMORY_DATA = 24;
292
293 /**
294 * This value is used to calculate the average memory usage.
295 */
296 public static final int MEMORY_FACTOR = 64;
297
298 /**
299 * The memory needed by a regular object with at least one field.
300 */
301 // Java 6, 64 bit: 24
302 // Java 6, 32 bit: 12
303 public static final int MEMORY_OBJECT = 24;
304
305 /**
306 * The memory needed by an object of class PageBtree.
307 */
308 public static final int MEMORY_PAGE_BTREE = 112 + MEMORY_DATA + 2 * MEMORY_OBJECT;
309
310 /**
311 * The memory needed by an object of class PageData.
312 */
313 public static final int MEMORY_PAGE_DATA = 144 + MEMORY_DATA + 3 * MEMORY_OBJECT;
314
315 /**
316 * The memory needed by an object of class PageDataOverflow.
317 */
318 public static final int MEMORY_PAGE_DATA_OVERFLOW = 96 + MEMORY_DATA;
319
320 /**
321 * The memory needed by a pointer.
322 */
323 // Java 6, 64 bit: 8
324 // Java 6, 32 bit: 4
325 public static final int MEMORY_POINTER = 8;
326
327 /**
328 * The memory needed by a Row.
329 */
330 public static final int MEMORY_ROW = 40;
331
332 /**
333 * The minimum write delay that causes commits to be delayed.
334 */
335 public static final int MIN_WRITE_DELAY = 5;
336
337 /**
338 * The name prefix used for indexes that are not explicitly named.
339 */
340 public static final String PREFIX_INDEX = "INDEX_";
341
342 /**
343 * The name prefix used for synthetic nested join tables.
344 */
345 public static final String PREFIX_JOIN = "SYSTEM_JOIN_";
346
347 /**
348 * The name prefix used for primary key constraints that are not explicitly
349 * named.
350 */
351 public static final String PREFIX_PRIMARY_KEY = "PRIMARY_KEY_";
352
353 /**
354 * Every user belongs to this role.
355 */
356 public static final String PUBLIC_ROLE_NAME = "PUBLIC";
357
358 /**
359 * The number of bytes in random salt that is used to hash passwords.
360 */
361 public static final int SALT_LEN = 8;
362
363 /**
364 * The name of the default schema.
365 */
366 public static final String SCHEMA_MAIN = "PUBLIC";
367
368 /**
369 * The default selectivity (used if the selectivity is not calculated).
370 */
371 public static final int SELECTIVITY_DEFAULT = 50;
372
373 /**
374 * The number of distinct values to keep in memory when running ANALYZE.
375 */
376 public static final int SELECTIVITY_DISTINCT_COUNT = 10000;
377
378 /**
379 * The default directory name of the server properties file for the H2 Console.
380 */
381 public static final String SERVER_PROPERTIES_DIR = "~";
382
383 /**
384 * The name of the server properties file for the H2 Console.
385 */
386 public static final String SERVER_PROPERTIES_NAME = ".h2.server.properties";
387
388 /**
389 * Queries that take longer than this number of milliseconds are written to
390 * the trace file with the level info.
391 */
392 public static final long SLOW_QUERY_LIMIT_MS = 100;
393
394 /**
395 * The database URL prefix of this database.
396 */
397 public static final String START_URL = "jdbc:h2:";
398
399 /**
400 * The file name suffix of all database files.
401 */
402 public static final String SUFFIX_DB_FILE = ".db";
403
404 /**
405 * The file name suffix of large object files.
406 */
407 public static final String SUFFIX_LOB_FILE = ".lob.db";
408
409 /**
410 * The suffix of the directory name used if LOB objects are stored in a
411 * directory.
412 */
413 public static final String SUFFIX_LOBS_DIRECTORY = ".lobs.db";
414
415 /**
416 * The file name suffix of file lock files that are used to make sure a
417 * database is open by only one process at any time.
418 */
419 public static final String SUFFIX_LOCK_FILE = ".lock.db";
420
421 /**
422 * The file name suffix of page files.
423 */
424 public static final String SUFFIX_PAGE_FILE = ".h2.db";
425
426 /**
427 * The file name suffix of temporary files.
428 */
429 public static final String SUFFIX_TEMP_FILE = ".temp.db";
430
431 /**
432 * The file name suffix of trace files.
433 */
434 public static final String SUFFIX_TRACE_FILE = ".trace.db";
435
436 /**
437 * The delay that is to be used if throttle has been enabled.
438 */
439 public static final int THROTTLE_DELAY = 50;
440
441 /**
442 * The maximum size of an undo log block.
443 */
444 public static final int UNDO_BLOCK_SIZE = 1024 * 1024;
445
446 /**
447 * The database URL format in simplified Backus-Naur form.
448 */
449 public static final String URL_FORMAT = START_URL +
450 "{ {.|mem:}[name] | [file:]fileName | {tcp|ssl}:[//]server[:port][,server2[:port]]/name }[;key=value...]";
451
452 /**
453 * The package name of user defined classes.
454 */
455 public static final String USER_PACKAGE = "org.h2.dynamic";
456
457 /**
458 * Name of the character encoding format.
459 */
460 public static final String UTF8 = "UTF8";
461
462 /**
463 * The maximum time in milliseconds to keep the cost of a view.
464 * 10000 means 10 seconds.
465 */
466 public static final int VIEW_COST_CACHE_MAX_AGE = 10000;
467
468 /**
469 * The name of the index cache that is used for temporary view (subqueries
470 * used as tables).
471 */
472 public static final int VIEW_INDEX_CACHE_SIZE = 64;
473
474 private Constants() {
475 // utility class
476 }
477
478 /**
479 * Get the version of this product, consisting of major version, minor version,
480 * and build id.
481 *
482 * @return the version number
483 */
484 public static String getVersion() {
485 String version = VERSION_MAJOR + "." + VERSION_MINOR + "." + BUILD_ID;
486 if (BUILD_VENDOR_AND_VERSION != null) {
487 version += "_" + BUILD_VENDOR_AND_VERSION;
488 }
489 return version;
490 }
491
492 /**
493 * Get the last stable version name.
494 *
495 * @return the version number
496 */
497 public static Object getVersionStable() {
498 return "1.3." + BUILD_ID_STABLE;
499 }
500
501 /**
502 * Get the complete version number of this database, consisting of
503 * the major version, the minor version, the build id, and the build date.
504 *
505 * @return the complete version
506 */
507 public static String getFullVersion() {
508 return getVersion() + " (" + BUILD_DATE + ")";
509 }
510
511 }
512