Debian Codegraph @

src/main/org/h2/command/CommandInterface.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6 package org.h2.command;
7
8 import java.util.ArrayList;
9 import org.h2.expression.ParameterInterface;
10 import org.h2.result.ResultInterface;
11 import org.h2.result.ResultWithGeneratedKeys;
12
13 /**
14 * Represents a SQL statement.
15 */
16 public interface CommandInterface extends AutoCloseable {
17
18 /**
19 * The type for unknown statement.
20 */
21 int UNKNOWN = 0;
22
23 // ddl operations
24
25 /**
26 * The type of a ALTER INDEX RENAME statement.
27 */
28 int ALTER_INDEX_RENAME = 1;
29
30 /**
31 * The type of an ALTER SCHEMA RENAME statement.
32 */
33 int ALTER_SCHEMA_RENAME = 2;
34
35 /**
36 * The type of an ALTER TABLE ADD CHECK statement.
37 */
38 int ALTER_TABLE_ADD_CONSTRAINT_CHECK = 3;
39
40 /**
41 * The type of an ALTER TABLE ADD UNIQUE statement.
42 */
43 int ALTER_TABLE_ADD_CONSTRAINT_UNIQUE = 4;
44
45 /**
46 * The type of an ALTER TABLE ADD FOREIGN KEY statement.
47 */
48 int ALTER_TABLE_ADD_CONSTRAINT_REFERENTIAL = 5;
49
50 /**
51 * The type of an ALTER TABLE ADD PRIMARY KEY statement.
52 */
53 int ALTER_TABLE_ADD_CONSTRAINT_PRIMARY_KEY = 6;
54
55 /**
56 * The type of an ALTER TABLE ADD statement.
57 */
58 int ALTER_TABLE_ADD_COLUMN = 7;
59
60 /**
61 * The type of an ALTER TABLE ALTER COLUMN SET NOT NULL statement.
62 */
63 int ALTER_TABLE_ALTER_COLUMN_NOT_NULL = 8;
64
65 /**
66 * The type of an ALTER TABLE ALTER COLUMN DROP NOT NULL statement.
67 */
68 int ALTER_TABLE_ALTER_COLUMN_DROP_NOT_NULL = 9;
69
70 /**
71 * The type of an ALTER TABLE ALTER COLUMN SET DEFAULT and ALTER TABLE ALTER
72 * COLUMN DROP DEFAULT statements.
73 */
74 int ALTER_TABLE_ALTER_COLUMN_DEFAULT = 10;
75
76 /**
77 * The type of an ALTER TABLE ALTER COLUMN statement that changes the column
78 * data type.
79 */
80 int ALTER_TABLE_ALTER_COLUMN_CHANGE_TYPE = 11;
81
82 /**
83 * The type of an ALTER TABLE DROP COLUMN statement.
84 */
85 int ALTER_TABLE_DROP_COLUMN = 12;
86
87 /**
88 * The type of an ALTER TABLE ALTER COLUMN SELECTIVITY statement.
89 */
90 int ALTER_TABLE_ALTER_COLUMN_SELECTIVITY = 13;
91
92 /**
93 * The type of an ALTER TABLE DROP CONSTRAINT statement.
94 */
95 int ALTER_TABLE_DROP_CONSTRAINT = 14;
96
97 /**
98 * The type of an ALTER TABLE RENAME statement.
99 */
100 int ALTER_TABLE_RENAME = 15;
101
102 /**
103 * The type of an ALTER TABLE ALTER COLUMN RENAME statement.
104 */
105 int ALTER_TABLE_ALTER_COLUMN_RENAME = 16;
106
107 /**
108 * The type of an ALTER USER ADMIN statement.
109 */
110 int ALTER_USER_ADMIN = 17;
111
112 /**
113 * The type of an ALTER USER RENAME statement.
114 */
115 int ALTER_USER_RENAME = 18;
116
117 /**
118 * The type of an ALTER USER SET PASSWORD statement.
119 */
120 int ALTER_USER_SET_PASSWORD = 19;
121
122 /**
123 * The type of an ALTER VIEW statement.
124 */
125 int ALTER_VIEW = 20;
126
127 /**
128 * The type of an ANALYZE statement.
129 */
130 int ANALYZE = 21;
131
132 /**
133 * The type of a CREATE AGGREGATE statement.
134 */
135 int CREATE_AGGREGATE = 22;
136
137 /**
138 * The type of a CREATE CONSTANT statement.
139 */
140 int CREATE_CONSTANT = 23;
141
142 /**
143 * The type of a CREATE ALIAS statement.
144 */
145 int CREATE_ALIAS = 24;
146
147 /**
148 * The type of a CREATE INDEX statement.
149 */
150 int CREATE_INDEX = 25;
151
152 /**
153 * The type of a CREATE LINKED TABLE statement.
154 */
155 int CREATE_LINKED_TABLE = 26;
156
157 /**
158 * The type of a CREATE ROLE statement.
159 */
160 int CREATE_ROLE = 27;
161
162 /**
163 * The type of a CREATE SCHEMA statement.
164 */
165 int CREATE_SCHEMA = 28;
166
167 /**
168 * The type of a CREATE SEQUENCE statement.
169 */
170 int CREATE_SEQUENCE = 29;
171
172 /**
173 * The type of a CREATE TABLE statement.
174 */
175 int CREATE_TABLE = 30;
176
177 /**
178 * The type of a CREATE TRIGGER statement.
179 */
180 int CREATE_TRIGGER = 31;
181
182 /**
183 * The type of a CREATE USER statement.
184 */
185 int CREATE_USER = 32;
186
187 /**
188 * The type of a CREATE DOMAIN statement.
189 */
190 int CREATE_DOMAIN = 33;
191
192 /**
193 * The type of a CREATE VIEW statement.
194 */
195 int CREATE_VIEW = 34;
196
197 /**
198 * The type of a DEALLOCATE statement.
199 */
200 int DEALLOCATE = 35;
201
202 /**
203 * The type of a DROP AGGREGATE statement.
204 */
205 int DROP_AGGREGATE = 36;
206
207 /**
208 * The type of a DROP CONSTANT statement.
209 */
210 int DROP_CONSTANT = 37;
211
212 /**
213 * The type of a DROP ALL OBJECTS statement.
214 */
215 int DROP_ALL_OBJECTS = 38;
216
217 /**
218 * The type of a DROP ALIAS statement.
219 */
220 int DROP_ALIAS = 39;
221
222 /**
223 * The type of a DROP INDEX statement.
224 */
225 int DROP_INDEX = 40;
226
227 /**
228 * The type of a DROP ROLE statement.
229 */
230 int DROP_ROLE = 41;
231
232 /**
233 * The type of a DROP SCHEMA statement.
234 */
235 int DROP_SCHEMA = 42;
236
237 /**
238 * The type of a DROP SEQUENCE statement.
239 */
240 int DROP_SEQUENCE = 43;
241
242 /**
243 * The type of a DROP TABLE statement.
244 */
245 int DROP_TABLE = 44;
246
247 /**
248 * The type of a DROP TRIGGER statement.
249 */
250 int DROP_TRIGGER = 45;
251
252 /**
253 * The type of a DROP USER statement.
254 */
255 int DROP_USER = 46;
256
257 /**
258 * The type of a DROP DOMAIN statement.
259 */
260 int DROP_DOMAIN = 47;
261
262 /**
263 * The type of a DROP VIEW statement.
264 */
265 int DROP_VIEW = 48;
266
267 /**
268 * The type of a GRANT statement.
269 */
270 int GRANT = 49;
271
272 /**
273 * The type of a REVOKE statement.
274 */
275 int REVOKE = 50;
276
277 /**
278 * The type of a PREPARE statement.
279 */
280 int PREPARE = 51;
281
282 /**
283 * The type of a COMMENT statement.
284 */
285 int COMMENT = 52;
286
287 /**
288 * The type of a TRUNCATE TABLE statement.
289 */
290 int TRUNCATE_TABLE = 53;
291
292 // dml operations
293
294 /**
295 * The type of an ALTER SEQUENCE statement.
296 */
297 int ALTER_SEQUENCE = 54;
298
299 /**
300 * The type of an ALTER TABLE SET REFERENTIAL_INTEGRITY statement.
301 */
302 int ALTER_TABLE_SET_REFERENTIAL_INTEGRITY = 55;
303
304 /**
305 * The type of a BACKUP statement.
306 */
307 int BACKUP = 56;
308
309 /**
310 * The type of a CALL statement.
311 */
312 int CALL = 57;
313
314 /**
315 * The type of a DELETE statement.
316 */
317 int DELETE = 58;
318
319 /**
320 * The type of an EXECUTE statement.
321 */
322 int EXECUTE = 59;
323
324 /**
325 * The type of an EXPLAIN statement.
326 */
327 int EXPLAIN = 60;
328
329 /**
330 * The type of an INSERT statement.
331 */
332 int INSERT = 61;
333
334 /**
335 * The type of a MERGE statement.
336 */
337 int MERGE = 62;
338
339 /**
340 * The type of a REPLACE statement.
341 */
342 int REPLACE = 63;
343
344 /**
345 * The type of a no operation statement.
346 */
347 int NO_OPERATION = 63;
348
349 /**
350 * The type of a RUNSCRIPT statement.
351 */
352 int RUNSCRIPT = 64;
353
354 /**
355 * The type of a SCRIPT statement.
356 */
357 int SCRIPT = 65;
358
359 /**
360 * The type of a SELECT statement.
361 */
362 int SELECT = 66;
363
364 /**
365 * The type of a SET statement.
366 */
367 int SET = 67;
368
369 /**
370 * The type of an UPDATE statement.
371 */
372 int UPDATE = 68;
373
374 // transaction commands
375
376 /**
377 * The type of a SET AUTOCOMMIT statement.
378 */
379 int SET_AUTOCOMMIT_TRUE = 69;
380
381 /**
382 * The type of a SET AUTOCOMMIT statement.
383 */
384 int SET_AUTOCOMMIT_FALSE = 70;
385
386 /**
387 * The type of a COMMIT statement.
388 */
389 int COMMIT = 71;
390
391 /**
392 * The type of a ROLLBACK statement.
393 */
394 int ROLLBACK = 72;
395
396 /**
397 * The type of a CHECKPOINT statement.
398 */
399 int CHECKPOINT = 73;
400
401 /**
402 * The type of a SAVEPOINT statement.
403 */
404 int SAVEPOINT = 74;
405
406 /**
407 * The type of a ROLLBACK TO SAVEPOINT statement.
408 */
409 int ROLLBACK_TO_SAVEPOINT = 75;
410
411 /**
412 * The type of a CHECKPOINT SYNC statement.
413 */
414 int CHECKPOINT_SYNC = 76;
415
416 /**
417 * The type of a PREPARE COMMIT statement.
418 */
419 int PREPARE_COMMIT = 77;
420
421 /**
422 * The type of a COMMIT TRANSACTION statement.
423 */
424 int COMMIT_TRANSACTION = 78;
425
426 /**
427 * The type of a ROLLBACK TRANSACTION statement.
428 */
429 int ROLLBACK_TRANSACTION = 79;
430
431 /**
432 * The type of a SHUTDOWN statement.
433 */
434 int SHUTDOWN = 80;
435
436 /**
437 * The type of a SHUTDOWN IMMEDIATELY statement.
438 */
439 int SHUTDOWN_IMMEDIATELY = 81;
440
441 /**
442 * The type of a SHUTDOWN COMPACT statement.
443 */
444 int SHUTDOWN_COMPACT = 82;
445
446 /**
447 * The type of a BEGIN {WORK|TRANSACTION} statement.
448 */
449 int BEGIN = 83;
450
451 /**
452 * The type of a SHUTDOWN DEFRAG statement.
453 */
454 int SHUTDOWN_DEFRAG = 84;
455
456 /**
457 * The type of an ALTER TABLE RENAME CONSTRAINT statement.
458 */
459 int ALTER_TABLE_RENAME_CONSTRAINT = 85;
460
461 /**
462 * The type of an EXPLAIN ANALYZE statement.
463 */
464 int EXPLAIN_ANALYZE = 86;
465
466 /**
467 * The type of an ALTER TABLE ALTER COLUMN SET INVISIBLE statement.
468 */
469 int ALTER_TABLE_ALTER_COLUMN_VISIBILITY = 87;
470
471 /**
472 * The type of a CREATE SYNONYM statement.
473 */
474 int CREATE_SYNONYM = 88;
475
476 /**
477 * The type of a DROP SYNONYM statement.
478 */
479 int DROP_SYNONYM = 89;
480
481 /**
482 * The type of an ALTER TABLE ALTER COLUMN SET ON UPDATE statement.
483 */
484 int ALTER_TABLE_ALTER_COLUMN_ON_UPDATE = 90;
485
486 /**
487 * The type of an EXECUTE IMMEDIATELY statement.
488 */
489 int EXECUTE_IMMEDIATELY = 91;
490
491 /**
492 * The type of ALTER DOMAIN ADD CONSTRAINT statement.
493 */
494 int ALTER_DOMAIN_ADD_CONSTRAINT = 92;
495
496 /**
497 * The type of ALTER DOMAIN DROP CONSTRAINT statement.
498 */
499 int ALTER_DOMAIN_DROP_CONSTRAINT = 93;
500
501 /**
502 * The type of an ALTER DOMAIN SET DEFAULT and ALTER DOMAIN DROP DEFAULT
503 * statements.
504 */
505 int ALTER_DOMAIN_DEFAULT = 94;
506
507 /**
508 * The type of an ALTER DOMAIN SET ON UPDATE and ALTER DOMAIN DROP ON UPDATE
509 * statements.
510 */
511 int ALTER_DOMAIN_ON_UPDATE = 95;
512
513 /**
514 * The type of an ALTER DOMAIN RENAME statement.
515 */
516 int ALTER_DOMAIN_RENAME = 96;
517
518 /**
519 * The type of a HELP statement.
520 */
521 int HELP = 97;
522
523 /**
524 * The type of an ALTER TABLE ALTER COLUMN DROP EXPRESSION statement.
525 */
526 int ALTER_TABLE_ALTER_COLUMN_DROP_EXPRESSION = 98;
527
528 /**
529 * The type of an ALTER TABLE ALTER COLUMN DROP IDENTITY statement.
530 */
531 int ALTER_TABLE_ALTER_COLUMN_DROP_IDENTITY = 99;
532
533 /**
534 * The type of ALTER TABLE ALTER COLUMN SET DEFAULT ON NULL and ALTER TABLE
535 * ALTER COLUMN DROP DEFAULT ON NULL statements.
536 */
537 int ALTER_TABLE_ALTER_COLUMN_DEFAULT_ON_NULL = 100;
538
539 /**
540 * The type of an ALTER DOMAIN RENAME CONSTRAINT statement.
541 */
542 int ALTER_DOMAIN_RENAME_CONSTRAINT = 101;
543
544 /**
545 * The type of a CREATE MATERIALIZED VIEW statement.
546 */
547 int CREATE_MATERIALIZED_VIEW = 102;
548
549 /**
550 * The type of a REFRESH MATERIALIZED VIEW statement.
551 */
552 int REFRESH_MATERIALIZED_VIEW = 103;
553
554 /**
555 * The type of a DROP MATERIALIZED VIEW statement.
556 */
557 int DROP_MATERIALIZED_VIEW = 104;
558
559 /**
560 * Get command type.
561 *
562 * @return one of the constants above
563 */
564 int getCommandType();
565
566 /**
567 * Check if this is a query.
568 *
569 * @return true if it is a query
570 */
571 boolean isQuery();
572
573 /**
574 * Get the parameters (if any).
575 *
576 * @return the parameters
577 */
578 ArrayList<? extends ParameterInterface> getParameters();
579
580 /**
581 * Execute the query.
582 *
583 * @param maxRows the maximum number of rows returned
584 * @param scrollable if the result set must be scrollable
585 * @return the result
586 */
587 ResultInterface executeQuery(long maxRows, boolean scrollable);
588
589 /**
590 * Execute the statement
591 *
592 * @param generatedKeysRequest
593 * {@code null} or {@code false} if generated keys are not
594 * needed, {@code true} if generated keys should be configured
595 * automatically, {@code int[]} to specify column indices to
596 * return generated keys from, or {@code String[]} to specify
597 * column names to return generated keys from
598 *
599 * @return the update count and generated keys, if any
600 */
601 ResultWithGeneratedKeys executeUpdate(Object generatedKeysRequest);
602
603 /**
604 * Stop the command execution, release all locks and resources
605 */
606 void stop();
607
608 /**
609 * Close the statement.
610 */
611 @Override
612 void close();
613
614 /**
615 * Cancel the statement if it is still processing.
616 */
617 void cancel();
618
619 /**
620 * Get an empty result set containing the meta data of the result.
621 *
622 * @return the empty result
623 */
624 ResultInterface getMetaData();
625
626 }