[jOOQ/jOOQ#9294] Add support for MariaDB FOR UPDATE .. WAIT n, NOWAIT

This commit is contained in:
Lukas Eder 2019-09-27 12:33:11 +02:00
parent c89266804c
commit ca5b5d9ddb
4 changed files with 43 additions and 53 deletions

View File

@ -38,6 +38,7 @@
package org.jooq;
// ...
import static org.jooq.SQLDialect.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
// ...
import static org.jooq.SQLDialect.POSTGRES;
@ -105,19 +106,16 @@ import static org.jooq.SQLDialect.POSTGRES;
*/
public interface SelectForUpdateWaitStep<R extends Record> extends SelectOptionStep<R> {
/**
* Add a <code>WAIT</code> clause to the <code>FOR UPDATE</code> clause at
* the end of the query.
* <p>
* Be careful not to confuse this with {@link Object#wait(long)} !
*
* @see SelectQuery#setForUpdateWait(int) see LockProvider for more details
*/
@Support({ MARIADB })
SelectOptionStep<R> wait(int seconds);
/**
* Add a <code>NOWAIT</code> clause to the <code>FOR UPDATE</code> clause at
@ -125,7 +123,7 @@ public interface SelectForUpdateWaitStep<R extends Record> extends SelectOptionS
*
* @see SelectQuery#setForUpdateNoWait() see LockProvider for more details
*/
@Support({ MYSQL, POSTGRES })
@Support({ MARIADB, MYSQL, POSTGRES })
SelectOptionStep<R> noWait();
/**

View File

@ -53,6 +53,7 @@ import static org.jooq.SQLDialect.HSQLDB;
// ...
import static org.jooq.SQLDialect.MARIADB;
// ...
// ...
import static org.jooq.SQLDialect.MYSQL;
// ...
// ...
@ -990,27 +991,24 @@ public interface SelectQuery<R extends Record> extends Select<R>, ConditionProvi
@Support({ DERBY, FIREBIRD, H2, HSQLDB, MYSQL, POSTGRES })
void setForUpdateOf(Table<?>... tables);
/**
* Some RDBMS allow for specifying the locking mode for the applied
* <code>FOR UPDATE</code> clause. In this case, the session will wait for
* some <code>seconds</code>, before aborting the lock acquirement if the
* lock is not available.
* <p>
* This automatically sets the {@link #setForUpdate(boolean)} flag, and
* unsets the {@link #setForShare(boolean)} flag, if it was previously set.
* <p>
* This has been observed to be supported by any of these dialects:
* <ul>
* <li>Oracle</li>
* </ul>
*
* @param seconds The number of seconds to wait for a lock
*/
@Support({ MARIADB })
void setForUpdateWait(int seconds);
/**
* Some RDBMS allow for specifying the locking mode for the applied
@ -1025,7 +1023,7 @@ public interface SelectQuery<R extends Record> extends Select<R>, ConditionProvi
* <li>Oracle</li>
* </ul>
*/
@Support({ MYSQL, POSTGRES })
@Support({ MARIADB, MYSQL, POSTGRES })
void setForUpdateNoWait();
/**

View File

@ -1788,14 +1788,11 @@ final class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
return this;
}
@Override
public final SelectImpl wait(int seconds) {
getQuery().setForUpdateWait(seconds);
return this;
}
@Override
public final SelectImpl noWait() {

View File

@ -1981,15 +1981,12 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
forUpdateOfTables = new TableList(Arrays.asList(tables));
}
@Override
public final void setForUpdateWait(int seconds) {
setForUpdate(true);
forUpdateWaitMode = ForUpdateWaitMode.WAIT;
forUpdateWait = seconds;
}
@Override
public final void setForUpdateNoWait() {