|
14 | 14 | use Doctrine\DBAL\Connection as DBALConnection;
|
15 | 15 | use Doctrine\DBAL\Exception as DBALException;
|
16 | 16 | use Doctrine\DBAL\Platforms\AbstractPlatform;
|
| 17 | +use Doctrine\DBAL\Platforms\MariaDb1060Platform; |
17 | 18 | use Doctrine\DBAL\Platforms\MariaDBPlatform;
|
18 | 19 | use Doctrine\DBAL\Platforms\MySQL57Platform;
|
| 20 | +use Doctrine\DBAL\Platforms\MySQL80Platform; |
19 | 21 | use Doctrine\DBAL\Platforms\MySQLPlatform;
|
20 | 22 | use Doctrine\DBAL\Platforms\OraclePlatform;
|
| 23 | +use Doctrine\DBAL\Platforms\PostgreSQL100Platform; |
| 24 | +use Doctrine\DBAL\Platforms\PostgreSQL94Platform; |
| 25 | +use Doctrine\DBAL\Platforms\PostgreSQLPlatform; |
21 | 26 | use Doctrine\DBAL\Platforms\SQLServer2012Platform;
|
22 | 27 | use Doctrine\DBAL\Platforms\SQLServerPlatform;
|
23 | 28 | use Doctrine\DBAL\Query\QueryBuilder;
|
@@ -391,28 +396,94 @@ class_exists(MySQLPlatform::class) ? new MySQLPlatform() : new MySQL57Platform()
|
391 | 396 | 'SELECT m.* FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE',
|
392 | 397 | ];
|
393 | 398 |
|
| 399 | + if (class_exists(MySQL80Platform::class) && !method_exists(QueryBuilder::class, 'forUpdate')) { |
| 400 | + yield 'MySQL8 & DBAL<3.8' => [ |
| 401 | + new MySQL80Platform(), |
| 402 | + 'SELECT m.* FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE', |
| 403 | + ]; |
| 404 | + } |
| 405 | + |
| 406 | + if (class_exists(MySQL80Platform::class) && method_exists(QueryBuilder::class, 'forUpdate')) { |
| 407 | + yield 'MySQL8 & DBAL>=3.8' => [ |
| 408 | + new MySQL80Platform(), |
| 409 | + 'SELECT m.* FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE SKIP LOCKED', |
| 410 | + ]; |
| 411 | + } |
| 412 | + |
394 | 413 | yield 'MariaDB' => [
|
395 | 414 | new MariaDBPlatform(),
|
396 | 415 | 'SELECT m.* FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE',
|
397 | 416 | ];
|
398 | 417 |
|
399 |
| - yield 'SQL Server' => [ |
400 |
| - class_exists(SQLServerPlatform::class) && !class_exists(SQLServer2012Platform::class) ? new SQLServerPlatform() : new SQLServer2012Platform(), |
401 |
| - 'SELECT m.* FROM messenger_messages m WITH (UPDLOCK, ROWLOCK) WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY ', |
402 |
| - ]; |
| 418 | + if (class_exists(MariaDb1060Platform::class)) { |
| 419 | + yield 'MariaDB106' => [ |
| 420 | + new MariaDb1060Platform(), |
| 421 | + 'SELECT m.* FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE SKIP LOCKED', |
| 422 | + ]; |
| 423 | + } |
403 | 424 |
|
404 |
| - if (!class_exists(MySQL57Platform::class)) { |
405 |
| - // DBAL >= 4 |
406 |
| - yield 'Oracle' => [ |
407 |
| - new OraclePlatform(), |
408 |
| - 'SELECT w.id AS "id", w.body AS "body", w.headers AS "headers", w.queue_name AS "queue_name", w.created_at AS "created_at", w.available_at AS "available_at", w.delivered_at AS "delivered_at" FROM messenger_messages w WHERE w.id IN (SELECT m.id FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC FETCH NEXT 1 ROWS ONLY) FOR UPDATE', |
| 425 | + if (class_exists(MySQL57Platform::class)) { |
| 426 | + yield 'Postgres & DBAL<4' => [ |
| 427 | + new PostgreSQLPlatform(), |
| 428 | + 'SELECT m.* FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE', |
409 | 429 | ];
|
410 | 430 | } else {
|
411 |
| - // DBAL < 4 |
412 |
| - yield 'Oracle' => [ |
| 431 | + yield 'Postgres & DBAL>=4' => [ |
| 432 | + new PostgreSQLPlatform(), |
| 433 | + 'SELECT m.* FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE SKIP LOCKED', |
| 434 | + ]; |
| 435 | + } |
| 436 | + |
| 437 | + if (class_exists(PostgreSQL94Platform::class)) { |
| 438 | + yield 'Postgres94' => [ |
| 439 | + new PostgreSQL94Platform(), |
| 440 | + 'SELECT m.* FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE', |
| 441 | + ]; |
| 442 | + } |
| 443 | + |
| 444 | + if (class_exists(PostgreSQL100Platform::class) && !method_exists(QueryBuilder::class, 'forUpdate')) { |
| 445 | + yield 'Postgres10 & DBAL<3.8' => [ |
| 446 | + new PostgreSQL100Platform(), |
| 447 | + 'SELECT m.* FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE', |
| 448 | + ]; |
| 449 | + } |
| 450 | + |
| 451 | + if (class_exists(PostgreSQL100Platform::class) && method_exists(QueryBuilder::class, 'forUpdate')) { |
| 452 | + yield 'Postgres10 & DBAL>=3.8' => [ |
| 453 | + new PostgreSQL100Platform(), |
| 454 | + 'SELECT m.* FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC LIMIT 1 FOR UPDATE SKIP LOCKED', |
| 455 | + ]; |
| 456 | + } |
| 457 | + |
| 458 | + if (!method_exists(QueryBuilder::class, 'forUpdate')) { |
| 459 | + yield 'SQL Server & DBAL<3.8' => [ |
| 460 | + class_exists(SQLServerPlatform::class) && !class_exists(SQLServer2012Platform::class) ? new SQLServerPlatform() : new SQLServer2012Platform(), |
| 461 | + 'SELECT m.* FROM messenger_messages m WITH (UPDLOCK, ROWLOCK) WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY ', |
| 462 | + ]; |
| 463 | + } |
| 464 | + |
| 465 | + if (method_exists(QueryBuilder::class, 'forUpdate')) { |
| 466 | + yield 'SQL Server & DBAL>=3.8' => [ |
| 467 | + class_exists(SQLServerPlatform::class) && !class_exists(SQLServer2012Platform::class) ? new SQLServerPlatform() : new SQLServer2012Platform(), |
| 468 | + 'SELECT m.* FROM messenger_messages m WITH (UPDLOCK, ROWLOCK, READPAST) WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY ', |
| 469 | + ]; |
| 470 | + } |
| 471 | + |
| 472 | + if (!method_exists(QueryBuilder::class, 'forUpdate')) { |
| 473 | + yield 'Oracle & DBAL<3.8' => [ |
413 | 474 | new OraclePlatform(),
|
414 | 475 | 'SELECT w.id AS "id", w.body AS "body", w.headers AS "headers", w.queue_name AS "queue_name", w.created_at AS "created_at", w.available_at AS "available_at", w.delivered_at AS "delivered_at" FROM messenger_messages w WHERE w.id IN (SELECT a.id FROM (SELECT m.id FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC) a WHERE ROWNUM <= 1) FOR UPDATE',
|
415 | 476 | ];
|
| 477 | + } elseif (class_exists(MySQL57Platform::class)) { |
| 478 | + yield 'Oracle & 3.8<=DBAL<4' => [ |
| 479 | + new OraclePlatform(), |
| 480 | + 'SELECT w.id AS "id", w.body AS "body", w.headers AS "headers", w.queue_name AS "queue_name", w.created_at AS "created_at", w.available_at AS "available_at", w.delivered_at AS "delivered_at" FROM messenger_messages w WHERE w.id IN (SELECT a.id FROM (SELECT m.id FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC) a WHERE ROWNUM <= 1) FOR UPDATE SKIP LOCKED', |
| 481 | + ]; |
| 482 | + } else { |
| 483 | + yield 'Oracle & DBAL>=4' => [ |
| 484 | + new OraclePlatform(), |
| 485 | + 'SELECT w.id AS "id", w.body AS "body", w.headers AS "headers", w.queue_name AS "queue_name", w.created_at AS "created_at", w.available_at AS "available_at", w.delivered_at AS "delivered_at" FROM messenger_messages w WHERE w.id IN (SELECT m.id FROM messenger_messages m WHERE (m.queue_name = ?) AND (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) ORDER BY available_at ASC FETCH NEXT 1 ROWS ONLY) FOR UPDATE SKIP LOCKED', |
| 486 | + ]; |
416 | 487 | }
|
417 | 488 | }
|
418 | 489 |
|
|
0 commit comments