From b7453e5fbe41b58e6973cf8e5c7fb828e2cb9165 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Wed, 25 Jun 2025 07:34:57 -0400 Subject: [PATCH] Adding SQL drop result --- lib/devsql.c | 20 ++++++++++++++++++-- lib/unimar.c | 16 ++++++++++++++++ lib/unimar.h | 3 +++ lib/unipos.c | 16 ++++++++++++++++ lib/unipos.h | 3 +++ 5 files changed, 56 insertions(+), 2 deletions(-) diff --git a/lib/devsql.c b/lib/devsql.c index c3aeb72..34dc284 100644 --- a/lib/devsql.c +++ b/lib/devsql.c @@ -42,10 +42,26 @@ typedef struct { /* command. */ /* */ /********************************************************/ -static SQLRES *dropresult(SQLRES *rs) +static SQLRES *dropresult(SQLTYP *sql,SQLRES *rs) { +#define OPEP "devsql.c:dropresult," + +switch(sql->sqldb) { + case db_postgres : + rs=(SQLRES *)pos_dropresult((POSRES *)rs); + break; + case db_maria : + rs=(SQLRES *)pos_dropresult((MARRES *)rs); + break; + default : + (void) rou_alert(0,"%s Unexpected type='%d' (BUG!?)", + OPEP,(int)sql->sqldb); + rs=(SQLRES *)0; + break; + } return rs; +#undef OPEP } /* @@ -403,7 +419,7 @@ while (proceed==true) { if ((nbr=nbrtupple(sql,rs))>0) { (void) rou_alert(0,"%s jmpdbg NBR='%d'",OPEP,nbr); } - rs=dropresult(rs); + rs=dropresult(sql,rs); break; default : proceed=false; diff --git a/lib/unimar.c b/lib/unimar.c index cc0b807..cff1460 100644 --- a/lib/unimar.c +++ b/lib/unimar.c @@ -153,6 +153,22 @@ return cleanstr; */ /********************************************************/ /* */ +/* procedure to drop/free all result information */ +/* */ +/********************************************************/ +PUBLIC MARRES *mar_dropresult(MARRES *rs) + +{ +#ifdef DB_MYSQL +(void) mysql_free_result((MYSQL_RES *)rs); +#endif +return (MARRES *)0; +} +/* + +*/ +/********************************************************/ +/* */ /* Procedure to extract data from the database. */ /* Return POSRES status pointer (can be NULL is not*/ /* successfull. */ diff --git a/lib/unimar.h b/lib/unimar.h index 9df6398..ecefce3 100644 --- a/lib/unimar.h +++ b/lib/unimar.h @@ -23,6 +23,9 @@ extern MARPTR *mar_closesql(MARPTR *marptr); //Procedure to detect and 'clean' any single quote within a string extern char *mar_cleanquote(char *sequence); +//procedure to drop/free all result information +extern MARRES *mar_dropresult(MARRES *rs); + //procedure to extract data from database extern MARRES *mar_gettupple(MARPTR *marptr,char *command); diff --git a/lib/unipos.c b/lib/unipos.c index 26a2aea..8b25de6 100644 --- a/lib/unipos.c +++ b/lib/unipos.c @@ -201,6 +201,22 @@ return cleanstr; */ /********************************************************/ /* */ +/* procedure to drop/free all result information */ +/* */ +/********************************************************/ +PUBLIC POSRES *pos_dropresult(POSRES *rs) + +{ +#ifdef DB_POSTGRESQL +(void) PQclear(rs); +#endif +return (POSRES *)0; +} +/* + +*/ +/********************************************************/ +/* */ /* Procedure to extract data from the database. */ /* Return POSRES status pointer (can be NULL is not*/ /* successfull. */ diff --git a/lib/unipos.h b/lib/unipos.h index 0113f9d..e0a4512 100644 --- a/lib/unipos.h +++ b/lib/unipos.h @@ -23,6 +23,9 @@ extern POSPTR *pos_closesql(POSPTR *posptr); //Procedure to detect and 'clean' any single quote within a string extern char *pos_cleanquote(char *sequence); +//procedure to drop/free all result information +extern POSRES *pos_dropresult(POSRES *rs); + //procedure to extract data from database extern POSRES *pos_gettupple(POSPTR *posptr,char *command); -- 2.47.3