/* 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
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
#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
}
/*
//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);
{
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;
#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
}
/*
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);