summaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
authorAlexandr Kuznetsov2024-05-24 09:47:10 +0000
committerGitHub2024-05-24 09:47:10 +0000
commit6ca29b7042cec545cedbbc69d17ac769a9ead5fd (patch)
tree1a6f4b9689358117e8c30d7445c33604113d0342 /test/src
parent7ec2337580447068b20dd3230c50229eae85dc08 (diff)
Fixed bugs, reported in issue #8. (#25)
* Fixed bugs, reported in issue #8. Bunch of memory leaks, occuring in tests. One heap-buffer-overrun in read operation at convert.c:3162. Two memory leaks, detected by my unit tests: password, conn_settings, pqopt fields overwrite if their values provided by both, system config and connstring. Restored reference counting lifetime managment of COL_INFO objects. Some minor cosmetic changes. Signed-off-by: Alexandr Kuznetsov <progmachine@xenlab.one> * Minor cosmetic changes. Signed-off-by: Alexandr Kuznetsov <progmachine@xenlab.one> * Forgot set col_info to NULL in TABLE_INFO object while clearing it. Signed-off-by: Alexandr Kuznetsov <progmachine@xenlab.one> * Fixing comments. Signed-off-by: Alexandr Kuznetsov <progmachine@xenlab.one> --------- Signed-off-by: Alexandr Kuznetsov <progmachine@xenlab.one>
Diffstat (limited to 'test/src')
-rw-r--r--test/src/cte-test.c14
-rw-r--r--test/src/cursor-block-delete-test.c12
-rw-r--r--test/src/premature-test.c30
3 files changed, 28 insertions, 28 deletions
diff --git a/test/src/cte-test.c b/test/src/cte-test.c
index a673ec0..97bad39 100644
--- a/test/src/cte-test.c
+++ b/test/src/cte-test.c
@@ -30,13 +30,13 @@ runTest(HSTMT hstmt)
intparam = 3;
cbParam1 = sizeof(intparam);
rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,
- SQL_INTEGER, /* value type */
- SQL_INTEGER, /* param type */
- 0, /* column size (ignored for SQL_INTEGER) */
- 0, /* dec digits */
- &intparam, /* param value ptr */
- sizeof(intparam), /* buffer len (ignored for SQL_INTEGER) */
- &cbParam1 /* StrLen_or_IndPtr (ignored for SQL_INTEGER) */);
+ SQL_INTEGER, /* value type */
+ SQL_INTEGER, /* param type */
+ 0, /* column size (ignored for SQL_INTEGER) */
+ 0, /* dec digits */
+ &intparam, /* param value ptr */
+ sizeof(intparam), /* buffer len (ignored for SQL_INTEGER) */
+ &cbParam1 /* StrLen_or_IndPtr (ignored for SQL_INTEGER) */);
CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt);
/* Execute */
diff --git a/test/src/cursor-block-delete-test.c b/test/src/cursor-block-delete-test.c
index 2069fe2..372b4c5 100644
--- a/test/src/cursor-block-delete-test.c
+++ b/test/src/cursor-block-delete-test.c
@@ -20,7 +20,7 @@ static SQLRETURN delete_loop(HSTMT hstmt)
BOOL use_first_last = 0;
int delcnt = 0, delsav, loopcnt = 0;
SQLSMALLINT orientation = SQL_FETCH_FIRST;
-
+
do {
printf("\torientation=%d delete count=%d\n", orientation, delcnt);
delsav = delcnt;
@@ -51,7 +51,7 @@ int main(int argc, char **argv)
int rc;
HSTMT hstmt = SQL_NULL_HSTMT;
int i, j, k;
- int count = TOTAL;
+ int count = TOTAL;
char query[100];
SQLLEN rowArraySize = BLOCK;
SQLULEN rowsFetched;
@@ -101,7 +101,7 @@ int main(int argc, char **argv)
rc = SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0);
CHECK_STMT_RESULT(rc, "SQLSetStmtAttr CONCURRENCY failed", hstmt);
rc = SQLSetConnectAttr(conn, SQL_AUTOCOMMIT, (SQLPOINTER) SQL_AUTOCOMMIT_OFF, 0);
-
+
rc = SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_KEYSET_DRIVEN, 0);
CHECK_STMT_RESULT(rc, "SQLSetStmtAttr CURSOR_TYPE failed", hstmt);
rc = SQLExecDirect(hstmt, (SQLCHAR *) "select * from tmptable", SQL_NTS);
@@ -132,8 +132,8 @@ int main(int argc, char **argv)
rc = SQLExecDirect(hstmte, (SQLCHAR *) "savepoint yuuki", SQL_NTS);
CHECK_STMT_RESULT(rc, "savpoint failed", hstmte);
}
- }
-
+ }
+
delete_loop(hstmt); /* the 2nd loop */
rc = SQLExecDirect(hstmte, (SQLCHAR *) "rollback to yuuki;release yuuki", SQL_NTS);
@@ -150,7 +150,7 @@ int main(int argc, char **argv)
CHECK_STMT_RESULT(rc, "SQLEndTran failed", hstmt);
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
-
+
/* Clean up */
test_disconnect();
diff --git a/test/src/premature-test.c b/test/src/premature-test.c
index 9ef9ea1..e3a1218 100644
--- a/test/src/premature-test.c
+++ b/test/src/premature-test.c
@@ -34,13 +34,13 @@ runtest(const char *query, char *bind_before, char *bind_after, int execute)
{
cbParam1 = SQL_NTS;
rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,
- SQL_C_CHAR, /* value type */
- SQL_CHAR, /* param type */
- 20, /* column size */
- 0, /* dec digits */
- bind_before, /* param value ptr */
- 0, /* buffer len */
- &cbParam1 /* StrLen_or_IndPtr */);
+ SQL_C_CHAR, /* value type */
+ SQL_CHAR, /* param type */
+ 20, /* column size */
+ 0, /* dec digits */
+ bind_before, /* param value ptr */
+ 0, /* buffer len */
+ &cbParam1 /* StrLen_or_IndPtr */);
CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt);
}
@@ -53,16 +53,16 @@ runtest(const char *query, char *bind_before, char *bind_after, int execute)
{
cbParam1 = SQL_NTS;
rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,
- SQL_C_CHAR, /* value type */
- SQL_CHAR, /* param type */
- 20, /* column size */
- 0, /* dec digits */
- bind_after, /* param value ptr */
- 0, /* buffer len */
- &cbParam1 /* StrLen_or_IndPtr */);
+ SQL_C_CHAR, /* value type */
+ SQL_CHAR, /* param type */
+ 20, /* column size */
+ 0, /* dec digits */
+ bind_after, /* param value ptr */
+ 0, /* buffer len */
+ &cbParam1 /* StrLen_or_IndPtr */);
CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt);
}
-
+
/* Don't execute the statement! The row should not be inserted. */
/* And execute */