]> SAFE projects GIT repository - jmp/mailleur/commitdiff
pos_lock and pos_unlock seems to be working
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 11 Jul 2025 19:41:28 +0000 (15:41 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Fri, 11 Jul 2025 19:41:28 +0000 (15:41 -0400)
lib/devsql.c
lib/devsql.h
lib/unimar.c
lib/unimar.h
lib/unipos.c
lib/unipos.h

index 89c016abc0afe71a72d475ff3356437ff65e6bbc..1a627e515b22f6d91b9e61de5c6a44cbd6ef53ff 100644 (file)
@@ -287,10 +287,34 @@ return locked;
 /*      specific database table.                        */
 /*                                                      */
 /********************************************************/
-PUBLIC int sql_unlock(SQLPTR *sqlptr,_Bool commit)
+PUBLIC _Bool sql_unlock(SQLPTR *sqlptr,_Bool commit)
 
 {
-return 1;
+#define OPEP    "devsql.c:sql_unlock,"
+
+_Bool unlocked;
+
+unlocked=false;
+if (sqlptr!=(SQLPTR *)0) {
+  SQLTYP *sql;
+
+  sql=(SQLTYP *)sqlptr;
+  switch(sql->sqldb) {
+    case db_postgres  :
+      unlocked=pos_unlock(sql->db.psql,commit);
+      break;
+    case db_maria      :
+      unlocked=mar_unlock(sql->db.psql,commit);
+      break;
+    default            :
+      (void) rou_alert(0,"%s Unexpected db type='%d' (BUG!?)",
+                          OPEP,(int)sql->sqldb);
+      break;
+    }
+  }
+return unlocked;
+
+#undef  OPEP
 }
 /*
 \f
index 3fd3635b72f3c7799bc454e8c63ea534c65423f5..6ec49d237145d60817a1e36d994e40e9fa9fa319 100644 (file)
@@ -26,7 +26,7 @@ extern SQLPTR *sql_closesql(SQLPTR *sqlptr);
 extern _Bool sql_lock(SQLPTR *sqlptr,char *tablename);
 
 //procedure to UNLOCK access to a database table
-extern int sql_unlock(SQLPTR *sqlptr,_Bool commit);
+extern _Bool sql_unlock(SQLPTR *sqlptr,_Bool commit);
 
 //procedure to make sure a string is acceptable
 //as key search by database
index 3db99cad67e3d8ad1ebb7c5fda053ea04255f301..487543d3d8eec67ff714d4479f679d852ae55aaa 100644 (file)
@@ -172,6 +172,32 @@ locked=false;
 #endif
 return locked;
 
+#undef  OPEP
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                     */
+/*      procedure to unlock access to a previously      */
+/*      locked table within database.                   */
+/*                                                     */
+/********************************************************/
+PUBLIC _Bool mar_unlock(MARPTR *marptr,_Bool commit)
+
+{
+#define OPEP    "unimar.c:mar_unlock,"
+
+_Bool unlocked;
+
+unlocked=false;
+#ifdef  DB_MYSQL
+  {
+  (void) rou_alert(0,"%s not implemented yet",OPEP);
+  }
+#endif
+return unlocked;
+
 #undef  OPEP
 }
 /*
index 5c7a6953357f836f4bcf93c962982e374a16c9e7..ca6b61f924927a29783c890d919c5a2b2614917c 100644 (file)
@@ -26,6 +26,9 @@ extern char *mar_cleanquote(char *sequence);
 //locking database one table access
 extern _Bool mar_lock(MARPTR *marptr,char *tablename);
 
+//unlocking the current database table lock access
+extern _Bool mar_unlock(MARPTR *marptr,_Bool commit);
+
 //procedure to drop/free all result information
 extern MARRES *mar_dropresult(MARRES *rs);
 
index cfdd38992da15fdadae6aa66c30f609fdc096cf1..ec7fccf142fc79ace26d221ac5b053e56ccd5018 100644 (file)
@@ -217,12 +217,10 @@ locked=false;
   {
   static const char *cmd="LOCK TABLE %s IN SHARE ROW EXCLUSIVE MODE";
 
-  PGconn *pf;
   char fullcmd[300];
   int phase;
   _Bool proceed;
 
-  pf=(PGconn *)posptr;
   (void) snprintf(fullcmd,sizeof(fullcmd),cmd,tablename);
   phase=0;
   proceed=true;
@@ -256,6 +254,41 @@ locked=false;
 #endif
 return locked;
 
+#undef  OPEP
+}
+/*
+\f
+*/
+/********************************************************/
+/*                                                     */
+/*      procedure to unlock access to a previously      */
+/*      locked table within database.                   */
+/*                                                     */
+/********************************************************/
+PUBLIC _Bool pos_unlock(POSPTR *posptr,_Bool commit)
+
+{
+#define OPEP    "unipos.c:pos_unlock,"
+
+_Bool unlocked;
+
+unlocked=false;
+#ifdef  DB_POSTGRESQL
+  {
+  char *cmd;
+
+  unlocked=true;
+  cmd="ROLLBACK";
+  if (commit==true);
+    cmd="COMMIT";
+  if (pos_request(posptr,cmd)<0) {
+    unlocked=false;
+    (void) rou_alert(0,"%s Unable to unlock table (Bug?) ",OPEP);
+    }
+  }
+#endif
+return unlocked;
+
 #undef  OPEP
 }
 /*
index a661645196f197139f279206d10d5117760f1b9c..f695869e62b37bd184d9db12c9519e082644b149 100644 (file)
@@ -24,7 +24,10 @@ extern POSPTR *pos_closesql(POSPTR *posptr);
 extern char *pos_cleanquote(char *sequence);
 
 //locking database one table access
-extern _Bool pos_lock(POSPTR *marptr,char *tablename);
+extern _Bool pos_lock(POSPTR *posptr,char *tablename);
+
+//unlocking the current database table lock access
+extern _Bool pos_unlock(POSPTR *posptr,_Bool commit);
 
 //procedure to drop/free all result information
 extern POSRES *pos_dropresult(POSRES *rs);