Skip to content

Commit c7b18bd

Browse files
committed
Allow Nowait and lock retry count in PostgreSQL without using savepoints.
Issue 203358 ffe5fe1
1 parent 64ba289 commit c7b18bd

File tree

3 files changed

+6
-25
lines changed

3 files changed

+6
-25
lines changed

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,7 @@ private void execute(int cursorIdx, Object[] parms, boolean preExecute)
274274
cursor.status = 0;
275275
try
276276
{
277-
executeSavePointOperation("SAVEPOINT gxselectforupdate", cursor);
278277
cursor.postExecute(this, getDataSource());
279-
executeSavePointOperation("RELEASE SAVEPOINT gxselectforupdate", cursor);
280278
}
281279
catch (SQLException e)
282280
{
@@ -346,7 +344,6 @@ private void execute(int cursorIdx, Object[] parms, boolean preExecute)
346344
{
347345
}
348346
}
349-
executeSavePointOperation("ROLLBACK TO SAVEPOINT gxselectforupdate", cursor);
350347
}
351348
}
352349
retryCount = retryCount + 1;
@@ -432,25 +429,6 @@ private void setParameters(int cursorIdx, Object[] parms, Cursor cursor,
432429
}
433430
}
434431

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

456434
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
@@ -39,6 +39,8 @@ public static void handleSQLError1(IErrorHandler errorHandler, SQLException e, M
3939
}
4040
if (!context.inErrorHandler)
4141
{
42+
if (e.getCause() != null && e.getCause() instanceof SQLException)
43+
e = ((SQLException)e.getCause());
4244
if (errorHandler != null)
4345
{
4446
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
@@ -96,9 +96,10 @@ public boolean DuplicateKeyValue(SQLException e)
9696
public boolean ObjectLocked(SQLException e)
9797
{
9898
String sqlstate = e.getSQLState().toLowerCase();
99-
if (sqlstate.indexOf("55p03")>=0)
100-
return true;
101-
return false;
99+
String sqlstateCause = "";
100+
if (e.getCause() != null && e.getCause() instanceof SQLException)
101+
sqlstateCause = ((SQLException)e.getCause()).getSQLState().toLowerCase();
102+
return sqlstate.contains("55p03") || sqlstateCause.contains("55p03");
102103
}
103104

104105
public boolean ObjectNotFound(SQLException e)

0 commit comments

Comments
 (0)