Skip to content

Commit fb8297f

Browse files
iroquetaclaudiamurialdo
authored andcommitted
Allow Nowait and lock retry count in PostgreSQL without using savepoints. (#941)
Issue 203358 (cherry picked from commit bec6c12)
1 parent 5f5ae90 commit fb8297f

File tree

3 files changed

+6
-23
lines changed

3 files changed

+6
-23
lines changed

java/src/main/java/com/genexus/db/DataStoreProvider.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,7 @@ private void execute(int cursorIdx, Object[] parms, boolean preExecute)
272272
cursor.status = 0;
273273
try
274274
{
275-
executeSavePointOperation("SAVEPOINT gxselectforupdate", cursor);
276275
cursor.postExecute(this, getDataSource());
277-
executeSavePointOperation("RELEASE SAVEPOINT gxselectforupdate", cursor);
278276
}
279277
catch (SQLException e)
280278
{
@@ -344,7 +342,6 @@ private void execute(int cursorIdx, Object[] parms, boolean preExecute)
344342
{
345343
}
346344
}
347-
executeSavePointOperation("ROLLBACK TO SAVEPOINT gxselectforupdate", cursor);
348345
}
349346
}
350347
retryCount = retryCount + 1;
@@ -430,23 +427,6 @@ private void setParameters(int cursorIdx, Object[] parms, Cursor cursor,
430427
}
431428
}
432429

433-
434-
private void executeSavePointOperation(String operation, Cursor cursor)
435-
{
436-
if (getDataSource().dbms.getId() == GXDBMS.DBMS_POSTGRESQL && GXutil.dbmsVersion( context, remoteHandle, getDataSource().name) > 7 && cursor instanceof ForEachCursor && cursor.isCurrentOf())
437-
{
438-
try
439-
{
440-
SentenceProvider.executeStatement(this, operation);
441-
}
442-
catch (Exception ex)
443-
{
444-
System.err.println(operation + " error " + ex.getMessage());
445-
ex.printStackTrace();
446-
}
447-
}
448-
}
449-
450430
static Object lock = new Object();
451431

452432
public void readNext(int cursorIdx)

java/src/main/java/com/genexus/db/DefaultExceptionErrorHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public static void handleSQLError(IErrorHandler errorHandler, SQLException e, Mo
2929
}
3030
if (!context.inErrorHandler)
3131
{
32+
if (e.getCause() != null && e.getCause() instanceof SQLException)
33+
e = ((SQLException)e.getCause());
3234
if (errorHandler != null)
3335
{
3436
context.globals.Gx_err = (short) cursor.status;

java/src/main/java/com/genexus/db/driver/GXDBMSpostgresql.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ public boolean DuplicateKeyValue(SQLException e)
8484
public boolean ObjectLocked(SQLException e)
8585
{
8686
String sqlstate = e.getSQLState().toLowerCase();
87-
if (sqlstate.indexOf("55p03")>=0)
88-
return true;
89-
return false;
87+
String sqlstateCause = "";
88+
if (e.getCause() != null && e.getCause() instanceof SQLException)
89+
sqlstateCause = ((SQLException)e.getCause()).getSQLState().toLowerCase();
90+
return sqlstate.contains("55p03") || sqlstateCause.contains("55p03");
9091
}
9192

9293
public boolean ObjectNotFound(SQLException e)

0 commit comments

Comments
 (0)