- correct behaviour in case of non-existent jobs
authorMiloš Mulač <mulac@civ.zcu.cz>
Thu, 27 Mar 2008 09:36:21 +0000 (09:36 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Thu, 27 Mar 2008 09:36:21 +0000 (09:36 +0000)
- better error description returned

org.glite.lb.server/src/db_calls.c

index cbdb0d6..4725cb6 100644 (file)
@@ -68,13 +68,17 @@ int edg_wll_LockJobRow(edg_wll_Context ctx, const char *job, int lock_mode)
        edg_wll_ResetError(ctx);
 
        if (lock_mode) 
-               trio_asprintf(&stmt, "select count(*) from jobs where jobid='%|Ss' for update", job);
+               trio_asprintf(&stmt, "select * from jobs where jobid='%|Ss' for update", job);
        else
-               trio_asprintf(&stmt, "select count(*) from jobs where jobid='%|Ss' lock in share mode", job);
+               trio_asprintf(&stmt, "select * from jobs where jobid='%|Ss' lock in share mode", job);
 
        if ((nr = edg_wll_ExecSQL(ctx,stmt,&sh)) < 0) goto cleanup;
        if (nr == 0) {
-                edg_wll_SetError(ctx,ENOENT,"no state in DB");
+               char *err;
+
+               asprintf(&err,"jobid='%s' not registered in DB", job);
+                edg_wll_SetError(ctx,ENOENT, err);
+               free(err);
                 goto cleanup;
        }